[FIX] resolve error in SDPA implementation#9
Open
student-Jungmin wants to merge 1 commit intoPSAL-POSTECH:torchsimfrom
Open
[FIX] resolve error in SDPA implementation#9student-Jungmin wants to merge 1 commit intoPSAL-POSTECH:torchsimfrom
student-Jungmin wants to merge 1 commit intoPSAL-POSTECH:torchsimfrom
Conversation
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 PR introduces two modifications to support Scaled Dot-Product Attention (SDPA) implementation.
First, I have updated the logic regarding memory movement constraints.
In the original implementation, all matmul operands were strictly required to undergo an "MVIN" operation.
However, for SDPA execution, it is necessary to allow buffers already residing in SRAM to serve as direct matmul operands. To address this, I modified the code to support SRAM-only buffers by allowing the system to bypass the mandatory initialization and move-in process when appropriate.
Second, I have addressed an architectural mismatch in the kernel operand mapping.
The original code assumed a fixed three-operand structure consisting of A(0), B(1), and Bias(2).
In the context of SDPA, the kernel processes Q(0), K(1), and V(2).
Under the previous assumption, the 'V' operand was incorrectly treated as a 'Bias' rather than a primary matmul operand. To resolve this, I added a new attribute to linalg.matmul that enables operand index reordering.
I also implemented the necessary logic to catch this attribute, ensuring that 'V' is correctly recognized and processed as a standard matmul operand instead of being misinterpreted as a bias.