Repository navigation
CUDA: fix misaligned synchronization in FA - #13469
Merged
JohannesGaessler merged 1 commit intoMay 12, 2025
Merged
Conversation
This was referenced May 12, 2025
CISC
approved these changes
May 12, 2025
Nexesenex
added a commit
to Nexesenex/croco.cpp
that referenced
this pull request
May 14, 2025
This reverts commit 95e1888.
Nexesenex
added a commit
to Nexesenex/croco.cpp
that referenced
this pull request
May 25, 2025
This reverts commit 4721a56.
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
fukuro-kun
pushed a commit
to fukuro-kun/fukuro-llama-cpp-turboquant
that referenced
this pull request
Jul 5, 2026
zommiommy
pushed a commit
to zommiommy/llama.cpp
that referenced
this pull request
Aug 18, 2026
crusaderky
added a commit
to crusaderky/llama.cpp
that referenced
this pull request
Sep 18, 2026
Port of upstream ggml-org/llama.cpp ggml-org#27870 (b74f590, PR by Siavash Norouzi), adapted to keep the beellama 0xFFFFFFFFULL shuffle masks and the KVarN dst_final_meta whole-tile publishing block. The old shape (kept since ggml-org#13469) put the meta-combine __syncthreads() inside 'if (np > 1 && threadIdx.y % np == 0)' with a separate 'else if (np > 1) __syncthreads()'. The paired barriers are formally divergent per the CUDA spec, and in practice the if-branch's post-barrier meta write-back races with the other warps re-entering the tile_Q reuse loop, which corrupts attention output data- and timing-dependently. This is the root cause of the catastrophic per-chunk KLD/PPL blowups seen on K2-Horizon-7B (GQA ratio 4, head dim 128 -> np = 4) with f16/bf16 KV caches and any exact tail: f16/f16, kvarn4 (intrinsic f16 tail) and bf16-tail runs collapse on whole chunks (chunk-9 PPL 5.11 -> 10.68 on Q5_K_M|f16) while quantized-body runs without a tail stay clean because they dispatch to fattn-vec. CPU runs of the same chunks/configs are clean, isolating the fault to this CUDA kernel. Restructure per upstream: all threads enter 'if (np > 1)', the combine reads run under 'threadIdx.y % np == 0', the __syncthreads() is unconditional, and the write-back runs after it under the same guard.
frostyautumnleaf
pushed a commit
to frostyautumnleaf/llama.cpp
that referenced
this pull request
Oct 5, 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.
See discussion following #13430 (comment) .
I added a
__syncthreadsinstruction in #13438 to fix a race condition. However, this instruction is for some kernel configuration only executed for part of the warps so the points at which warps wait for each other become misaligned. On a sufficiently long context this then causes incorrect results.