Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@htyu Is this for
tt.trans
?In other cases, we don't set the
needTrans
field when creating a sharedLayout.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's for tt.trans like below. When creating a shared encoding, it looks ahead to see if there's a transpose prior to the dot.
qk = tl.dot(q, tl.trans(k), allow_tf32=ALLOW_TF32) * alpha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned that
tl.trans
is a very tricky op.Let me clarify. The 10% improvement is due to the enablement of swizzling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this change speeds up our model that has above trans and dot operation by 10%.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW,
tl.trans
is used quite often in attention kernel of a transformer model, iiuc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc+ @vgokhale @scxiao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, do we need a change related to lines at: https://github.com/htyu/triton/blob/ab3aafb4a9158a60a4c3085a13b605f70488d6ff/include/triton/Dialect/TritonGPU/IR/TritonGPUAttrDefs.td#L166-L167
We have scenario of non-square tile now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no they should be good.
The changes here is only used to enable swizzling for operands of dot.
getMDim and getNDim are shapes of the result of dot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, this is related to mfma layout