Skip to content

Refactor module access to use PyTorch get_submodule / set_submodule - #1590

Merged
xin3he merged 5 commits into
intel:mainfrom
scopophobic:refactor/use-torch-submodule-api-clean
Apr 10, 2026
Merged

Refactor module access to use PyTorch get_submodule / set_submodule#1590
xin3he merged 5 commits into
intel: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.

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

Thank you, @scopophobic LGTM.

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

xin3he commented Mar 23, 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).

@xin3he

xin3he commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

@XuehaoSun Please help fix this CI issue.

Copilot AI review requested due to automatic review settings April 1, 2026 01:13

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.

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.

Comment thread auto_round/utils/model.py
@xin3he

xin3he commented Apr 1, 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).

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

@scopophobic

Copy link
Copy Markdown
Contributor Author

hi @xin3he, following up on this... all CI tests are green. Please let me know if there’s anything else needed from my side to get this merged. Appreciate your time!

@xin3he
xin3he merged commit 58221b4 into intel:main Apr 10, 2026
37 checks passed
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