FSDP2: handle footgun as a rejection case in pytorch issue 180666 (the mark of the beast) - #2914
Merged
Merged
Conversation
…e mark of the beast)
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.
This pull request adds important validation logic to prevent incompatible configurations when using FSDP v2 with CPU parameter offload, and extends test coverage to ensure these checks work as intended. The main focus is to avoid runtime errors caused by using certain optimizer options that are not supported together.
Validation logic for FSDP v2 CPU offload:
_normalize_input_args(cmd_args.py) and_load_fsdp_plugin(trainer.py) to raise errors if FSDP v2 CPU parameter offload is enabled together with either post-accumulate gradient hook based optimizers (e.g.,optimizer_release_gradientswith "optimi" optimizers) or thetorchaooptimizer CPU offload method. This prevents unsupported configurations and provides clear error messages to users. [1] [2]Test coverage improvements:
test_fsdp_cmd_args.pyto verify that invalid argument combinations are rejected and valid ones are allowed.test_trainer.pyto ensure that the trainer correctly raises errors for incompatible FSDP v2 CPU offload and optimizer settings.These changes improve the robustness of configuration handling and help users avoid hard-to-debug runtime failures.