Skip to content

Refactor module access to use PyTorch get_submodule / set_submodule#1590

Open
scopophobic wants to merge 5 commits intointel:mainfrom
scopophobic:refactor/use-torch-submodule-api-clean
Open

Refactor module access to use PyTorch get_submodule / set_submodule#1590
scopophobic wants to merge 5 commits intointel:mainfrom
scopophobic:refactor/use-torch-submodule-api-clean

Conversation

@scopophobic
Copy link
Copy Markdown
Contributor

@xin3he
Refactor module access to use PyTorch get_submodule / set_submodule for exact dotted module paths, while preserving prior “missing path should not crash” behavior by catching AttributeError/KeyError. This avoids CI failures caused by optional/missing submodules in some model variants.

Note: This is a new PR because I accidentally closed the previous one while iterating on the fix.

Type of Change: Bug fix / Refactor.

Copy link
Copy Markdown
Contributor

@xin3he xin3he left a comment

Choose a reason for hiding this comment

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

Thank you, @scopophobic LGTM.

@xin3he xin3he requested a review from n1ck-guo March 23, 2026 05:09
@xin3he
Copy link
Copy Markdown
Contributor

xin3he commented Mar 23, 2026

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@xin3he
Copy link
Copy Markdown
Contributor

xin3he commented Mar 23, 2026

@XuehaoSun Please help fix this CI issue.

Copilot AI review requested due to automatic review settings April 1, 2026 01:13
Copy link
Copy Markdown
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

Refactors internal module/attribute access helpers to use PyTorch’s native dotted-path APIs (get_submodule / set_submodule) for more reliable resolution, while keeping legacy “missing path should not crash” behavior. Also relaxes layer-name collection to skip missing layers rather than terminating the process.

Changes:

  • Add dedicated get_attr / set_attr for dotted attribute access (including parameter attributes like ...weight) with “missing returns/no-op” behavior.
  • Refactor get_module / set_module to use get_submodule / set_submodule, returning None / no-op on missing paths.
  • In _get_quantized_layer_names_outside_blocks, skip missing layers with a one-time warning instead of exiting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
auto_round/utils/model.py Introduces get_attr/set_attr and switches module replacement to get_submodule/set_submodule while preserving non-fail-fast behavior.
auto_round/compressors/base.py Avoids hard exit when a configured layer path is missing; logs and continues.

@xin3he
Copy link
Copy Markdown
Contributor

xin3he commented Apr 1, 2026

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@XuehaoSun
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.

6 participants