Conversation
jenchen13
reviewed
Dec 30, 2025
jenchen13
reviewed
Jan 6, 2026
updated/cleaned up tests KV Cache clean ups; added MCore hybrid tests Added amax sync for KVCache Quantization minor Signed-off-by: realAsma <akuriparambi@nvidia.com>
249227d to
89f507a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
- Coverage 74.69% 74.69% -0.01%
==========================================
Files 192 192
Lines 18946 18953 +7
==========================================
+ Hits 14152 14156 +4
- Misses 4794 4797 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: realAsma <akuriparambi@nvidia.com>
Signed-off-by: realAsma <akuriparambi@nvidia.com>
ChenhanYu
reviewed
Jan 6, 2026
jenchen13
approved these changes
Jan 6, 2026
7c6ea5a to
724451e
Compare
Signed-off-by: realAsma <akuriparambi@nvidia.com>
jenchen13
approved these changes
Jan 6, 2026
kevalmorabia97
pushed a commit
that referenced
this pull request
Jan 12, 2026
…uted Sync of KVCache Quantizer params (#727) ## What does this PR do? **Type of change:** Fix MCore KV Cache Quantization: Amax Device Placement Bug; Code clean up; Distributed Sync of KVCache Quantizer params; unittest expansion to hybrid models **Overview:** Fixes bugs preventing MCore KV Cache quantization from working during checkpoint restore. ### Bug Chain **Bug 1:** `is_enabled = self.weight_quantizer.is_enabled if hasattr(self, "weight_quantizer") else False` No `weight_quantizer` for KV-cache-only quant → `is_enabled=False` → metadata not saved → `modelopt_post_restore()` never called. *(Thanks to @jenchen13 )* **Bug 2:** After fixing Bug 1, `_amax` restored on CPU (via `_reset_pytorch_state_from_metadata`). Fallback `_calibrate_quantizers()` never called because `_amax` exists. **Bug 3:** Even if called, `_calibrate_quantizers()` fails — `core_attention` has no parameters → can't determine device/dtype. ### The Fix 1. Remove `is_enabled` check entirely — disabled modules may still need metadata restore. Explicitly skip `output_layer` from extra state callbacks (never quantized) 2. Set `dtype`/`device` on `core_attention` from parent Attention module, `modelopt_post_restore()` calls `self.to(device, dtype)` 3. Remove dead `_calibrate_quantizers()` code (will bring back similar logic for KV cache affine quantization) ### Previous Unit Test Was Wrong `model_test` was `mtq.quantize()`'d, not `mto.restore()`'d. Never tested actual restore path. ### Additional Fixes - Amax sync across DP/TP for KV cache quantizers - `flash_decode` auto-disabled ### Code Cleanup Removed ~100 lines of dead code. ## Testing 1. MCore KV Cache QAD with Nano V3 + Context Parallel works 2. Unit tests: hybrid models, KV+GEMM configs, correct restore workflow, backward pass validation ## Before your PR is "*Ready for review*" - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: Yes - **Did you add or update any necessary documentation?**: No - **Did you update Changelog?**: Yes --------- Signed-off-by: realAsma <akuriparambi@nvidia.com> Co-authored-by: Asma Thekkumpate <akuriparambi@cw-dfw-cs-001-vscode-02.cm.cluster>
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: Fix MCore KV Cache Quantization: Amax Device Placement Bug; Code clean up; Distributed Sync of KVCache Quantizer params; unittest expansion to hybrid models
Overview: Fixes bugs preventing MCore KV Cache quantization from working during checkpoint restore.
Bug Chain
Bug 1:
is_enabled = self.weight_quantizer.is_enabled if hasattr(self, "weight_quantizer") else FalseNo
weight_quantizerfor KV-cache-only quant →is_enabled=False→ metadata not saved →modelopt_post_restore()never called. (Thanks to @jenchen13 )Bug 2: After fixing Bug 1,
_amaxrestored on CPU (via_reset_pytorch_state_from_metadata). Fallback_calibrate_quantizers()never called because_amaxexists.Bug 3: Even if called,
_calibrate_quantizers()fails —core_attentionhas no parameters → can't determine device/dtype.The Fix
is_enabledcheck entirely — disabled modules may still need metadata restore. Explicitly skipoutput_layerfrom extra state callbacks (never quantized)dtype/deviceoncore_attentionfrom parent Attention module,modelopt_post_restore()callsself.to(device, dtype)_calibrate_quantizers()code (will bring back similar logic for KV cache affine quantization)Previous Unit Test Was Wrong
model_testwasmtq.quantize()'d, notmto.restore()'d. Never tested actual restore path.Additional Fixes
flash_decodeauto-disabledCode Cleanup
Removed ~100 lines of dead code.
Testing
Before your PR is "Ready for review"