Open
Conversation
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the experimental inplace-rotation implementation to better support models where head_dim is not hidden_size // num_heads (e.g., Qwen-3), reduce peak memory during weight rotation, and introduce a mechanism for model-specific rotation overrides.
Changes:
- Resolve
head_dimusingmapping.attn_head_dim→config.head_dim→hidden_size // num_headsin rotation + hook codepaths. - Add chunked (memory-efficient) weight rotation for large matrices and adjust OV rotation to always use a decomposed per-head + cross-head form.
- Introduce a special-model override registry and wire it into
apply_rotation_transform.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| auto_round/experimental/rotation_inplace/utils.py | Head-dim resolution update; new Hadamard handling paths (incl. chunked full-dim custom matrix) and non-pow2 behavior changes. |
| auto_round/experimental/rotation_inplace/special_model_handler.py | New registry/helpers for model-specific override application with logging. |
| auto_round/experimental/rotation_inplace/apply_rotation_transform.py | Adds _resolve_head_dim, chunked rotation helper, OV rotation fix, and applies model-specific overrides. |
| auto_round/main.py | Extends CLI --rotation_type choices to include quarot_hadamard. |
Comments suppressed due to low confidence (1)
auto_round/experimental/rotation_inplace/utils.py:521
- In
apply_exact_had_to_linear, the full-dimensionhad_matrixpath appliesW @ H.Tregardless ofoutput. This ignores theoutput=Truecontract and is inconsistent with the non-customoutput=Truepath (which rotates viaW = H @ W). Please implement the correct left-multiply whenoutput=Trueforhad_dim == -1(and update the chunked fast path accordingly).
if had_matrix is not None:
H = had_matrix.to(device=compute_dev, dtype=torch.float64)
if had_dim == -1:
# Full-dimension custom matrix
if output:
# W.T = H @ W.T → W = (H @ W.T).T = W @ H.T
W_ = W_ @ H.T
else:
# W = H @ W (rotate input columns: W_new[i,:] = sum H[i,j]*W[j,:])
# Actually for input side: W_new = W @ H (each row is rotated)
W_ = W_ @ H.T
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
WeiweiZhang1
approved these changes
Apr 23, 2026
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
for more information, see https://pre-commit.ci
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…to fix_rotation
for more information, see https://pre-commit.ci
…to fix_rotation
for more information, see https://pre-commit.ci
…to fix_rotation
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.
Description
Please briefly describe your main changes, the motivation.
Type of Change
Related Issues
Fixes or relates to #
Checklist Before Submitting