[GPU] Fix TritonEmitterTest.ScaledDotIsSupportedByReferencePlatform#936
[GPU] Fix TritonEmitterTest.ScaledDotIsSupportedByReferencePlatform#936mmakevic-amd wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses correctness issues for GPU Triton lowering of scaled-dot when operands are BF16 (notably fixing TritonEmitterTest.ScaledDotIsSupportedByReferencePlatform) by avoiding emission of tt.dot_scaled without valid scales, and aligns autotuner backend disabling behavior when binary libraries are turned off.
Changes:
- Disable
CUBLASLT_FISSIONautotuning backend whenxla_gpu_experimental_disable_binary_librariesis enabled. - Add a BF16-specific
scaled-dotlowering path that applies scales via broadcast/reshape + multiply and then emits a plainstablehlo.dot_general(+ add) instead ofxtile::DotScaledOp.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| xla/service/gpu/autotuning/autotuner_pass.cc | Disables CUBLASLT_FISSION when binary libraries are disabled to prevent unintended backend selection. |
| xla/codegen/xtile/codegen/dot_algorithms.cc | Introduces BF16 scaled-dot handling by dequantizing via explicit mul with broadcast scales and emitting stablehlo.dot_general. |
| if (lhs_dot_elem_type == b.getBF16Type() || | ||
| rhs_dot_elem_type == b.getBF16Type()) { |
There was a problem hiding this comment.
Nit: The || means a mixed F8+BF16 scenario would take this dequantize path for both operands, even though only the BF16 side truly needs it (F8 is supported by tt.dot_scaled). In the reference ScaledDotRewriter, BF16 operands get dequantized individually while F8 operands can still go through the scaled-dot path. This is fine for the current BF16+BF16 test case, but worth keeping in mind if mixed-precision scaled dots become supported.
There was a problem hiding this comment.
Same as above; fixed
| disabled_autotune_backends.push_back(autotuner::Backend::HIPBLASLT); | ||
| disabled_autotune_backends.push_back(autotuner::Backend::MIOPEN); | ||
| disabled_autotune_backends.push_back(autotuner::Backend::HIPBLASLT_FISSION); | ||
| disabled_autotune_backends.push_back(autotuner::Backend::CUBLASLT_FISSION); |
There was a problem hiding this comment.
LGTM. CUBLASLT_FISSION was clearly missing from this list alongside the existing CUBLASLT, CUDNN, HIPBLASLT, MIOPEN, and HIPBLASLT_FISSION entries.
Review SummaryThe approach is sound: BF16 operands can't go through Main concern: The new Overall this looks good for the BF16+BF16 case it targets. The inline comments flag edge cases worth hardening for future-proofing. |
|
I guess your changes are upon this commit openxla@28f3032 ? |
Yes these changes are old and already present on this branch |
All done. I enabled some other subtests for ROCm - I will split that in a separate PR for upstream, but let me know if I should do the same here |
Super! please put into separate PR for upstream. |
|
Hi @zoranjovanovic-ns could you please take a look at this before I open a PR to the upstream? |
Motivation
This PR fixes
TritonEmitterTest.ScaledDotIsSupportedByReferencePlatformsubtest from//xla/backends/gpu/codegen/triton/tests:fusion_emitter_device_test.Test started falling on ROCm after openxla@80931bb enforced Triton backend via:
Until this point, the subtest was using hipblaslt instead of Triton. The only reason it was still passing on CUDA side was that
CUBLASLT_FISSIONwas not added to the list of disabled backends. After changing that subtest consistently failed with mismatch errors on both platforms.Failing log:
Technical Details
XLA does not set scales for BF16 type https://github.com/openxla/xla/blob/111f921748b0643e70693b6b2a53a0d76b2af37a/xla/codegen/xtile/codegen/dot_algorithms.cc#L78-L120:
and it also skips ScaledDotRewriter for Triton https://github.com/openxla/xla/blob/111f921748b0643e70693b6b2a53a0d76b2af37a/xla/service/gpu/gpu_compiler.cc#L704-L706:
So it emits a
dot_scaledwith no scales, which explains the accuracy issues. This PR modifiesScaledDotfunction so that for bf16 it converts scale to operand type, broadcasts + reshapes it to operand shape, multiplies, then emits a plainstablehlo.dot_generalviaEmitStableHloDotAndAdd. This follows the logic fromScaledDotRewriter::RewriteComputation(https://github.com/openxla/xla/blob/9e1e4f3a8d7db8c626cd4079058353ce87d4f941/xla/backends/gpu/transforms/scaled_dot_rewriter.cc#L166-L192)Test Result
Problematic test now passes. After inspecting Triton dumps confirmed that instead of
tt.dot_scaled, it now emitstt.dot.Submission Checklist