Fix multi model ddp unused params#21768
Closed
Zish19 wants to merge 29 commits into
Closed
Conversation
for more information, see https://pre-commit.ci
…-multimodelddp-implementation test: cover MultiModelDDPStrategy
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…evious MultiModelDDP model example w/ new pl version
for more information, see https://pre-commit.ci
1. change all testcases snippets in right way; tested with one-by-one
for more information, see https://pre-commit.ci
5 tasks
This file contains hidden or 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
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.
I investigated issue #21548 and implemented a fix for unused parameter detection in
MultiModelDDPStrategy.Root cause:
MultiModelDDPStrategywraps child modules inDistributedDataParallel, but returns the rootLightningModule, so inheritedDDPStrategy.pre_backward()exits early becauseself.modelis not aDistributedDataParallelinstance. As a result,prepare_for_backward()is never called and unused parameter detection is skipped.Fix:
Override
MultiModelDDPStrategy.pre_backward()and iterate over DDP-wrapped child modules. Only arm reducers for modules with active trainable parameters (requires_grad=True) to avoid false-positive reducer errors during multi-optimizer manual optimization (for example GAN training withtoggle_optimizer()).I also enabled a regression test for unused parameter detection in:
tests/tests_pytorch/strategies/test_multi_model_ddp.pyBranch:
Zish19:fix-multi-model-ddp-unused-paramsValidation:
test_multi_model_ddp.pytest_ddp_integration.pyBoth passed locally.