Repository navigation
Add per-GPU memory accounting to host resource manager - #5090
Merged
Merged
Conversation
amogh09
reviewed
Aug 10, 2026
harishxr
force-pushed
the
mps-ec2-per-gpu-accounting
branch
6 times, most recently
from
August 13, 2026 18:16
ebeca03 to
e090a98
Compare
harishxr
force-pushed
the
mps-ec2-per-gpu-accounting
branch
from
August 14, 2026 13:53
e090a98 to
98c56f0
Compare
harishxr
force-pushed
the
mps-ec2-per-gpu-accounting
branch
from
August 14, 2026 16:53
98c56f0 to
d2bc1da
Compare
prateekchaudhry
approved these changes
Aug 14, 2026
amogh09
approved these changes
Aug 14, 2026
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.
Summary
Adds per-GPU memory accounting to the agent's
HostResourceManagerso GPU memory can be tracked and admitted per physical GPU, as the local scheduling foundation for NVIDIA MPS GPU sharing. Each GPU is modeled as a small account{total, remaining, mode}(mode ∈ FREE / MPS / WHOLE_GPU). MPS tasks reserve a memory share on a GPU while a whole-GPU task takes it exclusively. This replaces the GPU allocation role previously served by theGPUStringSet.Implementation details
agent/engine/host_resource_manager_gpu.go: a per-UUID pool (map[uuid]*gpuDeviceState) with{total, remaining, mode}. Admission keys offmode, which makes MPS/whole-GPU mode-mixing on one GPU impossible by construction. A GPU with no reported memory is seeded total 0 and is only usable via the whole-GPU path.task.GPUMemoryDemand{MiB, WholeGPU}type, returned fromToHostResources()as a second map alongside the CPU/MEMORY/PORTS resource map (not encoded into the SDKecstypes.Resource).consume/consumable/release/checkResourcesHealthtake that demand map. A non-MPS container setsWholeGPU; MPS containers on a GPU sum their caps intoMiB. There is no per-task stored balance, consume and release both recompute from the task, so they stay symmetric and restart-safe.doStartseeds one pool entry per GPU from the RCI-reported per-device memory, as anINTEGERcapacity keyedGPU_MEMORY:<uuid>. A GPU whose memory is not reported (older ecs-init, or an NVML query failure) is seeded with capacity 0: whole-GPU tasks still run against it, MPS sharing is refused (a cap cannot be enforced without a known total). This preserves the pre-existing whole-GPU behavior, which never depended on memory being known.Testing
New tests cover the changes: yes
Description for the changelog
Enhancement - Add per-GPU memory accounting to host resource manager
Additional Information
Does this PR include breaking model changes? If so, Have you added transformation functions? No
Does this PR include the addition of new environment variables in the README? No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.