Fix to-fsdp2: drop REMOVED / NOT_YET_IMPLEMENTED FSDP1 keys instead of leaking them#4065
Open
lollinng wants to merge 1 commit into
Open
Fix to-fsdp2: drop REMOVED / NOT_YET_IMPLEMENTED FSDP1 keys instead of leaking them#4065lollinng wants to merge 1 commit into
lollinng wants to merge 1 commit into
Conversation
convert_config_to_fsdp2's first branch caught both 'key not in mapping' (conversion_status is None) AND the ConversionStatus enum values, carrying the key over and continuing. That made the REMOVED / NOT_YET_IMPLEMENTED handling below unreachable, so FSDP1-only keys (fsdp_backward_prefetch, fsdp_sync_module_states, fsdp_use_orig_params, fsdp_forward_prefetch) leaked into the converted FSDP2 config. Only carry over keys that are genuinely absent from the mapping; let ConversionStatus values fall through to be dropped. Adds a regression test. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
accelerate to-fsdp2converts an FSDP1 config to FSDP2. Inconvert_config_to_fsdp2, the first branch of the per-key loop was:This carries the key over and
continues for both "key not in the mapping" (None) and theConversionStatusenum values (REMOVED/NOT_YET_IMPLEMENTED). As a result, theREMOVED/NOT_YET_IMPLEMENTEDhandling just below was dead code, and FSDP1-only keys —fsdp_backward_prefetch,fsdp_sync_module_states,fsdp_use_orig_params(REMOVED) andfsdp_forward_prefetch(NOT_YET_IMPLEMENTED) — leaked into the converted FSDP2 config instead of being dropped.Fix
Only carry over keys that are genuinely absent from the mapping (
conversion_status is None); letConversionStatusvalues fall through to theREMOVED/NOT_YET_IMPLEMENTEDbranches that drop them.Testing done (CPU)
Added
tests/test_cli.py::ToFSDP2Tester::test_convert_config_drops_removed_and_unimplemented_keys:It asserts the four FSDP1-only keys are dropped, that a renamed+value-mapped key (
fsdp_sharding_strategy: FULL_SHARD→fsdp_reshard_after_forward: True) and pass-through / unknown keys are preserved, and thatfsdp_versionis set to 2.ruffclean.