Uh oh!
There was an error while loading. Please reload this page.
fix(ci): treat max_size=0 as an uncapped pool in check_mempool_hygiene - #2538
Open
LeSingh1 wants to merge 1 commit into
Open
fix(ci): treat max_size=0 as an uncapped pool in check_mempool_hygiene#2538LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
`check_mempool_hygiene.py` exists to stop tests from creating memory pools
whose address-space reservation is sized from installed device memory
instead of from what the test allocates. It decided a pool was capped by
looking only for the *presence* of `max_size`, never at its value.
`max_size=0` is the default and, per `CUmemPoolProps.maxSize`, asks the
driver for its system-dependent size -- "When set to 0, defaults to a
system-dependent value" in both `DeviceMemoryResourceOptions` and
`PinnedMemoryResourceOptions`. So
DeviceMemoryResource(dev, DeviceMemoryResourceOptions(max_size=0))
DeviceMemoryResource(dev, {"max_size": 0})
create exactly the uncapped pool the check is meant to reject, and both
passed the check. The spelling is an easy one to reach for when silencing
the hook, which is the worst case: the annotation looks like a cap and
reserves the full window anyway.
Inspect the value for the literal `0` and report it, with a message that
names the value rather than claiming max_size is missing. Non-literals are
still accepted unchanged -- a named constant is usually the suite-wide
POOL_SIZE, and this checker does not guess -- and neither is `**kwargs` /
`**other`, where the value is not statically decidable.
`cuda_core/tests` has no `max_size=0` construction today, so the tightened
rule leaves the tree clean (`test_the_live_test_suite_is_clean` still
passes).Contributor
This was referenced Aug 9, 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 freeto 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.
Problem
ci/tools/check_mempool_hygiene.pyenforces the rule incuda_core/tests/AGENTS.md: a test-created pool withoutmax_sizereserves an address-space window sized from installed device memory rather than from what the test allocates, and the whole suite shares one process.It decides "capped" by looking only for the presence of
max_size, never its value:But
max_size=0is the default, andCUmemPoolProps.maxSize == 0asks the driver for its system-dependent size. FromDeviceMemoryResourceOptions(and identicallyPinnedMemoryResourceOptions):So these create exactly the uncapped pool the check exists to reject, and every one of them passes today:
Verified against
violations_in()onmain: all three return[], while the equivalentDeviceMemoryResourceOptions()is correctly reported.This is the worst shape for a hole in a lint:
max_size=0is the natural thing to reach for when quieting the hook, it looks like a cap in review, and it reserves the full window anyway.Fix
Inspect the value and report a literal
0.POOL_SIZE; the checker does not guess.**kwargs/**otherstill short-circuit to "capped", unchanged — including{"max_size": 0, **opts}, where the unpacking may override the literal. Not statically decidable, so not reported.max_size=0, which is the uncapped default) instead of claimingmax_sizeis missing. The omitted-max_sizemessage is unchanged.Also updated the corresponding rule in
cuda_core/tests/AGENTS.md, which is what contributors read.Effect on the tree
None:
cuda_core/testshas nomax_size=0construction today, so the tightened rule leaves the suite clean. The existingtest_the_live_test_suite_is_clean(which runsmain([])over the real tree) still passes.Tests
ci/tools/tests/test_check_mempool_hygiene.pygains threeUNCAPPEDcases (kwarg, kwarg among other options, dict literal), twoCAPPEDregression guards (a non-zero literal, and{"max_size": 0, **opts}), and one assertion on the new message.Verified with the index-safe swap (
cpaside,git show upstream/main:<path> >, run, restore):Full
pytest ci/tools/tests: 62 passed.ruff checkandruff format --checkclean on both changed files;python -m py_compileclean. No GPU is involved — this tool is pure AST analysis, so everything above was actually executed.