Repository navigation
RMSNorm / LayerNorm: do not hash a symbolic width in the launch settings cache - #14727
Conversation
… so dynamic compile traces again
|
@codex review |
Codex Review SummaryThis 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. More of your lovely PRs please. 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". |
# Conflicts: # unsloth/kernels/layernorm.py # unsloth/kernels/rms_layernorm.py
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
#13889 cached
calculate_settingsper width withfunctools.lru_cache, bypassing the cache only whentorch.compiler.is_compiling()is true. Undertorch.compile(dynamic=True)the tracedunsloth::rms_layernormop runs its fake implementation outside Dynamo, whereis_compiling()is False but the width is aSymInt, so the cache tries to hash it:So a compiled RMSNorm with
fullgraph=True, dynamic=Truefails on main, where it traced in one graph before #13889 (d64b080).Fix:
_settingsalso callscalculate_settingsdirectly when the width is not a plainint. Eager calls still hit the cache (the width there is always anint), so the host path is unchanged apart from onetype()check. The same guard goes intolayernorm.py, which got the same cache in #13889.Measured on one B200, torch 2.11.0, Triton 3.6.0, compiled norm with
fullgraph=True, dynamic=True, sequence lengths 64 / 80 / 96 / 127, widths 64 and 4096, fp32 and bf16:Update after syncing with main: #15180 moved
_settingsto a per-(capability, width) num_warps table (norm_num_warps), whosetable.get((capability, n_cols))hashes the width again. On NVIDIA that second lookup kept the same TypeError, sonorm_num_warpsnow matches a symbolic width by equality. Measured on a G4 (sm120): with only the_settingsguard,test_rms_layernorm_dynamic_shapes[4096-*]still fails; with both it passes.tests/test_norm_settings_symbolic_width.py::test_a_symbolic_width_reads_the_cuda_warps_table(CPU, capability patched) covers it and fails without the fix.Tests:
tests/test_norm_settings_symbolic_width.py(CPU): a symbolic width skips the cache and returnscalculate_settings's answer; an int width still uses the cache. The symbolic cases fail on main and pass here.tests/test_rms_rope_compile.py::test_rms_layernorm_dynamic_shapes(GPU): compiledfullgraph=True, dynamic=Trueforward and backward match eager bytes across three lengths, Llama and Gemma variants. Fails on main (4 of 4), passes here.test_rms_rope_compile.py, the multirow, triton_launch and weight-grad norm suites pass on this branch, except the two tiny-Llama fullgraph tests, which fail the same way on main.