Skip to content

fix(qwen38): use aiter's FlyDSL QSA prefill scorer instead of the vendored copy - #3237

Merged
valarLip merged 1 commit into
mainfrom
lingzha/qwen38-qsa-flydsl-compiled
Nov 12, 2026
Merged

valarLip merged 1 commit into
mainfrom
lingzha/qwen38-qsa-flydsl-compiled

Conversation

@ZLkanyo009

Copy link
Copy Markdown
Contributor

Refs #3192

With FlyDSL 0.5.0 (what aiter main requires and ATOM's CI installs), every plain call of a @flyc.jit function traces the function before it looks up the JIT cache. #3192 reported this for the Qwen3.8 mono kernel. ATOM's native Qwen3.8 path has a second caller with the same cause: qsa_paged_mqa_logits_flydsl in atom/model_ops/qwen4_exp/ops/qsa_flydsl_layout.py (the FlyDSL QSA prefill scorer from #2418) called its launcher directly. So every prefill scorer call that takes the FlyDSL path (more than 256 rows, BF16 index cache, 16 compressed rows per page, i.e. --block-size 64) traced the kernel again, about 70 ms per call.

Fix: use aiter's copy of the scorer, which already caches its compiled launcher.

  • qsa_flydsl_layout.py was upstreamed to aiter as aiter/ops/flydsl/kernels/mqa_logits/qsa_flydsl_layout.py in ROCm/aiter#6515. ATOM's file is byte-identical to that version.
  • ROCm/aiter#6946 (2bafed472) fixed the re-trace there: it launches through _run_compiled with specialization_key=inv_divisor.
  • qsa.py now imports aiter's module, and ATOM's copy is deleted. PAGE_SIZE and qsa_paged_mqa_logits_flydsl keep their names and signature, so the call site is unchanged. The import moved into the aiter group because ruff's isort rule (I001) requires it.

Needs aiter with ROCm/aiter#6946 (2bafed472, 10-27).

  • The import is at module level in qsa.py. With aiter older than 5b2a32e12 (ROCm/aiter#6515, 10-26) the module doesn't exist, so importing qsa.py fails. That also affects the SGLang plugin, which imports qwen4_exp when it registers its models (atom/plugin/register.py).
  • aiter between 5b2a32e12 and 2bafed472 imports fine but still re-traces.
  • CI installs aiter main's latest wheel, which has it (11-12: g8c964fa61; earlier gca6bc0f85). The scorer file is identical in 4d1980603, ca6bc0f85 and 8c964fa61.

Overlap with #2636: both PRs change atom/model_ops/qwen4_exp/ops/qsa.py. This PR changes only the one import line, and #2636 changes lines 41-66. git merge-tree of the two heads adds no conflict in qsa.py.

Validation (MI355X; Qwen3.8-Flash-Next MXFP4 recipe: TP1, MTP3, fp8 KV, bf16 index cache, --block-size 64, mono on). Two environments: aiter ca6bc0f85 + FlyDSL 0.5.0 (CI's), and aiter 4d1980603 + FlyDSL 0.4.0. "Before" is main f7b8962fd; both sides also carry the Qwen3.8 mono change of #3226, so that mono decode isn't the bottleneck with FlyDSL 0.5.0. The four servers ran at the same time, one GPU each, so this is not a quiet measurement.

FlyDSL 0.5.0 before FlyDSL 0.5.0 after FlyDSL 0.4.0 before FlyDSL 0.4.0 after
Median TTFT, 64K-token prompt (concurrency 1) 22.0 s 1.73 s 1.72 s 1.74 s
Median ITL, 64K / 512, concurrency 1 4.42 ms 4.42 ms 4.38 ms 4.37 ms
Median / mean ITL, 16K / 512, concurrency 2 5.63 / 13.67 ms 5.66 / 7.31 ms 5.62 / 7.08 ms 5.61 / 7.20 ms
GSM8K (1319, 5-shot, greedy, concurrency 16), strict-match 0.9795 0.9803 0.9773 0.9818
MTP acceptance during GSM8K 0.727 0.724 0.727 0.726
Generation throughput with 16 requests running 258 tok/s 1058 tok/s 1034 tok/s 1003 tok/s
  • With FlyDSL 0.5.0 this brings prefill back to the FlyDSL 0.4.0 numbers. With FlyDSL 0.4.0, which never re-traced on a cache hit, nothing changes beyond noise.
  • Decode steady state (median ITL) is the same in all four, since this scorer only runs in prefill. The higher mean ITL before the fix comes from decode steps that wait behind a slow prefill.
  • A probe through qsa.qsa_paged_mqa_logits(..., allow_flydsl=True): after the first call, four calls with new row, column, page and request counts. With FlyDSL 0.5.0 the old copy emitted a kernel on every call (about 70 ms each, also for a shape it had seen); aiter's copy emitted none (0.2-0.5 ms per call). A new divisor builds once, as it should. Visible counts and logits match the Triton scorer in every call.
  • CUDA graph capture with a warm FlyDSL cache takes 15 s with FlyDSL 0.5.0 both before and after this change (3 s with 0.4.0). Capture runs decode only, so this scorer isn't involved; the extra time is in the mono batch sizes (1-4).
  • CPU: black / ruff pass; affected_tests.py picks 7 test files, 35 passed / 28 skipped, the same as the base. No test is added: the kernel and its fix live in aiter, which has its own op test for it.

Not changed:

  • qsa.py as a whole is close to a copy of aiter's QSA dispatch layer aiter.ops.qsa. Moving ATOM onto that layer is a separate change.
  • _require_flydsl_scorer in tests/test_qwen4_exp_mtp.py only runs the [flydsl] scorer tests on gfx942, while the production path also uses this scorer on gfx950, so those tests never run on MI355X. That predates this PR.

cc @zovonoir @valarLip

…dored copy

With FlyDSL 0.5.0 every plain call of a `@flyc.jit` function traces it
before the JIT cache lookup. `qsa_flydsl_layout.qsa_paged_mqa_logits_flydsl`
called its launcher directly, so every prefill scorer call that takes the
FlyDSL path (more than 256 rows, BF16 index cache, 16 compressed rows per
page, i.e. `--block-size 64`) traced the kernel again. On MI355X with the
Qwen3.8 MXFP4 recipe, the median TTFT of a 64K-token prompt was 22.0 s
with FlyDSL 0.5.0 against 1.7 s with FlyDSL 0.4.0; with this change it is
1.7 s with FlyDSL 0.5.0 too.

`atom/model_ops/qwen4_exp/ops/qsa_flydsl_layout.py` is the same file as
aiter's `aiter/ops/flydsl/kernels/mqa_logits/qsa_flydsl_layout.py`
(upstreamed in ROCm/aiter#6515).
ROCm/aiter#6946 (2bafed472) fixed the
same problem there by launching through `_run_compiled` with
`specialization_key=inv_divisor`. Import aiter's module and delete the
copy; `PAGE_SIZE` and `qsa_paged_mqa_logits_flydsl` keep their names and
signature, so the call site is unchanged.

Needs aiter >= 2bafed472; CI installs aiter main's latest wheel, which
has it.

Refs #3192

Co-authored-by: Cursor <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Run after the PR is approved and Pre Checkin passes
  • ✅ Run immediately when an approval review is submitted
  • ✅ Can be requested before approval with labels
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, and SGLang
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests

Heavy jobs are skipped when the PR is not approved and no matching ci:* label is present.
Add labels via the sidebar or gh pr edit 3237 --add-label <label>

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ LGTM

Swapping the vendored scorer for aiter's aiter/ops/flydsl/kernels/mqa_logits/qsa_flydsl_layout.py is the right fix. The two files differ only in the _run_compiled(..., specialization_key=inv_divisor) launch and the .contiguous().view(-1) normalization. inv_divisor is the launcher's only Constexpr, so the cache key is complete. PAGE_SIZE and the 11-arg signature match the call at qsa.py:1795-1808. No other reference to the deleted file is left, and aiter#6946 (2bafed472) is already in aiter main. The 22.0 s -> 1.73 s 64K TTFT and the unchanged GSM8K score cover the perf and accuracy evidence. Pre Checkin (Black, Ruff, non-GPU unit tests) and the offline smoke test pass; the heavy model CI runs after approval.


Reviewed at 505565c.

@valarLip valarLip added the LGTM waiting pass for CI label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM waiting pass for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants