Repository navigation
Compiled attention test: DoRA downcast under autocast, fp32 model stays fp32 (red since #18099) - #18118
Merged
Conversation
…tocast and keeps an fp32 model fp32 (#18099)
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
tests/test_attention_dispatch_compiled_block.py::test_rerouted_xformers_keeps_the_fp32_downcastfails on main in the CPUrestshard since #18099 (seen on the staging runs of #18075 and #18076):Cause
#18099 made fp32 Q/K/V with autocast off stay fp32 (rerouted to SDPA) instead of being downcast to bf16 for xformers / flash, because that is a genuine fp32 model. The DoRA downcast still applies under autocast, which is how DoRA reaches this code in training. #18099 moved its own DoRA tests under autocast, but this compiled-path test in another file still called the reroute with plain fp32 inputs and no autocast, so it now sees the intended fp32 result.
The behaviour change is correct; the test predates it.
Fix
test_rerouted_xformers_keeps_the_fp32_downcastnow takes the autocast decision (_keeps_fp32_attentionreturns False), so it still checks the DoRA downcast through the compiled reroute. CPU CI cannot enter CUDA autocast, and fakingtorch.is_autocast_enabledtrips dynamo's global autocast guard ("Global autocast state changed while dynamo tracing"), so the decision is patched directly.test_rerouted_xformers_keeps_an_fp32_model_in_fp32covers the other half underfullgraphcompile: without autocast the reroute returns fp32 and matches the fp32 SDPA reference.Verification
test_rerouted_xformers_keeps_the_fp32_downcastfails.tests/test_attention_dispatch_compiled_block.pyandtests/utils/test_attention_dispatch_dora_dtype.py19 passed, 2 skipped._keeps_fp32_attentionforced to False (the pre-Keep attention in fp32 for fp32 models instead of downcasting to bf16 #18099 behaviour), the new fp32 test fails.