Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions h3_shaders.metal
Original file line number Diff line number Diff line change
Expand Up @@ -4003,6 +4003,10 @@ kernel void h3_gqa_causal_bf16(
threadgroup_barrier(mem_flags::mem_threadgroup);
}
float maximum = reductions[0];
/* WAR hazard: reductions[] is reused for the sum reduction. Without
* this barrier one thread can overwrite reductions[0] before another
* has read the max (antirez/h3.c#52). */
threadgroup_barrier(mem_flags::mem_threadgroup);
float local_sum = 0.0f;
for (uint key_row = tid; key_row < key_count; key_row += threads) {
float probability = exp(scores[key_row] - maximum);
Expand Down