Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRITON-BP]: Lack of support for ExpandDimOp #3221

Open
etiotto opened this issue Jan 21, 2025 · 1 comment
Open

[TRITON-BP]: Lack of support for ExpandDimOp #3221

etiotto opened this issue Jan 21, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@etiotto
Copy link
Contributor

etiotto commented Jan 21, 2025

Failing test:

/home/jovyan/intel-xpu-backend-for-triton/test/Triton/Intel/RaiseToBlockPointers/addptr_for_expand_ptr.mlir:21:13: remark: TritonRaiseToBlockPointer: ExpandDims Ops in loops are currently not supported
    %_ptr = scf.for %i = %c0 to %c12 step %c3 iter_args(%ptr = %2) -> (tensor<256x!tt.ptr<bf16>>) {
@etiotto etiotto self-assigned this Jan 21, 2025
@etiotto etiotto changed the title [TRITON-BP]: Lack support for ExpandDimOp [TRITON-BP]: Lack of support for ExpandDimOp Jan 21, 2025
@vlad-penkin vlad-penkin added the enhancement New feature or request label Jan 27, 2025
@etiotto
Copy link
Contributor Author

etiotto commented Jan 29, 2025

This happens when tt.expand_dims is in the body of an scf.for loop and references a block ptr passed into the loop as a init_arg.
For example:

    %6 = tt.make_tensor_ptr %arg0, [%c0_i64], [%c1_i64], [%c1024_i32] {order = array<i32>} : <tensor<256xbf16>>
    %7 = scf.for %arg1 = %c0 to %c12 step %c3 iter_args(%arg2 = %6) -> (!tt.ptr<tensor<256xbf16>>) {
      %8 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32>
      %9 = tt.expand_dims %8 {axis = 1 : i32} : tensor<256xi32> -> tensor<256x1xi32>
      %10 = tt.broadcast %9 : tensor<256x1xi32> -> tensor<256x256xi32>
      %11 = tt.make_range {end = 512 : i32, start = 256 : i32} : tensor<256xi32>
      %12 = tt.expand_dims %11 {axis = 0 : i32} : tensor<256xi32> -> tensor<1x256xi32>
      %13 = tt.broadcast %12 : tensor<1x256xi32> -> tensor<256x256xi32>
      %14 = arith.addi %10, %13 : tensor<256x256xi32>

     %x = tt.expand_dims %ptr {axis = 1 : i32} : tensor<256x!tt.ptr<bf16>> -> tensor<256x1x!tt.ptr<bf16>>

      %15 = tt.splat %c3_i32 : i32 -> tensor<256xi32>
      %16 = tt.advance %arg2, [%c3_i32] : <tensor<256xbf16>>
      scf.yield %16 : !tt.ptr<tensor<256xbf16>>
    }

Here %arg2 is a block ptr. The expand_dims operation yielding %x references it. We do not know how to rewrite that operation given that its argument %ptr is incremented at each loop iteration.

I think this pattern doesn't happen too often. So for now we can keep this a limitation. That is, when the scf.for loop contains an operation that references a rewritten ptr, but that operation cannot accepts a block ptr as its operand. We give up transforming the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants