Repository navigation
Measure qtensor GPU memory tests with allocator stats - #2707
Conversation
test_cast_fp4_impl_gpu_mem and test_mxfp8_quantize_gpu_mem measured memory with torch.cuda.mem_get_info(), which reports device-wide usage. On GPUs that share memory with the CPU, such as Jetson Thor, that value moves with every other allocation on the system, so the NVFP4 test fails intermittently there (2.05x-2.15x of the input against a 2.1x bound). Both tests now measure the caching allocator's peak while the cast runs, which counts only this process's tensors: 1.50x for NVFP4 and 2.10x for MXFP8 on Thor, stable across runs. Signed-off-by: LinCanNerd <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe NVFP4 cast and MXFP8 quantization memory tests now measure peak caching-allocator allocation with a shared helper. Their existing memory limits remain unchanged. ChangesCUDA memory test measurement
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk is identified in the supplied changes. 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@AAnoosheh When you have a moment, could you run |
|
/ok to test 2efefd2 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2707 +/- ##
==========================================
+ Coverage 71.54% 78.06% +6.52%
==========================================
Files 640 640
Lines 71316 71316
==========================================
+ Hits 51020 55671 +4651
+ Misses 20296 15645 -4651
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kevalmorabia97
left a comment
There was a problem hiding this comment.
Approve: a test-only fix that replaces the device-wide mem_get_info delta with the caching allocator's peak, with unchanged bounds.
No action needed.
No action needed:
- The helper syncs, resets the peak, and subtracts the starting
memory_allocated()(which includes the input), so it counts only what the call allocates, astest_qtensoralready does. - I reproduced the PR's ratios on an RTX 6000 Ada:
_cast_fp41.50x (bound 2.1x),MXFP8QTensor.quantize2.10x (bound 3x). Both tests pass. - No changelog needed; no setup-owned paths touched.
|
/ok to test 2efefd2 |
Ported from NVIDIA/Model-Optimizer#2707 Generated by autojump (AI); review before merging.
Ported from NVIDIA/Model-Optimizer#2707 Generated by autojump (AI); review before merging.
Ported from NVIDIA/Model-Optimizer#2707 Generated by autojump (AI); review before merging.
What does this PR do?
Type of change: Bug fix (tests)
Fixes #2706.
test_cast_fp4_impl_gpu_memandtest_mxfp8_quantize_gpu_memmeasured memory withtorch.cuda.mem_get_info(), which reports device-wide usage. On GPUs that share memory with the CPU, such as Jetson Thor, that value changes with every other allocation on the system. As a result, the NVFP4 test fails intermittently there: the measurement is 2.05×–2.15× of the input on an idle machine against a 2.1× bound, and higher when anything else is running.Both tests now measure the caching allocator's peak while the cast runs (
reset_peak_memory_stats(), thenmax_memory_allocated()minus the startingmemory_allocated()). This counts only the tensors the call allocates, the same waytest_qtensorin this file already checks memory. The bounds are unchanged.mem_get_infodelta (Thor)test_cast_fp4_impl_gpu_memtest_mxfp8_quantize_gpu_memThe allocator peak includes temporaries freed before the call returns, so it is the stricter measure of the call's working memory.
Usage
No API change.
Testing
On Jetson Thor (sm_110, JetPack 7.2.1, torch 2.13.0+cu130):
pytest tests/gpu/torch/quantization/test_qtensor_cuda.py -k gpu_mem: 5 of 5 runs passed. Before the change, the NVFP4 test failed intermittently.pytest tests/gpu/torch/quantization/test_qtensor_cuda.py: 219 passed.pre-commit run --files tests/gpu/torch/quantization/test_qtensor_cuda.py: passed.Before your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: N/AAdditional Information
Found while running
tests/gpu/torch/quantizationandtests/gpu/torch/kernelson Jetson Thor. The only other Thor-specific failure is #2705, which has its own PR.Summary by CodeRabbit