Skip to content

[FlyDSL] [Feature] gfx1250 prefill index block scores over an NVFP4 key cache - #8458

Open
XiaobingSuper wants to merge 17 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-index-score-prefill-nvfp4
Open

XiaobingSuper wants to merge 17 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-index-score-prefill-nvfp4

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

New gfx1250 FlyDSL ops in aiter.ops.flydsl.index_score_prefill, with one new kernel: causal block scores of prefill index queries over an NVFP4 key cache, and the same scorer fused with the top-16 block selection.

  • API. index_score_prefill_nvfp4, index_score_prefill_nvfp4_supported; index_topk_prefill_nvfp4, index_topk_prefill_nvfp4_supported, index_topk_prefill_nvfp4_preferred, index_topk_prefill_chunk_blocks.
  • Cache. Two byte views, each with its own page stride: e2m1 pairs [pages, 128, 64] and one E4M3 scale per 16 values [pages, 128, 8] (for example, views of one [pages, 9216] page array).
  • Output. For query row r of request b, index head h and 128-key block blk of b's pages, score[h, r, blk] is the max over the block's keys at or before r's position of e4m3(clamp(q, +-448)) . dequant(K), times sm_scale * log2(e) (multiplied in FP32). It is -inf for a block past the row's own. It is written for the blocks up to the block of the last row of r's 256-row tile, at most those that score and a block_table row both hold, into an fp32 [heads, >= total_q, max_block] tensor.
  • Kernel. Every dot is one 128-deep v_wmma_scale16_f32_16x16x128_f8f6f4 on the raw e2m1 rows and their scales (wmma_scale16), so K is never widened. Pages arrive by tensor DMA into an LDS ring (wave 0 copies the payload, wave 1 the scales). A CTA scores 256 rows (4 waves) over at most 32 blocks; its scores are staged in LDS and leave as one coalesced store per row chunk. There is one scorer build (ring of 4 pages) and one fused build per pin pair (ring of 3); the tuning keywords block_q / waves / ring / fold_max / pad_lds / sel32 and **_launch are removed, with the value-by-value max and the padded LDS rows always on (see Performance).
  • Block bound. The kernel takes max_block and clamps every request's blocks to it; the score strides are 64-bit kernel arguments, so the max(score.stride()) < 2**31 refusal is gone.
  • Input check. index_score_prefill_nvfp4_supported(...) takes the op's first nine arguments; the op raises ValueError when it is False or chunk_blocks < 1. It holds what the kernel assumes of its bare pointers and int32 strides: arch, dtypes, ranks, page layout and 16 B alignment, the same page count for payload and scale, one device, a non-empty cu_seqlens_q, metadata and score extents, a positive finite scale. chunk_blocks above 32 is clamped. A call with nothing to score (no rows, no request, no block, max_query_len <= 0) returns without a launch.
  • Fused top-16. index_topk_prefill_nvfp4 runs the same scorer and keeps each row's 16 best blocks of its chunk in LDS, so the scores never reach memory. It returns [heads, total_q, chunks * 16] int64 keys, unordered, 0 for no block; a row's later chunks are not written, so the caller masks them. index_topk_prefill_nvfp4_supported(...) takes its first ten arguments (no score, plus topk and max_block) and adds topk == 16 and 0 <= max_block <= 0xFFFF.
  • Caller's contract. What only the device can see is not checked: cu_seqlens_q ends at total_q, max_query_len covers every request, and the page ids of block_table are inside the cache.
  • Shared helpers. aiter/ops/flydsl/index_nvfp4.py (the cache predicate, the int32 metadata rule, the launch) and kernels/index_nvfp4_gfx1250.py (wmma_scale16, the scale helpers) are added byte-identical by this PR and by [FlyDSL] gfx1250 MiniMax-M3 decode indexer over the NVFP4 index cache: flat-plan scorer + top-k #8817 (the decode indexer). Neither PR depends on the other; whichever merges second rebases onto them.
  • Licence headers. The op and its kernel carry the repo's MIT / AMD header, as the other MiniMax-M3 index FlyDSL files on main do.

Performance

MI455X, one GPU, FlyDSL 0.5.3. No baseline on main: the PR adds the op.

Scorer builds, 4 index heads, at 587be47 (the last revision that had the keywords): median of 9 interleaved rounds, us, identical scores in all three builds.

new rows : cached rows 256/4/4, fold and pad off (old default) 128/2/2, fold + pad 256/4/4, fold + pad (this head)
14336 : 99968 315.4 262.9 264.9
300 : 99968 30.6 29.7 26.5
2048 : 30000 31.3 29.8 27.2
32768 on 384K 2636 2343 2288
ragged batch, 50K-300K 127.8 102.7 105.6

Fold + pad is never slower than the old default and the two geometries are within 3% of each other on the three long shapes, so 256/4/4 with fold + pad is the only build and the keywords are gone.

Op test timing rows (us column, same command as below) at 08332a5, whose builds are the head's (see Self-Review):

op test case scorer, dense Q fused top-16, default chunk fused top-16, chunk 64
1req 23.1 13.2 13.1
ends_empty 24.4 38.3 50.3
2k_40k - 48.1 73.6
m31_ragged - 180.4 180.2

The scorer and fused columns use different batches of the same name (1 and 4 index heads), so they are not a comparison of the two ops.

Why a new op and not a gfx1250 backend of score_prefill_flydsl_nvfp4

Main's score_prefill_flydsl_nvfp4 is gfx950-only (MFMA, gfx950 geometry and arch gate). Its k_round="exact" mode computes the same dot, but the contracts differ: its default k_round="e4m3" rounds K to e4m3, which the scaled WMMA on raw e2m1 cannot reproduce; it needs an out of exactly [heads, total_q, ceil(max_seq_len / 128)] pre-filled with -inf and writes only the causal window, where this op writes the -inf blocks of each tile itself; it rounds sm_scale * LOG2E from double, this op multiplies in FP32; and it chooses its own chunking from max_seq_len. The fused op also returns selection keys per chunk, a contract score_prefill_flydsl_nvfp4 has no counterpart for. A gfx1250 branch of score_prefill_flydsl for k_round="exact" with bf16 Q could call this kernel with an -inf-filled out, once one scale rounding is chosen. That can be a follow-up; this PR adds the kernel and its own entry points only.

Review answers

  • _gptr / _Lds: the kernel borrows five pa_decode LDS and tensor-DMA accessors (pointer, load, store, fp8, tdm_copy) through a subclass that sets only what they read. Moving them to a shared helper is a pa_decode refactor and is left out of this PR.
  • The block loop carries a state it does not use: without it FlyDSL's rewriter refuses the fused build and the scorer's ISA changes (host compile at an earlier revision of this branch; the comment at the loop says so).
  • The scale view must be 16 B aligned, as the payload. On MI455X a scale view offset by 8 B gave the same scores in the 3 scorer cases, but a page stride of 8 mod 16 is untested, so the op still requires 16 B.

Dependencies

None; based on main. See "Shared helpers" for the two files in common with #8817.

PR Self-Review

Reviewed revision

ec0bb5e

Behavior and intent

  • Adds the six entry points listed above (aiter/ops/flydsl/index_score_prefill.py), the gfx1250 kernel they launch, and two shared helper files: causal prefill block scores of index queries over an NVFP4 key cache, with the scaled WMMA reading the e2m1 payload and its E4M3 scales directly, and the same scorer fused with the top-16 selection.
  • No existing op, kernel or dispatch changes; nothing calls the new ops unless a caller does.
  • Why: aiter has no gfx1250 scorer for this cache; the existing NVFP4 prefill scorer is gfx950-only (see "Why a new op" above).

Validation and unverified scope

  • MI455X (gfx1250), one GPU, FlyDSL 0.5.3, at this head, at 08332a5 and at 587be47: python3 op_tests/test_flydsl_index_score_prefill_nvfp4.py exits 0 in all three. 7 scorer cells (3 one-hot bit for bit, 4 dense within 2e-3 + 1e-4 |ref|, one of them with the score and the table narrower than a request; 0 mismatches) and 16 fused top-16 cells (4 batches x 3 pin pairs and a chunk of 64) equal to the Triton selection of the scorer's scores. The test file is the same at this head.
  • This head against 08332a5, gfx1250 compile-only on a CPU host: the final ISA of the scorer and of the fused build at pins (0,1), (2,3), (0,0) is byte-identical once the kernel name is normalised (4 / 4). The head only removes the keywords and the branches they selected.
  • At this head, CPU host with the launch stubbed (script not committed): 30 scorer and 26 fused bad inputs raise ValueError before any build is compiled; 7 inputs that must be served are (4 launch, 3 return without a launch).
  • MI455X at 587be47, script not committed: the three-build timing in Performance, and the 8 B-offset scale view of "Review answers".
  • At this head: ruff check --no-cache (0.16.0) and black --check (26.10.1) clean on the five files of this PR. The two shared files are byte-identical to those at [FlyDSL] gfx1250 MiniMax-M3 decode indexer over the NVFP4 index cache: flat-plan scorer + top-k #8817's head 123e5f0.
  • Unverified: gfx1250 has no CI run of this test (on other GPUs it runs the refusal check and logs a skip); ATOM end to end with this head was not run; callers that passed the removed keyword arguments must drop them; the second-device cell did not run (one GPU visible); the row and block thresholds of index_topk_prefill_nvfp4_preferred come from an earlier revision and were not re-measured; a scale page stride of 8 mod 16.

PR-specific question

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?

  • op_tests/test_flydsl_index_score_prefill_nvfp4.py: before this PR the ops do not exist, so on gfx1250 the test fails at from aiter.ops.flydsl.index_score_prefill import index_score_prefill_nvfp4. No existing test covers them: test_flydsl_minimax_m3_index_score.py and test_flydsl_minimax_m3_index_score_prefill_fp4.py test the gfx950 MFMA scorers, which do not run on gfx1250.

Changed op tests

  • op_tests/test_flydsl_index_score_prefill_nvfp4.py (new, 247 lines)
    • Covers: the whole score tensor against an FP32 reference computed on the CPU. The scorer writes into a NaN-filled, strided, over-long view with a guard row and guard columns and reads a strided idx_q, so an entry it must not write has to stay NaN and a masked block has to be -inf. One-hot Q rows (values past +-448, +-inf, and one that is not E4M3) make each dot one product, which the WMMA returns exactly, so they must match bit for bit; dense rows must be within 2e-3 + 1e-4 |ref|. Cases: one request; a ragged batch that ends on an empty request, also with a score and table narrower than a request; 3 index heads over views of one [pages, 9216] page array; one cell on a second device when there is one. The fused op's 16 largest keys per row must equal, in order, the Triton top-16 of the scorer's scores (ties and zero rows included). A refusal check with the arch faked runs on any GPU: four bad inputs must raise before a launch.
    • Not redundant: it is the only test of these ops and this kernel.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu 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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 8458 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

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 stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…corer on the FP4 index cache (opt-in)

ATOM_M3_INDEX_SCORE_FLYDSL_PREFILL=1 (default off). On gfx1250 with the FP4
index cache (--index-cache-dtype fp4), the prefill indexer's block scores
come from aiter's index_score_prefill_nvfp4 (ROCm/aiter#8458) instead of
the Triton _index_block_score_kernel. This applies to prefills of at least
ATOM_M3_INDEX_SCORE_FLYDSL_MIN_ROWS rows (default 2048), where aiter's
predicate serves the call. The scorer writes the same score tensor, which
the selection then reads unchanged.

Every dot is the same scaled WMMA, so the scores and the top-k are bit for
bit the Triton kernel's; only the data movement differs (tensor-DMA pages,
16 B LDS operand reads). MI455X, one TP4 rank, 14336 new tokens on 99968
cached: 97 us against 172 (score + select + emit: 141 against 216). Short
prefills (300 rows) run 2-4 us slower than Triton, hence the row bound.

tests/test_minimax_m3_index_topk.py (CPU): the gate (flag, row bound, FP4
cache, aiter's predicate), and the FlyDSL scorer writing the score tensor
the selection reads with the Triton kernel not launched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lirui927
lirui927 force-pushed the xiaobingsuper/gfx1250-index-score-prefill-nvfp4 branch from 2a3de7d to ca82d01 Compare November 23, 2026 07:17
@lirui927

lirui927 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

I brought this PR to merge standard and force-pushed the branch, which is now linear on main bf59948. The original commit is unchanged, and two commits are on top:

  • 42fcfaa: fixes the Ruff CI failure. That was RUF100 plus four B023s; page_max moves out of the loop, and base, unit and blk are passed explicitly. The wrapper now raises ValueError on non-int32 metadata, a tensor on another device, misaligned cache views or a too-small score (+2.8 us host time per call). The shared constants now come from minimax_m3_index_score. The test gets a __main__ entry so CI runs it, and it now covers the default 256:4:4 config.
  • ca82d01: drops the lds_scores=False direct-store path and its argument. It was never faster: 128.5 vs 93.7 us at 14336:99968, and within 0.5 us elsewhere. ATOM#3713 does not pass lds_scores.

On gfx1250, the kept configs compile to byte-identical ISA before and after both commits. MI455X: this test 13 passed, test_flydsl_pa_decode_nvfp4.py 34 passed, and kernel time is unchanged (93.7 / 30.5 / 30.4 us). The merge commit for #8289 is replaced by #8289's head cherry-picked as is, so this PR still depends on #8289 (_wmma_scale16). The full notes are in the updated description. The two remaining minor items (the idx_q over-read for a trailing zero-length request, and the 32-bit score stride) are being fixed next.

XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…corer on the FP4 index cache

With the FP4 index cache, a prefill of at least 2048 rows takes its block
scores from aiter's index_score_prefill_nvfp4 (ROCm/aiter#8458) whenever
aiter's predicate serves the call (gfx1250 and its shapes), instead of the
Triton _index_block_score_kernel. The scorer writes the same score tensor,
which the selection then reads unchanged.

Every dot is the same scaled WMMA, so the scores and the top-k are bit for
bit the Triton kernel's. MI455X, one TP4 rank, 14336 new tokens on 99968
cached: 97 us against 172 (score + select + emit: 141 against 216). Short
prefills (300 rows) run 2-4 us slower than Triton, hence the row bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lirui927
lirui927 force-pushed the xiaobingsuper/gfx1250-index-score-prefill-nvfp4 branch from ca82d01 to 3e38182 Compare November 23, 2026 09:03
@lirui927
lirui927 marked this pull request as ready for review November 23, 2026 09:03
@lirui927
lirui927 requested a review from a team November 23, 2026 09:03
@aiter-bot

aiter-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision ec0bb5e26933 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

- Adds the six entry points listed above (`aiter/ops/flydsl/index_score_prefill.py`), the gfx1250 kernel they launch, and two shared helper files: causal prefill block scores of index queries over an NVFP4 key cache, with the scaled WMMA reading the e2m1 payload and its E4M3 scales directly, and the same scorer fused with the top-16 selection.
- No existing op, kernel or dispatch changes; nothing calls the new ops unless a caller does.
- Why: aiter has no gfx1250 scorer for this cache; the existing NVFP4 prefill scorer is gfx950-only (see "Why a new op" above).

Validation and unverified scope

- MI455X (gfx1250), one GPU, FlyDSL 0.5.3, at this head, at 08332a514 and at 587be47af: `python3 op_tests/test_flydsl_index_score_prefill_nvfp4.py` exits 0 in all three. 7 scorer cells (3 one-hot bit for bit, 4 dense within `2e-3 + 1e-4 |ref|`, one of them with the score and the table narrower than a request; 0 mismatches) and 16 fused top-16 cells (4 batches x 3 pin pairs and a chunk of 64) equal to the Triton selection of the scorer's scores. The test file is the same at this head.
- This head against 08332a514, gfx1250 compile-only on a CPU host: the final ISA of the scorer and of the fused build at pins (0,1), (2,3), (0,0) is byte-identical once the kernel name is normalised (4 / 4). The head only removes the keywords and the branches they selected.
- At this head, CPU host with the launch stubbed (script not committed): 30 scorer and 26 fused bad inputs raise `ValueError` before any build is compiled; 7 inputs that must be served are (4 launch, 3 return without a launch).
- MI455X at 587be47af, script not committed: the three-build timing in Performance, and the 8 B-offset scale view of "Review answers".
- At this head: `ruff check --no-cache` (0.16.0) and `black --check` (26.10.1) clean on the five files of this PR. The two shared files are byte-identical to those at #8817's head 123e5f058.
- Unverified: gfx1250 has no CI run of this test (on other GPUs it runs the refusal check and logs a skip); ATOM end to end with this head was not run; callers that passed the removed keyword arguments must drop them; the second-device cell did not run (one GPU visible); the row and block thresholds of `index_topk_prefill_nvfp4_preferred` come from an earlier revision and were not re-measured; a scale page stride of 8 mod 16.

PR-specific question

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?
- `op_tests/test_flydsl_index_score_prefill_nvfp4.py`: before this PR the ops do not exist, so on gfx1250 the test fails at `from aiter.ops.flydsl.index_score_prefill import index_score_prefill_nvfp4`. No existing test covers them: `test_flydsl_minimax_m3_index_score.py` and `test_flydsl_minimax_m3_index_score_prefill_fp4.py` test the gfx950 MFMA scorers, which do not run on gfx1250.

Changed op tests

- `op_tests/test_flydsl_index_score_prefill_nvfp4.py` (new, 247 lines)
  - Covers: the whole score tensor against an FP32 reference computed on the CPU. The scorer writes into a NaN-filled, strided, over-long view with a guard row and guard columns and reads a strided `idx_q`, so an entry it must not write has to stay NaN and a masked block has to be `-inf`. One-hot Q rows (values past +-448, +-inf, and one that is not E4M3) make each dot one product, which the WMMA returns exactly, so they must match bit for bit; dense rows must be within `2e-3 + 1e-4 |ref|`. Cases: one request; a ragged batch that ends on an empty request, also with a score and table narrower than a request; 3 index heads over views of one `[pages, 9216]` page array; one cell on a second device when there is one. The fused op's 16 largest keys per row must equal, in order, the Triton top-16 of the scorer's scores (ties and zero rows included). A refusal check with the arch faked runs on any GPU: four bad inputs must raise before a launch.
  - Not redundant: it is the only test of these ops and this kernel.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

Copilot AI balanced review requested due to automatic review settings November 25, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lirui927
lirui927 force-pushed the xiaobingsuper/gfx1250-index-score-prefill-nvfp4 branch from 9868c4a to eb46d13 Compare November 25, 2026 12:01
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XiaobingSuper XiaobingSuper changed the title [FlyDSL] [Perf] gfx1250 MiniMax-M3 prefill index block scores over the NVFP4 index cache [FlyDSL] [Feature] gfx1250 prefill index block scores over an NVFP4 key cache Nov 26, 2026
@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

@lirui927 both items are fixed in 32309d6 and still hold at 07a98c3:

  • idx_q over-read: Q is loaded only inside the CTA's live branch (it has rows of its request and a block to score), so the CTAs of an empty last request never form a row address at idx_q's end; in live CTAs, rows past q_len read the request's first row. The ends_empty case ends the batch on an empty request.
  • 32-bit score stride: the score address is built in 64 bits from int32 stride arguments, and the input check now rejects a score with any stride >= 2^31 (max(score.stride()) < 2**31 in index_score_prefill_nvfp4_supported).

MI455X at 07a98c3: python3 op_tests/test_flydsl_index_score_prefill_nvfp4.py 6/6 passed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lirui927

Copy link
Copy Markdown
Contributor

Added on top of this PR (one commit, 81312a438): index_topk_prefill_nvfp4, the prefill scorer fused with the top-16 block selection.

  • Each workgroup keeps every row's 16 best blocks of its chunk as a list in LDS (the scores never reach memory) and writes them as ATOM's _pack_score_key keys; a row's chunks share a floor through one int64 column, so blocks under it are not tried. ATOM's merge picks the row's 16: the same selection as scorer + selector.
  • Scorer options that leave every score unchanged: fold_max (the WMMA's 8 values folded straight into the running max, v_max3 only) and pad_lds (80-byte LDS rows: no 4-way bank conflict on the A-operand loads); fused-op option sel32 (the selection pass on 32-bit compares). The fused op defaults to the fastest measured build (fold_max, pad_lds, sel32, ring 3, chunk from the grid via index_topk_prefill_chunk_blocks).
  • index_topk_prefill_nvfp4_preferred (>= 8192 rows and >= 1024 blocks) says where the fused op beats scorer + selector; index_topk_prefill_nvfp4_supported reuses the scorer's input checks (_inputs_supported).

MI455X, 32K-row chunk, 4 index heads, top-16 identical to the reference, 0 wrong rows:

case scorer + Triton selector fused
384K 4007 us 2394 us (-40%)
600K 6584 us 4025 us
8K rows x 600K 1612 us 1117 us

Short chunks (2K rows, or 50K context) stay on scorer + selector by the preference (319 -> 273 us and 474 -> 401 us there with the new scorer options).

Host: the fused build's gfx1250 ISA is instruction for instruction the build validated on MI455X; 8 scorer / fused builds compile; ruff 0.16 + black clean. python op_tests/test_flydsl_index_score_prefill_nvfp4.py adds the options' bitwise check and the fused op against the scorer + a torch model of ATOM's selector (ties, zero rows, pins). The ATOM caller is in ROCm/ATOM#3713, whose default-on needs this commit first.

XiaobingSuper and others added 2 commits November 30, 2026 08:21
…e NVFP4 index cache

aiter.ops.flydsl.index_score_prefill.index_score_prefill_nvfp4: the
MiniMax-M3 prefill indexer's block scores on gfx1250. The index cache is
the NVFP4 one: e2m1 payload [pages, 128, 64] plus an E4M3 scale per 16
values [pages, 128, 8], each with its own page stride.

score[h, r, blk] is the max, over the block's keys at or before row r's
position, of e4m3(clamp(q)) . dequant(K), times sm_scale * log2(e). It is
written exactly where and how the Triton prefill scorer writes it. Every
dot is the 128-deep scaled WMMA (_wmma_scale16, a copy of the pa_decode
NVFP4 pipeline's helper until that pipeline lands on main). Pages arrive by
tensor DMA into an LDS ring (`ring` pages in flight), and operands are read
from LDS 16 B at a time. A CTA scores block_q rows (`waves` waves). With
lds_scores, each row's chunk of at most CHUNK_MAX blocks goes out in one
coalesced store.

index_score_prefill_nvfp4_supported() accepts gfx1250 and the cache shapes
above only.

MI455X, MiniMax-M3.1 TP4 rank, 14336 new tokens on 99968 cached: 97 us
against 172 us for the Triton scorer (score + select + emit 141 vs 216 us),
the scores bit for bit the Triton scorer's. Short prefills (300 rows) are
2-4 us slower, so callers use it from about 2048 rows.

op_tests/test_flydsl_index_score_prefill_nvfp4.py checks it against an
FP32 torch reference (about 2e-3 relative: the WMMA's internal sum is not
FP32-exact), for ragged batches, chunked prefixes and two CTA shapes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…I entry

- Bind page_max's per-page inputs (base, unit, blk) as arguments instead of
  closing over loop variables (ruff B023), drop an unused noqa (RUF100) and
  the debug-only store probe. The gfx1250 ISA of all four compiled
  configurations is byte-identical to before.
- Take PAGE, HEAD_DIM, LOG2E and the NVFP4 row sizes from the MiniMax-M3
  index scorer module instead of restating them.
- The wrapper passes every tensor as a bare pointer, so it now raises
  ValueError unless index_score_prefill_nvfp4_supported holds (which also
  checks 16-byte aligned cache views), every tensor is on idx_q's device, the
  four metadata tensors are int32 and score is [heads, >= total_q, *] fp32.
  An int64 seq_lens used to be read as int32 pairs. Host cost: +2.8 us a call.
- Test the wrapper's default shape and the direct-store path, add a rejection
  case, and give the file a __main__ so CI's `python3 <file>` runs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lirui927 and others added 7 commits November 30, 2026 08:21
… score store

The scores always go out through LDS in coalesced row chunks; the
lds_scores=False path (one 4-byte global store per block and row) is gone with
its wrapper argument. It was never faster: MI455X, one head, median of 20 x 50
launches, LDS-staged against direct stores (chunk 32 / 128):

  14336 new rows on 99968 cached:  93.7 us vs 128.5 / 139.6 us
  300 rows on 99968 cached:        30.6 us vs  31.3 / 109.1 us
  2048 rows on 30000 cached:       30.4 us vs  29.9 / 108.7 us
  300 rows, no prefix:             16.3 us vs  16.2 / 16.2 us (host bound)

The kept kernels compile to the same gfx1250 ISA as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, bound the score stride

- Q is loaded inside the CTA's live branch. A dead CTA of an empty request
  that ends the batch used to form a row address at idx_q's end; the compiled
  kernel had already sunk the loads past the exit branch, so this makes the
  source say what the ISA did. Same VGPR/SGPR counts, no scratch, same load
  and WMMA counts; only scheduling differs.
- The wrapper rejects a score whose per-head stride exceeds int32, the
  kernel's stride argument type. That is 8 GiB of scores per head, so a host
  check is cheaper than 64-bit stride arguments and costs nothing in the
  kernel.
- The ragged op-test case ends on an empty request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atch extents and wave count

The wrapper hands the kernel bare pointers, and three inputs it accepted
were read wrongly without an error:

- scale of any dtype with a [pages, 128, 8] shape (FP32 scales were read
  as E4M3 bytes): the supported check now takes uint8 or float8_e4m3fn;
- seq_lens, prefix_lens or block_table shorter than the batch
  cu_seqlens_q describes (read past their end);
- waves=1: wave 0 copies a page's payload and wave 1 its scales, so a
  one-wave CTA scored against scales nobody loaded.

chunk_blocks < 1 and a non-positive or non-finite sm_scale are refused
too: the kernel takes the block max before the scale, which equals
Triton's scale-then-max for a positive scale only.

The docstring names what only the device can see and so stays the
caller's to guarantee (cu_seqlens_q, max_query_len, block_table and
score covering each request's blocks), and says block_q-row tile where
it said 256-row.

Host-side only: the gfx1250 ISA of the three tested configurations is
byte-identical to the previous commit's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… score

The op test could pass with the scorer broken, and could fail with it
right:

- one index head only: dropping the head from the Q or the score address
  passed 13/13;
- |Q| below ~12: removing the +-448 clamp passed 13/13;
- only the causally valid scores were compared: the -inf of masked
  blocks and the entries the scorer must leave alone were not;
- torch.randperm was unseeded, so the pages differed from run to run,
  and the tolerance was relative to max(|ref|, 1e-3), which is tightest
  where a score happens to be near zero.

Now the reference is the whole score tensor (NaN where nothing may be
written, -inf where the block is past the row), for 1-3 heads, with
requests that are empty first and last, a tile boundary inside a page,
the cache as two tensors or as views of one [pages, 9216] page array,
and a 128-row / 2-wave / 2-page-ring CTA next to the 256-row ones.

Two kinds of Q. One-hot rows (values past +-448, +-inf, and one that is
not E4M3) make each dot a single product, which the scaled WMMA returns
exactly: those scores must be bitwise the reference's. Dense rows keep a
tolerance, now absolute plus relative (2e-3 + 1e-4 |ref|; the WMMA's
128-term sum was within 5.3e-4 of FP32's on MI455X for scores up to 27).

The reject case adds an FP32 scale, a short prefix_lens and waves=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test

- index_score_prefill_nvfp4_supported takes the op's first nine arguments
  and is the only place the inputs are checked; the op raises ValueError
  when it is False. It keeps what the kernel assumes of the bare pointers
  and int32 strides: gfx1250; bf16 Q with a contiguous 128-dim; both cache
  views as 1-byte [pages, 128, row] with contiguous, 16 B aligned pages
  (one tensor DMA a page); every tensor on Q's device; int32 metadata with
  a unit inner stride (now also for the three length vectors), covering the
  batch; an fp32 [heads, >= total_q, *] score with a unit block stride and
  int32 strides; a positive finite scale. chunk_blocks is a work split, so
  it is clamped to [1, CHUNK_MAX] instead of checked.
- The op, the kernel and the CHUNK_MAX comment describe what is computed
  instead of naming a model, an inference engine or its Triton kernel.
  The kernel's code is unchanged (same AST without docstrings).
- One op test against the FP32 torch reference (three request layouts,
  one-hot rows bitwise and dense rows within the WMMA tolerance, the
  wrapper default config). The reference runs on the CPU, so the test
  launches no GPU GEMM of its own. Drops the block_q/waves/ring variant
  sweep and the input validation and mocked gate tests; the GPU cases call
  the op, so they go through the check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ck selection

`index_topk_prefill_nvfp4`: the prefill scorer and ATOM's top-16 block
selection in one launch. Each workgroup keeps every row's 16 best blocks of
its chunk as a list in LDS (the scores never reach memory) and writes them as
ATOM's `_pack_score_key` keys; a row's chunks share a floor so blocks under it
are not tried. ATOM's merge then picks the row's 16: the same selection as the
scorer + Triton selector, index for index.

Also on the scorer (same scores): `fold_max` (the 8 values of a WMMA folded
straight into the running max, v_max3 only) and `pad_lds` (key rows 80 bytes
apart in LDS: no 4-way bank conflict on the A-operand loads); on the fused op
`sel32` (the selection pass on 32-bit compares). The fused op defaults to the
fastest build measured (fold_max, pad_lds, sel32, ring 3, chunk from the grid:
`index_topk_prefill_chunk_blocks`). `index_topk_prefill_nvfp4_preferred` says
where it beats the two launches (>= 8192 rows and >= 1024 blocks).

MI455X, 32K-row chunk, 4 index heads, against the scorer + ATOM's Triton
selector, top-16 identical, 0 wrong rows: 384K 4007 -> 2394 us, 600K 6584 ->
4025 us, 8K rows x 600K 1612 -> 1117 us.

The fused build's gfx1250 ISA is instruction for instruction the GPU-validated
one of the M3.1 image branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds write

A build with a smaller block_q writes the -inf blocks past a row's own only
up to its own tile's last row, so its NaN pattern differs from the default
build's for every request longer than one tile (ends_empty and paged_3h
with block_q=128 failed). Compare where the scores are finite and every
entry the option build writes instead; the scores themselves are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-index-score-prefill-nvfp4 branch from 81312a4 to 0955ffa Compare November 30, 2026 08:32
Copilot AI balanced review requested due to automatic review settings November 30, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

Rebased onto main (head 0955ffabb). This PR no longer carries #8289's pa_decode commits: its diff is now only the scorer's three files (aiter/ops/flydsl/index_score_prefill.py, aiter/ops/flydsl/kernels/index_score_prefill_nvfp4_gfx1250.py, op_tests/test_flydsl_index_score_prefill_nvfp4.py). The only thing it used from #8289 was the _wmma_scale16 scaled-WMMA helper, now copied unchanged into the kernel file until the pa_decode NVFP4 pipeline lands with #8365 or #8819. On MI455X the rebased scorer's outputs are bit-identical to the previous head 81312a438, and the fused top-16 keys are identical.

@lirui927 your commits are kept as they were (authorship included). One test fix on top: test_index_score_prefill_nvfp4_opts now compares only the blocks both builds write. A smaller block_q writes fewer -inf blocks past a row's own, so ends_empty / paged_3h failed at 81312a438, and the script stopped before the fused top-16 cases. The whole op test now passes 37 / 37.

For ATOM: index_score_prefill_nvfp4_supported() still takes the op's first nine arguments, and index_topk_prefill_nvfp4_supported() takes ten (no score, plus topk and max_block).

… device

Both launches run under `with torch.cuda.device(dev)`, as the gfx950
prefill scorer and the other device-keyed launchers do, so a call with
tensors on a non-current GPU compiles and launches on that GPU.

The fused top-16 docstring now states that the output is not initialised
and the caller masks a row's chunks past ceil(blocks / chunk_blocks)
before taking its 16 largest keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

review-pr scan (aiter's .claude/skills/review-pr, at 0955ffabb, auto-validation off, no GPU).

Fixed in 26e57d0dc: both _run_compiled launches in index_score_prefill.py (:145, :329) now run under with torch.cuda.device(dev), as the gfx950 prefill scorer does, so a call with tensors on a non-current GPU compiles and launches there. The fused top-16 docstring (:282-288) now states the caller contract the test already follows: the output is not initialised, and the caller masks the chunks past a row's own. Behaviour is unchanged. On one MI455X the op test passes; scores are byte-identical to the previous head, and every row's top-16 selection matches.

review-pr card

aiter PR #8458 — [FlyDSL] [Feature] gfx1250 prefill index block scores over an NVFP4 key cache

Adds a new gfx1250-only FlyDSL op that computes causal prefill index block scores over an NVFP4 key cache with scaled WMMA, plus a fused variant that keeps each row's top-16 blocks in LDS instead of writing the scores.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0, no GPU used); the target op_tests/test_flydsl_index_score_prefill_nvfp4.py exists and is gfx1250-only (it logs a skip on other GPUs, and no CI runner is gfx1250)
Perf (advisory): NOT RUN — auto-validation disabled, no GPU used; the PR adds the target, so base has nothing to time, and the PR's MI455X figures (93.5 / 31.2 / 30.9 us) name no baseline
Size: 1304 lines / 3 files — over the review bar
Design (advisory): SPLIT — (1) the scorer: index_score_prefill_nvfp4 + _supported, the non-select kernel build and its tests; (2) the fused top-16: the select/sel32 kernel branches, index_topk_prefill_nvfp4 + helpers and its test, stacked on (1)
Human: recommend Pleaplusone review whether aiter#8458 should add a separate gfx1250 op index_score_prefill_nvfp4 rather than a gfx1250 backend of score_prefill_flydsl_nvfp4, and whether the fused top-16's cross-CTA floor in keys column 0 is the selection contract ATOM wants

⚠️ [inferred] index_score_prefill.py:145 and :326 launch through _run_compiled without with torch.cuda.device(dev), while the gfx950 sibling scorer (minimax_m3_index_score_prefill.py:2560) and the other dev.index-keyed launchers on main wrap their launch in that guard — a call with tensors on a non-current GPU (single-process multi-GPU tests or tuners) may compile and launch under the wrong device and leave the scores unwritten. Author must wrap both launches in with torch.cuda.device(dev):.
📝 [verified] index_score_prefill.py:310 allocates keys with torch.empty, and CTAs whose chunk starts past their tile's last block exit without writing (live in index_score_prefill_nvfp4_gfx1250.py:255), so "the 16 largest keys of a row are its selection" holds only after masking chunks at or past ceil(blocks / chunk_blocks), as the test does at line 213 — a caller that takes top-16 over the whole row picks garbage whenever a row's tile ends before max_block (any ragged batch, and every earlier tile of a long prefill). Reviewer should ask whether the ATOM consumer masks those chunks, or whether the docstring should state the masking as a requirement.

lirui927 and others added 6 commits December 2, 2026 07:23
…lpers with the decode indexer

The scaled WMMA, the E8M0 scale operand, the selection pins and sm_scale_log2e
come from kernels/index_nvfp4_gfx1250.py, added here byte-identical to
ROCm#8817 together with index_nvfp4.py (the host side); the copy of
pa_decode's `_wmma_scale16` and the duplicate E4M3_MAX go. The two ops' launch
blocks become one `_launch`; the builder returns the launcher; the stale
`_lds32` name suffix goes.

Every build is byte-identical to 26e57d0 (whole gfx1250 code object, kernel
name normalised): the scorer (256/4/4 and 128/2/2 fold_max pad_lds) and the
fused build at pins (0,1), (2,3), (0,0), plain and 512x8; the launch arguments
are unchanged. Not run on a GPU.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…kernel, complete the input check

Needs a GPU run: the kernel takes one more argument and 64-bit score strides,
and the launch goes through the shared helper.

- The kernel clamps a request's blocks to a new `max_block` argument: what the
  score (or the fused op's `max_block`) and a block-table row both hold. A
  `seq_lens` longer than those no longer reads the table or writes a score row
  past its end.
- `_inputs_supported` is the shared cache predicate (new: payload and scale
  have the same page count, ranks checked first) plus the scale view's 16 B
  alignment, the int32 metadata with their ranks (block_table 2-D, the three
  others 1-D, cu_seqlens_q not empty) and one int32 bound for the int32
  strides and the table index.
- The score / key strides are 64-bit kernel arguments, so the
  `max(score.stride()) < 2**31` refusal goes.
- The scorer returns for no blocks or `max_query_len <= 0`; `chunk_blocks < 1`
  raises in both ops (the scorer still clamps to CHUNK_MAX);
  `sm_scale_log2e` is evaluated once a call.
- Launch through the shared `launch` (`current_stream_arg`).

ISA against 26e57d0: kernarg 104 -> 116 B, one more `s_min_i32`, the strides'
sign extensions go (scorer 4653 -> 4462 instructions, fused 3430 -> 3438); LDS
and VGPR counts unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…lock bound and the layout

Test (251 -> 247 lines):
- the scorer writes into a strided, over-long view of a NaN buffer with a
  guard row and guard columns, and reads a strided idx_q;
- one cell where the score and the block table hold fewer blocks than a
  request has (views, so nothing is out of bounds): nothing past them is
  written;
- one cell on a second device when there is one;
- one small check that four bad inputs are refused before anything is
  compiled (arch faked, so it runs on any GPU);
- `-c` selects the top-k cases too, a `gfx` column.
The build-option cases go (`_opts`, TOPK_OPTS): the fused test keeps a
`chunk_blocks` pair (default and 64).

Kernel: comments at the raw readfirstlane and at `_Lds`. ISA unchanged.

Not run on a GPU.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… the op and its kernel

As main's other MiniMax-M3 index FlyDSL files and the two shared files carry.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…early return for the fused op

The fused op's block bound is stated once, in the predicate it and its
_supported share, and refuses a negative max_block (ValueError). It returns
without a launch in the scorer's cases, max_query_len <= 0 included. The
query's head offset is computed in 64 bits, as the rest of the address. The
scale alignment comment says what was measured.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Faster on every measured shape on MI455X (e.g. 14336:99968 315 -> 265 us), same scores.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
lirui927 pushed a commit to lirui927/aiter that referenced this pull request Dec 2, 2026
…are the NVFP4 index helpers

Remove what no caller reaches: the scorer's per-request plan (`flat`, the 2-D
grid, `decode_score_programs`, the 64-block window), its `ring` parameter
(RING = 4), the op's `workgroups`, the selector's one-wave build (`waves`), and
the builders' unread "kernel" entry (they return the launcher).

What the decode and the prefill index kernels share moves to two files that are
byte-identical in ROCm#8458: kernels/index_nvfp4_gfx1250.py (the scaled
WMMA, the E8M0 scale operand, the pins, sm_scale_log2e) and index_nvfp4.py (the
cache predicate, the int32 metadata rule, the launch).

Every build the ops launch is byte-identical to ddc4c43 (whole gfx1250 code
object, kernel name normalised): the scorer at h4q8 / h4q1 / h1q8 / h5q3 and the
selector at 11 (width, top-k, emit) builds. Not run on a GPU.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
No caller passes block_q / waves / ring / fold_max / pad_lds / sel32, and
the defaults are the builds measured fastest on MI455X. The scorer and the
fused top-k op now build one kernel each (256 rows over 4 waves; ring 4 and
3), the constexpr branches of the other values are gone, and
index_topk_prefill_chunk_blocks takes no launch keywords.

The gfx1250 ISA of the scorer and of the fused build is unchanged (kernel
names aside, which no longer carry the options).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lirui927

lirui927 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

review-pr scan (aiter's .claude/skills/review-pr from main a9fb0c157, at head ec0bb5e2693395b8232c67db5974cda9a36c342a, merge target 0dbaa95c4, auto-validation off, no GPU used by the scan).

  • Deterministic part (fetch.sh, triage.py): 25 of 68 rules derived for this diff, 24 clear or not applicable, 1 fired (no base-vs-head timing: the PR adds the test target, so main has nothing to time). The diff applies to the merge target, every first-party import resolves, no guard is deleted, no FlyDSL buffer bound and no AOT pairing gap is reported, and the new test lands where a CI job collects it. All eight gates pass (answers, diagnostic, core files, ledger, card, refutations, independent reader 4 / 4 defended, design).
  • Fired by the description on the first pass, fixed in the description: three timing rows that named no comparison, and a self-review revision behind the head.
  • Fired by the code, not changed in this revision: the four findings in the card (two should-fix, two notes).
  • Closed since the scan at 0955ffabb: the block range is clamped in the kernel to what the score and a table row hold; payload and scale page counts and the block_table rank are checked; the refusals, a strided over-long score and a second-device cell are in the op test; the unused build variants and their keywords are gone.
review-pr card

ROCm/aiter PR #8458 — [FlyDSL] [Feature] gfx1250 prefill index block scores over an NVFP4 key cache

Adds gfx1250-only FlyDSL ops that score prefill index queries against an NVFP4 key cache block by block with the scaled WMMA, plus a fused build of the same kernel that keeps each row's 16 best blocks per chunk in LDS and returns selection keys instead of scores.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — auto-validation is disabled (REVIEW_AUTO_VALIDATE=0) and no GPU was used by this scan; the target op_tests/test_flydsl_index_score_prefill_nvfp4.py exists, so this is an environment gap, not a PR defect (the test is gfx1250-only and no CI runner is gfx1250; the PR's own MI455X run is one commit before this head)
Perf (advisory): NOT RUN — auto-validation is disabled, no GPU; the PR adds the target, so base has nothing to time; the description's three-build scorer table is the PR's own measurement at 587be47
Size: 1316 lines / 5 files — over the review bar
Design (advisory): SPLIT — (1) the two shared helper files (index_nvfp4.py, kernels/index_nvfp4_gfx1250.py), which aiter#8817 adds byte-identical; (2) the scorer: index_score_prefill_nvfp4 + index_score_prefill_nvfp4_supported, the non-select build and its test cells; (3) the fused top-16: the select branches, index_topk_prefill_nvfp4 with its helpers and test, stacked on (2)
Human: recommend Felix Li review whether aiter#8458 should carry index_score_prefill_nvfp4 as a separate gfx1250 op with its own contract rather than a gfx1250 backend of score_prefill_flydsl_nvfp4, and whether the unsynchronised per-row floor in keys column 0 of index_topk_prefill_nvfp4 is an acceptable selection contract

⚠️ [verified] op_tests/test_flydsl_index_score_prefill_nvfp4.py would still pass with parts of the fused op reverted: test_index_topk_prefill_nvfp4 (:147-187) always passes a block_table as wide as max_block, so the bound min(max_block, block_table.shape[1]) at aiter/ops/flydsl/index_score_prefill.py:328 is never exercised for the select build; no committed case calls index_topk_prefill_nvfp4_supported, passes max_block 0 or above 0xFFFF (:241), or expects a ValueError from the fused op (check_refusals at :190-213 feeds four inputs to the scorer only); and the scorer's second-device cell (:232) runs only with two visible GPUs. A regression in the fused op's bound or refusals would go unseen; the fused kernel runs on gfx1250 only, while a refusal added to check_refusals would run on any GPU. Author must add one fused cell with a table narrower than max_block and one fused refusal, and run the file once with two GPUs visible.
⚠️ [inferred] aiter/ops/flydsl/index_score_prefill.py:215-226 sets TOPK_PREFERRED_MIN_ROWS = 8192 and TOPK_PREFERRED_MIN_BLOCKS = 1024 from fused-against-two-launch timings (2897 vs 3370 us and the rest) that the comment itself says were taken with a scorer of 128 rows, 2 waves and a ring of 2, a build this head no longer has (the comment reconciles two scorer-alone points with today's build, within 3%, not the fused-against-two-launch crossover); no script or log in the PR produces them. If the crossover moved with the 256-row build, index_topk_prefill_nvfp4_preferred steers a caller to the slower of the two indexers near the thresholds. Author must re-measure the crossover rows at this head (or state the revision and script of each number) before the thresholds are relied on.
📝 [inferred] Earlier revisions of this PR took block_q / waves / ring / fold_max / pad_lds / sel32 on both ops and **_launch on index_topk_prefill_chunk_blocks; aiter/ops/flydsl/index_score_prefill.py at this head takes none of them, so a consumer written against the PR branch that passes one raises TypeError at call time. Nothing on main is affected. Reviewer should ask which ATOM revision calls these ops and whether it passes any removed keyword.
📝 [verified] aiter/ops/flydsl/kernels/index_score_prefill_nvfp4_gfx1250.py:47 imports the private _gptr from pa_decode/op_lds.py and :84-94 subclasses Gfx1250Memory without calling its constructor, setting only base and a one-field traits stand-in; a pa_decode change to what those five accessors read breaks this kernel at trace time, and by the description gfx1250 has no CI run of the one test that compiles it. Reviewer should ask whether the five borrowed LDS / tensor-DMA accessors should move to a shared helper in a tracked follow-up.

This branch has not been deployed

No deployments
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