Skip to content

enhance: add source config preservation in save_model and related tests - #2522

Open
xin3he wants to merge 2 commits into
mainfrom
xinhe/10-20a
Open

xin3he wants to merge 2 commits into
mainfrom
xinhe/10-20a

Conversation

@xin3he

@xin3he xin3he commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Description

Sometimes, the saved config is not suitable for re-loading. we should avoid this issue ahead.

Type of Change

Refactor

Related Issues

Fixes or relates to #2521

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.

@xin3he
xin3he requested review from chensuyue and lvliang-intel and a lite review from Copilot and removed request for Copilot October 20, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Three moderate issues remain in source-config handling and in-place saves.

1 open issue
What changed in this PR

Preserves source config.json during model export while updating quantization metadata and adding tests.

Changes:

  • Adds local/remote source-config preservation with fallback behavior.
  • Integrates preservation into save_model.
  • Adds coverage for preservation and fallback scenarios.
File Summary Findings
auto_round/​export/​utils.py Implements source configuration loading and preservation. Three moderate issues: JSON source files are treated as Hub IDs (1 vote); stale quantization_config is retained when removed (2 votes); in-place saves can overwrite the source before preservation (1 vote).
test/​unit/​common/​export/​test_export_utils.py Tests source configuration preservation and fallback cases. No findings.

Review effort: Lite

Comment thread auto_round/export/utils.py
@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

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

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

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

@n1ck-guo n1ck-guo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Should we extend this algorithm by incorporating some of the code from save_config_artifact? For example,when exception, try model.save_config / config.save_pretrained as line 90-111

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.

4 participants