Skip to content

Fix invalid group reference in revert_checkpoint_conversion_mapping#2035

Open
A-S-Manoj wants to merge 1 commit into
intel:mainfrom
A-S-Manoj:fix/revert-checkpoint-conversion-backreference
Open

Fix invalid group reference in revert_checkpoint_conversion_mapping#2035
A-S-Manoj wants to merge 1 commit into
intel:mainfrom
A-S-Manoj:fix/revert-checkpoint-conversion-backreference

Conversation

@A-S-Manoj

Copy link
Copy Markdown

Description

revert_checkpoint_conversion_mapping unconditionally stripped the capture
group out of each source regex pattern, even when the corresponding target
pattern still referenced that group via a backreference (e.g. \1).

This is fine for mappings where the target is a plain string, but
transformers-5.x checkpoint_conversion_mappings (e.g. Qwen3.5/3.6-MoE)
include entries like:

{r"^model\.language_model\.(.+)$": r"model.\1"}

Stripping the group here leaves \1 in the target dangling, and
re.subn(source_pattern, target_pattern, name) raises:

re.error: invalid group reference 1 at position 7

The fix only strips the capture group when the target pattern does not
backreference it, so patterns that rely on the captured suffix keep working
while the existing bare-tensor-suffix handling is unaffected.

Type of Change

Bug fix

Related Issues

Fixes #2028

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.
  • The CUDA CI has passed. You can trigger it by commenting /azp run Unit-Test-CUDA-AutoRound.

…ntel#2028)

Signed-off-by: A Sivasubramanian Manoj <sivasubramanianmanoj2310533@ssn.edu.in>
@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 2035 in repo intel/auto-round

@yiliu30

yiliu30 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] revert_checkpoint_conversion_mapping crashes with re.error "invalid group reference" on transformers-5.x models

2 participants