[Quark] Support online block-diagonal rotations in dense GEMM layers - #32272
fxmarty-amd wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for online block-diagonal rotations in OCP MX dense layers, a new feature for Quark quantization. The changes are primarily within vllm/model_executor/layers/quantization/quark/schemes/quark_ocp_mx.py to handle the configuration for these rotations, create and process the rotation matrix weights, and apply the transformation during the forward pass. The overall logic appears correct and aligns with the feature description. However, I've identified several instances of unsafe dictionary access that could lead to KeyError exceptions if the quantization configuration is not structured as expected. I've provided specific suggestions to improve the robustness of this code by using the .get() method for safer dictionary key access.
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Felix Marty <Felix.Marty@amd.com>
31b751f to
1f2345a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Signed-off-by: Felix Marty <Felix.Marty@amd.com>
|
cc @BowenBao @mgoin @robertgshaw2-redhat could you have a look? Thank you! |
| quant_config: dict[str, Any], | ||
| layer_names: list[str], |
There was a problem hiding this comment.
nit: I feel this increases the scope of information passed in, where previously weight_quant_spec and input_quant_spec are scoped in on this particular layer. now QuarkScheme also needs to handle parsing info from global quant_config based on layer_names. Do you think there's a way to reduce the surface?
There was a problem hiding this comment.
let me have a look shortly
There was a problem hiding this comment.
Do you have an other suggestion? We could pass to each QuarkScheme instead directly:
use_online_rotation: bool = False,
rotation_config: dict[str, Any] | None = None,
rotation_size: int | None = None,
but I don't feel like it is better
|
@tjtanaa could you review again if this can be landed? thanks! |
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Felix Marty <Felix.Marty@amd.com>
|
This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you! |
|
not stale |
|
This pull request has merge conflicts that must be resolved before it can be |
This PR adds support to load quantized models making use of online block-diagonal rotations in dense GEMM layers (OCP MX, FP8, INT8) and produced through AMD Quark library, based on the config.json's
quantization_configindicating which layers are using online rotations.See the notes: https://quark.docs.amd.com/latest/release_note.html#support-for-online-rotations-online-hadamard-transform
This is a naive non-optimized implementation.
We'll likely release models in the future. For the moment, we simply use in the CI:
amd-quark/internal-testing-qwen3_0.6b-mxfp4-hadamard,amd-quark/internal-testing-qwen3_0.6b-fp8-hadamard,amd-quark/internal-testing-qwen3_0.6b-mxfp4-tuned-orthogonal,amd-quark/internal-testing-qwen3_0.6b-fp8-tuned-orthogonal.Motivation
Online rotation (hadamard/orthogonal) has been shown to be a promising technique to recover from the accuracy drop seen in low-precision formats as MXFP4.
Using block-diagonal hadamard or orthogonal transforms is a popular strategy recently, as per e.g.
Test plan
pytest tests/quantization/test_quark.py -s -vvvvv -k "test_online_transform_loading"