Skip to content

enable per-physical-GPU replica counts in time-slicing and MPS#1787

Open
jonathan-meiri wants to merge 1 commit into
NVIDIA:mainfrom
jonathan-meiri:heterogeneous-time-slicing-replicas
Open

enable per-physical-GPU replica counts in time-slicing and MPS#1787
jonathan-meiri wants to merge 1 commit into
NVIDIA:mainfrom
jonathan-meiri:heterogeneous-time-slicing-replicas

Conversation

@jonathan-meiri

@jonathan-meiri jonathan-meiri commented May 19, 2026

Copy link
Copy Markdown

Summary

Enable per-physical-GPU replica counts in sharing.timeSlicing and sharing.mps config. See #1786 for the design context (prior art, what this does and doesn't try to do, MPS vs time-slicing semantics).

Contributed by @Meiri28 on behalf of @runatom-ai.

Closes #1786

Changes

  • api/config/v1/replicas.go: replace disableResoureRenaming with applyDefaults. The new helper still fills the existing defaults (auto-rename when renameByDefault: true and Rename is unset; default Devices.All = true when no selector is set) but no longer strips user-supplied Rename or Devices.List / Devices.Count. The two "not yet supported in the config" warnings go away.
  • api/config/v1/config.go: update DisableResourceNamingInConfig to call the new helper. Function name and public signature unchanged.
  • internal/rm/allocate.go: in distributedAlloc, change the sort key from min(total - available) to max(available). The two orderings are equivalent in the homogeneous case, but the previous key biased toward exhausting smaller physical GPUs first when replica counts differ. The now-unused total field and its initialization loop are removed.

Device-map construction in internal/rm/device_map.go is unchanged — it already handles Devices.All / Devices.Count / Devices.List correctly. Net behavior change is ~50 LoC plus tests.

Commits are DCO-signed.

@copy-pr-bot

copy-pr-bot Bot commented May 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@jonathan-meiri

Copy link
Copy Markdown
Author

Contributing on behalf of @runatom-ai.

@jonathan-meiri jonathan-meiri changed the title enable per-physical-GPU replica counts in time-slicing and MPS [runatom-ai] enable per-physical-GPU replica counts in time-slicing and MPS May 19, 2026
@jonathan-meiri jonathan-meiri changed the title [runatom-ai] enable per-physical-GPU replica counts in time-slicing and MPS enable per-physical-GPU replica counts in time-slicing and MPS May 19, 2026
jonathan-meiri pushed a commit to jonathan-meiri/k8s-device-plugin that referenced this pull request May 19, 2026
TDD red phase for an issue independent of NVIDIA#1787.

Setup: a node with two physical GPUs of equal advertised replica
counts, where one slot on the "second" GPU has already been allocated
to another pod. A new pod requests two more slots. The function name
and docstring of distributedAlloc promise an even spread, but today
the function deterministically picks both of the new pod's slots from
the GPU with the most remaining replicas — leaving the other physical
GPU's available slot untouched.

The bug is in the sort tie-break. After the first pick the per-GPU
'used' counts tie across the candidates, and sort.Slice is unstable,
so the next iteration ends up picking the next slot on the GPU we
just picked from rather than rotating to the sibling GPU that still
has capacity.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: runatom-ai <258621014+runatom-ai@users.noreply.github.com>
Signed-off-by: Jonathan Meiri <33288957+Meiri28@users.noreply.github.com>
@Dorsivan

Copy link
Copy Markdown

This can be extremely useful, is there any way I can help advance this?

@jonathan-meiri
jonathan-meiri force-pushed the heterogeneous-time-slicing-replicas branch from eb475d6 to c447e8b Compare July 14, 2026 13:24
Currently DisableResourceNamingInConfig silently strips per-entry
Rename and any non-Devices.All selection from Sharing.TimeSlicing.Resources
and Sharing.MPS.Resources, collapsing heterogeneous configs into a single
homogeneous resource. Operators cannot configure different replica counts
for different physical GPUs on the same node, even though the device-map
construction in internal/rm/device_map.go (getIDsOfDevicesToReplicate)
already handles Devices.All / Devices.Count / Devices.List correctly.

Replace disableResoureRenaming with applyDefaults, which fills defaults
for unset fields but leaves explicit user configuration intact. Auto-
rename when renameByDefault is true is preserved; Devices.All=true is
still the default when Devices is unset. The two "not yet supported in
the config" warnings go away.

Once devices selection is honored, the MPS daemon must only touch the
physical GPUs it is actually sharing. Previously the daemon iterated
every device in the resource manager (including unreplicated ones that
share the same resource name), which meant setComputeMode set
EXCLUSIVE_PROCESS on GPUs that were not part of the MPS-shared subset,
breaking their normal usage. The same over-reach affected
perDevicePinnedDeviceMemoryLimits and activeThreadPercentage. Introduce
a Daemon.sharedDevices() helper that returns only the annotated
(replicated) subset of the daemon's devices and route the three
call sites through it.

Tests cover:
  - api/config/v1: TimeSlicing and MPS both preserve per-entry Rename
    and Devices.List across DisableResourceNamingInConfig.
  - cmd/mps-control-daemon/mps: sharedDevices() excludes unreplicated
    devices; perDevicePinnedDeviceMemoryLimits and
    activeThreadPercentage compute using the shared subset only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: runatom-ai <258621014+runatom-ai@users.noreply.github.com>
Signed-off-by: Jonathan Meiri <33288957+Meiri28@users.noreply.github.com>
@jonathan-meiri
jonathan-meiri force-pushed the heterogeneous-time-slicing-replicas branch from c447e8b to 3db6617 Compare July 15, 2026 12:31
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.

Support per-physical-GPU replica counts in sharing.timeSlicing and sharing.mps

3 participants