Repository navigation
Fix RTN rounding and KQuant stored-weight error scoring - #2758
Merged
Ti-Tai Wang (titaiwangms) merged 2 commits intoOct 27, 2026
Merged
Conversation
Correct symmetric RTN range handling, perform low-precision weight-to-scale division in FP32 with rounding before zero-point addition, and score KQuant candidates using their stored representation. Include an RTN baseline and normalize intermediate groups consistently while preserving complete-group chunking, optional compute-device selection, output device/dtype, scale-floor, and floor API behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a2a5b82-7cd3-4a76-bb94-0998527ea723 Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Shared quantization changes warrant human review because CUDA qualification and quantization performance measurements remain outstanding for this port.
No open issues 🎉
What changed in this PR
This PR corrects shared weight-quantization numerics and makes KQuant candidate selection reflect the representation stored in Olive checkpoints, without changing checkpoint formats.
Changes:
- Fix symmetric RTN ranges and promote low-precision division before rounding.
- Score KQuant candidates using stored parameters, with per-group normalization and an RTN fallback.
- Add numerical regression tests and document the behavior changes.
| File | Description |
|---|---|
test/common/quant/test_quantizer_numerics.py |
Adds regression coverage for rounding, ranges, stored-error scoring, and chunking. |
olive/passes/pytorch/kquant.py |
Adds storage-aware scoring, normalized search, and a per-group RTN baseline. |
olive/common/quant/utils.py |
Corrects symmetric scale calculation and quantization rounding precision. |
docs/source/features/quantization.md |
Documents numerical changes and KQuant’s reconstruction-error guarantee. |
Review effort: Balanced
Ti-Tai Wang (titaiwangms)
requested review from
Jambay Kinley (jambayk) and
Xiaoyu Z (xiaoyu-work)
October 26, 2026 23:11
Construct an explicit legacy bare-Linear router fixture instead of asserting an upstream Transformers implementation detail. Verify the fixture belongs to the generic 2D walk but stays excluded with quantize_moe both disabled and enabled. Keep the existing real-router coverage unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a2a5b82-7cd3-4a76-bb94-0998527ea723 Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Jambay Kinley (jambayk)
approved these changes
Oct 27, 2026
Ti-Tai Wang (titaiwangms)
enabled auto-merge (squash)
October 27, 2026 18:00
Ti-Tai Wang (titaiwangms)
deleted the
titaiwang/fix-rtn-kquant-numerics
branch
October 27, 2026 18:11
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.
Describe your changes
Fix numerical errors in shared weight quantization and KQuant candidate selection:
Preserves upstream INT3 support, the minimum-positive-scale floor, complete-group chunking, optional compute-device selection, output device/dtype, and checkpoint packing formats. Existing quantized checkpoints are not rewritten on load. Newly quantized codes and scales can change.
Validation
Fresh offline CPU validation of this port onto
c063dd3bd071eb1bcb3eeb7e6d102454c4a33947:test/common/quant, local KQuant/RTN pass tests,test_quant_utils.py, andtest_rtn_mixed_qmoe.py.test_kquant.py::test_kquantandtest_rtn.py::test_gptq(8 parameterizations each); all other collected tests in the selected files ran or skipped normally.git diff --check, package-import provenance, and CLI help checks passed.lintrunner. The local Ruff executable is 0.16.2, versus the repository pin 0.15.11, and reportsCPY001for the existing yearless Microsoft copyright header. The identical failure reproduces on untouchedolive/common/quant/hf_utils.py. Supplemental Ruff checks pass with only that baseline diagnostic excluded; no repository lint configuration or existing headers were changed.Earlier model evidence (not a rerun of this upstream port)
The same numerical fixes in the earlier implementation were evaluated on Gemma4-26B-A4B-it with a fixed 500-question MMLU-Pro subset and the same evaluation recipe:
These are bounded observations, not a claim that the remaining BF16-to-INT4 accuracy gap is fixed. The RTN fallback bounds the computed per-group weighted reconstruction objective (subject to floating-point scoring), not downstream task accuracy. Full-model inference, CUDA qualification, and quantization-time/peak-memory measurements were not repeated for this latest-main port.
Checklist before requesting a review
lintrunner -a. Formatting/Pylint passed; full local lintrunner has the baseline Ruff-version issue described above.Release note: Correct RTN symmetric ranges and low-precision quantization rounding; rank KQuant candidates using their stored representation with a per-group RTN baseline and normalized numerical scoring. Checkpoint formats remain unchanged.
(Optional) Issue link
None.