[AMD] Guard degenerate axis info in atomic RMW lowering - #993
Open
WhatGhost wants to merge 1 commit into
Open
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
WhatGhost
requested review from
Galaxy1458,
menchunlei,
sunnycase and
zhzhcookie
as code owners
August 14, 2026 10:02
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.
Problem
Any tensor-indexed atomic on a shared-memory pointer crashes the compiler on the AMD backend with a segfault, e.g.
Root cause
mentioned in #972
AtomicRMWOpConversiondereferences the axis-info entry of its pointer operand and indexes the contiguity vector without checking either:tle.local_pointershas noAxisInfoVisitor, so its result carries a degenerate rank-0 entry and the indexing walks off an empty vector. The value is only used to refineenableIntraWaveReduce, which is restricted to CDNA3/CDNA4, so on RDNA the crash happens while computing something that is never used.Fix
Check the entry before using it and fall back to disabling intra-wave reduce
when the contiguity is unavailable.
Validation
Compiler behaviour, same input IR, only this patch differing:
tle_local_pointers_to_llvm.mlir(new case)Segmentation fault(exit 139)PASStt.atomic_rmwontle.local_pointers, checking it lowers tollvm.atomicrmw fadd ... : !llvm.ptr<3>.Conversion/amd: 33/35 pass; the two failures (async_ops_to_llvm_gfx1250,cluster_load) are pre-existing CHECK mismatches unrelated to this path.tritongpu_to_llvm.mlirforarch=gfx942andarch=gfx950is byte-identical before and after (matching md5), so the intra-wave reduce decision is untouched wherever axis info is well-formed.test_core.py -k atomicon gfx1201: 832 passed, 132 skipped, 0 failed.ds_add_f32, so the atomics are real and not lost updates.