Add exclusive self-attention(XSA) output modifier - #202
Open
ishaannk wants to merge 3 commits into
Open
Conversation
drisspg
reviewed
May 5, 2026
| K = self._split_heads(self.W_k(x)) | ||
| V = self._split_heads(self.W_v(x)) | ||
|
|
||
| if HAS_FLEX_ATTENTION and (score_mod is not None or block_mask is not None): |
Contributor
There was a problem hiding this comment.
we can assume flex-attention is always avail
drisspg
reviewed
May 5, 2026
Author
|
Hey @drisspg something still wrong? |
drisspg
reviewed
May 28, 2026
|
|
||
| Q, K, V = make_qkv(T=128) | ||
|
|
||
| if HAS_FLEX: |
Contributor
There was a problem hiding this comment.
same we shoudl be able to assert we have flex
drisspg
reviewed
May 28, 2026
| return Z | ||
|
|
||
|
|
||
| class XSAMultiheadAttention(nn.Module): |
Contributor
There was a problem hiding this comment.
I acutally dont want to be pesrscriptve on nn.Module thi sis fine touse int eh examples but I don think we should ship this by default
…sert HAS_FLEX - Remove XSAMultiheadAttention from attn_gym/mods (not prescriptive on nn.Module) - Move class into examples/xsa_attention.py where it belongs - Add assert HAS_FLEX in example_composable() instead of silent SDPA fallback - Update test import to pull XSAMultiheadAttention from examples
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.
Introduces exclusive_output_mod() - a post-output modifier that removes
the self-value projection from attention output, guaranteeing Z ⊥ V.
This is the first output_mod pattern in attention-gym. Existing score_mods
cannot implement XSA because it operates on the weighted-sum output, not
pre-softmax scores.