Skip to content

feat(inference): keep managed Ollama within its budget on each GPU - #14396

Merged
cv merged 1 commit into
v1from
cv/ollama-multi-gpu
Nov 11, 2026
Merged

cv merged 1 commit into
v1from
cv/ollama-multi-gpu

Conversation

@cv

@cv cv commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Managed Ollama services keep their per-GPU budget on every GPU the container sees: the runtime sets OLLAMA_GPU_OVERHEAD from the largest free memory among those GPUs, refuses to start when any of them has less than the budget free, and accepts a loaded model of up to the budget times the number of GPUs. NemoClaw still doesn't set OLLAMA_SCHED_SPREAD, so Ollama keeps its own placement. With one GPU, both values equal today's.

Problem

The Ollama runtime computed OLLAMA_GPU_OVERHEAD and the readiness bound from one GPU's counters (Capacity::gpu_memory). Ollama applies the overhead on every GPU it sees and reports one size_vram total in /api/ps, so on several GPUs those values would either leave a GPU more than the budget or reject a model split across GPUs.

Part of #14384: this is step 7, following decision 4 of the maintainer's decisions comment. What's left:

  • Step 4: hardware_capacity::budget, serving_memory, and check_memory still read the single-GPU Capacity::gpu_memory, which is unset with two or more GPUs, so a multi-GPU capacity stops there before this step's code runs.
  • Step 9: the runtime's populate still requires exactly one visible GPU, and container.gpuDevices takes one entry.

Change

  • crates/nemoclaw-runtime/src/ollama/runtime/process.rs: gpu_limits reads the per-GPU inventory from feat(inference): observe each GPU on a host #14388 (Capacity::gpus).
    • OLLAMA_GPU_OVERHEAD is the largest free memory among the GPUs minus the per-GPU budget, so no GPU offers Ollama more than the budget.
    • Every GPU must have the budget free, with the existing error.
    • Unified-memory GPUs, which report no framebuffer counters, keep an overhead of 0. A mix of GPUs with and without counters is refused, because their free memory can't be checked.
    • The readiness bound is the budget times the number of GPUs.
  • crates/nemoclaw-runtime/src/ollama/runtime/observation.rs: the readiness check still requires size_vram == size and bounds size_vram by that total.
  • OLLAMA_SCHED_SPREAD stays unset, as decision 4 chose; a test pins that.
  • docs/agents-inference/inference.md: Ollama's placement, the overhead, the free-memory check, and that /api/ps reports one total rather than each GPU's share, so the readiness check can't show which GPU exceeded its budget.

The memory fields' meaning, the provider's capacity accounting, and process supervision and error reporting don't change. limits.md gets no row: the missing per-GPU share is a property of Ollama's API that no NemoClaw issue would fix, so inference.md states it where it affects the reader.

Beyond CI

Unverified: Ollama on two or more GPUs. The multi-GPU cases are tested with fake GPU inventories only, because neither this host (one GB10) nor CI has several GPUs, and the runtime still requires one visible GPU.

@cv

cv commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author
Authoring session — opening
Field Status Value Evidence or limit
Harness recorded Pi 1.5.0 (session format 3), as a helper agent Session metadata and harness install path
Skills recorded nemoclaw-contributor-create-pr (complete read) Tool reads to the cutoff; no other skill file was read in full
Instruction files recorded AGENTS.md (injected); WRITING.md (complete read); .github/PULL_REQUEST_TEMPLATE.md (complete read); .github/SESSION_REPORT_TEMPLATE.md (complete read) Startup injection and tool reads to the cutoff; internal-docs/contributing/testing.md was read only in part
Tool calls partial typescript: 35 Wrapper calls from the first event to the signed-off commit, including failures; the nested workspace, git, gh, and shell calls inside each wrapper aren't counted
Session window recorded 2026-11-11T07:53Z to 2026-11-11T08:06Z; 13 min First event to the commit, including idle time
Compactions recorded 0 Complete record to the cutoff
Models recorded claude-opus-5-5 Model change event and assistant turns; no changes
Reasoning levels recorded high Thinking-level event; no changes

@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 6c686ad into v1 Nov 11, 2026
66 checks passed
@cv
cv deleted the cv/ollama-multi-gpu branch November 11, 2026 08:23
@cv cv changed the title feat(inference): keep managed Ollama within its budget on each GPU feat(inference): pass managed Ollama's per-GPU reserve to Ollama and llama.cpp Nov 11, 2026
@cv cv changed the title feat(inference): pass managed Ollama's per-GPU reserve to Ollama and llama.cpp feat(inference): keep managed Ollama within its budget on each GPU Nov 11, 2026
cv added a commit that referenced this pull request Nov 11, 2026
…14400)

Managed Ollama services now pass their per-GPU reserve to llama.cpp as
`LLAMA_ARG_FIT_TARGET` as well as to Ollama as `OLLAMA_GPU_OVERHEAD`,
and the docs say what each setting does and what NemoClaw enforces. This
follows up #14396 with its review fixes and the [amendment to decision
4](#14384 (comment)).

## Problem

#14396, as merged, overstates what `OLLAMA_GPU_OVERHEAD` does on Ollama
v0.40.14, the version the runtime image pins. Its docs and comments say
the reserve leaves no GPU more than the budget, but Ollama reads it only
for a log line (`server/sched.go:661-669`), the default context size
(`server/routes.go:2573`), and the MLX runner
(`mlxrunner/client.go:401`). GGUF layer fitting uses llama.cpp's `--fit`
with its own per-device margin, 1024 MiB by default, so the budget
wasn't applied while a model loaded, even on one GPU.

#14396 also added a per-GPU free-memory rule in `launch` that duplicates
`hardware_capacity::check_memory` and can't run with several GPUs yet.
And `inference.md` describes an Ollama weight-size check that no code
path has run since #13457.

Part of #14384, step 7. What's left:

- Step 4: `hardware_capacity::budget`, `serving_memory`, and
`check_memory` still read the single-GPU `Capacity::gpu_memory`, which
is unset with two or more GPUs, so a multi-GPU capacity stops there
before this code runs. The per-GPU fit check (every selected GPU has the
budget free) belongs there.
- Step 9: the runtime's `populate` still requires exactly one visible
GPU, and `container.gpuDevices` takes one entry. Its live run covers two
GPUs with a model between the per-GPU budget and 80% of one GPU's free
memory, reading per-GPU usage from `nvidia-smi`.

## Change

- `crates/nemoclaw-runtime/src/ollama/runtime/process.rs`:
- `gpu_limits` and its per-GPU free-memory rule are gone. `launch`
computes the reserve, the largest free memory among the GPUs in
`Capacity::gpus` minus the per-GPU budget, with the existing error when
it would be negative, and the readiness bound, the budget times the
number of GPUs. With one GPU, both equal the values before #14396.
- `LLAMA_ARG_FIT_TARGET` is the same reserve rounded up to whole MiB.
`ollama serve --help` documents it as the "Target free VRAM margin per
device for llama.cpp fit (MiB)", Ollama's `llama-server` inherits it
(`llm/llama_server.go:761-765`), and llama.cpp applies one value to
every device. When the reserve is below llama.cpp's 1024 MiB default
(`fit_params_target` in `common/common.h` at llama.cpp b11963, which
Ollama v0.40.14 pins), the runtime leaves the variable unset, so
NemoClaw never lowers llama.cpp's margin. Unified-memory GPUs report no
counters, get a reserve of 0, and keep llama.cpp's default.
- `OLLAMA_GPU_OVERHEAD` stays, as decision 4 chose, and
`OLLAMA_SCHED_SPREAD` stays unset; tests pin both.
  - The comments say what each setting does in v0.40.14.
- `docs/agents-inference/inference.md`: corrects what #14396 claimed. It
describes both settings, and says what NemoClaw does and doesn't
enforce. Ollama chooses its GPUs from raw free memory, so a model can
land on one GPU with part of it offloaded to the CPU instead of
spreading, and readiness then fails. NemoClaw enforces only the total,
after the load, through `/api/ps`, which reports one total and not each
GPU's share. The per-GPU budget is a margin llama.cpp keeps, not a
guarantee NemoClaw checks. The stale weight-size sentence is replaced by
what plan and readiness actually compare.

### For review: one-GPU behavior changes

- On a dedicated-memory GPU whose free memory exceeds the budget by at
least 1024 MiB, llama.cpp now fits the layers within the budget instead
of within free memory minus 1024 MiB. A model over budget is partly
offloaded to the CPU and fails readiness's `size_vram == size` check,
rather than loading fully on the GPU and failing its budget bound.
Either way, startup fails.
- With `LLAMA_ARG_FIT_TARGET` inherited, Ollama doesn't add its own
margin for a vision projector (`llm/llama_server.go:742-769`), so a
multimodal model gets NemoClaw's reserve without Ollama's projector
padding.

## Beyond CI

Unverified: Ollama on two or more GPUs, and the effect of
`LLAMA_ARG_FIT_TARGET` on a live load. The multi-GPU cases are tested
with fake GPU inventories only, because neither this host (one GB10,
unified memory, where the variable stays unset) nor CI has several GPUs,
and the runtime still requires one visible GPU. The Ollama and llama.cpp
behavior above comes from reading their sources at the pinned revisions,
not from a run.

Signed-off-by: Carlos Villela <[email protected]>
cv added a commit that referenced this pull request Nov 11, 2026
Managed vLLM and Ollama services' GPU memory settings now apply to each
GPU a service selects, and the fit checks and the
`vllm_capacity`/`ollama_capacity` reads check every selected GPU on its
own. Configurations on one GPU keep their meaning;
`container.gpuDevices` still takes one entry.

## Problem

The memory contract and its checks assumed one GPU. `validate_weights`
required all of a model's weights, plus the KV cache and 2 GiB, to fit
one budget even when vLLM splits them across GPUs. The vLLM and Ollama
hardware checks compared the budget with one GPU's total and free
memory, and the capacity data sources added every service's budget
against one GPU's total.

Part of #14384: this is step 4, following decisions 1, 5, and 6 of the
maintainer's decisions comment. What's left: step 9, lifting the
one-entry limit. With this change, the per-GPU Ollama reserve from
#14396 gets a budget that fits every selected GPU.

## Change

- **Field meaning:** `gpuMemoryGiB`, `gpuMemoryUtilization`,
`kvCacheGiB`, `hardware.minGpuMemoryBytes`, and a recipe's
`resources.gpuMemoryBytes` apply to each selected GPU, for vLLM and
Ollama. `GPU_MEMORY_MAX` (96 GiB) stays a per-GPU bound. The field
descriptions, the generated schema and configuration reference,
`models.md`, `inference.md`, `recipes.md`, and `provider.md` say so.
- **Weight check:** `validate_weights` is a lower bound: the safetensors
bytes divided by tensor × pipeline parallel size, rounded up, plus
`kvCacheGiB` and 2 GiB, must fit the per-GPU budget.
- **Hardware checks:** the vLLM and Ollama checks run on each GPU in
`Capacity::gpus`: each must match the hardware profile (or the recipe's
GPU and driver), meet `minGpuMemoryBytes` and the compute capability,
and hold the budget, with that much free when starting. Selected GPUs
don't need to be identical. The host reserve still applies once per
service.
- **Errors name the GPU:** a failed per-GPU check reads, for example,
`GPU-79b44e99-d10d-a381-8cd6-5ccb073eaea3: GPU free memory (bytes)
requires at least …`. The diagnostic holds the UUID as a number, so no
host text is echoed; a GPU without a UUID in NVIDIA's `GPU-` form is
named by its index (`GPU 1: …`). Single-GPU errors gain the prefix too.
- **Different GPU sizes (decision 6):**
- `gpuMemoryUtilization` passes through unchanged, and vLLM applies it
to each GPU's own total, so a service's budget on a GPU is that fraction
of the GPU's total.
- With a fixed budget, vLLM already gets `--kv-cache-memory-bytes` from
`kvCacheGiB`. vLLM v0.32.0 still requires `ceil(total ×
--gpu-memory-utilization)` free on each GPU at startup
([`request_memory`](https://github.com/vllm-project/vllm/blob/v0.32.0/vllm/v1/worker/utils.py)),
even with that flag. So the fraction NemoClaw passes is now the budget
over the **largest** selected GPU's total, which asks no GPU for more
than the budget. With identical GPUs, the fraction is unchanged. A
recipe's budget is converted the same way; recipes require every
selected GPU to carry the recipe's GPU name, so their GPUs don't differ
in size in practice.
- Ollama reserves one amount on every GPU, so its `gpuMemoryUtilization`
is taken of the **smallest** selected GPU's total.
- **Capacity accounting (decision 5):**
- With `gpu_devices`, the data sources observe the host once and resolve
each entry, an index or a UUID, to the GPU the host reports for it. One
entry is still read alone through `nvidia-smi --id`, as #13964 does;
several are read in one unfiltered `nvidia-smi` call. Two entries that
resolve to one GPU are refused, as a repeated string already is.
- `account` adds the listed services' per-GPU budgets on each selected
GPU and compares the sum with that GPU's total; unified memory still
uses host memory with the largest reserve once.
- The outputs keep their shape: `required_bytes` and `observed_bytes`
describe the GPU with the least room, so `compatible` is true only when
every GPU fits, and HCL on one GPU reads the same values. A per-GPU
output can come with step 9, when a read can list more than one GPU.
- The SDK doesn't detect overlap, and overlap across deployments stays
unreserved.
- The checks read only `Capacity::gpus`, and refuse an observation
without a GPU. Test fixtures and the fixture provider now record their
GPU with `Capacity::set_gpus`. The single-GPU fields (`gpu`,
`gpu_memory`, `compute_capability`, `driver_major`) remain, and only the
observation tests still read them; removing them is a follow-up.
- `Service::parallel_sizes` holds the tensor and pipeline sizes vLLM
gets, for both the arguments and the weight check.
- Not changed: Ollama's `OLLAMA_GPU_OVERHEAD` and readiness (#14396),
process supervision and error reporting (#14397), and the runtime's
exactly-one-GPU observation and the one-entry limit (step 9). The intent
record's format is unchanged, so `RECORD_FORMAT` and the release notes
stay.

### For review

- **Utilization on different GPU sizes departs from decision 6's
wording:** decision 6 says NemoClaw passes absolute amounts when
selected GPUs differ, so every GPU gets the same budget. With
`gpuMemoryUtilization`, this change instead passes the fraction through
and accounts each GPU at that fraction of its own total, as vLLM applies
it. `gpuMemoryUtilization` requires `kvCacheGiB: 0`, so there's no
absolute KV amount to pass, and converting the fraction would make
NemoClaw size vLLM's cache. A maintainer is confirming this.

## Beyond CI

Unverified: no multi-GPU host ran this; the per-GPU paths run only with
fake observations, because `container.gpuDevices` and `gpu_devices`
still take one entry.

---------

Signed-off-by: Carlos Villela <[email protected]>
cv added a commit that referenced this pull request Nov 11, 2026
…ms (#14413)

The release notes now list every user-visible change on `v1` since the
`v0.1.0-rc9` tag, including the breaking ones, and four example pages
drop claims that later changes made false.

## Problem

`docs/about/release-notes.md` listed three breaking changes and none of
the features, fixes, and onboarding changes that reached `v1` after
`v0.1.0-rc9`; it didn't name the configuration shapes the parser now
rejects or the intent record version `v0.1.0-rc9` writes.
Some example claims went stale:

- `examples/spark/README.md` said the pinned OpenShell has the Podman
TLS initialization blocker, ai-openshell/openshell#3427; its fix merged before
OpenShell 0.1.0, and `v1` pins 0.1.7.
- `examples/station/README.md` and `examples/gtc-dc/README.md` required
exactly one visible GPU on the host; since #13929,
`container.gpuDevices` lets a service on a host with more GPUs request
one.
- `examples/hcl/travel-team` said Fabric's Deep Agents adapter can't
turn reasoning off, NVIDIA/NeMo-Fabric#433; NVIDIA/NeMo-Fabric#439 fixed
that, and the pinned catalog's Deep Agents `reasoning_effort` accepts
`none`.
- The travel team cited #13313 for the booking key its service doesn't
receive, but #13313 closed when `openshell_api` landed.

## Change

- `docs/about/release-notes.md` gains "Changes Since v0.1.0-rc9",
grouped by area, from the commits in `v0.1.0-rc9..origin/v1`; where a
later commit changed an earlier one, the entry describes the current
code, and changes added and removed after the tag aren't listed:
- Agents and interfaces: #14037, #14038, #14269, #13981, #14024, #14186,
#14052, #14385, #13971, #13858, #13947, #14039, #14042, #14044, #14343.
- Inference: #13929, #14391, #14396, #14398, #14400, #13963, #13912,
#13964, #14388, #14390, #14397.
- Gateways and Kubernetes: #13909, #13970, #13922 (an existing
namespace, refused at plan by #13756, is now bound; cluster-wide reads
dropped), #14014, #14169, #13921.
- Plan, apply, and diagnostics: #14224, #13756, #14141, #14133, #14135,
#13775, #13744, #13701.
- Onboarding: #13693, #13695, #13741, #13757, #13851, #13978, #14228,
#14233, #14334, #14336.
- Examples and builds: #14166, #14184, #14188, #14191, #14192, #14200,
#13889, #14267, #14312, #14315, #14355, b30e9b4, #13781, #13813,
#14246, and the pins in `versions.json` and `image/fabric/Dockerfile`.
- Its breaking changes since the tag:
- the intent record moving from 15, which `v0.1.0-rc9` writes, through
16 (#14266), 17 (#14343), 18 (#13929), 19 (#14391) and 20 (#14394);
  - name-keyed `sandboxes` and `inferenceProviders` (#13703, #13705);
- a recipe `compatibility.gpu` outside every hardware profile (#13912);
- model tuning the adapter doesn't accept (#14111), and Hermes's
`max_tokens` losing its default (#14296);
  - `skills.paths` resolution (#14296);
  - endpoint and `networkCIDR` validation (#13847, #14081);
- the HCL `gateway_values` attribute (#14014), and Kubernetes ownership
receipts from before #13922 and #14014.
  The two earlier items stay, under their own heading.
- `examples/spark/README.md` replaces the closed OpenShell#3427 blocker
with the Podman and remote-model limits in `docs/resources/limits.md`.
- `examples/station/README.md` and `examples/gtc-dc/README.md` require
one GPU visible in the model container, and point to
`container.gpuDevices` for a host with more.
- `examples/hcl/travel-team/README.md` and `WALKTHROUGH.md` drop the
NeMo-Fabric#433 limitation, and the travel team's booking-key statements
link #14417 instead of #13313.

Not listed, because both changes landed after the tag: Deep Agents Code
(#14043, #14250), `compatibility.gpuCount` (#14391, #14394), and the
"Creating infrastructure state" progress step (#14169, #14248).

Checked and left unchanged: the root `README.md`,
`crates/nemoclaw-onboarding/README.md`,
`crates/nemoclaw-cli/assets/README.md`, `internal-docs/README.md`, the
other example READMEs, and every example YAML header comment. The GPU
autoscaling README and `load.sh` read the JSON fields `OperationResult`
serializes, and ai-openshell/openshell#4287 is fixed only after the pinned
0.1.7. The two pre-tag release-note items still match the schema and
SDK. `docs/README.md` is left to #14412, which retires the stale field
reference snapshot it describes.

Not verified: whether Hermes sends the booking key's placeholder to MCP
servers; #14417 tracks the live check.

## Beyond CI

Each relative link and anchor in the changed files resolves to an
existing file and heading.
@wscurran wscurran added area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior feature PR adds or expands user-visible functionality provider: ollama Ollama local model provider behavior v1 NemoClaw v1 branch labels Nov 12, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior feature PR adds or expands user-visible functionality provider: ollama Ollama local model provider behavior v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants