Skip to content

fix(nvidia): treat gpumem-percentage of 0 as unset - #11

Closed
Wangmin362 wants to merge 1 commit into
masterfrom
fix/gpumem-percentage-zero-v2
Closed

fix(nvidia): treat gpumem-percentage of 0 as unset#11
Wangmin362 wants to merge 1 commit into
masterfrom
fix/gpumem-percentage-zero-v2

Conversation

@Wangmin362

@Wangmin362 Wangmin362 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

What type of PR is this?

/kind bug

What this PR does / why we need it:

nvidia.com/gpumem-percentage: 0 is accepted today, so the scheduler computes memreq = Totalmem * 0 / 100 = 0: the pod fits any card however full it is, is booked with 0 memory, and the device plugin injects CUDA_DEVICE_MEMORY_LIMIT_0=0m, which hami-core reads as "no limit". The container can then use the whole card while the scheduler still thinks it is free.

nvidia.com/gpumem: 0 is fine because it leaves the percentage unset and falls through to the defaultMemory / whole-card branch below. This makes a non-positive percentage take the same path.

Which issue(s) this PR fixes:
NONE

Special notes for your reviewer:

Clamping to 100 instead would also stop the 0-memory booking, but it skips that defaultMemory branch, and unlike the 101 sentinel, 100 is not excluded in ComputeScore, so scoring would count a whole card.

On a V100-32GB node, a pod with gpumem-percentage: 0 got 0m and allocated 8 GiB while still booked as 0; a second pod asking for gpumem: 30000 on the same card was then admitted and died with cuMemoryAllocate failed res=2. I also ran a before/after A/B on an A100-80GB node with two shadow schedulers differing only in this change: an empty card is now booked as 81920 instead of 0, with 80000/81920 already booked the same request goes Pending with CardInsufficientMemory, and with defaultMemory: 512 it is booked as 512 and the container gets 512m instead of 0m.

The tests added for a zero percentage fail on master and pass here. This PR was written primarily by Claude Code, and I reviewed and tested it.

Does this PR introduce a user-facing change?:

A nvidia.com/gpumem-percentage of 0 is now treated as unset: the container gets the whole card, or defaultMemory when one is configured, instead of running with no GPU memory limit.

A gpumem-percentage of 0 made the scheduler book 0 memory, so the pod fit any
card and the device plugin injected CUDA_DEVICE_MEMORY_LIMIT=0m, which hami-core
reads as no limit. Handle it like nvidia.com/gpumem: 0: fall back to
defaultMemory, or to the whole card when no default is configured.

Signed-off-by: wangmin <wangmin@riseunion.io>
@Wangmin362
Wangmin362 force-pushed the fix/gpumem-percentage-zero-v2 branch from b212c15 to 837e4b1 Compare August 4, 2026 06:54
@Wangmin362 Wangmin362 changed the title fix(nvidia): treat gpumem-percentage of 0 as unset(自审 PR,按 ouyangluwei163 意见重做) fix(nvidia): treat gpumem-percentage of 0 as unset Aug 4, 2026
@Wangmin362
Wangmin362 changed the base branch from master to doc-master August 4, 2026 06:56
@Wangmin362
Wangmin362 changed the base branch from doc-master to master August 4, 2026 06:56
@Wangmin362

Copy link
Copy Markdown
Owner Author

内容已合入社区 PR Project-HAMi#2156 (head ab79651),本自审 PR 关闭。

@Wangmin362 Wangmin362 closed this Aug 4, 2026
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.

1 participant