Skip to content

[FlyDSL] [QSA] Sparse prefill follow-ups: runtime softmax scale, shared helpers, opt-in batch invariance - #8148

Merged
zufayu merged 2 commits into
ROCm:mainfrom
luocheng25:luocheng/qsa-prefill-followups-v2
Nov 19, 2026
Merged

zufayu merged 2 commits into
ROCm:mainfrom
luocheng25:luocheng/qsa-prefill-followups-v2

Conversation

@luocheng25

@luocheng25 luocheng25 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-ups to #6576 (QSA sparse prefill attention for MI308X), addressing its non-blocking review notes:

  1. The softmax scale is a runtime kernel argument instead of a compile-time constant.
  2. The QK, PV and rescale code and the direct key loop are defined once and shared.
  3. The kernels use FlyDSL's stable API. What has no stable equivalent is gathered in one section of sparse_prefill_common.py, each item with the reason it stays.
  4. The non-MI308X warning states what is reused, and group 16 (the largest group the interface accepts) is tested.
  5. qsa_sparse_prefill gains an opt-in batch_invariant=True mode that makes every request's output independent of the other requests in the batch. The default behavior is unchanged.
  6. The Triton QSA code copied from SGLang into the op test keeps SGLang's Apache-2.0 notice.

qsa_sparse_prefill only gains the trailing keyword-only batch_invariant=False.

Motivation

  • Compile-time scale. Every new softmax_scale recompiled all kernels (several seconds each), and graph capture with an unseen scale raised.
  • Duplicated code. _qk/_pv existed three times and _rescale twice; the direct and direct-packed main loops were about 80% the same.
  • Low-level dependencies. flydsl._mlir APIs, empty inline asm and hand-counted lgkmcnt waits were spread over the kernel files.
  • Batch-dependent rounding. Union tiles and the direct kernel round differently, and the choice between them is made for the whole call: union tiles are planned by the call's row count, the tile rows by its first request, and K3 routes over all tiles. The low bits of a request's rows can change with the other requests in the call, and callers that need determinism (SGLang's --enable-deterministic-inference) had no way to avoid it.

Changes

  • Runtime softmax scale. The kernels take SCALE_LOG2: fx.Float32, computed on the host and rounded once to FP32 (the value the constant had). It is no longer part of the compile or workspace key. The union kernel keeps it in a VGPR with an empty-asm pin: left in an SGPR, the scale makes the union kernel spill 12 SGPRs and calls up to 4.4% slower (prefill 4096, H12).
  • Shared code. _rescale, _read_q_g2r, _qk and _pv_step live in sparse_prefill_common.py; the direct and direct-packed kernels share their key loop.
  • Stable FlyDSL API. Kernel files no longer import flydsl._mlir. The low-level section of sparse_prefill_common.py holds the empty-asm register pins, the -packed-fp32-ops target feature, the ROCDL operations FlyDSL does not export, volatile LDS reads and the LdsQueue ledger that replaces hand-counted lgkmcnt waits. FP32-to-BF16 conversion stays the simplified round-to-nearest-even (bits + 0x7FFF + lsb, high halves joined by v_perm_b32), without inline asm.
  • batch_invariant=False, a new trailing keyword-only argument.
    • The default keeps the call-wide decisions: main's plans, routes and bits. The docstring states that the low bits may then depend on the other requests of the call.
    • With batch_invariant=True the decisions are taken per request: only requests of at least the union planning rows take union tiles, each request picks its own tile rows (BQ21/BQ42 for a full H6/H3 prefill; union compiles for the widest), and K3 routes no tile by the others. A request then gives the same bits alone as in any batch.
    • In both modes, a layout whose union scratch would exceed 4 GiB (about a million rows) runs direct only, as the docstring states.
    • The workspace cache key includes the mode.
  • Non-MI308X warning. "QSA sparse attention is tuned only for MI308X (gfx942, 80 CUs); this gfx942 has %d CUs and reuses the 80-CU MI308X settings: plans and routes follow the CU count, performance may not be optimal". The entry docstring says the same.
  • Tests. Group 16, runtime-scale graph and batch-invariance rows in op_tests/test_flydsl_qsa_sparse_prefill.py, and the SGLang notice (see Changed op tests).

Performance (if applicable)

GPU time of one qsa_sparse_prefill call: the profiler's span from the first kernel's start to the last kernel's end, with the GPU kept busy while the call is queued (host time hidden). MI308X (gfx942, 80 CUs), FlyDSL 0.5.0, one KV head, T = 512; identical CPU-generated inputs. Each tree and mode runs in its own process and repeats the call (warm caches): median of 20 samples per process and of 3 alternating rounds. K/V are BF16.

Default mode, main (66be4f6d2) vs this PR; the outputs are bitwise equal:

Hardware Workload/configuration Before (µs) After (µs) Change
MI308X prefill 4096, H12 670.7 670.1 −0.1%
MI308X prefill 12000, H12 2463.7 2465.1 +0.1%
MI308X prefill 12000, H3 1063.9 1060.5 −0.3%
MI308X prefill 32768, H6 6576.1 6571.4 −0.1%
MI308X 1024-row chunk after 131072 tokens, H12 288.3 285.6 −1.0%
MI308X 4096-row chunk after 126976 tokens, H6 493.4 492.7 −0.1%
MI308X one 256-row extend after 8192 tokens, H3 113.1 113.2 +0.1%
MI308X one 256-row extend after 8192 tokens, H12 119.1 118.8 −0.3%
MI308X one 128-row extend after 16384 tokens, H6 104.9 104.9 +0.0%
MI308X 5 requests (300/1024/0/64/1001 rows), H12 133.6 133.0 −0.5%
MI308X 12000-row prefill + 64- and 128-row extends, H3 1383.1 1377.9 −0.4%
MI308X two 2048-row prefills, H6 226.0 225.0 −0.5%
MI308X 8 × 256-row extends after 2k–16k tokens, H3 141.6 141.1 −0.4%

batch_invariant=True (opt-in), relative to the default mode of this PR:

Hardware Workload/configuration Default (µs) batch_invariant=True (µs) Change
MI308X single prefills (4096 and 12000 rows at H12, 12000 at H3, 32768 at H6), the 4096-row chunk at H6, single 128/256-row extends — — −0.2% to +0.4%
MI308X 12000-row prefill + 64- and 128-row extends, H3 1377.9 1175.6 −14.7%
MI308X two 2048-row prefills, H6 225.0 193.7 −13.9%
MI308X 5 requests (300/1024/0/64/1001 rows), H12 133.0 144.7 +8.8%
MI308X 1024-row chunk after 131072 tokens, H12 285.6 377.7 +32.3%
MI308X 8 × 256-row extends after 2k–16k tokens, H3 141.1 678.4 +380.9%
  • Default mode: within −1.0% to +0.1% of main on every layout.
  • batch_invariant=True: per-request tile rows make batches with a full prefill 14–15% faster. Without call-wide routing, a long-context chunk runs every proposed tile union (+32%), and requests below the union planning rows run direct, so a batch of short extends, which the default mode runs union, takes 4.8 times as long. This is why it is opt-in.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI300X

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. qsa_sparse_prefill only gains the trailing keyword-only batch_invariant=False, and default-mode outputs are bitwise unchanged.

PR Self-Review

Reviewed revision

40a96a6364b33261c184518c777dc220aedfa199

Behavior and intent

  • The default behavior is unchanged: main's plans, routes and bits.
  • batch_invariant=True gives batch-invariant outputs for callers that need determinism, such as SGLang's --enable-deterministic-inference. It is not the default because per-request decisions make some batches much slower (see Performance).
  • A new softmax scale compiles nothing and can be graph-captured directly.
  • Code structure. Shared QK/PV/rescale helpers and one low-level section replace per-kernel copies and scattered flydsl._mlir uses.

Validation and unverified scope

MI308X (gfx942, 80 CUs), FlyDSL 0.5.0.

  • python op_tests/test_flydsl_qsa_sparse_prefill.py: all rows pass, 238 checkAllclose comparisons, none skipped. With CU_NUM=304 (the plans of a 304-CU gfx942 such as MI300X) all rows pass too.
    • Batch invariance: in batch_invariance_h12 (5 requests, packed and raw direct, an empty request) and batch_invariance_full_prefill_h6 (BQ21 full prefill plus a short extend), every request alone with batch_invariant=True is bitwise equal to its rows in the batch. Each batch also runs in the default mode, within tolerance and on a workspace of its own.
    • Runtime scale: graphs captured at unseen scales replay correctly after the indices (and the slot table and pool pages) are rewritten in place; an eager call at another new scale adds no FlyDSL specialization.
  • Default mode against main: 26 outputs (13 layouts, each at the default and a new softmax scale) are bitwise equal.
  • Mode switching: default and batch_invariant=True calls interleaved on one stream (4 batch layouts, 3 calls each) give the same bits as each mode alone.
  • Lint: black --check (26.10.1) and ruff check (0.16.0) on the changed files are clean.
  • Not verified:
    • MI300X and other gfx942 parts (no hardware): only their plans were emulated with CU_NUM. They log the warning above.
    • The union-scratch fallback (millions of rows).

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? (the question the self-review rules select for changes under op_tests/)

  • Runtime-scale graph rows fail on main: a graph captured at a scale no earlier call used raised "Warm attention on this stream and layout before graph capture", and an eager call at a new scale compiled new specializations. No existing row changes the scale.
  • Batch-invariance rows fail on main: it has no batch_invariant argument, and its call-wide union planning and routing change the bits of a request's rows when other requests join the call. No existing row compares a request alone with the same request in a batch.
  • Group 16 rows fail if the largest group the interface accepts breaks (a 16-head direct wave, BQ8 union tiles). No existing row ran group 16.

Changed op tests

  • op_tests/test_flydsl_qsa_sparse_prefill.py: six rows, each run once at its own group (see PR-specific question): two group-16 rows, two runtime-scale graph rows (one through a slot table, so every kernel taking the scale runs), and two batch-invariance rows, which also run their batch in the default mode. The copied SGLang Triton code carries SGLang's Apache-2.0 notice, matching lines 9–309 of sparse_attn.py at SGLang 52fecfdf0908.

…ed helpers, opt-in batch invariance

Follow-ups to the review of ROCm#6576.

- The softmax scale is a kernel argument (FP32 softmax_scale * log2(e)): a new
  scale compiles nothing and can be graph-captured directly.
- The QK, PV and rescale code and the direct key loop are defined once in
  sparse_prefill_common.py and shared by the union and both direct kernels.
- The kernels use FlyDSL's stable API; what has no stable equivalent (empty-asm
  register pins, the target-features attribute, unexported ROCDL operations,
  volatile LDS reads and the lgkmcnt ledger) is gathered in one section of
  sparse_prefill_common.py with the reason it stays.
- qsa_sparse_prefill gains a trailing keyword-only batch_invariant=False. The
  default keeps the call-wide union/direct decisions, with main's bits. With
  batch_invariant=True they are made per request (union planning rows, tile
  rows, no K3 routing by the others), so a request gives the same bits alone
  as in any batch. The workspace key includes the mode.
- The non-MI308X warning says what is reused, and group 16 is tested.
- The SGLang Triton code copied into the op test keeps SGLang's Apache-2.0 notice.

Co-authored-by: Copilot <[email protected]>
@luocheng25
luocheng25 requested review from a team and a balanced review from Copilot November 18, 2026 02:31
@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 8148 --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.

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.

🟡 Changes recommended

The advertised mixed_union_packed case is absent from every runnable suite, so explicitly selecting it exits successfully without running any validation.

1 open issue
What changed in this PR

This PR updates AITER’s FlyDSL QSA sparse prefill attention with runtime softmax scaling, shared kernel helpers, and an opt-in batch-invariance mode while retaining the default routing behavior.

Changes:

  • Pass softmax scale at runtime rather than specializing kernels and workspaces for each value.
  • Consolidate attention helpers and direct-kernel loops, and centralize low-level FlyDSL operations.
  • Add per-request planning for batch invariance, expand tests, clarify hardware warnings, and preserve SGLang’s license notice.
File Description
op_tests/​test_flydsl_qsa_sparse_prefill.py Adds group-16, runtime-scale graph, and batch-invariance tests plus the SGLang notice.
aiter/​ops/​qsa.py Exposes the keyword-only batch_invariant option.
aiter/​ops/​flydsl/​qsa_sparse_prefill.py Updates workspace caching, runtime scale binding, and mode selection.
aiter/​ops/​flydsl/​kernels/​qsa/​sparse_prefill_union.py Uses runtime scaling and shared pipeline helpers.
aiter/​ops/​flydsl/​kernels/​qsa/​sparse_prefill_prepare.py Adds per-request tile planning and direct-only tile handling.
aiter/​ops/​flydsl/​kernels/​qsa/​sparse_prefill_direct.py Adapts raw K/V access to the shared direct loop.
aiter/​ops/​flydsl/​kernels/​qsa/​sparse_prefill_direct_packed.py Defines the shared direct loop and packed K/V adapter.
aiter/​ops/​flydsl/​kernels/​qsa/​sparse_prefill_common.py Consolidates math helpers, low-level operations, and LDS tracking.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 18, 2026 03:14
@aiter-bot

aiter-bot commented Nov 18, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 40a96a6364b3 · 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

- **The default behavior is unchanged:** main's plans, routes and bits.
- **`batch_invariant=True`** gives batch-invariant outputs for callers that need determinism, such as SGLang's `--enable-deterministic-inference`. It is not the default because per-request decisions make some batches much slower (see Performance).
- **A new softmax scale** compiles nothing and can be graph-captured directly.
- **Code structure.** Shared QK/PV/rescale helpers and one low-level section replace per-kernel copies and scattered `flydsl._mlir` uses.

Validation and unverified scope

MI308X (gfx942, 80 CUs), FlyDSL 0.5.0.

- **`python op_tests/test_flydsl_qsa_sparse_prefill.py`:** all rows pass, 238 `checkAllclose` comparisons, none skipped. With `CU_NUM=304` (the plans of a 304-CU gfx942 such as MI300X) all rows pass too.
  - Batch invariance: in `batch_invariance_h12` (5 requests, packed and raw direct, an empty request) and `batch_invariance_full_prefill_h6` (BQ21 full prefill plus a short extend), every request alone with `batch_invariant=True` is bitwise equal to its rows in the batch. Each batch also runs in the default mode, within tolerance and on a workspace of its own.
  - Runtime scale: graphs captured at unseen scales replay correctly after the indices (and the slot table and pool pages) are rewritten in place; an eager call at another new scale adds no FlyDSL specialization.
- **Default mode against main:** 26 outputs (13 layouts, each at the default and a new softmax scale) are bitwise equal.
- **Mode switching:** default and `batch_invariant=True` calls interleaved on one stream (4 batch layouts, 3 calls each) give the same bits as each mode alone.
- **Lint:** `black --check` (26.10.1) and `ruff check` (0.16.0) on the changed files are clean.
- **Not verified:**
  - MI300X and other gfx942 parts (no hardware): only their plans were emulated with `CU_NUM`. They log the warning above.
  - The union-scratch fallback (millions of rows).

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?* (the question the self-review rules select for changes under `op_tests/`)

- **Runtime-scale graph rows** fail on main: a graph captured at a scale no earlier call used raised "Warm attention on this stream and layout before graph capture", and an eager call at a new scale compiled new specializations. No existing row changes the scale.
- **Batch-invariance rows** fail on main: it has no `batch_invariant` argument, and its call-wide union planning and routing change the bits of a request's rows when other requests join the call. No existing row compares a request alone with the same request in a batch.
- **Group 16 rows** fail if the largest group the interface accepts breaks (a 16-head direct wave, BQ8 union tiles). No existing row ran group 16.

Changed op tests

- **`op_tests/test_flydsl_qsa_sparse_prefill.py`:** six rows, each run once at its own group (see PR-specific question): two group-16 rows, two runtime-scale graph rows (one through a slot table, so every kernel taking the scale runs), and two batch-invariance rows, which also run their batch in the default mode. The copied SGLang Triton code carries SGLang's Apache-2.0 notice, matching lines 9–309 of `sparse_attn.py` at SGLang 52fecfdf0908.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply

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 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.

🔵 Needs a closer look

The scheduler-sensitive gfx942 kernel and per-request routing changes lack native, head-matched correctness and performance validation, which this environment cannot independently perform.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@fsx950223 fsx950223 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.

No blocking defect found in head 40a96a6. Targeted MI308X testing passed runtime-scale graph capture, batch invariance, and group-16 coverage. Eight default-mode outputs were bitwise identical to the merge-base. Reviewed the complete diff, callers, prior feedback, and CI logs.

Validation:

  • PASS on local and hjbog-srdc-39.amd.com / sixifang_dev: git rev-parse HEAD
    Isolated local and remote head checkouts verified as 40a96a6. Remote merge-base verified as 66be4f6.
  • PASS on hjbog-srdc-39.amd.com / sixifang_dev: HIP_VISIBLE_DEVICES=0 flock -w 60 /workspace/codex-pr-review-8148-20261119/gpu.lock timeout 600 python3 op_tests/test_flydsl_qsa_sparse_prefill.py -c graph_new_scale_mixed_union_packed graph_new_scale_kv_slots_mixed_union_raw batch_invariance_h12 batch_invariance_full_prefill_h6 kv_slots_g16_hk2_ragged mixed_union_raw
    Exit 0; six cases and 31 comparisons passed, none skipped. Graph outputs matched eager outputs bitwise; unseen scales added zero specializations; individual requests matched batch-invariant batch outputs bitwise. Verified gfx942 MI308X, 80 CUs, idle device 0, intended AITER imports, and isolated FlyDSL 0.5.0. Log: gfx942-focused-final.log.
  • PASS on hjbog-srdc-39.amd.com / sixifang_dev: bash run-comparison.sh
    Exit 0. compare_default.py ran against isolated merge-base and head trees with separate caches. All eight outputs matched bitwise: mixed union/raw direct H12, mixed union/packed direct H12, full prefill 4096 H6, and full prefill 8192 H3, each at scales 0.0625 and 0.0517. Commands and results: run-comparison.sh, compare_default.py, gfx942-comparison.log.
  • PASS on hjbog-srdc-39.amd.com / sixifang_dev: HIP_VISIBLE_DEVICES=0 flock -w 60 /workspace/codex-pr-review-8148-20261119/gpu.lock timeout 180 python3 /workspace/codex-pr-review-8148-20261119/extra-h3.py
    Exit 0; four comparisons passed for an 8192-row full H3 prefill batched with a 1024-row long-context extend, including exact solo-versus-batch equality. Log: gfx942-extra-h3.log.
  • SKIP on dzm-mi355-gpu34-dev: ssh -o BatchMode=yes -o ConnectTimeout=10 -o RemoteCommand=none -o RequestTTY=no -o ControlMaster=no -o ControlPath=none dzm-mi355-gpu34-dev "squeue -h -u zhiming_ding_qle -o '%i|%N|%t'"
    Allocation discovery exited 255: connection to aac16.amd.com port 22 timed out. No remote GPU test ran. This op supports gfx942 only. Log: gfx950-allocation.log.

Remaining validation:

  • Other gfx942 CU counts, the union-scratch budget fallback, and pools exceeding 4 GiB were not independently tested.
  • No controlled before/after performance benchmark was run by the reviewer.
  • CI's MI35X job skipped this gfx942-only op; approval relies on the independent MI308X validation.
  • Detailed commands, environment failures, and validation evidence are preserved in review-validation-notes.txt and the task-directory logs.

Automated Codex review of commit 40a96a6364b3.

@zufayu
zufayu merged commit 58b4352 into ROCm:main Nov 19, 2026
eppaneamd added a commit that referenced this pull request Nov 23, 2026
Brings in #8148 (runtime softmax scale, shared QK/PV/rescale helpers,
stable FlyDSL API, batch_invariant) and #8149 (FP8 K/V on gfx942, K3
runnable-first chunks, task splits, core tiles). gfx942 runs main's
kernels; gfx950 runs this PR's kernels in main's forms (runtime
SCALE_LOG2, the prim wrappers and counted LDS ledger of
sparse_prefill_common, kernel_attrs()).

- Raw direct (_Raw) takes K/V row bytes (KV_STRIDE * 2) where main
  passed KV heads; K3's route cost reads the first three terms of the
  5-term route model (main unpacked exactly four) and _route_choice
  loops over len(limits).
- K3 keeps the Int32 chunk-local sort key under main's CHUNKED, and
  both CHUNKED variants compile on a key's first compile.
- One operand rule list (_check_call): main's compute, FP8 scale and
  batch_invariant rules beside the scale, stride and row rules;
  qsa_sparse_prefill_problem and the qsa.py wrappers take
  batch_invariant, k_scale, v_scale and compute. FP8 K/V of any FP8
  dtype are rejected off gfx942, right after the device rule: #8149's
  kernels are E4M3FNUZ, and gfx950's dtypes.fp8 is E4M3FN. With
  compute="bf16" the per-request K span rule applies with a slot table
  too: the op then runs packed BF16 copies of the FP8 K/V, so
  qsa_sparse_prefill_problem reports what that call raises.
- batch_invariant=True on gfx950: packed direct compiles the K16 loop
  raw direct runs, so packed and raw K/V give the same bits; the
  default mode keeps the K32 packed loop.
- Platform: the gfx950 entry and route_all_or_none; FP8 routes on
  gfx942 only; overrides of a switch are written 0 or 1.
- Tests: the op test is main's with this PR's suites appended (their
  layouts seeded by name; FP8 suites on gfx942, a rejection case
  elsewhere); the CPU tests cover main's rules.

The warm-up does not compile main's batch-invariant and FP8 variants
yet; the next commit extends it.

Validated with FlyDSL 0.5.3: on gfx950 the op test, the output bits
against this branch's head and K1-K3 against main's prepare module; on
gfx942 compile-only, ISA and launch arguments against main's. On gfx950
an eager call takes 10 to 15 us more host time than on the head (main's
operand rules and launch arguments); graph replay and kernel times are
unchanged.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[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.

6 participants