engine: opt-in GPU offload for the decision engine
Let the SemIf decision engine run on a GPU via llama.cpp. SemIf's llamacpp backend is CPU-only by construction (it hardcodes n_gpu_layers=0), so the agent wraps `_cpu_model_params` for the duration of the load and restores it after — no patch to the re-cloned engine source. - `engine.gpu_layers` / `gpu_device` / `gpu_split` in config (default 0 = CPU). - On the GPU path, force a full cache reset (`llama_memory_clear(mem, True)`): SemIf's metadata-only clear leaves stale hybrid-attention state on Vulkan, so repeated scores drift (0.08 -> 0.36 -> 0.43) and return wrong probabilities. - Fail loudly when `gpu_layers` is set but the build has no GPU backend. - bootstrap.sh: opt-in `--gpu auto|vulkan|rocm|cuda|cpu`. A GPU build is opt-in because llama.cpp's Vulkan backend splits the graph across CPU and Vulkan even at `n_gpu_layers=0`, roughly halving CPU throughput, so a CPU-only host must keep the CPU wheel. Detects the backend, installs the Vulkan build prereqs, and rebuilds when offload support disagrees (pip's wheel cache otherwise serves the CPU wheel back). - Bump the SemIf pin 1f2dea3 -> 23cf1f3. - Tests: unit coverage for the config mapping + loader patches; an integration test asserting GPU determinism and CPU parity. - Offload needs the accelerator to itself (~2.9 GiB for the 4B Q4 model): a GPU already holding another model makes the engine slower than CPU and can abort with `vk::DeviceLostError`.
This commit is contained in:
1 parent
4e70a5889e
commit
17f16a6bfc
9 files changed
+329
-16
No files matched your search
+5
-1
@@ -14,9 +14,13 @@
|
||||
"queue": {"max_size": 100},
|
||||
"engine": {
|
||||
"_comment": "Per-machine engine settings only. The pinned engine/tokenizer/GGUF refs (semif_repo, semif_ref, gguf_url, gguf_sha256, source, revision) live in the committed pins.json — bumped on update, never per-machine config. The GGUF path is derived from pins.json's engine.gguf_url under .runtime/models/; set `gguf` here only to override it with a custom path.",
|
||||
"_gpu_comment": "gpu_layers: 0 keeps the CPU-only default, -1 offloads every layer, a positive count offloads that many. Requires a llama-cpp-python built with a GPU backend (bootstrap detects Vulkan/ROCm/CUDA). gpu_device picks the llama.cpp device index and gpu_split sets its split mode (0 = none).",
|
||||
"backend": "llamacpp",
|
||||
"context_tokens": 4096,
|
||||
"threads": 8
|
||||
"threads": 8,
|
||||
"gpu_layers": 0,
|
||||
"gpu_device": null,
|
||||
"gpu_split": 0
|
||||
},
|
||||
"llm": {
|
||||
"_comment": "Small OpenAI-compatible model that authors a new category/skill title + description (never the runnable body — that is `codegen` below). Deliberately its own endpoint/model, so it can be local and fast even when codegen is remote. Runs on THIS machine's local ollama; bootstrap reads base_url/model from here (a --llm-url/--llm-model flag overrides for that run only) and pulls `model` if it is missing. `model` is required (no default): set it to a model the endpoint serves. Uses the same provider machinery as codegen (real SSE stream, token budget, idle watchdog); short JSON replies. Sampler params (temperature/top_p/presence_penalty/frequency_penalty) are opt-in: an unset value is omitted from the request so the server's model default applies — set them here only when you know the right values for the model. The draft is authored asynchronously by a single-slot worker and the request re-runs when it lands; an unreachable endpoint is graceful (traced, user notified), not fatal. disable_thinking sends reasoning_effort:none so a reasoning model answers the short JSON directly instead of spending the reply budget on hidden chain-of-thought (set false only for an endpoint that rejects the parameter). provider selects the transport: \"ollama\" (default; a local OpenAI-compatible server, context auto-detected via /api/show), \"opencode\" (the hosted OpenCode Console inference API at https://opencode.ai/inference/openai/v1 — set model to a Chat Completions family id such as kimi-k2.7-code or glm-5.3, and provide api_key or api_key_env; the ollama probe is skipped), or \"semif\" (the loaded SemIf decision GGUF generates in-process via SemIfEngine.generate — no endpoint/model/api_key is used; see the `semif` block below).",
|
||||
|
||||
Reference in new issue
Block a user