Skip to content

Switch production inference to llama-server after the backend comparison cleared every adoption gate (ADR-001067) - #443

Merged
Kaikei-e merged 9 commits into
mainfrom
feat/llamacpp-production-eval
Dec 4, 2026
Merged

Kaikei-e merged 9 commits into
mainfrom
feat/llamacpp-production-eval

Conversation

@Kaikei-e

@Kaikei-e Kaikei-e commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Why

ADR-001066 made news-creator's generation backend switchable between Ollama and llama-server and left the production default to a measured comparison. This PR records that comparison and switches production to llama-server (ADR-001067).

Before comparing, llama-server's thinking behaviour had to match Ollama's. Ollama thinks by default for Gemma 4 when a chat request does not set think, and production's non-streaming chats (rag answers, plan-query, the recap final summary) rely on that. llama-server was started with --reasoning off, so a plain switch would have changed speed and answers at the same time.

What

Thinking parity

  • llama-server starts with --reasoning on.
  • The llama.cpp chat driver passes think through with the same rules as the Ollama driver. Thinking is forced off only for streaming.

Comparison harness

  • plan-query and the recap final summary are benchmarked through the production prompt builders and chat drivers.
  • A comparison script checks both runs against the adoption gates.
  • The Augur eval can dump per-case results.

Result: all 13 gates passed

  • Each backend ran alone on the GPU with the same GGUF and the same context length.
  • Article summaries: TTFT −43%, end-to-end −13%, decode +3%.
  • plan-query: end-to-end −4%, schema pass rate unchanged.
  • Recap final summary: end-to-end +2.7% (within the ±5% gate), schema pass rate unchanged.
  • No errors on either backend.
  • Augur: 6/55 passed on llama-server against 5/55 on Ollama. This is weak evidence of answer quality: the eval set uses synthetic names, so retrieval finds no real documents and most passes are correct "no answer" replies. The ADR records this limitation.

Production switch

  • compose/ai.yaml runs news-creator-backend as llama-server (CUDA, b12808). GPU, memory limit, network and container name are unchanged. It no longer receives the whole host .env, only its three settings.
  • The previous Ollama definition moves to the opt-in overlay compose/compose.ollama.yaml, and its chown hook moves with it. The CUDA llama-server overlay is removed because it is now the default.
  • news-creator's LLM_BACKEND is pinned in the same compose render that picks the container kind: llamacpp by default, ollama in the Ollama overlay. NEWS_CREATOR_LLM_BACKEND is removed from LKAL, required env and the env templates, and is listed as retired, so a leftover host value is flagged.
  • Model volume: news-creator-backend sits only on the internal generation-raw-network and cannot download models itself. scripts/seed-llamacpp-models.sh fills its volume from a throwaway container, or from an already-verified volume, using the same sha256 pins as the entrypoint. A test keeps the URLs and pins in step.
  • news-creator startup: news-creator now exits when its plaintext listener fails startup, which is where the upstream-kind check runs. Before, the mTLS listener kept serving a half-initialised app and the process never restarted. llama-server takes longer than Ollama to become ready after a host reboot, so this fix is a precondition of the switch.

Rollout

  • Seed the model volume first. Before the deploy, run scripts/seed-llamacpp-models.sh on the host. The container cannot fetch the models.
  • Recreate both containers in one deploy. The deploy that ships this change must recreate news-creator-backend together with news-creator. If only news-creator is recreated, its startup check finds Ollama where it expects llama-server and it restarts until the inference container is switched too.
  • Rollback. Deploy the previous definition. The Ollama model volume is kept.

Tests

  • Tests and lint:
    • cd news-creator/app && uv run pytest: 1584 passed.
    • ./scripts/lint/run.sh news-creator/app, compose and repo all pass.
  • ADR checks: docdag validate --immutable-since origin/main and alt-harness adr-gate --base origin/main pass.
  • Compose render: checked with and without compose/compose.ollama.yaml.
  • Seed script: run against a throwaway volume. It copied and verified both files, then reported them as already present on a second run.
  • Commits: RED and GREEN are separate commits. A failure-pattern review found the startup hang, the host-env and compose split, the unseeded volume and the .env passthrough; the second RED/GREEN pair fixes them.

🤖 Generated with Claude Code

Kaikei-e and others added 9 commits December 4, 2026 01:29
…nd the llama.cpp chat driver to pass think through like the Ollama driver, forcing it off only for streaming (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nk through the llama.cpp chat driver like the Ollama driver, forcing it off only for streaming (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpt builders, a backend comparison against the adoption gates, and per-case Augur eval result dumps (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rompt builders and chat drivers, compare backends against the adoption gates, and dump per-case Augur eval results (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with Ollama kept as an opt-in overlay, the declared backend to be llamacpp, and the Ollama chown hook to leave the production audit (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a as the compose.ollama.yaml overlay, declare NEWS_CREATOR_LLM_BACKEND=llamacpp, and record the backend comparison that cleared every adoption gate (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…startup, the inference driver to be pinned in compose instead of read from the host env, the inference container to get no host .env, and a seed script for the llama-server model volume (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the inference driver in compose and retire NEWS_CREATOR_LLM_BACKEND, stop passing the host .env to llama-server, and add a seed script for its model volume (ADR-001067)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…format in the compose wiring test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kaikei-e
Kaikei-e merged commit 0dff387 into main Dec 4, 2026
46 checks passed
@Kaikei-e
Kaikei-e deleted the feat/llamacpp-production-eval branch December 4, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant