Repository navigation
feat(runtime): let Ollama download and store its own models - #13457
Merged
Merged
Conversation
Managed Ollama no longer downloads into Ollama's private cache layout. The runtime starts Ollama, asks it to pull the pinned model when absent, and serves only when Ollama reports the authored digest and the model sets only sampling parameters. This removes NemoClaw's Ollama downloader and cache test, and both runtimes move to Ollama 0.40.6, whose new cache layout no longer matters.
cv
enabled auto-merge (squash)
October 19, 2026 07:40
Contributor
|
v1 documentation preview: https://nvidia-preview-nemoclaw-v1-pr-13457.docs.buildwithfern.com/nemoclaw |
This was referenced Oct 19, 2026
cv
added a commit
that referenced
this pull request
Oct 19, 2026
Closes #13453. ## Failure Managed vLLM downloaded Hugging Face snapshots with NemoClaw's own resumable, checksumming download client in `nemoclaw-runtime`. It was a second model downloader to maintain, after the Ollama one #13457 removed. The design doc kept it because the Hugging Face client checks a file's size only after writing it. ## Decision Hugging Face's own client downloads, and NemoClaw keeps only what it owns. - **Kept:** - Resolving the snapshot's manifest from Hugging Face's API, which is metadata only. It still pins the commit revision, keeps only native safetensors, tokenizer and configuration files, never repository code, and drives memory planning and recipe pins. - Weight validation, recipe preparation, and the offline vLLM launch. - **Changed:** - A new `vllm::runtime::download` runs the image's `hf download <repo> <manifest files> --revision <commit> --local-dir <dir>`. It keeps the 8-hour limit and cancellation, and disables telemetry. Hugging Face's client resumes partial files and checks large files' SHA-256 as it downloads. - A new `snapshot::record` then checks each file's size and writes NemoClaw's manifest with the files marked verified. Later starts still compare modification times without downloading again. - **Removed** (−783 +70 lines in the runtime crate): - NemoClaw's download, resume and per-file verification code; - the registry functions only the removed Ollama downloader used; - the nine tests of that machinery, and the Hugging Face client evaluation (`runtimes/vllm/test_download.py`) with its live-tests section. Three remaining tests now exercise `record`: unfinished files, symlinks, and unsupported metadata. - **Docs:** `docs/design/runtime.md` and `docs/models.md` describe the new flow. The trade-off the design doc named still applies: Hugging Face's client can write past a file's expected size before rejecting it. NemoClaw's checks only bounded that for the files Hugging Face's API listed. The principle is to leave downloading to its owner. ## Validation - **New tests:** `record`'s tests failed against a stub before the change, and pass after. - `cargo ci` passes locally: 1,598 unit tests and 150 lifecycle tests. - **Live, ARM64, on a DGX Spark:** a rebuilt vLLM v0.32.0 runtime served `Qwen/Qwen3-0.6B` at commit `c1899de`. - The runtime reported "Hugging Face is downloading the selected model snapshot". - NemoClaw's manifest recorded all eight files verified. - A Deep Agents agent answered through the model. - After a container restart, the runtime reported "verifying selected model snapshot" and didn't download again. The AMD64 runtime uses the same code but wasn't run.
This was referenced 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 <cvillela@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13452. Supersedes #13450 and #13451.
Failure
Managed Ollama downloaded models with NemoClaw's own client, wrote them into Ollama's private cache layout, and checked that layout. That tied NemoClaw to Ollama's internal file format. Ollama 0.40 changed it (
manifests-v2), so the runtime couldn't move past 0.35.1, and every future layout change would have repeated the work.Decision
Ollama owns its model storage; NemoClaw only checks what Ollama reports.
Startup: the runtime starts Ollama on the retained volume, then
pull::ensuremakes sure the pinned model is present:/api/pull, and its progress becomes the runtime's status./api/tagsmust match the authored one, or startup stops.Kept from the old downloader: the check that model parameters set only sampling, not runner or resource settings such as
num_ctx. It now reads them from Ollama's/api/show. The 8-hour download limit also stays.Trade-off: Ollama's pull takes no expected digest, so a tag that moved upstream is downloaded and then refused, rather than never downloaded. The runtime still never serves a model whose digest differs, and the readiness inventory check confirms it again before loading.
Removed (+37 −631 lines overall):
registry.rs,model_source.rs) and the old startup recipe;The shared
snapshotdownloader stays for vLLM until Let vLLM download models by revision #13453.Ollama 0.40.6: both runtimes use it, pinned by its multi-platform digest. The LICENSE comes from the v0.40.6 commit; it's the same file, with the same SHA-256.
Docs and notices:
docs/design/runtime.md,docs/contributing/live-tests.mdand both runtime notices describe the new behavior. The notices also drop a history line.Validation
New unit tests in
pull.rsfailed against a stub before the change and pass after. They cover:cargo cipasses locally: 1,605 unit tests and 150 lifecycle tests.Live, ARM64, on a DGX Spark:
qwen3:0.6breported Ollama pulling the manifest and each layer itself, then passed readiness with the pinned digest.The AMD64 runtime uses the same multi-platform digest but wasn't run.