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

[BACKEND] Fix crash in coalesce pass with blocked ptr #3866

Merged
merged 6 commits into from
May 15, 2024

Conversation

etiotto
Copy link
Contributor

@etiotto etiotto commented May 9, 2024

The setCoalescedEncoding function can handle operations that have a 'mem access ptr' with type RankedTensorType:

  void
  setCoalescedEncoding(ModuleAxisInfoAnalysis &axisInfoAnalysis, Operation *op,
                       int numWarps, int threadsPerWarp,
                       llvm::MapVector<Operation *, Attribute> &layoutMap) {
    Value ptr = getMemAccessPtr(op);
    auto refTensorType = cast<RankedTensorType>(ptr.getType());

Therefore the caller in runOnOperation should avoid calling it when the 'mem access ptr' does not have RankedTensorType (otherwise the cast in the callee will fail).

@jlebar
Copy link
Contributor

jlebar commented May 9, 2024

Is it possible to write a test?

@etiotto
Copy link
Contributor Author

etiotto commented May 10, 2024

Is it possible to write a test?

@jlebar I have added a lit test in coalesce.mlir

Comment on lines 124 to 130
#mma = #triton_gpu.nvidia_mma<{warpsPerCTA = [8, 1], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0], instrShape = [16, 256, 16]}>

// CHECK-LABEL: @fwd_kernel
module attributes {"triton_gpu.num-warps" = 4 : i32, "triton_gpu.threads-per-warp" = 16 : i32} {
tt.func public @fwd_kernel(%arg0: !tt.ptr<f16> , %arg1: !tt.ptr<f16> , %arg2: !tt.ptr<f16> , %arg3: f32, %arg4: !tt.ptr<f32> , %arg5: !tt.ptr<f16> , %arg6: i32 , %arg7: i32 , %arg8: i32 , %arg9: i32 , %arg10: i32 , %arg11: i32 , %arg12: i32 , %arg13: i32 , %arg14: i32 , %arg15: i32 , %arg16: i32 , %arg17: i32 , %arg18: i32, %arg19: i32, %arg20: i32 , %arg21: i32) {
%cst = arith.constant dense<0.000000e+00> : tensor<128x16xf32, #mma>
%cst_0 = arith.constant dense<0.000000e+00> : tensor<128xf32, #triton_gpu.slice<{dim = 1, parent = #mma}>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you minimize the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was reduced (minimized) from a much larger test. I might be able to reduce it a bit more (remove some arguments). Let me try.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was reduced (minimized) from a much larger test.

If we accept patches with large testcases like this, our codebase quickly becomes difficult to maintain. Indeed I've lost many days dealing with failures in tests like this.

You may need to write a testcase by hand. Coming up with clear, small testcases is a critical part of contributing to Triton.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Now the test contains just a couple of operations.

@ThomasRaoux ThomasRaoux enabled auto-merge (squash) May 15, 2024 17:35
@ThomasRaoux ThomasRaoux disabled auto-merge May 15, 2024 17:44
@ThomasRaoux ThomasRaoux changed the title Fix CoalescePass [BACKEND] Fix crash in coalesce pass with blocked ptr May 15, 2024
@ThomasRaoux ThomasRaoux merged commit 25b4212 into triton-lang:main May 15, 2024
5 checks passed
@etiotto etiotto deleted the fix_coalesce branch May 16, 2024 13:06
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.

None yet

3 participants