Repository navigation
fix(qwen38): use aiter's FlyDSL QSA prefill scorer instead of the vendored copy - #3237
Conversation
…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]>
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
|
valarLip
left a comment
There was a problem hiding this comment.
✅ 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.
Refs #3192
With FlyDSL 0.5.0 (what aiter main requires and ATOM's CI installs), every plain call of a
@flyc.jitfunction 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_flydslinatom/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.pywas upstreamed to aiter asaiter/ops/flydsl/kernels/mqa_logits/qsa_flydsl_layout.pyin ROCm/aiter#6515. ATOM's file is byte-identical to that version.2bafed472) fixed the re-trace there: it launches through_run_compiledwithspecialization_key=inv_divisor.qsa.pynow imports aiter's module, and ATOM's copy is deleted.PAGE_SIZEandqsa_paged_mqa_logits_flydslkeep 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).qsa.py. With aiter older than5b2a32e12(ROCm/aiter#6515, 10-26) the module doesn't exist, so importingqsa.pyfails. That also affects the SGLang plugin, which importsqwen4_expwhen it registers its models (atom/plugin/register.py).5b2a32e12and2bafed472imports fine but still re-traces.g8c964fa61; earliergca6bc0f85). The scorer file is identical in4d1980603,ca6bc0f85and8c964fa61.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-treeof the two heads adds no conflict inqsa.py.Validation (MI355X; Qwen3.8-Flash-Next MXFP4 recipe: TP1, MTP3, fp8 KV, bf16 index cache,
--block-size 64, mono on). Two environments: aiterca6bc0f85+ FlyDSL 0.5.0 (CI's), and aiter4d1980603+ FlyDSL 0.4.0. "Before" is mainf7b8962fd; 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.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.affected_tests.pypicks 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.pyas a whole is close to a copy of aiter's QSA dispatch layeraiter.ops.qsa. Moving ATOM onto that layer is a separate change._require_flydsl_scorerintests/test_qwen4_exp_mtp.pyonly 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