Skip to content

[PyTorch] Remove fast param getter from modules - #1291

Merged
timmoon10 merged 3 commits into
NVIDIA:mainfrom
timmoon10:debug-fast-get-param
Oct 28, 2024
Merged

[PyTorch] Remove fast param getter from modules#1291
timmoon10 merged 3 commits into
NVIDIA:mainfrom
timmoon10:debug-fast-get-param

Conversation

@timmoon10

@timmoon10timmoon10 commented Oct 26, 2024

Copy link
Copy Markdown
Member

Description

#1191 added a fast accessor for params to work around CPU overheads from how PyTorch modules store params. This saves ~1 us per forward pass (out of a total ~100 us) in small benchmarks with the linear layer. However, we have experienced some problems with FSDP since it internally replaces the params with a flattened param and turns the original params into a plain tensor. The fast accessor was very hacky, and this edge case makes me think it's not worth the performance benefit.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refractor

Changes

  • Remove fast param accessor in TE modules

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10timmoon10 added the bug Something isn't working label Oct 26, 2024
@timmoon10

Copy link
Copy Markdown
MemberAuthor

/te-ci pytorch

Signed-off-by: Tim Moon <tmoon@nvidia.com>
@timmoon10

Copy link
Copy Markdown
MemberAuthor

/te-ci pytorch

@ksivamanksivaman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@timmoon10
timmoon10 merged commit 35bbe74 into NVIDIA:mainOct 28, 2024
@timmoon10
timmoon10 deleted the debug-fast-get-param branch October 28, 2024 23:47
timmoon10 added a commit that referenced this pull request Oct 28, 2024
* Add fallback for fast param getter
Signed-off-by: Tim Moon <tmoon@nvidia.com>
* Remove fast param getter
Signed-off-by: Tim Moon <tmoon@nvidia.com>
* Fix linter warning
Signed-off-by: Tim Moon <tmoon@nvidia.com>
---------
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.12.0bugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@timmoon10@ksivaman