Repository navigation
fix: default cast_forward_inputs to False (match FSDP2, avoid corrupting fp32 activations) - #15
Merged
Conversation
…ing fp32 activations) DedicatedState._pre_forward force-casts every floating-point tensor in a wrapped module's forward args/kwargs (recursing into tuple/list/dict) to the group's param_dtype when cast_forward_inputs is enabled. With the previous default of True, this silently downcast fp32 activations that must stay fp32 — e.g. a qwen2.5-VL model passes its rope cos/sin as an fp32 `position_embeddings` tuple through the decoder layers, which got cast to bf16 and then rejected by the rope CUDA kernel (`cos.scalar_type() == at::kFloat`), crashing pure-DMuon training. AdamW + FSDP2 was unaffected because torch FSDP2's MixedPrecisionPolicy.cast_forward_inputs defaults to False. Flip the default to False everywhere (policy dataclass field, the getattr fallbacks in state/api/diagnostics, and the ddp/fsdp2 backend param defaults), matching FSDP2. Activation casting for mixed-precision compute is then handled by autocast, and callers that genuinely want input casting can still set cast_forward_inputs=True explicitly. 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.
DedicatedState._pre_forward force-casts every floating-point tensor in a wrapped module's forward args/kwargs (recursing into tuple/list/dict) to the group's param_dtype when cast_forward_inputs is enabled. With the previous default of True, this silently downcast fp32 activations that must stay fp32 — e.g. a qwen2.5-VL model passes its rope cos/sin as an fp32
position_embeddingstuple through the decoder layers, which got cast to bf16 and then rejected by the rope CUDA kernel (cos.scalar_type() == at::kFloat), crashing pure-DMuon training. AdamW + FSDP2 was unaffected because torch FSDP2's MixedPrecisionPolicy.cast_forward_inputs defaults to False.Flip the default to False everywhere (policy dataclass field, the getattr fallbacks in state/api/diagnostics, and the ddp/fsdp2 backend param defaults), matching FSDP2. Activation casting for mixed-precision compute is then handled by autocast, and callers that genuinely want input casting can still set cast_forward_inputs=True explicitly.