Repository navigation
Studio ROCm: Windows wide-head SDPA guard and TunableOp tune hooks compile without a graph break - #18122
Merged
Conversation
#17976 moved Studio's guard to a lock-held flag pin, which Dynamo cannot trace (Unsupported context manager under fullgraph=True). Studio installs its guard before unsloth's, and unsloth's fix sees the shared marker and keeps Studio's wrapper, so a compiled Gemma 4 global layer on Windows ROCm hit the lock. The pin now runs in an allow_in_graph helper keyed by a string token, as in unsloth.import_fixes. The new test compiles the real Studio wrapper with fullgraph=True and fails on main.
… is missing Inductor's CPU backend needs cl on Windows; gfx1151 Windows runners have none, so the inductor parametrization failed there for a toolchain reason. The aot_eager case still checks the guard traces.
UNSLOTH_DIFFUSION_ROCM_TUNABLEOP=tune installs forward hooks on the denoiser root. The max tier compiles an SDXL U-Net whole (Module.compile, fullgraph), which traces those hooks; their RLock and process-global tuning switch raise Unsupported context manager at the first forward, and the whole-module U-Net compile has no eager fallback guard. The hooks now return early while compiling, so a compiled call only reads the table and tuning stays with eager calls.
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. Hooray! 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 was referenced Nov 17, 2026
danielhanchen
added a commit
that referenced
this pull request
Nov 17, 2026
…17659) (#18125) `tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding` fails on main in the CPU `rest-2` shard since #17659 (seen on the staging run of #18122): ``` E AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding, ... E + 'tests/studio/test_keep_awake_initialization.py:10: read_text()' ``` ## Cause `tests/studio/test_keep_awake_initialization.py` (added in #17659) reads `studio/src-tauri/src/keep_awake.rs` with `read_text()`. Without an encoding that uses the locale codepage on Windows (cp1252, cp932, ...), so the test breaks there as soon as the Rust file gains a non-ASCII byte. The lint is right; the new test missed it. ## Fix `read_text(encoding = "utf-8")`. ## Verification - main: the lint fails with the line above. - this branch: `tests/test_source_read_encoding.py` 16 passed.
danielhanchen
added a commit
that referenced
this pull request
Nov 17, 2026
… of a 1e-6 atol (intermittent m-r failure) (#18153) `studio/backend/tests/test_rocm_windows_wide_head_sdpa.py::test_guarded_wide_head_compiles_fullgraph[inductor]` (added in #18122) fails intermittently in the Studio `m-r` shard on unrelated PRs (seen on the staging run of #18075): ``` tests/test_rocm_windows_wide_head_sdpa.py:154: in test_guarded_wide_head_compiles_fullgraph assert torch.allclose(got, want, atol = 1e-6) E assert False ``` ## Cause The test compares the guarded SDPA call in eager (math backend) with the same call compiled `fullgraph` by Inductor. Inductor lowers the math SDPA to its own CPU kernel, so the two agree to fp32 rounding, not bit for bit. On this host the gap on a 512-wide head is already up to 8.3e-7 (seeds 0 to 3), right at the fixed `atol = 1e-6`, and the inputs were unseeded, so a draw on a different CPU (CI runners vary) can land just over it. The guard is fine; the bound was too tight for two different kernels. ## Fix - Seeded inputs (`torch.Generator().manual_seed(0)`), so a failure is reproducible. - `torch.testing.assert_close(got, want)` with the fp32 defaults (atol 1e-5, rtol 1.3e-6) and a comment saying why it is not bitwise. ## Verification - `tests/test_rocm_windows_wide_head_sdpa.py`: 11 passed, twice. - Sabotage: comparing against a non-causal eager result makes both `compiles_fullgraph` cases fail, so the check still catches a wrong answer.
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.
Both changes remove a Python lock from code that a whole-model
torch.compiletraces. On main each one makes a fullgraph compile fail withUnsupported context manager, and a default compile drop the call to eager.studio/backend/core/_rocm_windows_sdpa.pypins the math backend under athreading.Lock. Studio installs its guard before unsloth's, and unsloth's compile-safe guard (unsloth/import_fixes.py,_sdpa_math_onlyunderallow_in_graph) sees the shared marker and keeps Studio's wrapper, so a compiled Gemma 4 global layer (head dim 512) on Windows ROCm reaches the lock. The pin now runs in anallow_in_graphhelper keyed by a string token, as inunsloth.import_fixes.UNSLOTH_DIFFUSION_ROCM_TUNABLEOP=tune, forward hooks on the denoiser root hold anRLockand flip the process-wide tuning switch. The max tier compiles an SDXL U-Net whole (Module.compile, fullgraph), which traces those hooks and fails at the first forward, with no eager fallback. The hooks now return early undertorch.compiler.is_compiling(), so compiled calls only read the tuning table and tuning stays with eager calls.GPU results on gfx1151 (Radeon 8060S), base (main 62d66cb) vs this branch, same job and runner per fix
fullgraph=Truewith eager / aot_eager / inductorUnsupported context manager ... lockfullgraph=Truewith eager / aot_eager / inductorUnsupported context manager ... RLockfullgraph=FalseTests
studio/backend/tests/test_rocm_windows_wide_head_sdpa.py:test_guarded_wide_head_compiles_fullgraph[aot_eager|inductor]compiles the real Studio wrapper withfullgraph=True; fails on main. The inductor case skips on Windows when MSVC (cl) is not on PATH, since Inductor's CPU backend needs it.studio/backend/tests/test_diffusion_rocm_tunableop.py: new compile test; fails on main.Compiler: cl is not found(the skip above was added after that run); Linux TunableOp suite base 19 passed, this branch 20 passed.Not covered