Skip to content

[Test] Shrink the default shapes of test_topk_per_row.py - #7323

Merged
lirui927 merged 2 commits into
mainfrom
lirui/topk_per_row_ci_cases
Nov 3, 2026
Merged

lirui927 merged 2 commits into
mainfrom
lirui/topk_per_row_ci_cases

Conversation

@lirui927

@lirui927 lirui927 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Shrink the default shapes of op_tests/test_topk_per_row.py to keep CI short.

Motivation

CI runs the file without arguments; the default sweep of about 5000 timed shapes took 2264 s of one shard in run 41382065915.

Changes

  • New defaults -c 8 4096 90000 -k 512 2048 -b 4 -n 1 4 reach the same kernel paths as the old lists.
  • --full sets the old lists; loops and checks are unchanged.

Performance (if applicable)

Hardware Workload/configuration Before After Change
MI355X bare run 2264 s (CI) 327 s (local) -86%

Testing

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

Changed op tests

op_tests/test_topk_per_row.py: smaller default shapes and --full; no check changes.

@aiter-bot

aiter-bot commented Nov 2, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 8f93aaeaa463 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. 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?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

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

@github-actions

github-actions Bot commented Nov 2, 2026

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

Standard CI runs this file without arguments, and the default sweep of
about 5000 timed shapes took 2264 s of one shard. Shrink the defaults to
-c 8 4096 90000, -k 512 2048, -b 4 and -n 1 4. They still reach short
rows, the FlyDSL one-workgroup and split decode, ragged rows, both
one-block prefill kernels, the stable and value variants, and widths
past 65535. --full sets the previous lists for perf runs; the sweep
loops and checks are unchanged.

A bare run is 148 cases on gfx950 and took 327 s on one MI355X.
@lirui927
lirui927 force-pushed the lirui/topk_per_row_ci_cases branch from 52232bf to 5ceff8f Compare November 2, 2026 09:42
@lirui927 lirui927 changed the title Lirui/topk per row ci cases [Test] Shrink the default shapes of test_topk_per_row.py Nov 2, 2026
@lirui927
lirui927 marked this pull request as ready for review November 2, 2026 09:47
@lirui927
lirui927 requested a review from a team November 2, 2026 09:47
@zufayu
zufayu requested a review from junhaha666 November 3, 2026 01:15
@zufayu

zufayu commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

The direction is right — the old defaults put 336 of their 456 decode calls (74%) into a single dispatch gate — but dropping 32768 from -c takes a gate's only hit with it.

_FLYDSL_TOPK_DECODE_GATES in aiter/ops/topk.py decides whether a (width, num_rows, k) combination takes the FlyDSL decode path. Replaying the old and new defaults against that table on gfx950:

gate (min_width, max_width, max_rows) old hits new hits
(0, 20000, 128) 336 8
(32768, 65535, 16) 21 0
(65536, 131072, 32) 99 4

32768 was the only context length landing in [32768, 65535], so that gate goes uncovered: nothing in the default run exercises the path, and a change to its bounds would not be caught.

Adding 32768 back to -c is enough. The new -b [4] × -n [1, 4] gives num_rows of 4 and 16, and that gate allows up to 16, so it is satisfied as soon as the width is present.

Two things that are not caused by this PR but are worth folding in while the defaults are being redesigned:

  • (131072, 200000, 48) and (200000, None, 64) have been at zero coverage all along — the old -c topped out at 128000 and never reached 131072.
  • _FLYDSL_TOPK_DECODE_KS is (512, 1024, 2048, 4096), but -k has never included 4096, so that path has never run. Dropping 1024 here is fine (it shares a gate with 512), but 4096 is a gap.

A cheap guard against this class of regression: assert at startup that every gate in _FLYDSL_TOPK_DECODE_GATES[arch] is hit at least once by the configured sweep. The table is right there in the source, so a future narrowing cannot silently empty a gate, and the two gaps above would surface immediately.

Dropping 32768 from -c left the stable (32768, 65535, 16) gate on gfx950
without a hit, so put it back in the defaults.

Add the flydsl-decode-gates regression: for each gate in this arch's
_FLYDSL_TOPK_DECODE_GATES and each k in _FLYDSL_TOPK_DECODE_KS, run one
default-dispatch decode at the gate's smallest width (at least 2k) and
its row limit, assert that it routes to FlyDSL decode and matches
torch.topk. This also covers the gates from 131072 up and k=4096, which
the sweep never reached, without growing the prefill shapes that share
-c.

A bare run is now 192 cases on gfx950 and took 413 s on one MI355X.
@lirui927

lirui927 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

The direction is right — the old defaults put 336 of their 456 decode calls (74%) into a single dispatch gate — but dropping 32768 from -c takes a gate's only hit with it.

_FLYDSL_TOPK_DECODE_GATES in aiter/ops/topk.py decides whether a (width, num_rows, k) combination takes the FlyDSL decode path. Replaying the old and new defaults against that table on gfx950:

gate (min_width, max_width, max_rows) old hits new hits
(0, 20000, 128) 336 8
(32768, 65535, 16) 21 0
(65536, 131072, 32) 99 4
32768 was the only context length landing in [32768, 65535], so that gate goes uncovered: nothing in the default run exercises the path, and a change to its bounds would not be caught.

Adding 32768 back to -c is enough. The new -b [4] × -n [1, 4] gives num_rows of 4 and 16, and that gate allows up to 16, so it is satisfied as soon as the width is present.

Two things that are not caused by this PR but are worth folding in while the defaults are being redesigned:

  • (131072, 200000, 48) and (200000, None, 64) have been at zero coverage all along — the old -c topped out at 128000 and never reached 131072.
  • _FLYDSL_TOPK_DECODE_KS is (512, 1024, 2048, 4096), but -k has never included 4096, so that path has never run. Dropping 1024 here is fine (it shares a gate with 512), but 4096 is a gap.

A cheap guard against this class of regression: assert at startup that every gate in _FLYDSL_TOPK_DECODE_GATES[arch] is hit at least once by the configured sweep. The table is right there in the source, so a future narrowing cannot silently empty a gate, and the two gaps above would surface immediately.

@zufayu Ready for review at 8f93aae. 32768 is back in -c. A startup assert cannot pass while -c also sets the prefill rows, so a new flydsl-decode-gates regression runs default dispatch at each gate's smallest width and row limit for every k in _FLYDSL_TOPK_DECODE_KS, asserting the FlyDSL route and the result. That covers your two gates, k=4096, and three more zero-hit gates: gfx950 non-stable from 131072, gfx942 stable from 131072 and non-stable from 524288. MI355X bare run: 192 cases, 413 s.

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

Verified at 8f93aae: 32768 is back in the default -c, and test_flydsl_decode_gates is a better fix than the startup assert I suggested — you are right that an assert cannot work while -c also drives the prefill rows.

Driving each gate at its smallest width and row limit for every k in _FLYDSL_TOPK_DECODE_KS, and asserting the route rather than just the result, covers more than the regression I flagged: k=4096 and the three gates neither of us had hits for (gfx950 non-stable from 131072, gfx942 stable from 131072 and non-stable from 524288) were all dark before this.

413s for 192 cases is a good trade against the ~2226s this file measures today on MI35X.

@lirui927
lirui927 merged commit a1e3728 into main Nov 3, 2026
@lirui927
lirui927 deleted the lirui/topk_per_row_ci_cases branch November 3, 2026 09:22
JH-Leon-KIM-AMD added a commit that referenced this pull request Nov 4, 2026
Conflict in op_tests/test_topk_per_row.py with #7323: this branch moved the
argument parser into build_parser()/main(), #7323 shrank the default shapes
and added --full. Kept the functions and moved the new defaults, --full and
_FULL_MATRIX into them.

#7323's test_flydsl_decode_gates called _should_use_flydsl_topk_decode, which
this branch replaced with decode_backend_for_call; it now asserts the call
resolves to BACKEND_SINGLE (no max_row_len, so the adaptive path is declined).
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
* [Test] Shrink the default shapes of test_topk_per_row.py

Standard CI runs this file without arguments, and the default sweep of
about 5000 timed shapes took 2264 s of one shard. Shrink the defaults to
-c 8 4096 90000, -k 512 2048, -b 4 and -n 1 4. They still reach short
rows, the FlyDSL one-workgroup and split decode, ragged rows, both
one-block prefill kernels, the stable and value variants, and widths
past 65535. --full sets the previous lists for perf runs; the sweep
loops and checks are unchanged.

A bare run is 148 cases on gfx950 and took 327 s on one MI355X.

* [Test] Cover every FlyDSL decode gate in test_topk_per_row.py

Dropping 32768 from -c left the stable (32768, 65535, 16) gate on gfx950
without a hit, so put it back in the defaults.

Add the flydsl-decode-gates regression: for each gate in this arch's
_FLYDSL_TOPK_DECODE_GATES and each k in _FLYDSL_TOPK_DECODE_KS, run one
default-dispatch decode at the gate's smallest width (at least 2k) and
its row limit, assert that it routes to FlyDSL decode and matches
torch.topk. This also covers the gates from 131072 up and k=4096, which
the sweep never reached, without growing the prefill shapes that share
-c.

A bare run is now 192 cases on gfx950 and took 413 s on one MI355X.

---------

Co-authored-by: lirui927 <[email protected]>
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.

4 participants