Skip to content

Conversation

@n1ck-guo
Copy link
Contributor

Description

Move some functions that require delayed execution to post_init to avoid bugs caused by incorrect call order.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Other (please specify):

Related Issues

Fixes or relates to #

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.

@n1ck-guo n1ck-guo requested review from Copilot, wenhuach21 and xin3he and removed request for Copilot January 26, 2026 03:04
@n1ck-guo n1ck-guo requested a review from Kaihui-intel January 26, 2026 03:05
Copilot AI review requested due to automatic review settings January 26, 2026 06:37
Signed-off-by: n1ck-guo <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the initialization logic of the compressor by introducing a _post_init method to handle operations that require delayed execution. The changes move various setup operations from __init__ to _post_init to prevent bugs caused by incorrect call ordering, particularly for operations that depend on the model being fully loaded or other initialization steps being complete.

Changes:

  • Introduced a _post_init method to handle delayed initialization logic including scheme parsing, device setup, seed setting, and torch compile adjustments
  • Moved output directory path calculation logic from __main__.py into the quantize_and_save method
  • Simplified __init__ by deferring complex initialization steps that have dependencies on other attributes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
auto_round/compressors/base.py Refactored initialization by moving delayed-execution logic (scheme parsing, device setup, seed setting, etc.) from __init__ to new _post_init method; added path calculation to quantize_and_save and save_quantized
auto_round/main.py Simplified by removing output directory path calculation logic that was moved into the compressor class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

n1ck-guo and others added 2 commits January 26, 2026 14:44
Signed-off-by: n1ck-guo <[email protected]>
@n1ck-guo n1ck-guo requested a review from xin3he January 26, 2026 06:52
ValueError: If an unsupported format is specified.
"""
# post init
self._post_init()
Copy link
Contributor

Choose a reason for hiding this comment

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

How can developers know which initialization code belongs in post_init?

Signed-off-by: n1ck-guo <[email protected]>
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