[Example]: Dspark W4A16 PTQ script - #2027
Conversation
Signed-off-by: h-guo18 <67671475+h-guo18@users.noreply.github.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 #2027 +/- ##
=======================================
Coverage 66.83% 66.83%
=======================================
Files 519 519
Lines 58916 58916
=======================================
Hits 39376 39376
Misses 19540 19540
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: new example
Adds
examples/speculative_decoding/scripts/quantize_drafter.py, a CLI that quantizes an exported speculative-decoding drafter to W4A16 NVFP4.Needs no calibration data (the preset's per-block scales are dynamic, so
mtq.quantizeis called without aforward_loop) and no modeling code — exported drafters such asnvidia/MiniMax-M3-DSparkhave no importable model class, so each 2-D weight is wrapped in a throwawaynn.Linearunder its checkpoint key and ModelOpt's usualquantizer_namepatterns select over those names. Works for any drafter layout. Config comes fromQUANT_CFG_CHOICES; packing and scales go through the existing export helpers. No library code touched.Usage
python scripts/quantize_drafter.py \ --drafter_path nvidia/MiniMax-M3-DSpark \ --export_path ./MiniMax-M3-DSpark-W4A16Writes a unified-HF checkpoint (
w.weight/w.weight_scale/w.weight_scale_2) plushf_quant_config.json.lm_headis excluded by default — unlike on a base model it is 37% of this drafter's parameters, so--quantize_lm_headis a real lever (~1.9 GiB), but measure AL first.Testing
No automated test yet (see checklist). Validated on
nvidia/MiniMax-M3-DSpark: runs in 67 s on CPU, 9.98 GiB (fp32) -> 3.51 GiB; all 43 quantized tensors round-trip within 0.0952 relative error; the 29 untouched tensors are bit-identical tobf16(source); the 86 added keys are exclusively scale buffers.pre-commitpasses.Before your PR is "Ready for review"
CONTRIBUTING.md: N/Atests/examples/speculative_decoding/test over a small synthetic drafter if wanted before merge.Additional Information
Whether vLLM's DSpark drafter loader honours
quantization_configon the draft model is not verified here.