Skip to content

Add Qwen-Image DMD2 QAT and PEFT-backed SVDQuant - #2069

Draft
jingyu-ml wants to merge 1 commit into
mainfrom
jingyux/qwen-image-dmd2-svdquant-peft
Draft

Add Qwen-Image DMD2 QAT and PEFT-backed SVDQuant#2069
jingyu-ml wants to merge 1 commit into
mainfrom
jingyux/qwen-image-dmd2-svdquant-peft

Conversation

@jingyu-ml

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: new feature / backward-breaking SVDQuant representation change

This PR adds Qwen-Image support to the Diffusers quantization example and the FastGen DMD2/QAT flow. The final diff is scoped to Qwen-Image itself; the intermediate Qwen-Image-Edit/2511 implementation has been removed.

It also changes generic SVDQuant calibration for NVFP4, INT4, and INT8 recipes so the calibrated low-rank residual is owned by a structural Hugging Face PEFT adapter:

  • only layers actually calibrated by SVDQuant receive PEFT A/B parameters;
  • PEFT A/B are trainable by default and the quantizer-owned A/B copies are removed after calibration;
  • the forward remains Q(W_residual)x + B(Ax), including the existing input pre-scale and output-quantizer placement;
  • full mto.save / mto.restore and split modelopt_state + complete state_dict checkpoints rebuild the PEFT topology and preserve A/B exactly;
  • QATTrainer completes structural quantization before optimizer and distributed model preparation for train/evaluate/predict.

The generic unified/deployment exporter flow is intentionally unchanged.

Usage

model = mtq.quantize(model, quant_config, forward_loop)
optimizer = torch.optim.AdamW(
    (parameter for parameter in model.parameters() if parameter.requires_grad),
    lr=learning_rate,
)

mto.save(model, "svdquant.pt")
restored = mto.restore(clean_model, "svdquant.pt")

For split checkpoints, restore mto.modelopt_state(model) first and then load the complete model.state_dict() before constructing DDP/FSDP and the optimizer.

Testing

  • 52 passed: focused PEFT-backed SVDQuant tests, existing calibration tests, full CPU quantization regression file, and the layerwise-calibration support gate (Slurm 303961).
  • 12 passed, 1 skipped: Qwen-Image FastGen plugin and quantizer-state round-trip tests (Slurm 303935).
  • Real GB200 NVFP4 SVDQuant rank-32 validation (Slurm 303924): BF16 PEFT A/B were trainable, both updated in QAT, quantizer A/B were absent, and full plus split restore reproduced factors and outputs bitwise exactly.
  • Ruff lint/format, Python compilation, git diff --check, and a staged-snapshot scan confirming no Qwen-Image-Edit/2511/2512 or Attention Grill content in the PR.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ❌ New SVDQuant checkpoints store A/B in Hugging Face PEFT instead of weight-quantizer buffers; old SVDQuant checkpoint compatibility is intentionally not retained.
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A; PEFT is already part of the existing hf optional dependencies.
  • Did you write any new necessary tests?: ✅
  • Did you update CHANGELOG.rst?: ✅
  • Did you get Claude approval on this PR?: N/A while draft; independent code audits were completed for SVDQuant math and ModelOpt lifecycle behavior.

@copy-pr-bot

copy-pr-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b0bbc3ec-8047-44b3-a399-33a8fc54bdab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Add Qwen-Image support to the Diffusers quantization and FastGen DMD2/QAT flows.

Move calibrated SVDQuant low-rank factors into trainable Hugging Face PEFT adapters for NVFP4, INT4, and INT8 recipes, and preserve their topology and values through ModelOpt save/restore. Keep the final DMD2 example scoped to Qwen-Image by removing the intermediate Qwen-Image-Edit additions.

Signed-off-by: Jingyu Xin <jingyux@nvidia.com>
@jingyu-ml
jingyu-ml force-pushed the jingyux/qwen-image-dmd2-svdquant-peft branch from 4e8d35c to 1583d68 Compare August 5, 2026 02:13
@copy-pr-bot

copy-pr-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://NVIDIA.github.io/Model-Optimizer/pr-preview/pr-2069/

Built to branch gh-pages at 2026-08-05 02:17 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant