Repository navigation
Description
Problem
#1061 (PR #1062, a583d98, merged 05:57:48Z on 2026-10-03) set OLLAMA_MAX_LOADED_MODELS and OLLAMA_NUM_PARALLEL to "1" on every Ollama tier. On ollama-48gib-slow (hog, 2× Quadro P6000) that breaks RAG. The gateway still sends hog both embedding groups and five chat groups, so every chat request routed there evicts the embedding model, and every embedding evicts the chat model.
Measured read-only at 06:39Z:
- The live state. All nine DaemonSets run
MAX_LOADED=1/NUM_PARALLEL=1(kubectl get ds). The live gateway ConfigMap (applied 05:51:02Z) routes hog indevops-chat,devops-review,qwen3-coder:30b,gemma4:31b,qwen3.8:27b,bge-m3:latestandembeddinggemma:300m. - The failure. A review pinned to
qwen3-coder:30bstarted at 06:15 (ledger rows from 10551, 06:15:56). In hog's Ollama log:- From 06:15:34 to 06:19:47, hog loaded a runner 10 times, alternating bge-m3 (blob
sha256-daec…) and qwen3-coder (sha256-1194…). Each load was followed byloaded runners count=1. bge-m3 starts in 2.3–2.5 s; qwen3-coder takes 6.4–7.4 s warm and 26.9 s cold. - 124
/api/embedrequests arrived between 06:15:36 and 06:19:37. 16 took over 20 s, and 6 took 31.1–40.0 s (06:19:36–37). That is longer than the client's 30 s embedding read timeout (src/devops_cli/ai/rag/embeddings.py:812). - No
/api/embedarrived after 06:19:37, while 26/api/chatrequests kept coming until 06:32:26. That fits the run-wide RAG stop (ai/rag/investigator.py:55-62), which the firstEmbeddingsErrortriggers [inference about the client side; the client log was not read].
- From 06:15:34 to 06:19:47, hog loaded a runner 10 times, alternating bge-m3 (blob
- No embedding model is used here except bge-m3.
embeddinggemma:300mhas had no request in any Ollama or gateway log [measured by the slow-tier plan]. At release/v0.2.25 (e3ff98c), devops-cli names it only in the gateway ConfigMap, its copy insrc/devops_cli/k8s/gpu_matrix.py:745-765, the tests that mirror them, thek8s/README.mdexamples (:90,:115) and the fallback dimension table (config/constants.py:2107). Defaults, config docs and the knowledge base do not use it.config/defaults.py:201defaults toqwen3-embedding:0.6b, and the owner's config usesbge-m3:latest.
Hog is worth keeping as a background tier, outside the interactive pools:
- Its speed under fix(k8s): every ollama tier keeps one model loaded and serves one request at a time, so its kv cache holds one context #1061. Hog decodes qwen3-coder at 46.6–48.2 tok/s, against about 120 on condor (48gib-fast) and 88 on gemini (64gib-standard) [measured: llama-server print_timing, 06:16–06:17]. In the run since 06:15, its 25 calls had a median of 37.2 s, against 24.9 s on 48gib-fast (n=239) and 21.1 s on 64gib-standard (n=137) [measured: spend.db, read-only].
- Why it leaves the pools. At
NUM_PARALLEL=1, a background job on hog would sit in front of review calls in its single queue. - Two models fit. qwen3-coder at 1 × 128k projects 29,040 MiB (28.4 GiB) on hog, bge-m3 takes 833 MiB, and llama.cpp reports 48,535 MiB free [measured: hog log, 06:15:44].
- Ollama checks VRAM too, not just the count. When another runner is resident and a new model's predicted size exceeds 80% of free VRAM, it evicts anyway (Ollama v0.34.4
sched.go).- qwen3-coder is predicted at about 25 GiB, so it should log
fits alongside existing models[inference from code]. - qwen3.8:27b was predicted at 42.1 GiB and evicted bge-m3 at 04:11:03 even under
MAX_LOADED=2[measured]. - So only qwen3-coder (or something smaller) can share hog with the embedder. The dense models stay off it.
- qwen3-coder is predicted at about 25 GiB, so it should log
The ConfigMap is copied as code: get_gateway_routing_entries (src/devops_cli/k8s/gpu_matrix.py:661) returns the model_list, and tests/test_k8s_gpu_matrix.py::test_gateway_routing_entries_generation (:129) asserts that the two are equal (26 entries at e3ff98c). The owner's local edit, which comments out the two 16gib-fast embedding entries, already breaks that test and test_gateway_routes_to_provider_vram_services.
Source: .data/slow-tier-plan-20261003.md, section 3, and its verification pass. The log times above were re-read at 06:39Z.
Acceptance criteria
-
In
k8s/llm/profiles/ollama-profiles.yaml, DaemonSetollama-48gib-slow(:467-470) setsOLLAMA_MAX_LOADED_MODELS: "2"and addsOLLAMA_KEEP_ALIVE: "-1", each with a one-line comment saying why.OLLAMA_NUM_PARALLELstays"1"on every tier. The header comment (:3-5) names the exception: ollama-48gib-slow keeps its embedding model and one background model loaded. -
k8s/llm/gateway/configmap.yamlsends hog no interactive or review traffic. These ollama-48gib-slow deployments are deleted:devops-chat'sollama_chat/qwen3.8:27b(:22-28);devops-review(:99-103);qwen3-coder:30b(:123-127), so the group stays an exact copy ofdevops-review;gemma4:31b(:149-155);qwen3.8:27b(:164-170).
bge-m3:latestkeeps its hog deployment andmodel_info.mode: embedding. -
Both
embeddinggemma:300mgroups (:70-83) are deleted, and so is the 16gib-fastbge-m3:latestdeployment (:55-61), sobge-m3:latesthas one deployment, on hog. Nothing is left commented out. -
A
devops-backgroundgroup is added, and it is the only chat group with a hog deployment:# Background tier: hog's only generation model; in no interactive pool. - model_name: devops-background litellm_params: model: ollama_chat/qwen3-coder:30b api_base: http://ollama-48gib-slow.llm.svc.cluster.local:11434 timeout: 1100 # under the review client's 1,200 s read timeout, so an abandoned call frees the slot num_retries: 0
It sets no
max_input_tokens. LiteLLM v1.103.0 writes a deployment's top-levelmodel_infointo the cost-map entry everyollama_chat/qwen3-coder:30bdeployment reads, so a window there would become the window ofdevops-coder,devops-reasoning,devops-reviewand the pinnedqwen3-coder:30bgroup too (feat(review): per-model review quality baseline for the devops-review pool #475 keeps pinned groups windowless). The tier'sOLLAMA_CONTEXT_LENGTHof 128000 is its limit. -
router_settings.fallbacksgains- devops-review: [devops-background]. It gains nodevops-chat: [devops-background]rule, and the pinned groups (qwen3-coder:30b,gpt-oss:20b) stay out of every fallback rule. -
get_gateway_routing_entries(src/devops_cli/k8s/gpu_matrix.py:661) returns the newmodel_list(19 entries), andtest_gateway_routing_entries_generationstill asserts that they are equal. -
tests/test_k8s_llm_gateway.pyfollows the manifests:test_every_ollama_tier_keeps_one_model_and_serves_one_request(:369-385) expects"1"for both settings on every tier, exceptOLLAMA_MAX_LOADED_MODELS"2"on ollama-48gib-slow. It also readsOLLAMA_KEEP_ALIVE:"-1"on ollama-48gib-slow and unset everywhere else.test_gateway_configmap_virtual_models(:112) expectsdevops-background, the third fallback rule and noembeddinggemma:300m.test_gateway_review_pool_spans_ollama_backends(:183) andtest_gateway_routes_to_provider_vram_services(:227) expect no hog deployment in the review pools and onebge-m3:latestbase.
-
A new test: every non-embedding deployment whose
api_baseis ollama-48gib-slow belongs todevops-background, anddevops-backgroundhas exactly one deployment. It fails on the current ConfigMap. -
k8s/README.mdsays whatdevops-backgroundis for:review path --watch,ai pipeline,ai agentsandanalyze --enhanced, pointed at it through environment overrides withDEVOPS_CLI_AI_MAX_RETRIES=1, and never inconfig.yaml. Its examples (:90,:115) namebge-m3:latestinstead ofembeddinggemma:300m. -
fix(k8s): every ollama tier keeps one model loaded and serves one request at a time, so its kv cache holds one context #1061's task file is not edited. This item's task file records the hog exception.
-
The tests run offline and call no gateway, Ollama or model.
-
changelog.d/1064.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited. -
uv run devops cipasses. -
(person-run) Apply the profiles (
kubectl apply -k k8s/llm/profiles), then the ConfigMap, thenkubectl -n llm rollout restart deploy/llm-gateway. Note the time.- During a background job, hog's log shows
fits alongside existing modelsandloaded runners count=2, and nopredicted to exceed available memory, evicting. kubectl -n llm logs ds/ollama-48gib-slow --since=15m | grep -E 'POST +"/api/(chat|embed)'shows/api/embed, plus/api/chatonly while adevops-backgroundjob runs.- No
/api/embedtakes over 30 s during a generation. Record its p95; if it is over about 2 s, say so on this issue.
- During a background job, hog's log shows
Key questions
- Why not keep one model on hog? (proposed) The cap of 1 is what fails. Between 06:15:34 and 06:19:47, bge-m3 and qwen3-coder evicted each other 10 times, and six embeddings waited 31–40 s, past the client's 30 s. Embeddings then stopped while chat continued. Hog serving bge-m3 alone would also work, and the owner can do that today by removing the five chat deployments. But hog would then hold no generation model, and the two models fit together with about 18 GiB to spare. So hog keeps two: the embedder and qwen3-coder.
- Why no failover for embeddings? (proposed) Not in this item. LiteLLM v1.103.0 ignores per-deployment
timeoutandnum_retriesonollama/embeddings: the Ollama embed handler posts throughlitellm.module_level_aclientwith no per-call timeout (defaultrequest_timeout6000 s), and_aembeddingnever applies a deployment'snum_retries[code: LiteLLM v1.103.0main.py,router.pyand the Ollama embed handler, per the plan's verification]. A hung hog would therefore never fail over within the client's 30 s, and only fast failures (connection refused, 5xx) would. The obvious second host, gemini, serves four generation models, soMAX_LOADED=2there would still let an embedding evict its review model. Until then, a restart of hog's Ollama pod pauses RAG. Once the RAG client fixes (fix(ai): a failing embedding model pauses rag lookups instead of ending rag for the run, and each embedding model gets its own prompts, cache keys, dimension and bounded chunks #1065) land, the review carries on without RAG. - Why
devops-review: [devops-background]and notdevops-chat: [devops-background]? (proposed) LiteLLM chains fallbacks. Adevops-chatrule would also letdevops-coder(compose) anddevops-reasoningfailures reach hog throughdevops-coder→devops-chat→devops-background. Fallbacks fire on errors once the group's retries fail, and a gateway timeout counts as one: the router's 1,500 s timeout outlasts the review client's 1,200 s, so adevops-reviewcall that timed out at the gateway was already given up, and the fallback then spends hog's slot (up to 1,100 s) on a reply nobody reads. Becausecontext_window_fallbacksis set, an oversizeddevops-reviewprompt re-raises instead of falling back, so it never reaches hog. The pinned groups get no fallback (test_a_review_model_has_a_group_of_its_review_deployments_alone, feat(review): per-model review quality baseline for the devops-review pool #475), so a review pinned toqwen3-coder:30bgets none. - Why
timeout: 1100andnum_retries: 0? (proposed) At one slot, a call the client has abandoned still holds hog until the gateway gives up. 1,100 s is under the review client's 1,200 s read timeout (config/defaults.py:300).num_retries: 0stops the gateway re-queuing the same work on the same slot. The client retries too:ai.max_retriesis 5 in the owner's config, and_retry_chat_dispatch(ai/client/unified.py:630) re-sends after a timeout. That is why the README's recipe setsDEVOPS_CLI_AI_MAX_RETRIES=1. - Why
KEEP_ALIVE=-1on hog only? (proposed) The gateway sends hog only two models, so nothing needs to be unloaded there. Without it, Ollama unloads a model after 5 idle minutes and the next call pays the reload (6.4–7.4 s warm, 26.9 s cold). The gateway path sends no per-requestkeep_alive. A third model would evict one of the two; the embedding-model switch (feat(ai): embeddings through the llm gateway, with embedding model evaluation #481) runsollama stopfirst. - How does this interact with the gateway health-check routing item now being built (its issue is not filed yet)? (proposed) This item owns placement: groups, weights, fallbacks, per-deployment
timeout/num_retriesand the hog exception. That item owns liveness. It must not probedevops-background: the group has one deployment, so a probe queues behind real work atNUM_PARALLEL=1and times out. It should probe at most the one model each Ollama host keeps loaded, because on Ollama a chat probe loads the model it names. It should also keepmodel_info.mode: embeddingon the embedding entries and ignore transient errors. Both items edit the ConfigMap,gpu_matrix.pyand their tests, so whichever lands second rebases. - Do reviews lose capacity? (proposed) A little. Hog carried weight 1 of 16 in
qwen3-coder:30band 1 of 22 indevops-review. Its calls since 06:15 had a median of 37.2 s against 21–25 s on the other two tiers. While hawk (16gib-fast) is NotReady, the pools are condor and gemini. - Is this a v0.2.25 critical fix? (proposed) Yes. It fixes a regression that fix(k8s): every ollama tier keeps one model loaded and serves one request at a time, so its kv cache holds one context #1061 (a583d98) introduced in v0.2.25, which has not shipped. While hog sits in the pools, any review routed there turns RAG off for the run. It is P1, as fix(review): passing criteria leave a finding for the verifier instead of verifying it, and running the cited test counts as evidence #1043 and fix(review): the scanned-clean check invalidates only claims about a dependency's own advisories #1044 were.
Depends on: none.
Order: lands before the v0.2.25 cut. The health-check routing item edits the same ConfigMap, gpu_matrix.py and tests; whichever lands second rebases. #1060 (backlog) and #795 (v0.2.29) also edit ollama-profiles.yaml; this item lands first.
Related:
- fix(k8s): every ollama tier keeps one model loaded and serves one request at a time, so its kv cache holds one context #1061: one model and one slot per tier (the regression).
- feat(ai): ollama model residency per-pod model budget, keep-alive, ms/token #598: Ollama residency and keep-alive; this item decides hog's.
- feat(ai): embeddings through the llm gateway, with embedding model evaluation #481: the embedding-model switch, run after the RAG client fixes (fix(ai): a failing embedding model pauses rag lookups instead of ending rag for the run, and each embedding model gets its own prompts, cache keys, dimension and bounded chunks #1065).
- fix(ai): a failing embedding model pauses rag lookups instead of ending rag for the run, and each embedding model gets its own prompts, cache keys, dimension and bounded chunks #1065: the RAG client fixes (circuit breaker instead of the run-wide stop).
- fix(review):
review path --watchreviews only the files that changed #1067, fix(ai):analyze --enhancedandai agentsuse theai.tasks.metadatamodel #1068:--watchand the metadata task, which usedevops-background. - feat(review): per-model review quality baseline for the devops-review pool #475: pinned review groups.
- fix(ai): the spend ledger records every attempt the gateway failed, including the retry transport's, and its gap to the gateway's count is measured first #1019: client and gateway retries.
- fix(k8s): the ollama tier DaemonSets drop privilege escalation and capabilities, use RuntimeDefault seccomp and a read-only root filesystem, and run as non-root where the model directory allows #1060: Ollama DaemonSet hardening, in the same file.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(k8s): ollama-48gib-slow keeps its embedding model and qwen3-coder…
dan-petty commentedon Oct 3, 2026
Closed by #1071, merged into
release/v0.2.25.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.dan-petty commentedon Oct 3, 2026
Applied and checked (2026-10-03 14:24Z).
kubectl apply -k k8s/llm/profiles,kubectl apply -f k8s/llm/gateway/configmap.yaml,kubectl -n llm rollout restart deploy/llm-gatewayat 14:24:23Z, after akubectl diffthat showed only this item's changes (the background tier'sOLLAMA_MAX_LOADED_MODELS1 → 2 andOLLAMA_KEEP_ALIVE "-1", and the gateway ConfigMap). Both rollouts completed; no other tier's pods restarted.devops-background.ollama-48gib-slow), exercised directly through a port-forward (no gateway key needed): onebge-m3:latestembed (3.9 s, cold load), oneqwen3-coder:30bgeneration (7.1 s, cold load), then three embeds at 22–40 ms. The log showsllama-server model fits alongside existing models(predicted 25.1 GiB, num_ctx 128000) and nopredicted to exceed available memory, evicting./api/pslists both models loaded, keep-alive unbounded.20261003-060647).llmwith the key fromllm-gateway-secretsviasecretKeyRefsent onedevops-backgroundchat to the in-cluster gateway URL: HTTP 200 in 0.6 s, reply "OK", and the background tier logged the matchingPOST /api/chat(83 ms, model already loaded).feat(release): v0.2.25 (#1089)
fix(k8s): open webui, the ollama ingress, the gateway and the cli's d…
feat(ai): the LLM stack dashboard shows latency per output token, and…