Skip to content

Refactor: use get_submodule with manual traversal fallback in get_module#1677

Open
yael-shr wants to merge 2 commits intointel:mainfrom
yael-shr:refactor-get-module-api
Open

Refactor: use get_submodule with manual traversal fallback in get_module#1677
yael-shr wants to merge 2 commits intointel:mainfrom
yael-shr:refactor-get-module-api

Conversation

@yael-shr
Copy link
Copy Markdown

Description

This PR transitions the get_module function to use PyTorch's native get_submodule API for better performance. It includes a manual traversal fallback to maintain backward compatibility and handle complex paths/regex as discussed in the related issue.

Type of Change

  • Performance improvement
  • Code refactoring

Related Issues

Fixes or relates to #1362

Checklist Before Submitting

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

Note: Refactored a single core function to apply changes globally across 25+ files without cluttering the PR.

Comment thread auto_round/utils/model.py
fallback to manual traversal for backward compatibility.
"""
try:
return module.get_submodule(key)
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.

Thanks, we had changed it to use get_submodule API.

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.

2 participants