Skip to content

[FlyDSL] [gfx950] Add explicit page strides and 64-bit rebase for FP4 MQA logits - #5518

Merged
LiuYinfeng01 merged 9 commits into
ROCm:mainfrom
LiuYinfeng01:dsv4-fp4-strided-pages
Nov 4, 2026
Merged

LiuYinfeng01 merged 9 commits into
ROCm:mainfrom
LiuYinfeng01:dsv4-fp4-strided-pages

Conversation

@LiuYinfeng01

@LiuYinfeng01 LiuYinfeng01 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

KV cache layout: ATOM vs vLLM

The diagrams below apply only to the DeepSeek V4 FP4 indexer path covered by this PR. The exact ordering within a block, other cache regions, and padding depend on the allocation.

ATOM: each layer's pages are adjacent; K and scales are stored in separate pools
K pool:     [this layer K0][this layer K1][this layer K2] ... [other layers' K ...]
Scale pool: [this layer S0][this layer S1][this layer S2] ... [other layers' S ...]

vLLM: each shared block contains cache regions for multiple layers/types
Block 0: [this layer K0][this layer S0][other cache regions / padding ...]
Block 1: [this layer K1][this layer S1][other cache regions / padding ...]
Block 2: [this layer K2][this layer S2][other cache regions / padding ...]

Here, page stride is the distance between the starts of the same data region in adjacent physical pages. It is not necessarily the size of that region's own page payload. This PR makes the reader use the actual stride and handle large offsets by rebasing the page pointer in 64 bits; it does not rearrange or copy the entire KV pool.

For example, locate the K data of physical page 2 relative to the start of this layer's K0. Assume each K page contains 4096 bytes, while the shared block stride is 16384 bytes (an illustrative value, not a fixed value of the actual configuration):

  • The old kernel uses the K page's own size: 2 × 4096 = 8192.
  • The correct address uses the actual stride: 2 × 16384 = 32768.

Both results are byte offsets relative to the start of this layer's K0. The page ID is the same, but the old kernel multiplies it by the wrong stride and therefore reads from the wrong location.

Worked example: page table, stride, preshuffle and 64-bit rebase

The following walks through one read. All row, page, and byte indices are zero-based. All address values are byte offsets relative to the start of this layer's K0, not absolute GPU addresses. The example uses 64-row pages and D=128: each K row contains 64 packed FP4 bytes, so a page contains 4096 K bytes and 256 scale bytes. We continue to assume a shared block stride of 16384 bytes for illustration.

1. Writer and reader must agree on the in-page format

Preshuffle describes the byte order within a page; page stride describes the distance between pages. These are separate properties. The default vLLM #60834 Triton MXFP4 path also uses a shuffled format: vLLM obtains it from AITER's cache_format() and passes shuffle=layout to the writer. The optional FlyDSL path in vLLM #56834 writes K/scales directly in FlyDSL's in-page format. Different preshuffle formats are not automatically interchangeable, and this does not require an extra copy to rearrange the data after writing it.

Code references: format propagation in the default Triton path and in-page offsets in the writer paired with FlyDSL.

For example, locate packed byte 19 of K row 5 within a page (a packed byte index, not FP4 element 19):

  • In ordinary row-major storage, the in-page offset would be 5 * 64 + 19 = 339.
  • In the FlyDSL 64-row page format used here, each row is split into four 16-byte chunks. The page stores chunk 0 of every row, then chunk 1 of every row, and so on.
  • Byte 19 belongs to chunk 1 at byte 3 within that chunk, so its actual in-page offset is 1 * 64 * 16 + 5 * 16 + 3 = 1107.

If the writer stores this byte at offset 1107, the reader must retrieve it from offset 1107. Reading offset 339 as though the data were row-major would still be wrong even with the correct page ID and page stride. Scales also have a matching in-page order. This 64-row page format is an existing FlyDSL contract, not a new layout invented by #5518.

2. Block table selects the physical page; stride locates its start

Suppose a request's logical pages 0, 1, and 2 map to physical pages [2, 7, 1]. To read row 5 of that request:

logical_page = 5 // 64 = 0
row_in_page  = 5 % 64  = 5
physical_page = block_table[0] = 2
page_start_offset = 2 * 16384 = 32768
in_page_offset = 1107
K_byte_offset = 32768 + 1107 = 33875

Likewise, physical page 7 starts at 7 * 16384 = 114688, and physical page 1 starts at 1 * 16384 = 16384. The table selects the page, the stride locates its start, and the preshuffle format locates the data within that page.

kv_cache.stride(0) is tensor metadata describing the distance between the starts of adjacent physical pages. It is not calculated from the current request's page table and is not necessarily equal to the page payload size. The K/scale tensors here are uint8, so their element strides are also byte strides. More generally, the byte stride is tensor.stride(0) * tensor.element_size().

The page table itself also has a row stride. For example, each request may have 3 valid page IDs but reserve 5 int32 slots per row:

request 0: [8, 3, 9, padding, padding]
request 1: [2, 7, 1, padding, padding]

Logical page 0 of request 1 must be read from table[1 * 5 + 0], not table[1 * 3 + 0]; the latter points into request 0's padding. Here, block_tables.stride(0) == 5 is measured in int32 elements, equivalent to 20 bytes, not 5 bytes.

The actual reader uses bt_bt[pid_b * _stride_bt + safe_bi] in _load_phys. The runtime wrapper passes kv_cache.stride(0), kv_scale.stride(0), and block_tables.stride(0). See the #5518 reader.

3. Int64 is an integer width, not a 64-row page or FP64 data

Int64 means computing integers using 64 binary bits. It does not mean a 64-row page or 64 bytes, and it does not convert FP4 K data to FP64. Page stride determines the multiplier; integer width determines whether the resulting large value can be represented. Both must be correct.

To illustrate the same formula, suppose the page table returns physical page 281250:

page_start_offset = 281250 * 16384 = 4,608,000,000 bytes
32-bit unsigned maximum          = 4,294,967,295
4 GiB boundary                    = 4,294,967,296 bytes

This example page ID and stride reproduce the original failing offset of 4,608,000,000 bytes recorded in the PR; they do not imply that the original run used page ID 281250. Simply truncating the value to its low 32 bits would leave 313,032,704. That is an arithmetic illustration of overflow: the actual kernel may instead return zeros through out-of-bounds masking or encounter a memory-access fault, so it must not be assumed to always read this truncated address. Signed 32-bit intermediate calculations can fail earlier, at the 2 GiB boundary.

Changing only the multiplication to 64 bits is insufficient because the buffer load's relative byte offset still has a 32-bit range. #5518 first computes and moves the buffer base in 64 bits, then reads using a small in-page offset:

old: base = K0;                    huge byte offset = 4,608,000,000 + 1107
new: base = K0 + 4,608,000,000;    local byte offset = 1107

The mathematical target remains K0 + 4,608,001,107, but the new method no longer puts the entire large offset into the buffer instruction's 32-bit relative offset. The code converts the physical page ID to fx.Int64 before computing byte_offset=phys_shared * fx.Int64(_stride_kv_block) and passing it to _i32_buffer. Converting to 64 bits after a 32-bit multiplication has already overflowed would be too late.

The _i32_buffer implementation moves the pointer before creating the buffer descriptor. Its byte_offset // fx.Int64(4) is only a unit conversion: the pointer advances in 4-byte int32 words, so moving 4,608,000,000 bytes means advancing 1,152,000,000 words. It does not shrink the address or lose precision.

Scales are rebased separately using their own start pointer and stride. The vLLM scale view's start pointer already includes the 4096-byte offset past the K region in this layer's page. This process only computes addresses; it does not move K/scales or change the shared pool's block-major arrangement.

Summary

Extend the existing gfx950 FlyDSL paged MXFP4 MQA scorers with shared-pool page strides and 64-bit physical-page rebasing. This changes addressing, not FP4 arithmetic or the default dense layout. Consumer: vllm-project/vllm#57517.

The public runtime wrappers read kv_cache.stride(0), kv_scale.stride(0), and block_tables.stride(0); optional stride arguments belong to the build/compile APIs. Cache strides are bytes for uint8 tensors; table stride is int32 elements. _i32_buffer(..., byte_offset=...) rebases the descriptor before page-local loads.

The scorers now also accept 128-row pages while retaining the 256-token compute chunk. Scale writers/readers use four equal token groups instead of a hard-coded 16-row group, preserving the existing 64-row ABI and correctly packing the two 64-token warp regions of a 128-row page. Both 64- and 128-row decode and prefill cases match the exact FP4-dequant reference at cosine 1.000000. The default decode and prefill correctness sweeps now include 128-row page cases.

The original offset is 4,608,000,000 bytes = 4.608 GB = 4.292 GiB, not 4.6 GiB. #4609 migrated existing scorers to the fx API; it did not first introduce FP4 scoring.

PR Self-Review

Reviewed revision

f6f8f20

Behavior and intent

This revision extends the existing gfx950 FP4 paged MQA decode and prefill scorers to shared-pool caches. Runtime wrappers derive K/scale page strides and block-table row strides from the tensors; physical-page offsets are computed in 64 bits and rebase the buffer descriptor before page-local loads. The existing contiguous-page assumptions and 32-bit physical-page byte offsets cannot address separated layers in a shared pool, including the original 4,608,000,000-byte offset. This is an addressing change, not a change to FP4 arithmetic or the 64-row dense ABI.

The explicit path also supports 128-row pages with a 256-token compute chunk. The writer and readers interleave four equal token groups, rather than assuming every group contains 16 tokens. The decode CTA default uses host-known row/context buckets with an explicit override; no device-to-host synchronization is introduced. Existing row-group dispatch is retained.

The merge with main preserves upstream compiled-launch caching and the prefill row-plan specialization fix. Cache arguments use fixed one-element no-copy views: ordinary flattening rejects page gaps, while a full-span view can overflow the cached launcher's signed-32-bit tensor-dimension marshalling above 2 GiB. These views retain the data pointer and storage offset; the kernel constructs its own buffer resources using explicit strides and 64-bit rebasing, not the view extent.

Validation and unverified scope

Current-revision checks ran on physical GPU 0 of an AMD Instinct MI355X/gfx950, Torch 2.13.0+rocm10.0.0, Triton 3.8.0+git669b31ac, FlyDSL 0.4.1. The tested source tree exactly matches this merge commit. Disposable containers used read-only candidate source, isolated caches and AITER_TRITON_ONLY=1; existing services and their dependencies were not changed. The base image was sha256:cf6db5a2006b361b8e658d29580de2a11baaacd85e909657b4fee8b362d8eccf.

Primary command, from the repository root in that environment:

python op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py \
  --case all --json-output /evidence/address-results.json

Result: 40 layout/path/execution comparisons passed, not 40 independent model tests. This covers decode/prefill, dense/strided layouts, eager/graph replay, both sides of 2 GiB and 4 GiB, the original 4.608 GB offset, signed random inputs/nonuniform scales, shuffled pages/padded tables, nonzero storage offsets, tail/empty windows, output guards and deliberate page-map/scale mutations. The original constant-logit case is retained. The independent FP4-dequant checks use unchanged rtol=2e-4, atol=2e-3; dense/strided payload equivalence is checked separately.

Focused existing cases also passed: three decode cases including 64/128-row pages and an MTP/head variation; five prefill cases including 128 heads, ragged/nonzero windows and 128-row pages; four precomputed-decode-schedule cases for next_n=1,2,4,5 in eager/graph mode; and host CTA-selector assertions. Representative commands:

PYTHONPATH=.:op_tests python - <<'PY'
import test_flydsl_pa_mqa_logits_fp4 as decode
import test_flydsl_pa_mqa_logits_fp4_prefill as prefill
import test_flydsl_pa_mqa_logits_fp4_strided_pages as strided
decode.test_default_varctx_parallel_unit_num()
for next_n in (1, 2, 4, 5):
    strided.test_precomputed_decode_schedule_empty_windows(next_n)
decode.test_pa_mqa_logits_fp4_qfp4_kvfp4(
    batch=2, max_ctx=512, heads=64, kv_block_size=128, bench=False
)
prefill.run_case(
    2, [[50, 120, 200], [40, 100]], kv_block_size=128, seed=5
)
PY

Two additional 64-row FP4 compression-writer smoke cases, decode and prefill, passed the existing FP4-dequant check with bit-exact E8M0 scales. Black 26.3.0, CI-pinned Ruff 0.16.0 --no-cache, Python syntax checks and git diff --check HEAD^2 HEAD passed for the PR slice. Logs and structured results are retained locally under outputs/pr5518-conflict-fix-20261030/; local artifact paths are not public download links.

Unverified scope: no clean package/wheel build, full-model quality or serving validation, non-gfx950 numerical execution, or new performance measurement was performed for this merge. The performance tables below are historical measurements under their stated earlier revisions/stacks, not current-head reruns. The existing compression writer reference hardcodes the 64-row scale layout, so independent 128-row writer validation is not claimed; 128-row readers did pass independent FP4-dequant references. Hosted CI must be checked separately; local success does not establish hosted CI success or overall review readiness.

PR-specific question

The path-specific question asks what each changed op test would fail on before this PR and why an existing canonical test is insufficient. The pre-existing decode/prefill suites generated dense 64-row pages with small physical offsets. Passing them does not exercise shared-pool page gaps, padded block-table rows, layer/storage offsets, descriptor rebasing across 2/4 GiB, or 128-row scale grouping. The added decode/prefill cases extend those canonical suites instead of replacing their references or weakening tolerances. The separate shared-pool file compares identical payload bytes under different storage layouts and adds adversarial offsets, graph replay and mutation sensitivity that those small dense cases cannot provide.

The previously recorded negative control against upstream scorer files 246efe9105ba produced a GPU memory-access fault on the small strided case; this historical negative control was not rerun in a shared service. During the current merge validation, ordinary flattening was reproduced to reject page gaps, and full-span cached-launch arguments failed at the 2 GiB case with a signed-32-bit marshalling error. The final fixed-size views passed the same complete regression without tolerance changes. Benchmark reporting additions are evidence-generation helpers, not a claim that every added line is a before-PR correctness failure.

Changed op tests

  • op_tests/test_flydsl_pa_mqa_logits_fp4.py: extends the existing canonical decode suite with page-size-aware scale packing, a default 128-row-page correctness case, and exact host CTA-bucket/MTP-divisibility assertions. The old rectangular path rejects 128-row pages and its hard-coded scale assumptions cannot cover the new layout. Existing dense 64-row numerical cases do not check these boundaries or the new host-only selector contract. This file remains the decode owner; it is not duplicated by the shared-pool adversarial suite.
  • op_tests/test_flydsl_pa_mqa_logits_fp4_prefill.py: extends the existing canonical prefill suite and its reference cache writer to four equal scale groups, adds a 128-row-page case, and retains ragged/nonzero-window checks. The old path rejects 128-row pages, and the old 16-token grouping is insufficient for their scale layout. The FP8 gather/scorer comparison, paired FP4/FP8/BF16 cosine reporting and repeated-shape benchmark helpers serve this prefill measurement protocol; they are not independent correctness regressions. Reusing these quantization/reference helpers avoids a second competing prefill oracle in the new suite.
  • op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py: adds storage-layout and large-address regression coverage absent from both dense canonical suites: same-byte dense/shared-pool comparisons, independent FP4-dequant outputs, 2/4 GiB boundaries and original 4.608 GB offset, nonzero Q/K/scale/output offsets, padded page-table rows, shuffled mappings, output canaries, eager/graph replay and deliberate wrong-map/scale detection. It also checks precomputed decode schedules with changed empty/short MTP windows. Existing dense tests neither allocate these address ranges nor vary these storage strides, so they cannot detect the original dense-page assumption or the new cached-launch flattening/marshalling failures. It reuses canonical prefill helpers rather than replacing their math reference.

FP8 -> FP4 indexer micro-benchmark

This is the primary performance comparison for the scorer: the previous paged
FP8 indexer pipeline gathers paged K/scales into contiguous buffers and then
runs FP8 MQA logits; the FP4 path reads the paged cache directly in one kernel.
Both operate on the same synthetic indexer shape and exclude model GEMMs,
attention, scheduler and CPU/server overhead.

MI355X/gfx950, H=64, D=128, page=64. These results were measured inside the
Sep-10 ROCm 10 nightly (sha256:72e90adf360c...), with Torch
2.12.0+rocm10.0.0 and Triton
3.8.0+git4cff872c.rocm10.0.0. The FP8 arm uses the exact merged #5603 source
(a84bd368); the FP4 arm adds only this PR's three runtime scorer files. Each
shape uses five independent processes, with 10 warmups and 50 timed iterations
per process; medians are shown. FP8 total includes paged gather and FP8 logits;
FP4 is the single direct-paged scorer.

Shape B Query rows / request Context FP4 us FP8 gather us FP8 total us FP8 / FP4 FP4 vs BF16 cos FP8 vs BF16 cos FP4 vs FP8 cos
1x512x64K 1 512 65,536 259.82 8.41 315.00 1.21x 0.987314 0.999301 0.985827
1x1Kx64K 1 1,024 65,536 450.64 8.48 591.55 1.31x 0.987140 0.999295 0.985643
1x1Kx128K 1 1,024 131,072 864.12 13.90 1166.32 1.35x 0.987143 0.999293 0.985628
4x256x16K 4 256 16,384 126.85 8.35 184.82 1.47x 0.987142 0.999295 0.985647
8x128x8K 8 128 8,192 63.57 8.99 111.17 1.75x 0.987139 0.999295 0.985643
1x8Kx8K 1 8,192 8,192 414.53 4.31 536.86 1.30x 0.987229 0.999298 0.985725

Across this exact-stack sweep, FP4 is 1.21x–1.75x faster than FP8
gather+score. FP4-vs-FP8 is computed directly from both output vectors over the
same valid windows. Every shape also reports cos=1.000000 against the exact
FP4-dequant reference, separating kernel correctness from the expected
quantization difference.

for spec in \
  "1 512 65536" "1 1024 65536" "1 1024 131072" \
  "4 256 16384" "8 128 8192" "1 8192 8192"; do
  read -r bs nq ctx <<< "$spec"
  for repeat in {0..4}; do
    python - "$bs" "$nq" "$ctx" "$repeat" <<'PY'
import sys
from op_tests.test_flydsl_pa_mqa_logits_fp4_prefill import run_case
bs, nq, ctx, repeat = map(int, sys.argv[1:])
run_case(
    bs,
    [[ctx] * nq for _ in range(bs)],
    seed=42 + repeat,
    bench=True,
    iters=50,
    warmup=10,
    parallel_unit_num=max(512, bs * nq),
)
PY
  done
done

The existing op-test calls the FP8 reference pipeline ATOM cp_gather+fp8_logits; that test name and implementation remain unchanged.
Decode uses H=64, D=128, page=64 and the new graph-stable auto-CTA schedule.
The search covered 16–4096 CTAs at 8K/32K/64K/128K; each final row is the
median of five independent processes with 20 warmups and 100 timed iterations.
FP4 and FP8 are measured in the same process on identical inputs.

Context Decode batch Auto CTA FP4 us (range) FP8 us FP8 / FP4
8K 1 64 4.21 (3.62–4.27) 4.17 0.99x
8K 2 96 4.34 (3.75–4.43) 4.31 0.99x
8K 4 256 4.48 (3.95–4.58) 4.35 0.97x
8K 8 256 4.54 (3.94–4.58) 4.50 0.99x
8K 16 512 4.84 (4.80–4.91) 4.82 1.00x
8K 64 512 8.36 (8.09–8.62) 11.89 1.42x
128K 1 256 4.04 (3.99–4.59) 4.14 1.03x
128K 2 512 5.45 (4.86–5.50) 5.50 1.01x
128K 4 1280 7.37 (7.26–8.05) 12.36 1.68x
128K 8 1280 11.87 (11.07–12.04) 20.79 1.75x
128K 16 2048 17.60 (17.37–17.99) 33.27 1.89x
128K 64 4096 56.53 (55.46–57.02) 165.55 2.93x

At 8K, the tuned grid removes the fixed-512 low-batch penalty: B1–B16 are
within 3% of FP8 and B64 is 1.42x faster. At 128K, B1/B2 are at parity and
B4–B64 are 1.68x–2.93x faster; B64 drops from 70.44 us with 512 CTAs to
56.53 us with the tuned grid. The selection uses only host-known row and
maximum-context buckets, so it adds no device-to-host synchronization and is
stable under graph replay. Explicit parallel_unit_num remains an override.

Correctness / regression

Local MI355X, gfx950, GPU 7. Four-commit branch: functional kernel commit d6807379, consolidated test/benchmark commit 0030d058, CI coverage fix 063f3eb5, and auto-CTA tuning commit 6ab04df3; all are authored by LiuYinfeng01. Torch 2.12.0+git6bbd260, HIP 7.2.53211; original validation used image Triton 3.7.1; the complete correctness suite and standard shape sweep were rerun with the upstream CI Triton 3.8.0+amd.rocm7.2.0.git111ff227 pin. The strided-page test now enables graph replay and page-map/scale sensitivity checks by default, while non-gfx950 runners print [skip] and exit 0. No NVIDIA validation is implied.

python op_tests/test_flydsl_pa_mqa_logits_fp4.py
python op_tests/test_flydsl_pa_mqa_logits_fp4_prefill.py
python op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py \
  --json-output address-results.json
Check Result
Existing decode sweep PASS; cosine 1.000000, existing error/mask checks
Existing prefill/variable-qlen sweep PASS; cosine against FP4 reference 1.000000, BF16 comparison and -inf masks retained
Random dense vs shared-pool PASS; identical payloads, separately contiguous dense K/scales, bit-identical dense/strided outputs
Independent FP4-dequant oracle PASS; rtol=2e-4, atol=2e-3; nonuniform signed Q/K and per-group scales
Small, 2 GiB and 4 GiB boundary, original 4.608 GB offset PASS; sequentially bounded allocations, nonzero layer/Q/scale offsets
Multiple requests, shuffled pages, padded table rows PASS
Nonzero/empty windows, tail contexts, output guards PASS
Prefill and decode graph capture/replay PASS; logical outputs poisoned between replays
Deliberately wrong page map / scale permutation Detected; restored inputs pass
Total recorded layout/path/execution comparisons 40 PASS; includes original constant 8192.0 regression
Non-gfx950 default invocation SKIP; prints [skip] and exits 0
CTA tuning and paired final A/B 1,792 correctness-passing records; 5-process final medians

Negative control: running the new small strided case against upstream scorer files from 246efe9105ba produced a GPU memory-access fault (exit 134). The patched source passes the same test. Do not run this negative control in a shared serving process.

Appendix: stride/rebase performance non-regression

Following the same-change isolation used in #5285: only the three scorer files differ between baseline 246efe9105ba and patched source; same dependencies, GPU and test. Three alternating process-level repetitions, 20 warmups, 100 timed iterations each; table reports the median of the three event-time averages. Dense K/scales and tables are genuinely contiguous and valid on both versions.

Scope: public scorer API including internal schedule and output reset, CUDA graph replay; not kernel-only and not vLLM. Rows=32, requests=3, context upper bound=8192 with ragged/empty windows, H=64, D=128, page=64.

Path Before us After us Latency change
Prefill 36.564 36.442 -0.33%
Decode 37.704 37.779 +0.20%

Observed ranges overlap (prefill before 36.277–36.635, after 36.070–36.681 us; decode before 37.628–37.764, after 37.197–37.856 us). This auxiliary check only shows that shared-pool addressing did not materially regress the already-existing FP4 scorer; it is not the FP8 -> FP4 speedup table above.

# Run against each source revision, interleaving baseline/patched runs.
python op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py \
  --case small --layout dense --rows 32 --context 8192 \
  --graph --benchmark --iters 100 --warmup 20 --json-output dense-results.json

Artifacts retained locally under results/local-kernel-validation/: aiter-address-full.json, aiter-before-after.json, aiter-main-repeat*.json, aiter-patched-repeat*.json. Black and Ruff pass on changed files.

AI assistance

AI assistance was used at the author's request. Human review remains required before marking ready.

Signed-off-by: LiuYinfeng01 [email protected]

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5518 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

…MQA logits

Teach pa_mqa_logits_fp4 decode/prefill to honor caller-provided K/scale/block-table
page strides and rebase each physical cache page in 64-bit address space before
building buffer descriptors. Fixes wrong logits when shared KV pools place pages
beyond the 4 GiB range of buffer-instruction byte offsets (reproduced at 4.6 GiB
in DeepSeek V4 BLHNC layouts).

Assisted-by: OpenAI API coding assistant

Signed-off-by: LiuYinfeng01 <[email protected]>
@github-actions github-actions Bot changed the title [FlyDSL][gfx950] Add explicit page strides and 64-bit rebase for FP4 MQA logits [FlyDSL] [gfx950] Add explicit page strides and 64-bit rebase for FP4 MQA logits Sep 15, 2026
@zufayu
zufayu requested a review from coderfeli September 16, 2026 01:52
@zufayu

zufayu commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Advisory review (static + hand-run; not a merge gate). Validation/Perf ran no GPU stage — reasons are on their lines below. Findings tagged [verified] are traced to code/repro.

Extends the gfx950 FlyDSL paged MXFP4 MQA scorers (decode + ragged prefill) to take the KV-cache, scale and block-table page strides from the real tensors and to rebase each physical page in 64-bit before the within-page buffer loads, so shared BLHNC pools whose pages sit beyond the 4 GiB range of a buffer instruction's byte offset address correctly.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 and no head-matched report was supplied; the triaged target op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py is gfx950-only and this review box is gfx942. The PR's own CI stands in: on head commit 0030d05 the gfx950 leg of Aiter Test ran the new test green (all records "correctness": "passed", dense vs strided bit-identical, physical page offsets up to 4,613,299,200 bytes — past the 2^32 buffer-offset limit, plus 2 GiB / 4 GiB boundary cases), while the gfx942 leg fails on the new file's exit convention (finding 1).
Perf (advisory): NOT RUN — no gfx950 GPU on this review box (gfx942 only) and auto-validation disabled, so no validator base-vs-head timing exists; the PR supplies its own isolated before/after (only the three scorer files differ from baseline 246efe9, three alternating process repetitions, 20 warmup / 100 timed iterations): prefill 36.564 → 36.442 us (-0.33%), decode 37.704 → 37.779 us (+0.20%), overlapping observed ranges.

⚠️ [verified] op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py:493 ends main() with raise SystemExit(f"gfx950 required; ..."), which exits 1 — but aiter's CI executes every op_tests/test_*.py via plain python3 <file> on BOTH the MI35X (gfx950) and MI300X (gfx942) legs, and the sibling gfx950-only tests exit 0 with a printed "[skip]" (test_flydsl_pa_mqa_logits_fp4.py:699, test_flydsl_pa_mqa_logits_fp4_prefill.py:791). The PR's own CI run confirms the impact: the MI300X shard-5 job logs "gfx950 required; current architecture: gfx942" → "❌ Test failed: op_tests/test_flydsl_pa_mqa_logits_fp4_strided_pages.py", and the required Aiter Test Gate check stays red on every push until this is fixed (the other red MI300X shard is test_topk_select.py dying in hipErrorIllegalState — a file this PR does not touch, an unrelated flake). Author must replace the raise with the sibling skip convention (print "[skip]" and return, or exit 0) so the gfx942 leg goes green.

📝 [verified] CI invokes the new test with no flags, so the default run covers eager mode only — every record in the green gfx950 CI log reads "mode": "eager", "sensitivity_checked": false; the CUDAGraph capture/replay and the page-map / scale-permutation mutation checks (the parts guarding the production CUDA-graph decode path) ran only in the author's local --graph --sensitivity invocation. Reviewer should ask for those flags in the standard CI invocation, or for the local JSON logs to be attached to the PR.

Exit successfully on non-gfx950 runners and enable graph replay plus page-map/scale sensitivity checks in the default CI invocation.

Signed-off-by: LiuYinfeng01 <[email protected]>
Select a graph-stable CTA count from host-known batch and context buckets tuned on MI355X, while preserving explicit caller overrides. Cover the 8K/32K/64K/128K schedule table and MTP divisibility constraints.

Signed-off-by: LiuYinfeng01 <[email protected]>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
@valarLip

Copy link
Copy Markdown
Collaborator

please give a full test results for perf before/after this PR

@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 13, 2026
@zufayu
zufayu requested review from yadaish and zhiding512 October 15, 2026 07:17
Guard decode and prefill compute with CTA-uniform effective window bounds.
Skip Q/K loads and matrix instructions for padded or fully masked slots
without changing scheduling, valid logits, or graph-stable metadata.
Cover precomputed speculative schedule refresh in eager and graph replay.

Assisted-by: OpenAI
Signed-off-by: Liuyinfeng01 <[email protected]>
Resolve the shared schedule relocation without losing tuned CTA selection
or preallocated-buffer validation. Preserve upstream ragged row-group and
packed-output dispatch together with 64/128-page varctx support and empty
CTA compute guards. Keep the public schedule imports used by vLLM.

Assisted-by: OpenAI
Signed-off-by: Liuyinfeng01 <[email protected]>
@zufayu
zufayu removed the request for review from yadaish October 29, 2026 10:19
Resolve FlyDSL API cleanup conflicts while preserving explicit page strides, 64-bit rebasing and 64/128-row scale layouts. Keep cached launchers compatible with strided and multi-GiB cache storage using fixed-size no-copy views.

Validated on gfx950 with FlyDSL 0.4.1: 40 addressing/path/execution comparisons, focused decode/prefill and schedule checks, FP4 writer checks, Black and Ruff.

Signed-off-by: Liuyinfeng01 <[email protected]>
@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision eae452f01f4b · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

valarLip
valarLip previously approved these changes Nov 2, 2026
Replace the fixed block_k=256 restriction with the packed-scale geometry contract: block_k=64*num_warps, 64/128-row pages, and whole-page chunks. Preserve the default 256/4 configuration while restoring OPUS 64/1 cross-check compatibility.

Mask non-writer lanes and negative prefill window offsets before buffer stores to prevent offset wraparound at unaligned window starts. Extend existing shared-pool and canonical prefill regressions without weakening tolerances.

Validated on MI355X with FlyDSL 0.4.1: 36 OPUS corner rows, 20 zero-mismatch FlyDSL comparisons, 8 NaN propagation checks, 88 shared-pool comparisons, and focused decode/prefill/MTP schedule cases. Black 26.3.0 and Ruff 0.16.0 pass. Full hosted CI and new performance measurements were not rerun.

Signed-off-by: Liuyinfeng01 <[email protected]>
@LiuYinfeng01
LiuYinfeng01 force-pushed the dsv4-fp4-strided-pages branch from c56d8af to eae452f Compare November 3, 2026 03:16
@LiuYinfeng01
LiuYinfeng01 requested a review from valarLip November 3, 2026 06:14
@LiuYinfeng01
LiuYinfeng01 merged commit 3a14384 into ROCm:main Nov 4, 2026
@LiuYinfeng01
LiuYinfeng01 deleted the dsv4-fp4-strided-pages branch November 4, 2026 00:33
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
… MQA logits (ROCm#5518)

[FlyDSL][gfx950] Add explicit page strides and 64-bit rebase for FP4 MQA logits

Honor caller-provided K, scale, and block-table page strides in FP4 MQA
decode and prefill. Rebase each physical cache page using 64-bit addressing
to support shared KV pools with page offsets beyond 4 GiB.

Support 64/128-token pages and compatible block_k/num_warps configurations.
Tune persistent CTA scheduling, skip empty compute windows, and fix masked
prefill stores. Add shared-pool addressing and graph-replay regressions.

Signed-off-by: Liuyinfeng01 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants