Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions k8s/llm/gateway/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ model_list:
model: ollama_chat/qwen3.8:27b
api_base: http://ollama-48gib-fast.llm.svc.cluster.local:11434
model_info:
max_input_tokens: 128000
max_input_tokens: 262144
- model_name: devops-chat
litellm_params:
model: ollama_chat/qwen3.8:27b
Expand Down Expand Up @@ -140,7 +140,7 @@ model_list:
model: ollama_chat/gemma4:31b
api_base: http://ollama-48gib-fast.llm.svc.cluster.local:11434
model_info:
max_input_tokens: 128000
max_input_tokens: 262144
- model_name: gemma4:31b
litellm_params:
model: ollama_chat/gemma4:31b
Expand All @@ -153,7 +153,7 @@ model_list:
model: ollama_chat/qwen3.8:27b
api_base: http://ollama-48gib-fast.llm.svc.cluster.local:11434
model_info:
max_input_tokens: 128000
max_input_tokens: 262144
- model_name: qwen3.8:27b
litellm_params:
model: ollama_chat/qwen3.8:27b
Expand Down
2 changes: 1 addition & 1 deletion k8s/llm/profiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model_list:
model: ollama_chat/qwen3.8:27b
api_base: http://ollama-48gib-fast.llm.svc.cluster.local:11434
model_info:
max_input_tokens: 128000
max_input_tokens: 262144
- model_name: devops-chat
litellm_params:
model: ollama_chat/qwen3.8:27b
Expand Down
11 changes: 9 additions & 2 deletions k8s/llm/profiles/ollama-profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# gemini has 15.3 GiB of memory, and its 160000 context length can exhaust host memory without
# a prompt cache bound (#2382).
#
# Context lengths were measured on the tiers (#2822). ollama-48gib runs 262144, the native limit
# of qwen3-coder:30b and qwen3.8:27b: with q8_0 KV cache, qwen3-coder:30b takes 37 GB of the
# 48 GiB at that length, 100% on the GPUs, and read a 142000-token prompt in 84 s. ollama-16gib
# runs 131072, the native limit of gpt-oss:20b, which takes 13 GB with q4_0 KV cache. The 70B
# models of ollama-64gib stay at 160000: their KV cache already fills that tier. ollama-48gib-slow
# stays at 128000: Pascal GPUs read a long prompt too slowly to gain from more.
#
# Every tier runs ollama as UID and GID 10001, which no host login account uses, with RuntimeDefault
# seccomp, no privilege escalation, all capabilities dropped and a read-only root filesystem; /tmp is
# an emptyDir. HOME is /home/ollama, so the key and models/ stay in the hostPath /var/lib/ollama,
Expand Down Expand Up @@ -110,7 +117,7 @@ spec:
- name: OLLAMA_MODELS
value: /home/ollama/.ollama/models
- name: OLLAMA_CONTEXT_LENGTH
value: "48000"
value: "131072"
- name: OLLAMA_MAX_LOADED_MODELS
value: "2"
- name: OLLAMA_NUM_PARALLEL
Expand Down Expand Up @@ -542,7 +549,7 @@ spec:
- name: OLLAMA_MODELS
value: /home/ollama/.ollama/models
- name: OLLAMA_CONTEXT_LENGTH
value: "128000"
value: "262144"
- name: OLLAMA_MAX_LOADED_MODELS
value: "2"
- name: OLLAMA_NUM_PARALLEL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-10-31
skip_specs: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Proposal

## Why

Issue #2822: tier `ollama-48gib` (node condor, 2 RTX 3090) runs at a context length of 128000, and tier `ollama-16gib` (node hawk, RTX 5070 Ti) at 48000. The models of both tiers accept more, and the GPUs hold more. The owner wants the longer context where the hardware allows it.

## What Changes

- `OLLAMA_CONTEXT_LENGTH` of `ollama-48gib` goes from 128000 to 262144, the native limit of `qwen3-coder:30b` and `qwen3.8:27b`.
- `OLLAMA_CONTEXT_LENGTH` of `ollama-16gib` goes from 48000 to 131072, the native limit of `gpt-oss:20b`.
- The gateway `max_input_tokens` of the three routes to `ollama-48gib` follow, rendered with `devops ai gateway render --apply`.
- The header of `ollama-profiles.yaml` records the measured numbers and why the other tiers stay.
- The change sets `skip_specs: true` in `.openspec.yaml`: it changes two manifest values and the values that follow from them. No command, option or message changes.
- This change fits in one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

None.

## Impact

- Cluster: the DaemonSets `ollama-48gib` and `ollama-16gib` restart when Argo CD syncs. A loaded model reloads at its new length.
- Gateway: `k8s/llm/gateway/config.yaml`.

## Feasibility

Measured on 2026-10-31 in the running pods, with a temporary model made from the real one with a larger `num_ctx` (removed after the test):

- `qwen3-coder:30b` on condor at 128000: `ollama ps` shows 30 GB, and the GPUs hold 15.3 and 14.5 GiB.
- The same model at 262144: 37 GB, 100% GPU, with 18.9 and 17.9 GiB used of 24 GiB. About 6 GiB per GPU stays free. The 7-day peak of the node was 32.8 of 48 GiB, and the host uses 29% of 64 GB of memory.
- A prompt of 142214 tokens was read in 84 s (1690 tokens/s) and the model answered the instruction at its end. GPU memory did not grow.
- `gpt-oss:20b` on hawk at 131072 with q4_0 KV cache: 13 GB, with 13.7 of 16.3 GiB used on the GPU.
- Arithmetic from `ollama show -v`: KV cache per token with q8_0 is 51 KiB for `qwen3-coder:30b`, 34 KiB for `qwen3.8:27b` (only every fourth layer keeps a cache) and 170 KiB for the 70B models. That is why `ollama-64gib` stays: its 70B models fill the tier at 160000.

## Existing Tool Considered

Ollama's own `OLLAMA_CONTEXT_LENGTH` and the existing `devops ai gateway render`. Nothing is built.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Context lengths

- [x] Set `OLLAMA_CONTEXT_LENGTH` of `ollama-48gib` to 262144 and of `ollama-16gib` to 131072, and expect these values in the profile test
- Verification: `uv run pytest tests/test_ai_gateway_render.py -n 0`
- [x] Render the gateway configuration and update the example in the profiles README
- Verification: `uv run devops ai gateway render` shows no difference

## 2. Verification

- [x] Run the full CI quality checks
- Verification: `uv run devops ci`
2 changes: 1 addition & 1 deletion tests/test_ai_gateway_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_load_tier_context_lengths_against_repository_profiles() -> None:
lengths.get("ollama-48gib"),
lengths.get("ollama-48gib-slow"),
lengths.get("ollama-64gib"),
) == (48000, 48000, 48000, 128000, 128000, 160000)
) == (131072, 48000, 48000, 262144, 128000, 160000)


def test_load_service_context_lengths_maps_services_to_tier_limits(tmp_path: Path) -> None:
Expand Down
Loading