Skip to content

PR #41980: [XLA:GPU] Insert ReshapeDecomposer before LayoutNormalization in AutotunerAndPostCleanup - #117755

Merged
copybara-service[bot] merged 1 commit into
masterfrom
exported_pr_911114333
May 6, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
exported_pr_911114333

Conversation

@copybara-service

Copy link
Copy Markdown

PR #41980: [XLA:GPU] Insert ReshapeDecomposer before LayoutNormalization in AutotunerAndPostCleanup

Imported from GitHub PR openxla/xla#41980

📝 Summary of Changes
Add the missing pipeline.AddPass() before LayoutNormalization in GpuCompiler::AutotunerAndPostCleanup — the third call site introduced by xla 6874dd2 without ReshapeDecomposer, mirroring the inline pattern at the three pre-existing sites. One-line change.

🎯 Justification
#41481 added ReshapeDecomposer ahead of two LayoutNormalization sites to prevent a RET_CHECK when GemmRewriter pins a __cublas$lt$matmul output and a downstream reshape becomes non-bitcast. xla 6874dd23a1 added a third LayoutNormalization site without the precondition and reopened the bug, most visibly on ROCm under multi-process pytest (tests/nn_test.py::testDotProductAttention*, tests/pallas/gpu_paged_attention_test.py).

AutotunerAndPostCleanup is the autotuner's boundary in the main pipeline: FissionBackend::ApplyConfig + InlineFissionedComputation can re-introduce a non-bitcast reshape there when the hipBLASLt candidate wins. Only that LayoutNormalization invocation is downstream of the layout shift, so the cleanup belongs at exactly that one site.

The fix preserves --xla_disable_hlo_passes=reshape-decomposer (no encapsulation) and stays in a single named pipeline (no HLO-dump pollution).

🚀 Kind of Contribution
🐛 Bug Fix

🧪 Execution Test
xla/tools/run_hlo_module on the jit_dot_general HLO from jax.nn.dot_product_attention(impl='xla'), using the cuBLAS-LT-first hack from #817 + XLA_FLAGS=--xla_gpu_autotune_level=0 to deterministically force the failing path on a single MI355X gfx950.
Copybara import of the project:

--
94b1d0cf77c759a40830902af3815b56cfc32019 by Ruturaj4 [email protected]:

[XLA:GPU] Insert ReshapeDecomposer before LayoutNormalization in AutotunerAndPostCleanup

Restores LayoutNormalization::HandleReshape's ShapeUtil::ReshapeIsBitcast
precondition on the GpuCompiler::AutotunerAndPostCleanup path. PR #41481
(commit 788f269) added ReshapeDecomposer before two LayoutNormalization
invocations in xla/service/gpu/gpu_compiler.cc to satisfy that
precondition after GemmRewriter pins __cublas$lt$matmul output layouts
to {n-1,...,1,0}. Commit 6874dd2 ("Move gemm-conv autotuner pass after
fusion passes behind a flag.") introduced a third LayoutNormalization
invocation inside the new AutotunerAndPostCleanup helper without a
matching ReshapeDecomposer, reopening the RET_CHECK whenever the
autotuner fissions __triton_gemm back to __cublas$lt$matmul.

Add the missing ReshapeDecomposer call, mirroring the inline pattern at
the three pre-existing sites. AutotunerAndPostCleanup is the autotuner's
boundary in the main pipeline; FissionBackend::ApplyConfig +
InlineFissionedComputation can re-introduce a non-bitcast reshape there
when the hipBLASLt candidate wins, and only that LayoutNormalization
invocation is downstream of the layout shift. The fix preserves
--xla_disable_hlo_passes=reshape-decomposer (no encapsulation) and stays
in a single named pipeline (no HLO-dump pollution).

Reproduces the original 41481 failure mode on ROCm under multi-process
pytest (tests/nn_test.py::testDotProductAttention*,
tests/pallas/gpu_paged_attention_test.py) once the autotuner picks the
hipBLASLt fission backend. See PR #817's cuBLAS-LT-first patch +
XLA_FLAGS=--xla_gpu_autotune_level=0 for a deterministic single-process
reproducer.

Co-authored-by: magaonka [email protected]

Merging this change closes #41980

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#41980 from ROCm:fix-encapsulate-reshape-decomposer-in-layout-normalization 94b1d0cf77c759a40830902af3815b56cfc32019

…ion in AutotunerAndPostCleanup

Imported from GitHub PR openxla/xla#41980

📝 Summary of Changes
Add the missing pipeline.AddPass<ReshapeDecomposer>() before LayoutNormalization in GpuCompiler::AutotunerAndPostCleanup — the third call site introduced by xla 6874dd2 without ReshapeDecomposer, mirroring the inline pattern at the three pre-existing sites. One-line change.

🎯 Justification
#41481 added ReshapeDecomposer ahead of two LayoutNormalization sites to prevent a RET_CHECK when GemmRewriter pins a __cublas$lt$matmul output and a downstream reshape becomes non-bitcast. xla 6874dd23a1 added a third LayoutNormalization site without the precondition and reopened the bug, most visibly on ROCm under multi-process pytest (tests/nn_test.py::testDotProductAttention*, tests/pallas/gpu_paged_attention_test.py).

AutotunerAndPostCleanup is the autotuner's boundary in the main pipeline: FissionBackend::ApplyConfig + InlineFissionedComputation can re-introduce a non-bitcast reshape there when the hipBLASLt candidate wins. Only that LayoutNormalization invocation is downstream of the layout shift, so the cleanup belongs at exactly that one site.

The fix preserves --xla_disable_hlo_passes=reshape-decomposer (no encapsulation) and stays in a single named pipeline (no HLO-dump pollution).

🚀 Kind of Contribution
🐛 Bug Fix

🧪 Execution Test
xla/tools/run_hlo_module on the jit_dot_general HLO from jax.nn.dot_product_attention(impl='xla'), using the cuBLAS-LT-first hack from #817 + XLA_FLAGS=--xla_gpu_autotune_level=0 to deterministically force the failing path on a single MI355X gfx950.
Copybara import of the project:

--
94b1d0cf77c759a40830902af3815b56cfc32019 by Ruturaj4 <[email protected]>:

[XLA:GPU] Insert ReshapeDecomposer before LayoutNormalization in AutotunerAndPostCleanup

Restores LayoutNormalization::HandleReshape's ShapeUtil::ReshapeIsBitcast
precondition on the GpuCompiler::AutotunerAndPostCleanup path. PR #41481
(commit 788f269) added ReshapeDecomposer before two LayoutNormalization
invocations in xla/service/gpu/gpu_compiler.cc to satisfy that
precondition after GemmRewriter pins __cublas$lt$matmul output layouts
to {n-1,...,1,0}. Commit 6874dd2 ("Move gemm-conv autotuner pass after
fusion passes behind a flag.") introduced a third LayoutNormalization
invocation inside the new AutotunerAndPostCleanup helper without a
matching ReshapeDecomposer, reopening the RET_CHECK whenever the
autotuner fissions __triton_gemm back to __cublas$lt$matmul.

Add the missing ReshapeDecomposer call, mirroring the inline pattern at
the three pre-existing sites. AutotunerAndPostCleanup is the autotuner's
boundary in the main pipeline; FissionBackend::ApplyConfig +
InlineFissionedComputation can re-introduce a non-bitcast reshape there
when the hipBLASLt candidate wins, and only that LayoutNormalization
invocation is downstream of the layout shift. The fix preserves
`--xla_disable_hlo_passes=reshape-decomposer` (no encapsulation) and stays
in a single named pipeline (no HLO-dump pollution).

Reproduces the original 41481 failure mode on ROCm under multi-process
pytest (tests/nn_test.py::testDotProductAttention*,
tests/pallas/gpu_paged_attention_test.py) once the autotuner picks the
hipBLASLt fission backend. See PR #817's cuBLAS-LT-first patch +
`XLA_FLAGS=--xla_gpu_autotune_level=0` for a deterministic single-process
reproducer.

Co-authored-by: magaonka <[email protected]>

Merging this change closes #41980

PiperOrigin-RevId: 911205496
@copybara-service
copybara-service Bot force-pushed the exported_pr_911114333 branch from d1edd2b to c726caf Compare May 6, 2026 09:46
@copybara-service
copybara-service Bot merged commit c726caf into master May 6, 2026
1 check passed
@copybara-service
copybara-service Bot deleted the exported_pr_911114333 branch May 6, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large batch size with dense layers will fail all_reduce occasionally

1 participant