New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid false-positive warnings about method calls on the Fabric-wrapped module #18819
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
awaelchli
changed the title
Better non-forward() warnings for Fabric
Avoid false-positive warnings about method calls on the Fabric-wrapped module
Oct 19, 2023
awaelchli
added
the
fun
Staff contributions outside working hours - to differentiate from the "community" label
label
Oct 21, 2023
Borda
approved these changes
Oct 22, 2023
carmocca
approved these changes
Oct 22, 2023
This seems to be breaking
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR implements a better way to warn users in case they call a method on the wrapper.
A warning is currently printed on any call to a method that is not forward(), given that the original module is wrapped by a distributed wrapper like DDP, FSDP or similar. See an example in Lightning-AI/litgpt#641
This PR restricts this warning to only the case when an actual module forward call occurs. A call to a method that does not run inputs through the submodules is not considered problematic anymore.
I ran a quick benchmark to measure the impact of adding the model hooks:
Times measured with:
GPU benchmark
master:
10 loops, best of 10: 184.9 msec per loop
branch:
10 loops, best of 10: 208.9 msec per loop
CPU benchmark
master:
10 loops, best of 10: 151 msec per loop
branch:
10 loops, best of 10: 173.7 msec per loop
The benchmarks show a ~20 msec impact when running with the hooks in this extreme example of a super small model. On regular-sized models, the impact is not measurable.
📚 Documentation preview 📚: https://pytorch-lightning--18819.org.readthedocs.build/en/18819/
cc @Borda @carmocca @justusschock @awaelchli