Files
homelab/ansible/roles/llm-inference-multimodel/templates/llama-server-router-preset.ini.j2
Hermes Agent service account ad70b3439c feat(llm): add nomic-embed-text-v1.5-Q4_K_M to astro-orbiter router
OpenViking Phase 1b (t_34b96e83) — Ryan-approved implementation.

Changes:
- roles/llm-inference-multimodel/templates/llama-server-router-preset.ini.j2:
  Add [nomic-embed-text-v1.5] section with embedding=true, n-gpu-layers=99,
  ctx-size=8192, load-on-startup=true, sleep-idle-seconds=-1. No flash-attn
  or KV cache params (embedding models use bidirectional forward pass, not
  autoregressive KV cache). Var: llm_router_nomic_ctx_size.

- roles/llm-inference-multimodel/defaults/main.yml:
  Add llm_router_nomic_ctx_size: 8192.

- host_vars/astro-orbiter/vars.yml:
  Add nomic-embed-text-v1.5-Q4_K_M.gguf to llm_staged_models list
  (size_bytes: 84106624, source: nomic-ai/nomic-embed-text-v1.5-GGUF).
  Update VRAM note to reflect 5 registered models (nomic adds ~84MB,
  negligible given sleep-idle-seconds=-1 / load-on-startup=true pinning).

- playbooks/day2_add_nomic_embed.yml:
  New day2 playbook following the coder-alias pattern:
  Phase 1: idempotent GGUF download (exact size check)
  Phase 2: redeploy preset INI
  Phase 3: redeploy + restart systemd unit
  Phase 4: /v1/models gate (all 5 models present)
  Phase 5: /v1/embeddings smoke test (vector returned, not empty)

VRAM: ~84MB, always pinned. No impact on generative model LRU behavior.
peter-parker Helm values already point at :8002 for the embedding endpoint.
2026-08-13 23:18:27 -05:00

157 lines
8.7 KiB
Django/Jinja

; ------------------------------------------------------------------------------
; FILE: roles/llm-inference-multimodel/templates/llama-server-router-preset.ini.j2
; DESCRIPTION: llama.cpp --models-preset INI for llama-server-router.
;
; Purpose: define all router-served GGUFs as named model entries so that:
; - Each model is explicitly named and configured (no auto-discovery surprises)
; - Aliases can be added per model (impossible with --models-dir alone)
; - The Phi-3.5-mini-instruct-Q8_0 entry carries the alias
; "Phi-3.5-mini-instruct-8bit" — Ryan's Hermes auxiliary.title_generation
; already references this friendlier name; both names resolve to the same
; GGUF child process.
;
; INI format notes (llama.cpp preset.md):
; - Section header (e.g. [Phi-3.5-mini-instruct-Q8_0]) is the primary model ID
; that appears in /v1/models and that clients send in the "model" field.
; - `alias` adds an ADDITIONAL name — both the section name and the alias work.
; - The `model` key is the absolute path to the GGUF file.
; - All other keys map directly to llama-server CLI flags (underscores or hyphens).
;
; Known upstream issues (Aug 2026):
; - GH #22364: --models-preset creates an extra "default" model entry in
; /v1/models. This is cosmetic — it has no functional effect on model
; selection by name. Document and move on.
; - GH #23460: can't pass per-model samplers via --models-preset in router
; mode. Non-issue: Hermes always sends sampling params in the request body.
;
; Added 2026-08-12 (t_9adf0889): Phi alias — War Machine.
; All per-model settings carry over unchanged from the --models-dir baseline
; (ctx_size=65536, n_gpu_layers=99, cache=q4_0 for both K and V, models-max=4).
;
; UPDATED (t_ryan_per_model_ctx, per Ryan/JARVIS request): Llama-3.1-8B and
; Phi-3.5-mini now get PER-MODEL ctx-size/flash-attn matched to actual
; workload instead of the uniform 65536 used by every model previously:
; - Llama-3.1-8B-Instruct-Q4_K_M: ctx-size 8192 (tool-routing/micro-tasks)
; - Phi-3.5-mini-instruct-Q8_0: ctx-size 32768 (long web scrapes/logs)
; Both now request explicit flash-attn=true (was "auto"). Qwen3.6-35B is
; INTENTIONALLY left untouched at ctx-size 65536 / flash-attn auto — not part
; of this change. Existing aliases (Meta-Llama-3.1-8B-Instruct-4bit,
; Phi-3.5-mini-instruct-8bit) are PRESERVED unchanged to avoid breaking live
; Hermes custom_providers routing — see role README / deployment report for
; the alias-naming ambiguity flag (Ryan's pasted TOML used different alias
; strings: "llama-3.1-8b" / "phi-3.5-mini").
;
; UPDATED (t_34b96e83, 2026-08-13, per Ryan approval): Added nomic-embed-text-v1.5
; embedding model. Embedding models fold cleanly into the router preset via
; embedding=true. No alias needed — clients call it by section name.
; VRAM estimate ~90MB (negligible). sleep-idle-seconds=-1 keeps it always loaded
; since embedding calls are latency-sensitive and it costs near-nothing to hold.
; load-on-startup=true ensures the embedding endpoint is warm at boot without
; waiting for the first request. — War Machine.
; ------------------------------------------------------------------------------
; --- Production model: Qwen3.6-35B-A3B-UD-Q4_K_S ----------------------------
; Primary model ID: Qwen3.6-35B-A3B-UD-Q4_K_S (unchanged from --models-dir)
; ~20GB, primary Hermes production LLM. Context: 64K with q4_0 KV cache.
[Qwen3.6-35B-A3B-UD-Q4_K_S]
model = {{ llm_models_dir }}/Qwen3.6-35B-A3B-UD-Q4_K_S.gguf
n-gpu-layers = {{ llm_router_gpu_layers }}
ctx-size = {{ llm_router_ctx_size }}
cache-type-k = {{ llm_router_cache_type_k }}
cache-type-v = {{ llm_router_cache_type_v }}
batch-size = {{ llm_router_batch_size }}
ubatch-size = {{ llm_router_ubatch_size }}
parallel = {{ llm_router_parallel }}
; --- Auxiliary model: Phi-3.5-mini-instruct-Q8_0 ----------------------------
; Primary model ID: Phi-3.5-mini-instruct-Q8_0 (unchanged from --models-dir)
; Alias: Phi-3.5-mini-instruct-8bit (NEW — Ryan's config target)
; Both names resolve to this GGUF child process.
; ~3.8GB, auxiliary.title_generation consumer in Ryan's Hermes config.
; The alias is deployed — "model not found" errors are resolved.
;
; KNOWN ISSUE (2026-08-12, t_9adf0889):
; json_schema response_format fails for Phi-3.5-mini in llama.cpp router
; mode due to chat template grammar sampler incompatibility (GH #23460).
; The grammar sampler generates root ::= "assistant|>\n" ... which fails
; to initialize. This means Hermes auxiliary.title_generation still errors
; with "HTTP 400: Failed to initialize samplers" when json_schema format
; is requested. Without response_format (plain text), Phi works fine.
;
; Resolution options:
; a) Update auxiliary.title_generation.model in ~/.hermes/config.yaml to
; Meta-Llama-3.1-8B-Instruct-Q4_K_M (which supports json_schema) — Ryan
; needs to approve this config.yaml write (protected file).
; b) Rebuild llama.cpp from a newer commit if this bug is fixed upstream.
; c) Accept title generation degradation for Phi-specific structured output.
[Phi-3.5-mini-instruct-Q8_0]
model = {{ llm_models_dir }}/Phi-3.5-mini-instruct-Q8_0.gguf
alias = Phi-3.5-mini-instruct-8bit
n-gpu-layers = {{ llm_router_gpu_layers }}
ctx-size = {{ llm_router_phi_ctx_size }}
flash-attn = {{ llm_router_phi_flash_attn }}
cache-type-k = {{ llm_router_cache_type_k }}
cache-type-v = {{ llm_router_cache_type_v }}
batch-size = {{ llm_router_batch_size }}
ubatch-size = {{ llm_router_ubatch_size }}
parallel = {{ llm_router_parallel }}
; --- Auxiliary model: Meta-Llama-3.1-8B-Instruct-Q4_K_M --------------------
; Primary model ID: Meta-Llama-3.1-8B-Instruct-Q4_K_M (unchanged from --models-dir)
; Alias: Meta-Llama-3.1-8B-Instruct-4bit (NEW — friendlier name)
; Both names resolve to this GGUF child process.
; ~4.6GB, general-purpose small model. Works with json_schema structured output.
[Meta-Llama-3.1-8B-Instruct-Q4_K_M]
model = {{ llm_models_dir }}/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf
alias = Meta-Llama-3.1-8B-Instruct-4bit
n-gpu-layers = {{ llm_router_gpu_layers }}
ctx-size = {{ llm_router_llama_ctx_size }}
flash-attn = {{ llm_router_llama_flash_attn }}
cache-type-k = {{ llm_router_cache_type_k }}
cache-type-v = {{ llm_router_cache_type_v }}
batch-size = {{ llm_router_batch_size }}
ubatch-size = {{ llm_router_ubatch_size }}
parallel = {{ llm_router_parallel }}
; --- Coder model: Qwen2.5-Coder-14B-Instruct-Q4_K_M -------------------------
; Primary model ID: Qwen2.5-Coder-14B-Instruct-Q4_K_M (filename-derived)
; Alias: Qwen2.5-Coder-14B-Instruct-4bit (friendlier name)
; Both names resolve to this GGUF child process.
; ~8.4GB weights + ~0.6GB KV @ 16K ctx = ~9.0GB VRAM.
; ctx-size=16384, flash-attn=true per task t_55c164f5 / Ryan's request.
; Source: bartowski/Qwen2.5-Coder-14B-Instruct-GGUF (public, no auth)
; Added 2026-08-13 (t_55c164f5) — War Machine.
[Qwen2.5-Coder-14B-Instruct-Q4_K_M]
model = {{ llm_models_dir }}/Qwen2.5-Coder-14B-Instruct-Q4_K_M.gguf
alias = Qwen2.5-Coder-14B-Instruct-4bit
n-gpu-layers = {{ llm_router_gpu_layers }}
ctx-size = {{ llm_router_coder_ctx_size }}
flash-attn = {{ llm_router_coder_flash_attn }}
cache-type-k = {{ llm_router_cache_type_k }}
cache-type-v = {{ llm_router_cache_type_v }}
batch-size = {{ llm_router_batch_size }}
ubatch-size = {{ llm_router_ubatch_size }}
parallel = {{ llm_router_parallel }}
; --- Embedding model: nomic-embed-text-v1.5 ----------------------------------
; Primary model ID: nomic-embed-text-v1.5 (section name / client-visible ID)
; ~84MB GGUF — negligible VRAM, always-loaded. Embedding endpoint: /v1/embeddings.
; embedding=true: required to expose /v1/embeddings and embed the model (not chat).
; n-gpu-layers=99: GPU offload all layers (tiny model, no reason to leave on CPU).
; ctx-size=8192: per task spec (OpenViking Phase 1b, t_34b96e83).
; load-on-startup=true: warm at boot — embedding callers (peter-parker) are
; latency-sensitive; no cold-load wait on first request.
; sleep-idle-seconds=-1: never evict — ~84MB is negligible, always keep hot.
; NO flash-attn, NO KV cache params: embedding models use a different forward
; pass (bidirectional, no autoregressive KV cache). These keys are irrelevant
; for embedding inference and may be silently ignored or cause warnings; omit.
; Source: nomic-ai/nomic-embed-text-v1.5-GGUF (public, no auth needed)
; Added 2026-08-13 (t_34b96e83) — War Machine.
[nomic-embed-text-v1.5]
model = {{ llm_models_dir }}/nomic-embed-text-v1.5-Q4_K_M.gguf
embedding = true
n-gpu-layers = {{ llm_router_gpu_layers }}
ctx-size = {{ llm_router_nomic_ctx_size }}
load-on-startup = true
sleep-idle-seconds = -1