[NVBug: 6524370] use sequential device_map for DiffusionGemma - #2041
[NVBug: 6524370] use sequential device_map for DiffusionGemma#2041juhi10071998 wants to merge 1 commit into
Conversation
DiffusionGemma ties weights between its encoder and decoder. Loading it
with device_map="auto" (balanced) can place the two sides of a tied pair
on different GPUs; the tie cannot then be honored and one side is left on
the meta device, so the pre-quantization preview fails with:
RuntimeError: Tensor.item() cannot be called on meta tensors
Detect DiffusionGemma configs in get_model and select
device_map="sequential", which keeps tied modules together. This mirrors
the existing per-model handling for bart and t5, where device_map="auto"
similarly mis-shards tied encoder/decoder weights.
Multi-GPU only; single-GPU runs were unaffected. Previously this required
passing --use_seq_device_map manually.
Fixes NVBug 6524370
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Juhi Mittal <juhim@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2041 +/- ##
==========================================
- Coverage 69.97% 69.96% -0.02%
==========================================
Files 519 519
Lines 59399 59399
==========================================
- Hits 41565 41559 -6
- Misses 17834 17840 +6
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:
|
What does this PR do?
Type of change: Bug fix
Fixes NVBug 6524370.
DiffusionGemmaties weights between its encoder and decoder.get_modelloads withdevice_map="auto"(examples/hf_ptq/example_utils.py), and"auto"is an alias for"balanced"— accelerate splits the model evenly across all visible GPUs by size, with no awareness of tied parameters. On multi-GPU it can place the two sides of a tied pair on different devices; the tie then cannot be honored and one side is left on themetadevice.The pre-quantization preview in
pre_quantizethen reaches(input_ids == self.config.image_token_id).any()ingeneration_diffusion_gemma.pyand fails:This is multi-GPU-only by construction: with one visible GPU the balanced split is trivial, nothing is separated, and nothing lands on
meta.This PR detects DiffusionGemma configs in
get_modeland selectsdevice_map="sequential", which fills one GPU before spilling to the next and so keeps tied modules together. It mirrors the existing per-model handling forbartandt5, wheredevice_map="auto"similarly mis-shards tied encoder/decoder weights.Detection reads
model_typeandarchitecturesfrom the config and ignores underscores, since the family is spelleddiffusion_gemmain the Transformers module path andDiffusionGemmain the class name.Usage
No API change. Previously this needed the flag passed manually:
It is now selected automatically, and the model load logs:
Passing
--use_seq_device_mapexplicitly still works and is unaffected.Testing
diffusiongemma-26B-A4B-itand thenvfp4_experts_onlyrecipe;--use_seq_device_mapresolves the crash, confirming the device-mapping cause.is_diffusion_gemmachecked against both config spellings,architectures=None,architectures=[], and agemma3negative to confirm no over-match —get_model_typealready ordersDiffusionGemmabeforeGemmafor exactly this substring-collision reason.pre-commit run --files examples/hf_ptq/example_utils.pypasses (ruff, ruff-format, mypy, bandit).Draft pending an end-to-end PTQ run on 4x GB200 with the patch applied and no CLI flag.
Before your PR is "Ready for review"
CONTRIBUTING.md: N/Aget_modeldevice-map selection; happy to add a config-level test foris_diffusion_gemmaif wanted.Additional Information
NVBug 6524370. Same class of failure as the existing
t5workaround inget_model; a general "any tied encoder/decoder model" rule was considered but rejected, sincetie_word_embeddings=Trueholds for most decoder-only LLMs whereautois fine and forcing sequential would regress large-model runs.🤖 Generated with Claude Code