Skip to content

Make lcode bench count the part of a loaded model in RAM - #261

Open
nasser1941 wants to merge 4 commits into
mainfrom
fix/bench-memory
Open

nasser1941 wants to merge 4 commits into
mainfrom
fix/bench-memory

Conversation

@nasser1941

Copy link
Copy Markdown
Owner

Builds on #260 and merges after it. This branch has #260's commit, then main merged in, then its own two commits. Until #260 merges, the diff below includes #260's changes too; this PR's own are 784f8dd (CHANGELOG placement after merging main) and f3395e9 (the change).

What changes

lcode bench read /api/ps directly. With Ollama 0.40, lcode-qwen3.6-35b at 32K on a 12 GB GPU printed Loaded in 18s · 10.4 GB, 98% on the GPU, because Ollama leaves out the ~12 GB of experts that stay mapped from the model's file in RAM. The summary and the --markdown table said the same.

It now uses residency.placement (which matches lcode-qwen3.6-35b:latest) and #260's residency.with_estimate, so it says what the line after a load says:

  Loaded in 18s · ~23 GB, 42% on the GPU and the rest in system RAM · reads prompts at 905 tok/s

and ~23 GB, 42% on GPU in the summary's Memory row. When Ollama counts the whole model (all of it on the GPU, or a model outside the catalog), both show Ollama's numbers as before, in the load line's words: 6.6 GB, all on the GPU.

The JSON

--json results keep Ollama's count under the names it always had: memory_gb (10.4) and gpu_percent (98). docs/bench.md promises that existing fields keep their meaning until schema changes, and older results only have Ollama's count, so comparing those two fields across results stays like for like. lcode's estimate goes next to them:

Field Example Meaning
estimated_memory_gib 22.7 The whole model by the catalog's estimate, in GiB, as lcode setup shows it (~23 GB)
estimated_gpu_percent 42 The share of that on the GPU

Both are null when Ollama counts the whole model. lcode bench --compare reads only --harbor results, which record no memory, so nothing changes there.

Docs and CHANGELOG

  • docs/bench.md: the example's Loaded line, What's measured, the 12 GB laptop table (with a note that 0.58.0 printed Ollama's 10.5 GB, 98% on GPU), the JSON example and the field table.
  • docs/models.md: names lcode bench next to the load line and lcode doctor.
  • CHANGELOG.md: a Fixed entry under the new Unreleased.

Merging main

Main released 0.62.0 after #260 branched, which renamed the old Unreleased section. Merging main filed #260's two CHANGELOG entries under [0.62.0] without a conflict. 784f8dd puts them back under Unreleased, where this PR's entry follows them. After #260 merges, merging main here again will likely conflict in Unreleased, since both sides add #260's entries there: keep main's and this PR's entry after them.

Testing

  • uv run pytest: 1156 passed, 2 skipped
  • uv run ruff check . && uv run ruff format --check .: clean
  • uv run basedpyright: 0 errors
  • uv run --group docs mkdocs build --strict: builds
  • New tests in tests/test_bench.py, with FakeOllama: Ollama 0.40's numbers for lcode-qwen3.6-35b:latest (the line, the JSON and the Memory row), a model all on the GPU and one outside the catalog (Ollama's count stands), and a model measured after its tasks because the load failed. All three fail on the old bench.py.
  • Not run against a real Ollama: no model was loaded on the GPU, because of the gate nights.

🤖 Generated with Claude Code

nasser1941 and others added 4 commits November 7, 2026 14:50
lcode doctor looked for lcode-qwen3.6-35b in /api/ps, where Ollama lists
lcode-qwen3.6-35b:latest, so its Loaded line never appeared for the models
lcode setup creates. It now finds the model the way the load line does
(same_model) and says the same thing, with the context.

The line after a load repeated /api/ps, which leaves out the weights that
stay mapped from the model's file in system RAM: with Ollama 0.40,
qwen3.6-35b at 32K on a 12 GB GPU showed as "10.5 GB, 98% on the GPU" while
~12 GB of experts were in RAM. For catalog models partly off the GPU, lcode
now counts the model at the catalog's estimate, the one lcode setup and
lcode doctor show: "~23 GB, 42% on the GPU and the rest in system RAM".
With that share the warning that another program is using GPU memory can
fire again; it now says how much of the model fits rather than calling the
catalog's figure usual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging main filed them under 0.62.0, the release that renamed the old Unreleased section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lcode bench read /api/ps directly, so with Ollama 0.40 it printed lcode-qwen3.6-35b at 32K on a 12 GB GPU as
10.4 GB, 98% on the GPU, leaving out the ~12 GB of experts that stay mapped from the model's file in RAM. It now
uses residency.placement and with_estimate, as the line after a load does: ~23 GB, 42% on the GPU and the rest in
system RAM, and ~23 GB, 42% on GPU in the summary.

--json results keep Ollama's count in memory_gb and gpu_percent, so they still compare with older results, and add
the estimate in estimated_memory_gib and estimated_gpu_percent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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