Skip to content

[TritonToLinalg](fix) fix zero-stride load boundary - #1509

Draft
zhanwei33 wants to merge 1 commit into
triton-lang:mainfrom
zhanwei33:agent/fix-zero-stride-block-ptr-boundary-only
Draft

[TritonToLinalg](fix) fix zero-stride load boundary#1509
zhanwei33 wants to merge 1 commit into
triton-lang:mainfrom
zhanwei33:agent/fix-zero-stride-block-ptr-boundary-only

Conversation

@zhanwei33

Copy link
Copy Markdown
Contributor

Summary

  • Compute a boundary-checked tile size from the original tt.make_tensor_ptr
    logical shape and offsets when any static stride is zero.
  • Preserve the existing direct structured lowering (strided<[0, ...]> and
    memref.copy) for those loads; this PR does not add a fallback or change
    later TTAdapter/BishengIR stages.
  • Add MLIR coverage for all-zero stride, mixed zero/non-zero stride, negative
    offsets, and the unchanged regular non-zero-stride path.

Root cause

The generic boundary-size helper reconstructs logical coordinates from the
remapped physical pointer. A zero stride removes that physical-coordinate
information, so the reconstruction can reach a 0 / 0 expression and leave a
required OpFoldResult absent. Using the original tensor-pointer shape and
offsets retains the logical coordinates needed for the boundary calculation.

Scope

This is the boundary-only alternative to #1508. It fixes the
triton-to-linalg conversion crash only; it intentionally leaves downstream
acceptance of the resulting zero-stride memref to the existing pipeline. Do
not merge both PRs.

Validation

  • pre-commit run --files third_party/ascend/lib/TritonToLinalg/LoadStoreConverter.cpp third_party/ascend/unittest/Conversion/General/TritonToLinalg/zero_stride_block_ptr_load.mlir

  • cmake --build <isolated-build> --target TritonToLinalg -- -j 16

  • Built a triton-opt driver from this source with the existing TA command-line
    pass registration enabled solely for this check, then ran the new regression:

    triton-opt -allow-unregistered-dialect \
      "--triton-to-linalg=global-kernel=false named-ops=True" \
      --split-input-file \
      third_party/ascend/unittest/Conversion/General/TritonToLinalg/zero_stride_block_ptr_load.mlir \
      | FileCheck \
      third_party/ascend/unittest/Conversion/General/TritonToLinalg/zero_stride_block_ptr_load.mlir

@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 11, 2026
@zhanwei33 zhanwei33 changed the title [TritonToLinalg] Fix zero-stride block pointer load boundary check [TritonToLinalg](fix) fix zero-stride load boundary Aug 11, 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.

1 participant