Fix incompatible weight names#1759
Open
mengniwang95 wants to merge 15 commits intomainfrom
Open
Conversation
Co-authored-by: Copilot <copilot@github.com>
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes weight-name mismatches caused by Transformers checkpoint key conversion (via _checkpoint_conversion_mapping), so exported quantized checkpoints/configs retain the expected “original” key names and can be loaded by downstream runtimes (e.g., sglang).
Changes:
- Added utility helpers to apply/revert checkpoint conversion mappings for parameter/block names.
- Applied checkpoint conversion mapping when deriving
quant_block_listduring inference-time model conversion. - Reverted checkpoint conversion mapping when saving shard tensors and when serializing
to_quant_block_namesinto exported configs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| auto_round/utils/common.py | Adds helpers to apply/revert checkpoint conversion regex mappings. |
| auto_round/inference/convert_model.py | Applies checkpoint conversion mapping when building quantization block prefixes. |
| auto_round/compressors_new/shard_writer.py | Reverts mapped names when writing shard tensor keys. |
| auto_round/compressors_new/base.py | Reverts mapped to_quant_block_names in exported serialization metadata. |
| auto_round/compressors/shard_writer.py | Reverts mapped names when writing shard tensor keys (old arch). |
| auto_round/compressors/base.py | Reverts mapped to_quant_block_names in exported serialization metadata (old arch). |
| auto_round/autoround.py | Attempts to merge extra_config values into constructor args (currently introduces a crash when extra_config=None). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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). |
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
yiliu30
approved these changes
Apr 30, 2026
Co-authored-by: Copilot <copilot@github.com>
for more information, see https://pre-commit.ci
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
transformers will do checkpoint name conversion automatically and then cause the mismatch between quantized weight name and original name
W4A16 Qwen2.5-VL-7B-Instruct generated by this PR can be loaded by sglang and transformers
Example for this issue (qwen2_5_vl):
The original weight names are:
"model.layers.0.mlp.down_proj.weight"
"visual.blocks.0.attn.proj.weight"
...
After AR quantiztaion, the saved weight names are:
"model.language_model.layers.0.mlp.down_proj.weight" (incorrect weight)
"model.visual.blocks.0.attn.proj.weight" (incorrect weight name)
"model.layers.0.mlp.down_proj.qweight"
...
the block_name_to_quantize is:
"block_name_to_quantize": [
"model.language_model.layers",
"model.layers"
],
Since the change of weight name, sglang can not load the quantized weight.
Using this PR, the AR generated weight names will be:
"model.layers.0.mlp.down_proj.qweight"
"visual.blocks.0.attn.proj.weight"
...
and the block_name_to_quantize is:
"block_name_to_quantize": "model.layers"
Type of Change
Bug fix
Related Issues
#982
Checklist Before Submitting
/azp run Unit-Test-CUDA-AutoRound.