Skip to content

[FIX] resolve error in SDPA implementation#9

Open
student-Jungmin wants to merge 1 commit intoPSAL-POSTECH:torchsimfrom
student-Jungmin:fix/sdpa-implementation-error
Open

[FIX] resolve error in SDPA implementation#9
student-Jungmin wants to merge 1 commit intoPSAL-POSTECH:torchsimfrom
student-Jungmin:fix/sdpa-implementation-error

Conversation

@student-Jungmin
Copy link

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.

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.

1 participant