Skip to content

fix(docker): set model container CPU limits through the provider's cpus - #14491

Merged
cv merged 3 commits into
v1from
cv/docker-cpus
Nov 16, 2026
Merged

cv merged 3 commits into
v1from
cv/docker-cpus

Conversation

@cv

@cv cv commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Managed vLLM and Ollama containers on Docker now get container.cpuLimitMillis through the Docker provider's cpus attribute, so NemoClaw no longer computes a CFS quota or adds a label to force replacement when the limit changes.

Problem

Before Docker provider 4.7.0, cpus read back in a different format and replaced the container on every apply (kreuzwerker/terraform-provider-docker#1017), so NemoClaw set cpu_period and cpu_quota itself, raised quotas below 1 ms to the kernel's minimum, and added a nemoclaw.nvidia.com/cpu-limit-millis label, because the provider changes cpu_quota in place without sending it to Docker. Provider 4.7.0, pinned since #14482, fixes the read-back, and cpus forces replacement.

Change

  • docker_container sets cpus to the limit as a CPU count, such as "1.25" for 1250 millicores, and drops cpu_period, cpu_quota, and the CPU label. The native container configuration sets NanoCpus to match.
  • Removes the quota computation and its 1 ms minimum: Docker accepts --cpus 0.001 and the runtime raises the quota to the kernel's minimum itself.
  • Changing cpuLimitMillis still replaces the container, now because the provider marks cpus as forcing replacement; updatePolicy: Preserve refuses it.
  • The memory label stays: the provider still lowers memory on a running container in place.
  • The first apply after this change replaces a model container that sets cpuLimitMillis; the release notes list this as a breaking change.

Beyond CI

With OpenTofu 1.13.9, Docker provider 4.7.0, and Docker Engine 29.6.2 on linux/arm64, a docker_container with cpus planned ["delete", "create"] with replace_paths = [["cpus"]] for each change (1.25, 2, 0.01, 12, 0.001), set HostConfig.NanoCpus to the authored value, and planned no changes on the unchanged reapply, including 2 read back as 2.0. A container with --cpus 0.001 ran with cpu.max 1000 100000.

cv added 3 commits November 16, 2026 09:04
Docker provider 4.7.0 reads `cpus` back without a diff and replaces the
container when it changes, so a CPU limit no longer needs a CFS quota
computed by NemoClaw or a label that forces replacement.

Signed-off-by: Carlos Villela <[email protected]>
@cv

cv commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author
Authoring session — opening
Field Status Value Evidence or limit
Harness partial Pi coding agent 1.5.2 with the Pit TypeScript tool Version from the running harness's install path; the session header records only its schema version
Skills recorded test-driven-development (complete read); write-tests (complete read); nemoclaw-contributor-create-pr (complete read) Skill reads to cutoff; write-tests' tofu-test reference not read
Instruction files recorded AGENTS.md (injected); WRITING.md (complete read); internal-docs/design/scope.md (complete read); .github/PULL_REQUEST_TEMPLATE.md (complete read); .github/SESSION_REPORT_TEMPLATE.md (complete read) Injections and reads to cutoff; internal-docs/contributing/testing.md was read with its middle truncated, so it is not counted
Tool calls recorded typescript: 72 Includes failed calls, to cutoff; nested host calls inside each program are not counted
Tokens recorded input: 8279226; cached input: 8128122; output: 43090 Sum of assistant message usage (input + cacheRead + cacheWrite; cacheRead; output) to cutoff
Session window recorded 2026-11-16T15:41Z to 2026-11-16T16:21Z; 39 min First event to cutoff, including idle time
Compactions recorded 0 Complete record to cutoff
Models recorded claude-opus-5-5 Model change entry; no later changes
Reasoning levels recorded high Thinking-level entry; no later changes

@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv enabled auto-merge (squash) November 16, 2026 16:34
@cv
cv merged commit a376032 into v1 Nov 16, 2026
60 of 61 checks passed
@cv
cv deleted the cv/docker-cpus branch November 16, 2026 16:35
cv added a commit that referenced this pull request Nov 16, 2026
Every managed vLLM and Ollama container on Docker now carries the
`nemoclaw.nvidia.com/memory-limit-gib` label, including one with the
default 104 GiB limit, so any memory limit change replaces the
container.

## Problem

The label, which forces replacement when the memory limit changes, was
added only when the limit differed from 104 GiB, so containers created
before memory limits were configurable stayed unchanged. That branch is
compatibility code, and its reason for the label was incomplete: it
named only the OOM kill, not that the servers size from the limit at
start.

## Change

- `docker_container` always gets the label; the 104 GiB branch and the
`DEFAULT_MEMORY_LIMIT_GIB` re-export that only it used are gone.
- The comment records why a memory change must restart the container:
Docker provider 4.7.0 updates `memory` and `memory_swap` in place,
Docker applies a lower limit to the running server and the kernel
OOM-kills it, and Ollama and NemoClaw's supervisor size from the limit
only at start.
- Omitting the limit and declaring `memoryLimitGiB: 104` still compile
the same container.
- The `Preserve` check that refuses an in-place memory decrease stays.
- `provider.md` describes the label without the 104 GiB exception,
`inference.md` drops the sentence about earlier bundles, and the release
notes drop the one-time replacement notes for this label and for
`cpuLimitMillis` (#14491), since intent record 22 already makes every
`v0.1.0-rc10` deployment redeploy.

## Beyond CI

With OpenTofu 1.13.9, Docker provider 4.7.0, and Docker Engine 29.6.2 on
linux/arm64, a container without the label and with `memory_swap` equal
to `memory` planned `["update"]` for each memory change and kept running
when the limit rose or stayed above its usage. Lowered below its usage,
apply succeeded and the kernel OOM-killed the container (exit 137,
`OOMKilled`). Ollama v0.40.16 reads `memory.max` and `memory.current`
when it loads a model, and NemoClaw loads one model once; on GB10, CUDA
allocations don't count toward the container's memory cgroup.

---------

Signed-off-by: Carlos Villela <[email protected]>
@wscurran wscurran added area: local-models Local model providers, downloads, launch, or connectivity platform: container Affects Docker, containerd, Podman, or images refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch labels Nov 16, 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 platform: container Affects Docker, containerd, Podman, or images refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants