Commit 762d326

mo khan <mo@mokhan.ca>
2026-09-05 06:04:34
refactor: stop exposing GGUF_N_CTX/THREADS/N_GPU_LAYERS as config
Convention over configuration: n_ctx, n_threads, and n_gpu_layers all have a single correct answer computable from the model and host (model's trained context, host's physical cores, offload everything when a GPU backend exists), so there's no reason to let a user override them with a worse manual value. Removes the three env vars; GGUF_MODEL/GGUF_MAX_TOKENS/GGUF_TEMP/GGUF_SEED remain since those are genuine preferences with no computable optimum. Claude-Session: https://claude.ai/code/session_01FpbgyAMtPEkDbo2kx78qR6
1 parent 8d2c0f3
Changed files (1)
lib
elelem
lib/elelem/llama/plugin.rb
@@ -5,14 +5,16 @@ Elelem::Providers.register(:gguf) do
 
   Elelem::Net::GGUF.new(
     model: ENV.fetch("GGUF_MODEL", File.expand_path("~/.elelem/models/Qwen3.8-27B-UD-Q4_K_XL.gguf")),
-    # 0 = auto: the native shim asks llama.cpp for the model's trained max
-    # context (falling back to smaller sizes if it doesn't fit), and picks
-    # thread count from the host's physical cores. Set GGUF_N_CTX/GGUF_THREADS
-    # to override.
-    n_ctx: Integer(ENV.fetch("GGUF_N_CTX", "0")),
-    n_threads: Integer(ENV.fetch("GGUF_THREADS", "0")),
+    # n_ctx/n_threads/n_gpu_layers are calculated, not configured: the native
+    # shim asks llama.cpp for the model's trained max context (falling back to
+    # smaller sizes if it doesn't fit) and picks thread count from the host's
+    # physical cores; every layer is offloaded whenever a GPU backend is
+    # present. Convention over configuration -- there's no better answer a
+    # user could supply than what the hardware and model already determine.
+    n_ctx: 0,
+    n_threads: 0,
+    n_gpu_layers: gpu ? 999 : 0,
     max_tokens: Integer(ENV.fetch("GGUF_MAX_TOKENS", "4096")),
-    n_gpu_layers: Integer(ENV.fetch("GGUF_N_GPU_LAYERS", gpu ? "999" : "0")),
     temp: Float(ENV.fetch("GGUF_TEMP", "0.7")),
     seed: Integer(ENV.fetch("GGUF_SEED", "-1"))
   )