Skip to content

Stop reporting a fast-kernel failure that never ran in test_topk_row_prefill - #6479

Merged
yzhou103 merged 4 commits into
ROCm:mainfrom
yzhou103:fix/topk-row-prefill-harness
Oct 23, 2026
Merged

yzhou103 merged 4 commits into
ROCm:mainfrom
yzhou103:fix/topk-row-prefill-harness

Conversation

@yzhou103

Copy link
Copy Markdown
Contributor

top_k_per_row_prefill_fast is only called under
if get_gfx() == "gfx942", but everything downstream consumed its results unconditionally. On every other arch the kernel is never launched, so indices_fast keeps the -1 fill it was allocated with and us_fast keeps its 1e6 sentinel -- and the test then compares that buffer against torch.topk and derives a speedup from the sentinel. A gfx950 run reports 2048 invalid indices per row, correct=False, 0.000x speedup and -2831676.54% improvement for a kernel that was never on the GPU, which reads as a kernel bug.

Hoist the arch test into fast_supported and gate every consumer on it: the indices_fast dump, the correctness comparison, the speedup and improvement math, the terminal summary, and the four result columns. Unsupported now yields None rather than a sentinel, so the summary DataFrame and prefill_topk.csv no longer carry fabricated 1000000.0 / 0.00x / False values. The gfx942 path is unchanged except that a kernel reporting us_fast == 0 now gives None instead of 0.0.

Also fail loudly on an unimplemented data_generation. create_random_logits only implements random and 10LSBits, yet load_pt and threshold_bin_data were both offered in choices; either one fell through to the shared -inf epilogue and died with an UnboundLocalError on logits at a line that has nothing to do with the cause. Add the missing else: raise and narrow choices to what exists.

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

…prefill

`top_k_per_row_prefill_fast` is only called under
`if get_gfx() == "gfx942"`, but everything downstream consumed its
results unconditionally. On every other arch the kernel is never
launched, so `indices_fast` keeps the `-1` fill it was allocated with
and `us_fast` keeps its `1e6` sentinel -- and the test then compares
that buffer against `torch.topk` and derives a speedup from the
sentinel. A gfx950 run reports `2048 invalid indices` per row,
`correct=False`, `0.000x` speedup and `-2831676.54%` improvement for a
kernel that was never on the GPU, which reads as a kernel bug.

Hoist the arch test into `fast_supported` and gate every consumer on
it: the `indices_fast` dump, the correctness comparison, the speedup
and improvement math, the terminal summary, and the four result
columns. Unsupported now yields `None` rather than a sentinel, so the
summary DataFrame and `prefill_topk.csv` no longer carry fabricated
`1000000.0` / `0.00x` / `False` values. The gfx942 path is unchanged
except that a kernel reporting `us_fast == 0` now gives `None` instead
of `0.0`.

Also fail loudly on an unimplemented `data_generation`.
`create_random_logits` only implements `random` and `10LSBits`, yet
`load_pt` and `threshold_bin_data` were both offered in `choices`;
either one fell through to the shared `-inf` epilogue and died with an
`UnboundLocalError` on `logits` at a line that has nothing to do with
the cause. Add the missing `else: raise` and narrow `choices` to what
exists.
@yzhou103
yzhou103 requested review from a team and a balanced review from Copilot October 13, 2026 12:33
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (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 gfx1201 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 6479 --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.

yzhou103 and others added 2 commits October 22, 2026 10:53
fast_supported only means the kernel exists. A zero timing still left speedup as None, and the summary then compared and formatted that None.

Co-authored-by: Cursor <[email protected]>
fast_timed can be true while improvement_pct stays None, and formatting that None aborted the run before the CSV was written.

Co-authored-by: Cursor <[email protected]>
@yzhou103
yzhou103 merged commit 8fcd369 into ROCm:main Oct 23, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants