Repository navigation
Fix tf32 for real. - #41481
Merged
Merged
Fix tf32 for real.#41481
Conversation
Contributor
Author
|
Ugh I still fail Linux CPU and MacOS CPU. I tested Windows CPU and Linux GPU and assumed that would be enough. I will take a look tomorrow. |
|
Are the failures related? Might be broken at HEAD. I'll force a rerun. |
|
So just to clarify, you're moving the dependency to if_static, but what if the user accesses the API from open source? What is the expected behavior? |
Contributor
Author
|
The expected behavior is the API is always accessible and there is one copy of the global variable. In the static case, it will directly be linked in. In the dynamic case, it will be linked in libtensorflow_framework but not any pywrap_tensorflow_internal or any other shared libraries. I think I fixed the issue, but we will see :) |
av8ramit
approved these changes
Jul 17, 2020
copybara-service Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…r LayoutNormalization Imported from GitHub PR openxla/xla#41481 📝 Summary of Changes Fix intermittent RET_CHECK in xla/service/layout_normalization.cc:431 fail hit by jax.nn.dot_product_attention(impl='xla') under multi-GPU pytest. Root cause: - When the autotuner picks hipBLASLt over Triton for a dot, GemmRewriter pins the __cublas$lt$matmul output to the canonical layout {n-1, ..., 1, 0}. - Layout assignment had already planned the downstream reshape assuming a non-canonical layout, so after the pin the reshape is no longer a bitcast. - LayoutNormalization then fails its ShapeUtil::ReshapeIsBitcast invariant and aborts. Fix: - Insert a ReshapeDecomposer pass before each post-GemmRewriter LayoutNormalization in gpu_compiler.cc. - Any downstream non-bitcast reshape left behind by the layout pin is decomposed into transpose + bitcast, restoring the ReshapeIsBitcast invariant LayoutNormalization relies on. Without this, many JAX tests fail intermittently with: RET_CHECK failure in external/xla/xla/service/layout_normalization.cc:431 whenever autotuning flips the dot backend to hipBLASLt. 🚀 Kind of Contribution Please remove what does not apply: 🐛 Bug Fix Copybara import of the project: -- 0214ff852a379a2549efcf123193a89e26a501e0 by magaonka <[email protected]>: [XLA:GPU] Insert ReshapeDecomposer before post-GemmRewriter LayoutNormalization Restores the bitcast-only invariant of LayoutNormalization on the cuBLAS-LT custom-call path. After GemmRewriter pins a "__cublas$lt$matmul" output layout to {n-1,...,1,0}, a downstream reshape whose layout was consumer-pulled to a non-canonical permutation is no longer bitcast-compatible. LayoutNormalization::HandleReshape RET_CHECKs on this. Re-decompose any non-bitcast reshape so the precondition holds, mirroring the existing ReshapeDecomposer that already runs before LayoutNormalization at the cuDNN-conv site. Both insertion sites are protected: - After AddGemmRewriterPasses + GemmBroadcastFoldingRewriter (covers dots that GemmFusion declined to wrap in __triton_gemm). - After AddConvAndGemmAutotuningPass + GemmBroadcastFoldingRewriter (covers dots that GemmFusion wrapped, where the autotuner later fissions back to __cublas$lt$matmul). Merging this change closes #41481 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#41481 from magaonka-amd:fix/reshape-decomposer-before-layout-normalization 0214ff852a379a2549efcf123193a89e26a501e0 PiperOrigin-RevId: 904877102
copybara-service Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…r LayoutNormalization Imported from GitHub PR openxla/xla#41481 📝 Summary of Changes Fix intermittent RET_CHECK in xla/service/layout_normalization.cc:431 fail hit by jax.nn.dot_product_attention(impl='xla') under multi-GPU pytest. Root cause: - When the autotuner picks hipBLASLt over Triton for a dot, GemmRewriter pins the __cublas$lt$matmul output to the canonical layout {n-1, ..., 1, 0}. - Layout assignment had already planned the downstream reshape assuming a non-canonical layout, so after the pin the reshape is no longer a bitcast. - LayoutNormalization then fails its ShapeUtil::ReshapeIsBitcast invariant and aborts. Fix: - Insert a ReshapeDecomposer pass before each post-GemmRewriter LayoutNormalization in gpu_compiler.cc. - Any downstream non-bitcast reshape left behind by the layout pin is decomposed into transpose + bitcast, restoring the ReshapeIsBitcast invariant LayoutNormalization relies on. Without this, many JAX tests fail intermittently with: RET_CHECK failure in external/xla/xla/service/layout_normalization.cc:431 whenever autotuning flips the dot backend to hipBLASLt. 🚀 Kind of Contribution Please remove what does not apply: 🐛 Bug Fix Copybara import of the project: -- 0214ff852a379a2549efcf123193a89e26a501e0 by magaonka <[email protected]>: [XLA:GPU] Insert ReshapeDecomposer before post-GemmRewriter LayoutNormalization Restores the bitcast-only invariant of LayoutNormalization on the cuBLAS-LT custom-call path. After GemmRewriter pins a "__cublas$lt$matmul" output layout to {n-1,...,1,0}, a downstream reshape whose layout was consumer-pulled to a non-canonical permutation is no longer bitcast-compatible. LayoutNormalization::HandleReshape RET_CHECKs on this. Re-decompose any non-bitcast reshape so the precondition holds, mirroring the existing ReshapeDecomposer that already runs before LayoutNormalization at the cuDNN-conv site. Both insertion sites are protected: - After AddGemmRewriterPasses + GemmBroadcastFoldingRewriter (covers dots that GemmFusion declined to wrap in __triton_gemm). - After AddConvAndGemmAutotuningPass + GemmBroadcastFoldingRewriter (covers dots that GemmFusion wrapped, where the autotuner later fissions back to __cublas$lt$matmul). Merging this change closes #41481 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#41481 from magaonka-amd:fix/reshape-decomposer-before-layout-normalization 0214ff852a379a2549efcf123193a89e26a501e0 PiperOrigin-RevId: 904877102
copybara-service Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…r LayoutNormalization Imported from GitHub PR openxla/xla#41481 📝 Summary of Changes Fix intermittent RET_CHECK in xla/service/layout_normalization.cc:431 fail hit by jax.nn.dot_product_attention(impl='xla') under multi-GPU pytest. Root cause: - When the autotuner picks hipBLASLt over Triton for a dot, GemmRewriter pins the __cublas$lt$matmul output to the canonical layout {n-1, ..., 1, 0}. - Layout assignment had already planned the downstream reshape assuming a non-canonical layout, so after the pin the reshape is no longer a bitcast. - LayoutNormalization then fails its ShapeUtil::ReshapeIsBitcast invariant and aborts. Fix: - Insert a ReshapeDecomposer pass before each post-GemmRewriter LayoutNormalization in gpu_compiler.cc. - Any downstream non-bitcast reshape left behind by the layout pin is decomposed into transpose + bitcast, restoring the ReshapeIsBitcast invariant LayoutNormalization relies on. Without this, many JAX tests fail intermittently with: RET_CHECK failure in external/xla/xla/service/layout_normalization.cc:431 whenever autotuning flips the dot backend to hipBLASLt. 🚀 Kind of Contribution Please remove what does not apply: 🐛 Bug Fix Copybara import of the project: -- 0214ff852a379a2549efcf123193a89e26a501e0 by magaonka <[email protected]>: [XLA:GPU] Insert ReshapeDecomposer before post-GemmRewriter LayoutNormalization Restores the bitcast-only invariant of LayoutNormalization on the cuBLAS-LT custom-call path. After GemmRewriter pins a "__cublas$lt$matmul" output layout to {n-1,...,1,0}, a downstream reshape whose layout was consumer-pulled to a non-canonical permutation is no longer bitcast-compatible. LayoutNormalization::HandleReshape RET_CHECKs on this. Re-decompose any non-bitcast reshape so the precondition holds, mirroring the existing ReshapeDecomposer that already runs before LayoutNormalization at the cuDNN-conv site. Both insertion sites are protected: - After AddGemmRewriterPasses + GemmBroadcastFoldingRewriter (covers dots that GemmFusion declined to wrap in __triton_gemm). - After AddConvAndGemmAutotuningPass + GemmBroadcastFoldingRewriter (covers dots that GemmFusion wrapped, where the autotuner later fissions back to __cublas$lt$matmul). Merging this change closes #41481 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#41481 from magaonka-amd:fix/reshape-decomposer-before-layout-normalization 0214ff852a379a2549efcf123193a89e26a501e0 PiperOrigin-RevId: 904924797
copybara-service Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…r LayoutNormalization Imported from GitHub PR openxla/xla#41481 📝 Summary of Changes Fix intermittent RET_CHECK in xla/service/layout_normalization.cc:431 fail hit by jax.nn.dot_product_attention(impl='xla') under multi-GPU pytest. Root cause: - When the autotuner picks hipBLASLt over Triton for a dot, GemmRewriter pins the __cublas$lt$matmul output to the canonical layout {n-1, ..., 1, 0}. - Layout assignment had already planned the downstream reshape assuming a non-canonical layout, so after the pin the reshape is no longer a bitcast. - LayoutNormalization then fails its ShapeUtil::ReshapeIsBitcast invariant and aborts. Fix: - Insert a ReshapeDecomposer pass before each post-GemmRewriter LayoutNormalization in gpu_compiler.cc. - Any downstream non-bitcast reshape left behind by the layout pin is decomposed into transpose + bitcast, restoring the ReshapeIsBitcast invariant LayoutNormalization relies on. Without this, many JAX tests fail intermittently with: RET_CHECK failure in external/xla/xla/service/layout_normalization.cc:431 whenever autotuning flips the dot backend to hipBLASLt. 🚀 Kind of Contribution Please remove what does not apply: 🐛 Bug Fix Copybara import of the project: -- 0214ff852a379a2549efcf123193a89e26a501e0 by magaonka <[email protected]>: [XLA:GPU] Insert ReshapeDecomposer before post-GemmRewriter LayoutNormalization Restores the bitcast-only invariant of LayoutNormalization on the cuBLAS-LT custom-call path. After GemmRewriter pins a "__cublas$lt$matmul" output layout to {n-1,...,1,0}, a downstream reshape whose layout was consumer-pulled to a non-canonical permutation is no longer bitcast-compatible. LayoutNormalization::HandleReshape RET_CHECKs on this. Re-decompose any non-bitcast reshape so the precondition holds, mirroring the existing ReshapeDecomposer that already runs before LayoutNormalization at the cuDNN-conv site. Both insertion sites are protected: - After AddGemmRewriterPasses + GemmBroadcastFoldingRewriter (covers dots that GemmFusion declined to wrap in __triton_gemm). - After AddConvAndGemmAutotuningPass + GemmBroadcastFoldingRewriter (covers dots that GemmFusion wrapped, where the autotuner later fissions back to __cublas$lt$matmul). Merging this change closes #41481 PiperOrigin-RevId: 904952544
pull Bot
pushed a commit
to A-Archives-and-Forks/tensorflow
that referenced
this pull request
May 6, 2026
…Normalization 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 tensorflow#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 tensorflow#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 tensorflow#41980 PiperOrigin-RevId: 911205496
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.
I thought I fixed this in #40957, but when I fixed the build error on Windows, I inadvertently caused tf32 to stop working again.