cuda.core: make managed-prefetch test page-size aware#2268
Open
rparolin wants to merge 1 commit into
Open
Conversation
TestPrefetchBatch.test_per_buffer_location hardcoded a 4096-byte allocation and assumed two pooled buffers landed on separate physical pages. Managed-memory prefetch and CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION operate at page granularity, so on nvidia-64k aarch64 kernels both 4 KB buffers shared one 64 KB page; prefetching buf[1] to the device migrated the shared page and buf[0]'s host prefetch reported device 0 (assert 0 == -1). Derive the allocation size from mmap.PAGESIZE so each buffer occupies a full page on every platform, and add a precondition asserting the two buffers sit on distinct pages so a pool-packing regression fails loudly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Should fix #2267. |
|
kkraus14
approved these changes
Jun 26, 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
TestPrefetchBatch.test_per_buffer_locationstarted failing on the CTK 13.x linux-aarch64 CI configs after the runners moved to thenvidia-64k(64 KB page-size) kernel:Root cause
The test hardcoded a 4096-byte allocation and assumed two pooled buffers landed on separate physical pages. Managed-memory prefetch and
CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATIONoperate at page granularity, andManagedMemoryResourceis a pool, so the twoallocate(4096)calls are packed adjacently (pointers 4 KB apart).bufs[1]to the device migrates the whole shared page → queryingbufs[0]reports device 0 instead of host (-1) →assert 0 == -1.The prefetch itself worked correctly; the test's premise (sub-page allocations are independently prefetchable) only holds when buffer size ≥ page size. The failure is latent on any genuine 64 KB-page platform (Grace / Grace-Blackwell), so reverting the runner kernel only masks it.
Fix
_MANAGED_TEST_ALLOCATION_SIZEfrommmap.PAGESIZEso each buffer occupies a full page on every platform (no hardcoded page size).Verification
pytest tests/memory/test_managed_ops.py→34 passed, 1 skippedon an x86 (4 KB page) RTX 5880 Ada box, including the guardedtest_per_buffer_location.🤖 Generated with Claude Code