Repository navigation
Conversation
Add an NVFP4 case to test_export_hf_checkpoint_cpu_offloaded. NVFP4 is the
format that crashed with a cuda/cpu device mismatch when exporting a
CPU-offloaded model in 0.35.0, and the test only covered FP8.
Also stop the fixture from mapping the parent modules ("" and "model").
Mapping them made accelerate load the offloaded layer onto the GPU before
offloading it, so after hook removal its weight came back on GPU rather than
CPU, unlike from_pretrained(device_map=...) as hf_ptq loads it. Without this
the new case cannot reproduce the bug's device layout.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2825 +/- ##
==========================================
+ Coverage 69.33% 78.65% +9.31%
==========================================
Files 654 655 +1
Lines 72665 72777 +112
==========================================
+ Hits 50385 57242 +6857
+ Misses 22280 15535 -6745
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:
|
meenchen
reviewed
Oct 15, 2026
meenchen
left a comment
Contributor
There was a problem hiding this comment.
Bot review (bedrock-claude-opus-5-5) — DM the bot to share feedback.
LGTM: this is a well-motivated regression test for NVBug 6779760, but it edits an existing test file, so a human needs to sign off.
Needs action:
- Sign off on the edits to
tests/gpu/torch/export/test_offload_export.py. The_make_cpu_offloaded_modelfix and the parametrizedquant_algocheck are justified, and the existing FP8 cases and their assertions are unchanged.
No action needed:
- The fixture change also affects
test_streaming_export_matches_batch_export. The author reports all 5 tests passing, which includes it. - The author checked that the test catches the bug: with 0.35.0's export behaviour put back, only the NVFP4 case fails, with the original
cuda:0 and cpuerror. The unmodified test file passes, which shows the old test missed it. I inspected the tests but didn't run them. - The PR body says the same root-mapped
device_mapin_test_utils/torch/quantization/offload.pywill be fixed in a follow-up PR. That's fine.
This branch has not been deployed
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.
What does this PR do?
Type of change: new tests
Adds NVFP4 to the CPU-offloaded export GPU test (
test_export_hf_checkpoint_cpu_offloaded). Until now that test covered only FP8.NVBug 6779760: on a 64 GB DGX Spark, the NVFP4 playbook (ModelOpt 0.35.0) crashed during export with
RuntimeError: Expected all tensors to be on the same device ... cuda:0 and cpu. On GB10,cudaMemGetInfodoes not count reclaimable page cache as free memory, sohf_ptqCPU-offloads part of the model.Main is already fixed. Device alignment came in #432 (0.39.0), and offloaded models have used the streaming exporter since #2008 (0.46.0). This PR adds a regression guard for that exact configuration.
The fixture also needed a fix. It mapped the parent modules (
"","model") to GPU 0, which makes accelerate load the "offloaded" layer onto the GPU before offloading it. After hook removal, that layer's weight came back on GPU instead of CPU, so the fixture never produced the bug's layout.from_pretrained(device_map=...), which is howhf_ptqloads, does not do this. The fixture now leaves the parents unmapped.Follow-up (not in this PR):
tests/_test_utils/torch/quantization/offload.py::make_cpu_offloaded_modelbuilds the same root-mapped device_map. It is used bytest_vllm_fakequant_hf_export.pyandtest_accelerate_gpu.py.Testing
All runs were on a DGX Spark (GB10) in
nvcr.io/nvidia/tensorrt-llm/release:spark-single-gpu-dev, with torch 2.8.0a0, transformers 5.18.0 and accelerate 1.10.1.pytest tests/gpu/torch/export/test_offload_export.py: 5 passed.get_weights_scaling_factororget_weight_scaling_factor.[quant_cfg2-NVFP4]fails, with the bug'sRuntimeError ... cuda:0 and cpu.cpuand amax oncuda:0after hook removal, matchingfrom_pretrained(device_map=...). Before the fix, both were oncuda:0.weight_scale_2exact, ~0.09 relative error on both).Not run: other GPU architectures, and CI's environment.
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
NVBug 6779760. The playbook fix (bump the Spark section from 0.35.0 to 0.41.0) is tracked on the bug.
🤖 Generated with Claude Code
Summary by CodeRabbit