feat(fast): add opt-in fused D256 SDPA - #8
Open
Gajesh2007 wants to merge 2 commits into
Open
Conversation
This was referenced Aug 17, 2026
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.
Summary
force_fusedcontrol to scaled dot-product attentionhead_dim=256vmap) requests rather than silently falling backBD >= 128This is a bounded-memory control, not an automatic speed route. M4 Max measurements show composed attention remains faster, so the default is unchanged.
Before
After
flowchart LR A[D256 full-attention request] --> B{force_fused?} B -- no --> C[unchanged composed path] B -- yes --> D[validate GPU, dtype, shape, mask] D --> E[FP16/BF16 Steel D256] D -- unsupported --> F[explicit error] G[vmap of forced primitive] --> FCode Flow
flowchart LR subgraph Before A1[fast.scaled_dot_product_attention] --> B1[use_fallback] B1 --> C1[full dims 64/80/128 only] end subgraph After A2[legacy overload or force-aware overload] --> B2[capability validation] B2 --> C2[primitive state includes force_fused] C2 --> D2[normal Steel D256 no-JIT/JIT symbol] C2 --> E2[vmap rejects forced execution] endVerification
Performance Note
The generic fused path reduces attention transient memory but is slower on M4 Max. It remains opt-in so runtimes can make the memory/throughput decision explicitly.