page_attn: make global-max reduction order-invariant - #535
Open
taste-software wants to merge 1 commit into
Open
Conversation
taste-software
commented
Jul 12, 2026
The phase-1 decode kernels reduced the per-head global max with a
fcmpxchg-if-first / fmax-else scheme that assumed pGlobalMax was seeded
to 0. That contract was implicit and fragile:
1. Single-tile case (max_seq_len <= 64): only arrival 0 runs, via
fcmpxchg(expected 0). Any seed other than 0 leaves pGlobalMax
untouched, so the max is never written.
2. Even with a 0 seed the reduction is not order-invariant: a later
arrival's fmax(0, neg) = 0 can mask a negative max before arrival
0's fcmpxchg overwrites it, losing the true max whenever the whole
head's max is negative.
Replace it with the mathematically correct reduction: seed pGlobalMax
to FP32_MIN (the identity for max) and have every arrival do an
unconditional atomic fmax. This is order-invariant and seed-explicit;
the arrival counter (pPollP) is now unused in this path but kept so the
buffer layout is unchanged.
Applied to the fp16 (GQA=4, GQA=2) and fp8 (E4M3FN, E5M2) phase-1
kernels, with the matching FP32_MIN seed of the pGlobalMax slice in
page_attn_decode.
Files:
csrc/eagle/page.attn.h fp16 GQA=4/GQA=2 phase-1
csrc/eagle/page.attn.fp8.h fp8 GQA=4/GQA=2 phase-1
csrc/eagle/eagle.sycl seed pGlobalMax slice to FP32_MIN
Author
|
@Wesley-Du i use your kernels for my project and this is a good change I think. |
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.