[TMTensor] Add lowering of attention with an explicit scale value#4593
Open
AGindinson wants to merge 1 commit into
Open
[TMTensor] Add lowering of attention with an explicit scale value#4593AGindinson wants to merge 1 commit into
AGindinson wants to merge 1 commit into
Conversation
This allows to pass along the scale constant when set at the Torch level and lifts the restriction on dynamic head dim size. Essentially follows up on commit f53b5be.
ziereis
reviewed
Jun 11, 2026
| if (relativeError > 1e-6) { | ||
| return rewriter.notifyMatchFailure( | ||
| loc, "scale must be None or 1/sqrt(headDim)"); | ||
| double expectedScale = 1.0 / std::sqrt(static_cast<double>(headDim)); |
There was a problem hiding this comment.
do we still need this? for my understanding the limitation before for restricting the scale to 1.0/sqrt(head_dim) is because we could not pass the scale as a parameter to the op and IREE would always implicitly assume its 1.0/sqrt(head_dim) if we can set it as attribute now i assume would not need this limitation anymore?
ziereis
reviewed
Jun 11, 2026
| mlir::FloatAttr scaleAttr{}; | ||
| if (!isa<Torch::NoneType>(scale.getType())) { | ||
| double scaleFloat; | ||
| if (!matchPattern(scale, m_TorchConstantFloat(&scaleFloat))) |
There was a problem hiding this comment.
i guess it would even be nice we could just make the scale a regular input to the op so we don't have to require it to be a constant. However i see how this might be a bit complicated with variadic arg handling the op currently has.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This allows to pass along the scale constant when set at the Torch level and lifts the restriction on dynamic head dim size.
Essentially follows up on commit f53b5be.