Repository navigation
[FlyDSL] [Bugfix] Fix PA decode scaling and merge alignment - #7147
Merged
zhiding512 merged 2 commits intoOct 30, 2026
Conversation
Signed-off-by: fsx950223 <[email protected]>
Keep the merge-alignment changes, but restore the fused exponent of unmasked per-token FP8 pages, which folds the query scale and log2(vnorm) into one FMA. Splitting it added two VALU operations per score: the unmasked page loop traded 32 v_pk_fma_f32 for 32 v_pk_mul_f32 and 64 v_pk_add_f32. Finite inputs with large per-token K scales or logits can again overflow or lose the V normalization. FP8 dense verify on gfx1250 (H16/KV1/D128, page 128, three requests with four causal queries, eight partitions), median of ten alternating rounds: context 007cc39 8f7fc89 this commit 8K 11.053 us 11.716 us (+6.0%) 11.046 us (-0.1%) 32K 31.763 us 34.623 us (+9.0%) 31.761 us (0.0%) The merge-alignment changes leave this shape's FP8 and BF16 tile-kernel ISA unchanged. Co-authored-by: Cursor <[email protected]>
zhiding512
approved these changes
Oct 30, 2026
4 of 10 tasks
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
Finite FP8 inputs can produce NaNs or lose V normalization in #7079's gfx1250 per-wave path when per-token K scales or logits are large. Offset scratch can also select a last-arriver merge with misaligned 64-bit atomics, while the cluster merge declares vector alignment that offset scratch and odd output strides do not guarantee.
This follow-up targets
zhiding512/gfx1250-pa-merge-partitions, the branch behind #7079. Merging it updates that PR.Changes
log2(vnorm)to the exponent.test_pa_decode_planandtest_pa_decode_graph_plan_refreshfunctions.Performance
These are correctness fixes. A fixed eight-partition FP8 dense-verify measurement (H16/KV1/D128, page128, three requests with four causal queries each) shows their cost relative to the original #7079 head
007cc391b:Separately, the fixed #7079 branch remains 1.27× faster geometrically across 28 dense decode/verify, sparse decode/verify/prefill and ATOM-plan workloads than latest main
269675dead7aa919c9c5eae09cb42e83a35c6567(BF16 1.29×, FP8 1.26×). That comparison measures the whole #7079 branch plus these fixes. The one-partition ATOM prefill path is effectively unchanged.Measurements used gfx1250 (256 CUs), physical GPU 1, PyTorch 2.11 ROCm 10.1, HIP 7.16 and FlyDSL 0.4.1, with GPU jobs serialized. The latest-main comparison uses identical seeded inputs and plans, five ten-call CUDA graphs with five timed replays each, and the median of three alternating rounds. Timings include decode and reduction, excluding planning, compilation and allocations. Three short dense decode cases had round spans above 10%; their exact ratios are less stable. Bandwidth and roofline counters were not collected.
Testing
python -m pytest -q op_tests/test_flydsl_pa_decode.py— 209 passed, 5 skipped.git diff --checkpassed on the five changed files.align 2); offset numerical checks match the reference.