Conversation
|
Adding some numbers here for M2 Ultra: |
|
Very nice! If I understand correctly it's slightly faster than the baseline for head_dim=128 as opposed to a bit slower. |
| // } | ||
| // } | ||
| // } | ||
| // } |
Yes! Its a few percent faster, and saves memory over the unfused baseline |
|
I tested it on the flux example and the memory savings are super nice 🚀 This is flux-schnell generating 4 images of size 1024x512. No speed regression noticed. Before After @jagrit06 there is a compilation warning for the |
|
Yes let's get rid of that warning. I am fine with allowing c++17 stuff in metal. You pass |
* Share KV smem * Fix bfloat error * Unroll O = S @ V loop * Perf upgrade * Remove commented out function * Add -Wno-c++17-extensions flag to metal flags * Add -Wno-c++17-extensions flag to metal extension flags
…(fixes hd256 garbage) The fused steel attention kernel guards its V-tile load + MMA accumulation with two simdgroup_barrier(mem_none) calls, but only 'if constexpr (BD == 128)'. Those barriers were added by upstream ml-explore#1899 ('Enabling fused attention for head dim 128') as a CORRECTNESS fix for the large-head-dim reuse hazard: a single Vtile fragment is reloaded and MMA'd every (iq,id,ik) iteration, so without the barriers the next load races the prior MMA's read. head_dim=256 was instantiated but never ROUTED to the fused path (old use_fallback forced it unfused), so the barriers were never extended to it. PR ml-explore#3660's routing (key_sequence_length > 16384 -> fused for hd 192/256) finally exercises BD=256, and the missing barriers race -> wrong attention -> multilingual word-salad on long-context prefill. Fix: gate on 'BD >= 128' so 128/192/256 all get the barriers (64/80 keep their working barrier-free path). Adding a simdgroup execution barrier can only remove a race, never introduce one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Proposed changes
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes