Skip to content

[CuTeDSL] local_tile: apply a flat projection while tracing (fixes abort with cute_ext.copy) - #3959

Open
yunweili3 wants to merge 1 commit into
NVIDIA:mainfrom
yunweili3:fix-3957-local-tile-proj
Open

yunweili3 wants to merge 1 commit into
NVIDIA:mainfrom
yunweili3:fix-3957-local-tile-proj

Conversation

@yunweili3

Copy link
Copy Markdown
Contributor

Fixes #3957.

Problem

On a rank-2 tensor, cute.local_tile with a projection that drops a mode, followed by cute_ext.copy from or to the tile, aborts the process during compilation (pm.run), with no diagnostic:

gA = cute.local_tile(mA, (128, 64, 1), (cta_m, cta_n, None), proj=(1, 1, None))
cute_ext.copy(cute_ext.partition(gA, tid, layout_tv=tv, tiler=tl), buf, copy_atom=atom)

Reproduced on a B200 with nvidia-cutlass-dsl 4.9.0.dev1 using the script from the issue. What I found while narrowing it down:

  • The IR before the passes differs from the working cute.local_tile(mA, (128, 64), (cta_m, cta_n)) only in the cute.local_tile op: tile [128:1;64:1;1:0], coord (?,?,_) and proj = "(1,1,_)" instead of the two-mode tile and coord. The printed tile layout is the same, (128,64):(1,128).
  • It needs a projection that really drops a mode: (1, 1, None) and (1, None, 1) abort, proj=(1, 1) compiles. Static or dynamic coord and a 1x1 or larger grid make no difference.
  • It needs cute_ext.copy: cute_ext.partition alone, or indexed loads and stores on the tile, compile.
  • Rank-3 inputs with the same projection (coord (m, n, None, l)) compile.

The abort itself is inside the compiler passes, which I cannot see, so this PR does not fix it there.

Change

local_tile now applies a flat projection itself: it drops the projected modes from the tiler and from the coord (modes of the coord past the projection are kept) and emits the op without proj. This selects the same tile, and the emitted IR is the form that already works. Tilers or coords that are not plain tuples of the projection's rank still pass proj to the op as before.

If you would rather fix this in the pass and keep proj on the op, the test below may still be useful.

Tests

New test/python/CuTeDSL/test_local_tile_proj_copy.py: copies a (256, 128) tensor tile by tile through cute_ext.copy, for rank 2 and 3, with no projection, an identity projection, and projections dropping the last and the middle mode. Each case runs in a subprocess, since the regression kills the process.

  • Before the change: the two rank-2 cases with a dropped mode fail (abort), the other 6 pass.
  • After the change: all 8 pass, and the four commands from the issue all print PASS.
  • GEMM-style projections on 3-mode tensors ((1, None, 1), (None, 1, 1), (1, 1, None) with coord (m, n, None, l), as in the dense GEMM examples) address the same elements before and after the change.

cute.local_tile(t, (128, 64, 1), (m, n, None), proj=(1, 1, None)) on a
rank-2 tensor, followed by cute_ext.copy from or to the tile, aborted the
process during compilation without a diagnostic (NVIDIA#3957).

For a flat proj over a tuple tiler and coord, drop the projected modes
from the tiler and the coord in Python and emit the op without proj. It
selects the same tile. Other forms of tiler/coord still pass proj to the
op.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [CuTeDSL] SIGABRT compiling a cute_ext copy kernel with rank-2 inputs and local_tile(..., proj=...)

1 participant