Add k_quant_linear mixed-precision quantization for hybrid attention … - #2100
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in mixed-precision INT4→INT8 promotion path for Qwen3.5 hybrid (linear + full) attention models by introducing a k_quant_linear int4_algo_config mode and making layer-type metadata available during base-class initialization.
Changes:
- Parse
layer_typesbeforesuper().__init__()so base init-time quantization config can inspect linear-attention layers. - Remove the always-on INT8 overrides for linear-attention projections/MLP and replace them with an opt-in
make_int4_algo_config()override keyed onk_quant_linear. - Add a Qwen3.5-specific
make_int4_algo_config()implementation that promotes selected MatMul weights to INT8.
Contributor
|
Can we add onnxruntime-genai/src/python/py/models/builder.py Lines 413 to 420 in 19c2f7b |
kunal-vaishnavi
approved these changes
Apr 28, 2026
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.
Adds
k_quant_linearas a newint4_algo_configoption that promotes linear attention projections and their MLPs from INT4 to INT8. This improves accuracy for hybrid models like Qwen3.5 where linear attention recurrence accumulates quantization errors across the full sequence (unlike softmax attention which normalizes per-step).Changes
onnxruntime-genai
qwen.py:make_int4_algo_config()override withk_quant_linearsupportlayer_typesparsing beforesuper().__init__()somake_int4_algo_configcan access it during base class initializationint4_algo_config)