Skip to content

[AtomicOp](fix) Extend atomic min/max canonicalization - #1566

Merged
WuTYSFG merged 1 commit into
triton-lang:main-devfrom
CHNJZ:atomic
Aug 14, 2026
Merged

WuTYSFG merged 1 commit into
triton-lang:main-devfrom
CHNJZ:atomic

Conversation

@CHNJZ

@CHNJZ CHNJZ commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Background

PR [#1460](#1460) introduced AtomicMaxMinCanonicalizer to fuse the integer atomic operations expanded from floating-point atomic_min/atomic_max back into a single floating-point atomic operation before discrete-mask conversion.

However, the canonicalizer did not cover the following two IR forms.

Changes

  1. Support scalar floating-point atomic min/max

    Floating-point atomics whose value is produced by a scalar reduction use scalar types instead of TensorType. Their positive sign mask is also represented as:

    %sign = arith.shrui %value_bits, %c31_i32 : i32
    %positive = arith.cmpi eq, %sign, %c0_i32 : i32

    Extend the canonicalizer to:

    • Obtain the element type from both scalar and tensor values.
    • Recognize the scalar cmpi eq 0 sign-mask form.
    • Create an all-true mask for both scalar and shaped atomic operations.
  2. Support pointers represented as splat(bitcast(ptr))

    For tensor atomics constructed from a scalar base pointer, the pointer conversion may be represented as:

    %int_ptr = tt.bitcast %float_ptr : !tt.ptr<f32> -> !tt.ptr<i32>
    %int_ptrs = tt.splat %int_ptr : !tt.ptr<i32> -> tensor<...x!tt.ptr<i32>>

    PR [AtomicOp](fix) Fuse expanded floating-point atomic min/max #1460 only recognized atomics whose pointer was directly defined by tt.bitcast.

    Extend the canonicalizer to recognize both direct bitcast and splat(bitcast(ptr)) forms, rebuild the corresponding floating-point pointer tensor, and remove dead pointer splat/bitcast operations after fusion.

Test

  • Add regression coverage for scalar floating-point atomic_max.
  • Add regression coverage for 4D floating-point atomic_min using a splatted scalar base pointer.

@github-actions github-actions Bot added compiler Changes to C/C++ compiler backend (lib/, include/) python Changes to Python runtime or bindings ascend-backend Changes to the Ascend NPU backend labels Aug 14, 2026
@CHNJZ CHNJZ changed the title [Atomicop](fix)Add unit test for float scalar atomic max kernel using Triton [Atomicop](fix)AtomicOp Extend floating-point atomic min/max canonicalization Aug 14, 2026
@CHNJZ CHNJZ changed the title [Atomicop](fix)AtomicOp Extend floating-point atomic min/max canonicalization [Atomicop](fix)Extend floating-point atomic min/max canonicalization Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Commits

Identity Commits
chnjz233 <ji…@huawei.com> 1 (signed off)

@CHNJZ CHNJZ changed the title [Atomicop](fix)Extend floating-point atomic min/max canonicalization [AtomicOp](fix)Extend atomic min/max canonicalization Aug 14, 2026
@CHNJZ CHNJZ changed the title [AtomicOp](fix)Extend atomic min/max canonicalization [AtomicOp](fix) Extend atomic min/max canonicalization Aug 14, 2026
@CHNJZ

CHNJZ commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

/retry

@CHNJZ
CHNJZ force-pushed the atomic branch 3 times, most recently from e580e2b to defef8a Compare August 14, 2026 07:23
Signed-off-by: chnjz233 <jiangzheng26@huawei.com>
@WuTYSFG
WuTYSFG merged commit 5f20519 into triton-lang:main-dev Aug 14, 2026
14 checks passed
HinPeng pushed a commit that referenced this pull request Aug 15, 2026
xuedinge233 pushed a commit to xuedinge233/triton-ascend that referenced this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ascend-backend Changes to the Ascend NPU backend compiler Changes to C/C++ compiler backend (lib/, include/) python Changes to Python runtime or bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants