Skip to content

Conversation

@christopherpriebe
Copy link
Contributor

Refactored kWidth assignment for DotOp out of the primary rewrite rules into a separate rewrite rule.

// CHECK-LABEL: mfma_chain_dot_kWidth_bf16
// CHECK-GFX950: tt.dot {{.*}} : {{.*}} -> tensor<128x128xf32, #mma>
// CHECK-GFX950: tt.dot {{.*}} : tensor<128x128xbf16, #ttg.dot_op<{opIdx = 0, parent = #mma, kWidth = 4}>> * tensor<128x128xbf16, #ttg.dot_op<{opIdx = 1, parent = #mma, kWidth = 4}>> -> {{.*}}
// CHECK-GFX950: tt.dot {{.*}} : tensor<128x128xbf16, #ttg.dot_op<{opIdx = 0, parent = #mma, kWidth = 8}>> * tensor<128x128xbf16, #ttg.dot_op<{opIdx = 1, parent = #mma, kWidth = 8}>> -> {{.*}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change intentional? The refactoring should not change the test case,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is related to a request from a customer for kWidth=8 for chained dot.

newBType = RankedTensorType::get(newBType.getShape(), newBType.getElementType(), newBEnc);

Value newA = ttg::ConvertLayoutOp::create(rewriter, loc, newAType, dotOp.getA());
Value newB = ttg::ConvertLayoutOp::create(rewriter, loc, newBType, dotOp.getB());
Copy link
Contributor

@yiqian1 yiqian1 Nov 21, 2025

Choose a reason for hiding this comment

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

This works when the original convertlayoutOp is right before the dotOp. A more general way is to go backward and find the corresponding convertLayoutOp (skip other ops in between) and either replace it with a new one or add a new one after it. If you add a new converLayoutOp, I think removeConverLayout can combine two adjacent convertLayoutOp into one. If there're other ops in between, I doubt removeConvertLayout can combine them. Then, you'll still have a convertLayoutOp with am undesired kWidth.

return 4;
else if (!tail)
return kBase * kPack;
return kBase;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to return the original kWidth here.

@zhanglx13 zhanglx13 marked this pull request as draft December 1, 2025 17:56
@christopherpriebe christopherpriebe marked this pull request as ready for review December 1, 2025 20:44
@zhanglx13 zhanglx13 marked this pull request as draft December 1, 2025 21:12
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.

2 participants