Repository navigation
[FlyDSL] Add packed D256 PA decode pipeline for gfx950 - #6655
Conversation
Port the packed D256 pipeline from 06fa786 to current main, preserving its partition reducer. Support page16/page64, per-token KV, both packed V layouts and sliding windows; reject non-transposed K. Fix the tuning CLI output and use the shared XCD helper. Co-authored-by: Sami Remes <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
On gfx950, FP8 paged attention with head dimension 256 now uses a shared K/V pipeline for page sizes 16/64 and up to 32 query rows. The pipeline supports per-tensor or per-token KV scales, plain or transposed packed V, and positive sliding windows. Non-transposed 4D K caches raise
NotImplementedError; gfx942 uses the generic tile path.This is a standalone PR against
main, incorporating the packed pipeline from #5949 and the extensions in #6617 through06fa78657. It is based onmainat285579b62and preserves the partition reducer already merged in #6619. The packed pipeline credits Sami Remes for the original implementation.Changes
trans_k=Trueas the compiler default and explicitly reject non-transposed K. Reuse aiter'sget_num_xcdsin the existing reducer launcher and fix the tuning CLI's removed-layout reference.Validation
At
6ff647358, using the pinned FlyDSL 0.4.0:op_tests/test_flydsl_pa_decode.py: 113 passed, 4 skipped; skips are partition caps above the device's CU count.op_tests/test_flydsl_pa_decode.py: 117 passed.atol=rtol=0.005, including 32 graph-replay cases. Covers BF16/FP16 queries, both KV scale modes and packed V layouts, QL1–4 at GQA8, windows 0/1/17/257/8193, small/large budgets, single/multi-tile plans, empty/tail contexts and sinks. Maximum FP32 reference error: 0.0016555.git diff --checkpassed.Validation uses
AITER_AOT_IMPORT=1and equivalent Torch reference quantizer formulas in the harness to avoid unrelated CK imports; PA kernels and independent FP32 references execute from source.The tile implementation is byte-identical to
06fa78657. At that source revision, the prior 320-case page16 matrix (including 32 graph replays) passed with maximum FP32 error 0.0016555. A separate unscaled random GQA16/QL2/window17 input had FP32 error 0.00748747 in both the old generic path and the new pipe, with bit-identical outputs; this is an existing FP8 precision limitation.Follow-up validation at
b7a54ab96: removedtest_stage_bound_covers_planand grouped the tuning geometry dimension checks. Returns and exception types/messages match the prior implementation for dimensions 0–8. Black, Ruff and diff checks passed; pytest collected 116 remaining tests. The GPU suite results above are from6ff647358; GPU tests were not rerun for this follow-up.Follow-up validation at
80f1394d5(2×CU default and tuning cleanup), with pinned FlyDSL 0.4.0:prepare_pa_decode_planselects 2×CU (160 on gfx942; 512 on gfx950).b7a54ab96with an explicit 2×CU budget; all 19 captured graphs replay successfully on each GPU.git diff --checkpass. The existing test module's executable AST is unchanged; this follow-up adds no in-tree tests and does not rerun the full GPU suite above.Performance versus main
The latest commit
80f1394d5defaults to 2×CU for all shapes. The main/PR tables below were measured atb7a54ab96, before this follow-up, when eligible gfx950 D256 shapes defaulted to 1×CU. The later direct 1×CU/2×CU comparison motivated restoring 2×CU; these historical main/PR timings are not a rerun of the latest default.Compared
main285579b with PR b7a54ab, using pinned FlyDSL 0.4.0 on gfx950/MI355X (256 CUs) and gfx942/MI308X (80 CUs). Both variants ran in one process on the same GPU with identical query/KV inputs and separate source snapshots. The reducer source is byte-identical between revisions.Each GPU ran 80 configurations: D256, BF16 queries, FP8 KV (OCP on gfx950, FNUZ on gfx942), 8 query heads / 1 KV head, page sizes 16/64, per-tensor/per-token KV scales, and
trans_v=false/true. Ten(context, batch, QL, window)geometries per combination:(8192,1,1,0),(8192,4,4,0),(8192,32,1,0),(8192,32,4,257),(131072,1,1,0),(131072,4,4,0),(131072,1,1,8193),(131072,4,4,8193),(524288,1,1,0),(524288,4,4,0).Autotuning and saved tuning results were disabled. At measured revision
b7a54ab96, each revision used its publicprepare_pa_decode_plandefault: gfx950 main used a 2×CU work budget and the PR used CU count for eligible D256 shapes; gfx942 used 2×CU on both. Plan capacity is also capped by batch × max partitions. The comparison therefore includes the default scheduling behavior at that measured revision.All ratios below are main latency / PR latency; greater than 1 means the PR is faster. Geometric means use all ten geometries; the range includes every measured configuration.
gfx950 / MI355X
Per-token KV improves with both V layouts: 1.120–1.143× geometric-mean cold speedup, with every measured per-token case above 1×. Page64/per-tensor improves by about 1.085×. Page16/per-tensor is mixed and includes a regression: at context 524288, B4, QL4, window 0,
trans_v=true, main takes 204.52 µs and the PR takes 240.61 µs (0.850×, 17.6% higher latency). This PR does not have a blanket no-regression claim.Representative cold decode times at context=131072, B4, QL4, window=0:
gfx942 / MI308X
The gfx942 path shows no material movement in this sweep: group geometric means are 0.999–1.001× and individual cold ratios are 0.994–1.009×. All 80 main/PR outputs are bit-identical; the gfx950 pipe is not selected.
Correctness and regression follow-up
Every main and PR output in the 160 configuration comparisons passed the independent, chunked FP32 causal/sliding-window reference with
atol=rtol=0.005and zero tolerance mismatches. Per-token scales vary by page/token and K/V use separate scales. Maximum FP32 absolute error: 0.00283734 on gfx950 and 0.00232045 on gfx942. gfx950 has 52/80 bit-identical outputs; maximum main/PR difference is 0.000442505, consistent with different partition plans.The page16 regression was retested in 24 additional paired comparisons: three geometries
(8192,32,1,0),(524288,1,1,0),(524288,4,4,0)× both scale modes × both V layouts × default/equal work budgets. This repeat reversed candidate order and used 30 calls per profile. All reference checks passed. At context 524288/B4/QL4 withtrans_v=true, the default repeat is 205.96 → 240.77 µs; equal 512 work budgets give 205.19 → 245.07 µs (0.837×). Equal budgets do not eliminate the page16/per-tensor regression, so it cannot be attributed solely to the default budget change.Serving throughput and CPU/host overhead were not measured. The raw results, per-kernel samples, source hashes and harness are retained outside the PR in
/aiter/pr6655_main_perf_20261018/.Larger batch/context: direct 1×CU versus 2×CU
PR revision b7a54ab was tested directly with workgroup budgets 256 (1×CU) and 512 (2×CU) on the same gfx950/MI355X, using FlyDSL 0.4.0. This isolates the budget comparison within the PR; these numbers are separate from the main/PR speedups above.
144 configurations cover D256, BF16 queries, FP8 KV, GQA8, QL1/4, page16/64, both KV scale modes and
trans_v=false/true, with window=0. The(context, batch)pairs are(131072,64/128/256/512),(524288,32/128),(1048576,32/128)and(2097152,32). The largest independent K+V allocation is 64 GiB. Inputs use independently addressed physical pages, seeded random block tables, deterministic FP8 values and separate varying per-token K/V scales; both budgets share the same input allocations.Cold measurements sum attention+reduce GPU durations after a 2 GiB read-only flush; step timing also includes the plan-update kernel. Each budget uses ten calls per profile and three alternating rounds. Warm measurements time five decode calls per graph, three samples per round and five alternating rounds. Compilation, FP32 reference computation and flush time are excluded. Clocks use the existing dynamic policy. Runtime device identity is recorded as PCI 0000:85:00.0.
The ratios in this section are 2×CU latency / 1×CU latency: above 1 favors 1×CU; below 1 favors 2×CU. Each row aggregates 18 context/batch/QL geometries.
At these larger shapes, 1×CU has no consistent advantage. Page16/per-token favors 2×CU by about 1.8% in geometric-mean cold latency. The largest observed difference is at context=524288, B128, QL1, page16, per-token, trans_v=true: 5536.94 µs (1×CU) → 5172.81 µs (2×CU), a 6.6% latency reduction with 2×CU. Page64 is mostly close; individual configurations favor either budget.
Representative direct cold timings:
For batch≤256, the budgets produce 256 versus 512 active tasks. At batch=512, both produce 512 active tasks, so the plans are equivalent and timings agree within about 0.2%. Page-ID staging can also change with budget because the maximum tiles per task changes; recorded staging/partition data is retained with each result.
A separate fresh-process repeat at context=524288/B128 covered 16 configurations, doubled calls per cold profile to 20, and reproduced the page16/per-token/QL1 difference:
trans_v=false5524.94 → 5173.34 µs,trans_v=true5530.13 → 5174.55 µs (about 6.4% lower latency with 2×CU).All 144 primary + 16 repeat comparisons passed the independent batched/chunked FP32 reference with
atol=rtol=0.005, zero tolerance mismatches, and maximum primary FP32 absolute error 0.000137745. Based on this comparison, follow-up80f1394d5restores the existing 2×CU default for all shapes and removes the special-case selection code. Native autotuning and saved configuration overrides remain available. Serving throughput and positive sliding windows were not measured in this expanded sweep.Raw latency, TFLOPS/TB/s, sample data, source hashes and device identity are retained outside the PR in
/aiter/pr6655_large_budget_20261018/.Historical comparison against the pre-main integration source
Previous validation of
06fa78657against7072a730ecovered 48 gfx950 and 24 gfx942 D256/page64 configurations; all outputs were bit-identical and no material regression was observed (largest measured slowdown below 0.5%). Those measurements used the previous partition reducer. These historical numbers are separate from the current-main measurements above.