Repository navigation
Description
Problem Description
ollama-16gib sets OLLAMA_KV_CACHE_TYPE: q4_0. The other eight tiers set q8_0 (k8s/llm/profiles/ollama-profiles.yaml). Ollama passes the value to llama-server for every model, also for the embedding model (--cache-type-k q4_0 --cache-type-v q4_0). The 4-bit KV cache changes the vectors of qwen3-embedding:0.6b: for the same input, a vector from ollama-16gib has a cosine of 0.78 to 0.92 against a vector from a q8_0 tier.
The gateway lists ollama-16gib-fast as an order: 2 deployment of qwen3-embedding:0.6b (k8s/llm/gateway/config.yaml). When an order-1 tier fails or cools down, a RAG batch goes to it. Its vectors then go into the same Qdrant collection as the q8_0 vectors, and retrieval of those chunks gets worse. Nothing records which tier made a vector.
Reproduction Steps
- Make sure that
ollama-16gibhas no model loaded (kubectl -n llm exec ds/ollama-16gib -c ollama -- ollama ps), so the test evicts nothing. - Port-forward
ds/ollama-16gibandds/ollama-48gib-slow. - Send the same
/api/embedrequest to each:{"model": "qwen3-embedding:0.6b", "input": [<three texts>], "options": {"num_ctx": 8192}}. - Compute the cosine of each pair of vectors.
Expected vs Actual Behavior
- Expected: every tier that serves the embedding group makes the same vector for the same input (cosine 0.999 or more, the noise between two GPU families).
- Actual: on 2026-10-28, with Ollama 0.34.4, three texts gave cosines of 0.858, 0.922 and 0.784 between
ollama-16gib(q4_0) andollama-48gib-slow(q8_0). On Ollama 0.40.12, with the KV cache type equal, the same comparison across two GPU families gave 0.9995 to 0.9997, so the KV cache type causes the difference.
Environment Diagnostics
- Ollama 0.34.4 on every tier. 0.40.12 passes
OLLAMA_KV_CACHE_TYPEtollama-serverin the same way (llm/server.go,llm/llama_server.go). qwen3-embedding:0.6b, Q8_0 GGUF, last-token pooling.
Logs, Traces, or Terminal Output
llama-server command on the q8_0 tier: --cache-type-k q8_0 --cache-type-v q8_0 --flash-attn auto --embedding -b 2048 -ub 2048. On a q4_0 tier the same command has --cache-type-k q4_0 --cache-type-v q4_0.
Proposed design
Problem statement
The ollama-16gib tier sets OLLAMA_KV_CACHE_TYPE to q4_0 while the other eight tiers set q8_0. Ollama passes this value to llama-server for every model, including the embedding model. The 4-bit KV cache changes the vectors of qwen3-embedding:0.6b, so a vector from the 16gib tier has a cosine of 0.78 to 0.92 against a vector from a q8_0 tier. When the gateway routes a RAG embedding batch to the 16gib tier as an order-2 fallback, the drifted vectors enter the shared Qdrant collection and degrade retrieval quality for those chunks.
Acceptance criteria
- Criterion 1: The ollama-16gib DaemonSet in k8s/llm/profiles/ollama-profiles.yaml sets OLLAMA_KV_CACHE_TYPE to q8_0.
Verification: Read the ollama-16gib container env block in k8s/llm/profiles/ollama-profiles.yaml and confirm the value is q8_0. - Criterion 2: All nine Ollama tiers in ollama-profiles.yaml use the same OLLAMA_KV_CACHE_TYPE value.
Verification: Grep for OLLAMA_KV_CACHE_TYPE in k8s/llm/profiles/ollama-profiles.yaml and confirm every occurrence has the value q8_0. - Criterion 3: After the change, the same /api/embed request sent to ollama-16gib and ollama-48gib-slow returns vectors with a cosine similarity of 0.999 or higher.
Verification: Port-forward both DaemonSets, send the same three-text embedding request to each, and compute the pairwise cosine. Every pair must be 0.999 or above.
Key questions
- Will the 16gib tier have enough VRAM for a q8_0 KV cache with its 48000-token context and two loaded models?: Yes. The 16gib tier uses a shorter context (48000) than the other embedding tiers (128000 or more), and the issue and intake both treat the one-line change as safe. The knowledge base document confirms q4_0 saves roughly 50% of per-slot VRAM, so q8_0 uses more, but the shorter context and the tier's 16-to-20 GiB GPU target absorb the difference. (proposed) [sources: k8s/llm/profiles/ollama-profiles.yaml:117, src/devops_cli/ai/knowledge_base/it_domains/tools/ollama.md:31, openspec/changes/archive/2026-10-28-2395-ollama-0-40-12/design.md:16]
- Should the fix also add metadata to record which tier produced each vector in the Qdrant collection?: No. The intake scopes this item to the one-line config fix. Recording the producing tier is a separate concern and is not part of this change. (proposed) [sources: k8s/llm/gateway/config.yaml]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
Activity
dan-petty commentedon Oct 28, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
A configuration error (q4_0 vs q8_0) produces wrong embedding vectors, which is a defect in the deployment profile.The bug silently degrades RAG retrieval only when the order-1 tier fails, so it is not a crash but it corrupts index data.Drifted vectors in the shared Qdrant collection reduce retrieval quality for every chunk they affect, but the trigger is a fallback scenario.The core fix is changing OLLAMA_KV_CACHE_TYPE from q4_0 to q8_0 in the profile YAML, a one-line config edit.Both items concern the embedding fallback path across tiers, but #2027 fixes routing spread while this candidate fixes the KV cache type that makes fallback vectors inconsistent.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
devops-cli-service commentedon Nov 1, 2026
Staged: branch
fix/2396-the-q4-0-ollama-16gib-tier, draft pull request #2988. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
docs(openspec): plan #2396 set ollama-16gib KV cache to q8_0 (#2988)
43 remaining items
devops-cli-service commentedon Nov 1, 2026
Cleared the stop at group 1 by the rule
digest: the runner image changed since the stop, from sha256:04d655904252706a7321aed38fa5cafd293625c5db469f252f57163a7c463f16 to sha256:c4ca1742d66bef1bfb15d41d7c54ebf2d0c674a8aaf413f2b28253a0963e4ab0. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a commentimplement: retry.devops-cli-service commentedon Nov 1, 2026
Pull request #3101 is ready for review. The checks passed.
Spend: 36 model requests, 876581 input tokens, 4851 output tokens.
fix(k8s): remove a trailing space in the ollama profiles comment (#2396)
devops-cli-service commentedon Nov 1, 2026
The runner Job devops-cli-runner-20261101-201520-b97a ended: succeeded.
Image digest: sha256:c4ca1742d66bef1bfb15d41d7c54ebf2d0c674a8aaf413f2b28253a0963e4ab0
The last lines of its log: