Skip to content

[Triton/Gluon] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths - #7846

Closed
yhl-amd wants to merge 1 commit into
ROCm:mainfrom
yhl-amd:hyi/topk-gating-light-384
Closed

yhl-amd wants to merge 1 commit into
ROCm:mainfrom
yhl-amd:hyi/topk-gating-light-384

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

topk_gating gets a light Triton kernel for 384-expert sqrtsoftplus routing (DeepSeek-V4.1) at decode widths on gfx950. The choice is static, from the arch table and the call's shape: a renormalized 384-expert sqrtsoftplus call without shared columns, within the table's row limit, on gfx950, runs the Triton kernel; every other call runs HIP as before. The kernel follows the lane layout of the HIP kernel that topk_gating runs there, so ids and weights are bit-identical. The signature and the routed contract (v1) of topk_gating do not change, so callers change nothing. Every call on other arches (gfx1250 and gfx1250-strict included) keeps HIP.

This moves the routing top-k of ROCm/ATOM#3129 into aiter, as requested in that review: ATOM then calls topk_gating and keeps no copy of the aiter lane layouts. This PR does not change ATOM.

Motivation

For 384 experts at decode widths, topk_gating launches a register kernel that is heavier than a short row needs. This launch is on the routed critical path of every MoE layer, and decode runs it inside CUDA graphs, where the Triton kernel is faster. In eager mode the Triton launch costs more host time than the HIP launch; that trade-off is measured and posted in the PR comments.

Technical details

  • _sqrtsoftplus_384_topk (Triton, one program per row) uses the layout of the HIP kernel that it replaces. On gfx950 that is topk_gating_kernel_opt (one 64-lane wave, six experts per lane, sort_network_desc<6>), which the HIP dispatch uses for all row counts. The kernel has only that layout.

    Each lane sorts its experts with the same network. Top-k rounds of a lane argmax (lowest lane on a tie) then select the experts. The weights are summed in selection order and the sum has the same floor. So ties, NaN/inf rows and the renorm sum order give the same bits as the HIP kernel. num_valid_rows is read on the device (pad rows get id -1 and weight 0), so a replayed CUDA graph follows each step's count. An arch whose HIP kernel has another layout needs its own kernel path and test before it can have a table entry.

  • gfx1250-strict is not in the table: the Triton kernel was never timed against its HIP kernel on hardware, so it keeps HIP.

  • gfx1250 is not in the table. Since [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922 its HIP path for 384 experts, top-k up to 8 and up to 1024 rows is topk_gating_kernel_opt_vwave<.., 384, 2, ..>. The Triton kernel with that layout (two 32-lane waves, six experts per lane) is bit-identical to it, but it is not faster under graph replay, so gfx1250 keeps HIP.

  • One table, SQRTSOFTPLUS_384_ARCHS in aiter/ops/triton/moe/moe_routing/topk_gating.py, keyed by get_gfx_runtime(): max_rows for each arch. The dispatch and the test row limits read it.

  • Dispatch in topk_gating, after the existing HERD check and before topk_gating_fwd. The first topk_gating call that reaches it, whatever its shape, resolves the module-level arch entry (the entry of the runtime arch, or None) and binds the Triton launcher once (importing aiter needs no GPU). The first test is then arch is not None, so on an arch that is not in the table every later call ends there. On gfx950 the next tests are score_func == "sqrtsoftplus", need_renorm, no shared columns and gating_output.shape[-1] == 384; only a call that passes all of them pays for _can_use_sqrtsoftplus_384_topk, which checks the row range (gfx950: up to 2048, above which HIP is faster) and the tensor contract (BF16 logits [rows, 384] with unit column stride, FP32 bias of [384] with unit stride or none, FP32/INT32 outputs of [rows, topk] with unit column stride and row stride at least topk, top-k 1 to 8). A call that does not fit runs HIP. No capture-state query and no per-call environment read. gfx942 runs the same HIP kernel as gfx950, but it is not enabled until it is measured there.

  • The launcher is private, _sqrtsoftplus_384_topk_launch. topk_gating is the one place that checks the tensor contract; the launcher checks only num_valid_rows. It computes the padded top-k with a shift instead of triton.next_power_of_2 and passes the scale as a float, so an int routed_scaling_factor also works.

  • The output-tensor checks of this predicate and of the gfx1250 sigmoid specialization are one helper, _topk_outputs_ok.

  • op_tests/test_moe_topk_gating.py runs the softplus-384 section by default on an arch in the table, so a HIP-only change to topk_gating (which Standard Tests run through that file) also runs the bit-identity check against the Triton kernel. The section checks every config with a random bias and with none, on its benchmark rows and on four special rows (all NaN, NaN in every third column, constant, few distinct values). When it was added by default and no config fits the given --num-tokens/--topk, it is skipped with a message and the other sections still run; it raises only when named with --section. select_triton_tests does not pick test_topk_gating_sqrtsoftplus_384.py for csrc/ or aiter/ops/topk.py changes; that pytest file runs in the Triton tests when Triton paths change, and in the nightly or ci:triton-355 run.

  • No new environment variables.

Note: #7838 (open) changes how the HIP kernels pick a NaN expert. Whichever of the two PRs lands second must update the other side; the bit-identity checks here have all-NaN rows and fail if they differ.

PR Self-Review

Reviewed revision

9909b700251d

Behavior and intent

  • Changed behavior: on gfx950, topk_gating sends renormalized 384-expert sqrtsoftplus calls (no shared columns, BF16 logits, FP32 or no bias, top-k 1 to 8, rows up to the arch's max_rows) to the new Triton kernel instead of the HIP topk_gating_fwd, in eager mode and in CUDA graphs, with the same bits. Other score functions, other expert counts, shared columns, other dtypes, larger row counts and other arches, gfx1250 and gfx1250-strict included, keep the HIP path. The signature and routed contract of topk_gating are unchanged. op_tests/test_moe_topk_gating.py runs its softplus-384 section by default on gfx950.
  • Why the existing behavior is not enough: the HIP kernel is a general register top-k. For a short 384-expert row it does more work than needed, and it sits on the routed critical path of every MoE layer in decode. ATOM#3129 carried a copy of this kernel and the aiter lane layouts; the review there asked to move it into aiter.

Validation and unverified scope

  • gfx950, at 9909b700251d: pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py tests/test_plugin_contracts.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py passes, and python3 op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py passes, including the first-launch-under-capture case (the gfx1250-only sigmoid cases skip). python op_tests/test_moe_topk_gating.py with no arguments runs every default section and the softplus-384 section passes with no id or weight-bit mismatch; with --num-tokens 4096 it skips softplus-384 and runs the rest. python3 -m pytest -q tests has the same single failure as the merge base (test_mega_moe_gfx1250_recipe.py::test_layout, which fails there too) and adds the new passing cases. Deleting any single term of the dispatch guard makes the CPU dispatch test fail. pytest tests, the deletion check and the eager timings ran at 73f2e1949, which differs from this revision only in how the op-test section passes its inputs to the graph timer. Eager host cost of default calls against the merge base, the cost on an arch off the table, and eager and graph-replay timings of the shapes that now take Triton are in the PR comments.
  • gfx1250 and other arches off the table: not run on hardware at this revision. There a call ends at the first test of the 384-expert dispatch (the cached None), which the CPU dispatch test checks and which was timed on gfx950 with the cached entry set to None. The gfx1250 sigmoid specialization uses the shared _topk_outputs_ok helper; op_tests/triton_tests/moe/moe_routing/test_topk_gating.py passed on gfx1250 with the same helper at 1974ec1e7708.
  • Unverified: gfx1250-strict (no hardware; it is not in the table, so it keeps HIP). The ci:gfx1250-ffm-triton label is set, but that job is skipped for PRs from forks, and for same-repo branches it swaps in the shared/reduced_tests_for_FFM_CI tree, so it does not run this file.
  • Also unverified: gfx942 (not enabled), and end-to-end serving with this revision.
  • black 26.10.1 / ruff 0.16.0 clean on the changed files.

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?

  • test_topk_gating_sqrtsoftplus_384.py fails before this PR at import: the arch table and the kernel do not exist. Against a wrong implementation it fails on any id or weight-bit difference between topk_gating (asserted not to call HIP) and topk_gating_fwd (wrong lane layout, tie order, NaN handling, renorm sum order or pad rows), on a non-renormalized or sigmoid call reaching the Triton kernel, on a dispatch range that differs from the table, on a graph that ignores a changed num_valid_rows, and on a first compile that breaks inside capture. No canonical test covers this: the existing sections of op_tests/test_moe_topk_gating.py check the HIP kernels against a torch reference with a tolerance; they do not check bit identity between two kernels, this dispatch, or a Triton compile during capture.
  • op_tests/test_moe_topk_gating.py (softplus-384 section) fails before this PR because the section does not exist. On gfx950 it now runs by default, so it also fails a later HIP-only change that makes topk_gating_fwd differ from the Triton kernel in any bit, with or without a bias, including on all-NaN, partly-NaN, constant and tied rows.

Changed op tests

  • op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py (new): bit identity of eager topk_gating (asserted not to call HIP) against the raw HIP binding on every arch in the table, for row counts up to the arch's limit, top-k 1/6/8, random / heavy ties / NaN+inf and all-NaN / constant rows, no / linear / random bias, with num_valid_rows; strided logits; column-sliced outputs with different row strides for weights and ids; rejection of a bad num_valid_rows; the dispatch range; HIP for a non-renormalized or sigmoid call; topk_gating captured and replayed with a changing num_valid_rows (asserts it does not call HIP); and, in a fresh process with an empty Triton cache, a first compile and load inside capture, with replays checked against HIP. Not redundant: it is the only test of this kernel and of this dispatch.
  • op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py (new, CPU; in op_tests/ so that Standard Tests run it, and it runs pytest on itself under python3 file): the dispatch on CPU tensors with the arch patched and both kernels replaced by recorders: the row range of every arch in the table (gfx950); that an arch off the table stops at the cached None after a first call of another shape (256 experts or softmax); that a first call of another shape on gfx950 resolves the entry; that a call in range runs Triton (FP32 bias, empty bias, None); that calls which cannot match (no renorm, sigmoid, softmax, a shared column, 256 or 512 experts) never reach the tensor checks; that the arch is queried once; and one case for each term of the guard that must go to HIP: zero rows, 256 and 512 experts with no bias, FP16 logits, a BF16 bias, FP32 biases of [383], [192] and a column-strided [384], top-k 0 and 9, column-strided and [8, 1, 384] logits, column-strided, overlapping-row, short and wider outputs, FP16 weights, INT64 and 1-D ids. Not redundant: the GPU test file needs an arch in the table, so CI on other runners never reaches the dispatch.
  • op_tests/test_moe_topk_gating.py (section softplus-384, default on an arch in SQRTSOFTPLUS_384_ARCHS): the same comparison through topk_gating over the chosen row counts and top-k, with graph timing of both kernels. Not redundant with the pytest file: it is the check that Standard Tests run when only the HIP side changes.

Test plan

  • pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py tests/test_plugin_contracts.py on gfx950.
  • python op_tests/test_moe_topk_gating.py on gfx950 (runs the softplus-384 section by default).

🤖 Generated with Claude Code

@yhl-amd
yhl-amd requested a review from a team November 12, 2026 01:46
@yhl-amd yhl-amd self-assigned this Nov 12, 2026
@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 7846 --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.

@aiter-bot

aiter-bot commented Nov 12, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 9909b700251d · 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

- Changed behavior: on gfx950, `topk_gating` sends renormalized 384-expert sqrtsoftplus calls (no shared columns, BF16 logits, FP32 or no bias, top-k 1 to 8, rows up to the arch's `max_rows`) to the new Triton kernel instead of the HIP `topk_gating_fwd`, in eager mode and in CUDA graphs, with the same bits. Other score functions, other expert counts, shared columns, other dtypes, larger row counts and other arches, gfx1250 and gfx1250-strict included, keep the HIP path. The signature and routed contract of `topk_gating` are unchanged. `op_tests/test_moe_topk_gating.py` runs its `softplus-384` section by default on gfx950.
- Why the existing behavior is not enough: the HIP kernel is a general register top-k. For a short 384-expert row it does more work than needed, and it sits on the routed critical path of every MoE layer in decode. ATOM#3129 carried a copy of this kernel and the aiter lane layouts; the review there asked to move it into aiter.

Validation and unverified scope

- gfx950, at `9909b700251d`: `pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py tests/test_plugin_contracts.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py` passes, and `python3 op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py` passes, including the first-launch-under-capture case (the gfx1250-only sigmoid cases skip). `python op_tests/test_moe_topk_gating.py` with no arguments runs every default section and the `softplus-384` section passes with no id or weight-bit mismatch; with `--num-tokens 4096` it skips `softplus-384` and runs the rest. `python3 -m pytest -q tests` has the same single failure as the merge base (`test_mega_moe_gfx1250_recipe.py::test_layout`, which fails there too) and adds the new passing cases. Deleting any single term of the dispatch guard makes the CPU dispatch test fail. `pytest tests`, the deletion check and the eager timings ran at `73f2e1949`, which differs from this revision only in how the op-test section passes its inputs to the graph timer. Eager host cost of default calls against the merge base, the cost on an arch off the table, and eager and graph-replay timings of the shapes that now take Triton are in the PR comments.
- gfx1250 and other arches off the table: not run on hardware at this revision. There a call ends at the first test of the 384-expert dispatch (the cached `None`), which the CPU dispatch test checks and which was timed on gfx950 with the cached entry set to `None`. The gfx1250 sigmoid specialization uses the shared `_topk_outputs_ok` helper; `op_tests/triton_tests/moe/moe_routing/test_topk_gating.py` passed on gfx1250 with the same helper at `1974ec1e7708`.
- Unverified: gfx1250-strict (no hardware; it is not in the table, so it keeps HIP). The `ci:gfx1250-ffm-triton` label is set, but that job is skipped for PRs from forks, and for same-repo branches it swaps in the `shared/reduced_tests_for_FFM_CI` tree, so it does not run this file.
- Also unverified: gfx942 (not enabled), and end-to-end serving with this revision.
- black 26.10.1 / ruff 0.16.0 clean on the changed files.

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?

- `test_topk_gating_sqrtsoftplus_384.py` fails before this PR at import: the arch table and the kernel do not exist. Against a wrong implementation it fails on any id or weight-bit difference between `topk_gating` (asserted not to call HIP) and `topk_gating_fwd` (wrong lane layout, tie order, NaN handling, renorm sum order or pad rows), on a non-renormalized or sigmoid call reaching the Triton kernel, on a dispatch range that differs from the table, on a graph that ignores a changed `num_valid_rows`, and on a first compile that breaks inside capture. No canonical test covers this: the existing sections of `op_tests/test_moe_topk_gating.py` check the HIP kernels against a torch reference with a tolerance; they do not check bit identity between two kernels, this dispatch, or a Triton compile during capture.
- `op_tests/test_moe_topk_gating.py` (`softplus-384` section) fails before this PR because the section does not exist. On gfx950 it now runs by default, so it also fails a later HIP-only change that makes `topk_gating_fwd` differ from the Triton kernel in any bit, with or without a bias, including on all-NaN, partly-NaN, constant and tied rows.

Changed op tests

- `op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py` (new): bit identity of eager `topk_gating` (asserted not to call HIP) against the raw HIP binding on every arch in the table, for row counts up to the arch's limit, top-k 1/6/8, random / heavy ties / NaN+inf and all-NaN / constant rows, no / linear / random bias, with `num_valid_rows`; strided logits; column-sliced outputs with different row strides for weights and ids; rejection of a bad `num_valid_rows`; the dispatch range; HIP for a non-renormalized or sigmoid call; `topk_gating` captured and replayed with a changing `num_valid_rows` (asserts it does not call HIP); and, in a fresh process with an empty Triton cache, a first compile and load inside capture, with replays checked against HIP. Not redundant: it is the only test of this kernel and of this dispatch.
- `op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py` (new, CPU; in `op_tests/` so that Standard Tests run it, and it runs pytest on itself under `python3 file`): the dispatch on CPU tensors with the arch patched and both kernels replaced by recorders: the row range of every arch in the table (gfx950); that an arch off the table stops at the cached `None` after a first call of another shape (256 experts or softmax); that a first call of another shape on gfx950 resolves the entry; that a call in range runs Triton (FP32 bias, empty bias, `None`); that calls which cannot match (no renorm, sigmoid, softmax, a shared column, 256 or 512 experts) never reach the tensor checks; that the arch is queried once; and one case for each term of the guard that must go to HIP: zero rows, 256 and 512 experts with no bias, FP16 logits, a BF16 bias, FP32 biases of `[383]`, `[192]` and a column-strided `[384]`, top-k 0 and 9, column-strided and `[8, 1, 384]` logits, column-strided, overlapping-row, short and wider outputs, FP16 weights, INT64 and 1-D ids. Not redundant: the GPU test file needs an arch in the table, so CI on other runners never reaches the dispatch.
- `op_tests/test_moe_topk_gating.py` (section `softplus-384`, default on an arch in `SQRTSOFTPLUS_384_ARCHS`): the same comparison through `topk_gating` over the chosen row counts and top-k, with graph timing of both kernels. Not redundant with the pytest file: it is the check that Standard Tests run when only the HIP side changes.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

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
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

yhl-amd added a commit to yhl-amd/ATOM that referenced this pull request Nov 12, 2026
The light 384-expert top-k now lives in aiter's topk_gating dispatch
(ROCm/aiter#7846), next to the HIP kernels whose lane layout it follows.
V4.1 already reaches topk_gating through FusedMoE.select_experts, so ATOM
needs no code for it. Remove router_topk.py, its test and the moe.py hook,
and revert the unrelated get_gfx change in router.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Boss2002n
Boss2002n requested a balanced review from Copilot November 12, 2026 02:33

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

Active issues include architecture detection that can reject supported GPUs, empty benchmark sweeps that raise KeyError, and missing count-tensor validation that permits an unmasked device load from an empty tensor.

3 open issues
What changed in this PR

Adds a lightweight Triton path for 384-expert sqrtsoftplus routing in topk_gating, supporting DeepSeek-V4.1 decode workloads while preserving HIP selection and weight behavior.

Changes:

  • Adds architecture-specific routing layouts for gfx950 and gfx1250.
  • Limits dispatch by input format, row count, and graph-capture state, retaining HIP fallback.
  • Adds bitwise HIP comparison tests, graph-replay checks, and a timing benchmark.
File Description
op_tests/​triton_tests/​moe/​moe_routing/​test_topk_gating_sqrtsoftplus_384.py Tests bitwise parity, dispatch limits, strided inputs, and graph replay.
op_tests/​test_moe_topk_gating.py Adds the softplus-384 correctness and timing sweep.
aiter/​ops/​triton/​moe/​moe_routing/​topk_gating.py Adds the public wrapper and architecture-specific layout table.
aiter/​ops/​triton/​_triton_kernels/​moe/​moe_routing/​topk_gating.py Implements sqrtsoftplus scoring, top-k selection, and normalization.
aiter/​ops/​topk.py Adds guarded dispatch to the Triton specialization.

Review effort: Balanced

Comment thread op_tests/test_moe_topk_gating.py Resolved
Comment thread op_tests/test_moe_topk_gating.py Resolved

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

⚠️ Action required before merge (4)

  1. Run the new test on gfx1250 and post the result. On gfx1250 topk_gating takes the Triton kernel for every renormalized 384-expert sqrtsoftplus call up to 1024 rows, in eager mode and in graphs (_SQRTSOFTPLUS_384_ROWS, aiter/ops/topk.py:114). The WAVES=4 / EPT=3 branch and the wave-list merge (_triton_kernels/.../topk_gating.py:207-211, 275-297) have never run on hardware for this branch. CI only ran the MI35X layout (test_topk_gating_sqrtsoftplus_384.py passed there), and the PR body itself asks for a gfx1250 run. Add ci:gfx1250-ffm-triton or run the file on a gfx1250 box. A CPU transliteration of both layouts against the HIP kernels matched on 672 rows covering ties, NaN, ±inf and exhausted lanes, but that check cannot reach device math (exp2/log2/sqrt_rn against libm).
  2. Test the first Triton launch under capture. On gfx950 eager calls never reach the Triton kernel (graph_only=True), so in a real server the first JIT compile and module load happen inside graph capture. test_topk_gating_graph_replay_with_a_changing_row_count compiles the kernel before capture (:183, "eager topk_gating may run HIP"), so this case is not tested. Either drop that pre-compile in one case and show that capture still works, or warm the kernel up in topk_gating's first eager call on gfx950.
  3. Keep one arch table. The dispatch looks the arch up with get_gfx_runtime() in _SQRTSOFTPLUS_384_ROWS. The wrapper uses Triton get_arch() with an unchecked SQRTSOFTPLUS_384_LAYOUTS[...] (moe_routing/topk_gating.py:85). op_tests/test_moe_topk_gating.py:1177 hard-codes 1024 for gfx1250 a third time. Put (waves, lanes, ept, max_rows, graph_only) in one table keyed by get_gfx_runtime(), have the test read its row limit from that table, and add tl.static_assert(EPT == 3 or EPT == 6), because the else branch assumes 6.
  4. Clean up the small items.
    • The win_lane == LANES fallback (:230) is dead: NaN choices are mapped to -inf, so some lane always ties best. Remove it.
    • best_wave = tl.sum(tl.zeros(...)) (:258) is just a zero. Write 0.
    • The bench_sqrtsoftplus_384 docstring (test_moe_topk_gating.py:524) says the bit check runs in a CUDA graph, but it runs eagerly. The graph is only used for timing.
    • The rejects_a_bad_row_count parametrize builds CPU tensors and calls .cuda() (:134). op_tests/triton_tests/README.md rule 1 forbids that.
    • Fill in the PR Self-Review sections that aiter-bot lists.

Reviewed at 6451736. Copilot's 3 items (num_valid_rows check, runtime arch in the softplus-384 section, empty sweep) are fixed at head. Step 0: this is the light variant asked for in ATOM#3129, and no existing Triton routing top-k gives HIP bit-identity.

@yhl-amd yhl-amd added the ci:gfx1250-ffm-triton Run gfx1250 FFM tests label Nov 14, 2026
@yhl-amd

yhl-amd commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks for the review. All four items are addressed in 941a984 (one new commit on top of 6451736, no rebase).

1. gfx1250 run. I added ci:gfx1250-ffm-triton. As far as I can see that job only runs for PRs from branches of this repository and runs main's reduced Triton test tree, so it will not pick up this file from a fork PR. At the previous head 6451736 the new test file, --section softplus-384 (rows up to 1024, top-k 1/2/4/6/8, no id or weight-bit mismatch) and the default sections of op_tests/test_moe_topk_gating.py passed on gfx1250, so the WAVES=4 / EPT=3 branch and the wave-list merge have run on hardware. The kernel changes since then are only item 4 below plus the static asserts. I will post a gfx1250 pytest log of the file at 941a984.

2. First Triton launch under capture. New test test_topk_gating_first_triton_launch_under_capture. It starts a fresh Python process with an empty TRITON_CACHE_DIR, makes eager topk_gating calls first (they run HIP and give the reference for each num_valid_rows), and asserts that nothing compiled the kernel yet. Then it captures topk_gating with topk_gating_fwd patched to fail, asserts that the capture compiled the kernel, and replays with three row counts, checking ids and weight bits against HIP. It passes on gfx950. The same script also passes at 6451736, so the capture-time compile was not broken there; the test now pins it. I kept the pre-compile in the replay test, so that test still checks the replays on their own.
Related change: gfx1250 is now graph-only too. Eager topk_gating there kept the Triton kernel before, and in eager calls the Triton launch costs more host time than the kernel saves. Now eager calls on both arches stay on HIP, and in a server the first Triton launch always happens under capture, which is what the new test covers. So I did not add an eager warm-up.

3. One arch table. SQRTSOFTPLUS_384_ARCHS in aiter/ops/triton/moe/moe_routing/topk_gating.py, keyed by get_gfx_runtime(), holds SqrtSoftplus384Arch(waves, lanes, ept, max_rows, graph_only). _can_use_sqrtsoftplus_384_topk, the wrapper and both tests read it. _SQRTSOFTPLUS_384_ROWS and SQRTSOFTPLUS_384_LAYOUTS are gone, and so is the Triton get_arch() lookup. The wrapper raises ValueError for an arch outside the table. The softplus-384 section takes its row limit from max_rows. The kernel has tl.static_assert(EPT == 3 or EPT == 6) and also asserts WAVES * LANES * EPT == 384.

4. Small items.

  • Removed the win_lane == LANES fallback, with a comment that NaN choices are -inf, so some lane always ties best.
  • best_wave = 0.
  • The bench_sqrtsoftplus_384 docstring now says the bit check runs eagerly and the graph is used only for timing.
  • rejects_a_bad_row_count is parametrized on (numel, dtype) and builds the count with torch.full(..., device="cuda"). No CPU tensor or .cuda() is left.
  • The PR description now has the Self-Review sections at 941a984.

Checks: black, ruff and py_compile pass on the five files. On gfx950 the whole new test file passes, and --section softplus-384 over rows 1 to 4096 and top-k 1/2/4/6/8 has no mismatch (rows above the table limit are skipped).

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

⚠️ Action required before merge (2)

  1. Post the gfx1250 pytest log of test_topk_gating_sqrtsoftplus_384.py at this head. On gfx1250 every captured 384-expert sqrtsoftplus call up to 1024 rows now takes the Triton kernel (SQRTSOFTPLUS_384_ARCHS["gfx1250"], aiter/ops/triton/moe/moe_routing/topk_gating.py:40). The WAVES=4 / EPT=3 branch, the wave-list merge and the new test_topk_gating_first_triton_launch_under_capture have no posted gfx1250 result at 941a984. The label does not help: ffm-bringup.yaml:47,57 runs only when head.repo == repository, so this fork PR skips it. The 6451736 run is reported in prose only. Please paste the pytest summary (pass/fail per test) of the whole file, run at 941a984 on gfx1250 or gfx1250-strict.
  2. Make the aiter-bot Self-Review pass. The bot still reports two FAILs at 941a984, and its own parser (.github/scripts/pr_self_review.py:264-303) agrees on the current description:
    • ### Reviewed revision must hold only the SHA. 941a984 (941a984…) fails head_sha.startswith(revision). Write 941a98479bc7.
    • The validation answer must contain a word that matches the limitation regex, for example unverified or not run. "Not verified yet" and "Not measured" do not match. Rename that bullet to "Unverified: …".

Re-reviewed at 941a984. Already fixed: first Triton launch under capture is tested in a fresh process with an empty cache, and it passed on MI35X CI (shard 3, job 132319490518). One arch table SQRTSOFTPLUS_384_ARCHS keyed by get_gfx_runtime() is now used by the dispatch, the wrapper and both tests. static_assert(EPT == 3 or EPT == 6) and WAVES*LANES*EPT == 384 are added. The dead win_lane == LANES fallback is removed (a CPU transliteration replay asserts it never fires: 672 rows, 0 mismatches against HIP). best_wave = 0. The bench docstring is corrected. The bad-count test is built on the device. gfx1250 is now graph-only as well.

@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip sorry for the missing reply on your 05:33Z review. Item 2 (Self-Review) was fixed in the description at 05:33:16Z, a few seconds before your review was posted, but the aiter-bot comment did not refresh then: on that event the required CI still counted as pending, so the bot did not rewrite its report. I triggered a manual refresh (run 44008692536). The bot comment now reads Author self-review accepted at 941a98479bc7, with PASS on the author answers.

  • ### Reviewed revision holds only `941a98479b`.
  • The validation section's limitation bullet starts with "Unverified:" (and the follow-up bullet with "Also unverified:").
  • validate_author_answers from main's .github/scripts/pr_self_review.py returns no findings for this description at this head.

Item 1, the gfx1250 pytest summary of op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py at 941a984, is still open: I don't have a gfx1250 machine at the moment. I'll paste the per-test pass/fail summary here once I do. No code change in this reply.

@yhl-amd

yhl-amd commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Performance on gfx1250 (relative)

Measured at 645173655. The current head 941a98479 makes gfx1250 graph-only: eager calls run the HIP kernel again. Its only kernel changes are two tl.static_asserts and two equivalent simplifications: a dead fallback where is dropped, and best_wave starts at a constant 0. So the graph-path kernel is unchanged in effect. It is re-timed at 941a98479 in the update at the end.

Config: DeepSeek-V4.1-Flash router, 384 experts, sqrtsoftplus, top-6, renormalized, routed scale 1.5, FP32 bias, BF16 logits, num_valid_rows set. I compared this PR's topk_gating dispatch with the HIP topk_gating_fwd it replaces, in the same process, alternating, median of 5 rounds.

  • Under CUDA graph capture (the decode path): 36% to 40% less time per call for 1 to 512 rows, 28% less at 768 rows and 31% less at 1024 rows. Above 1024 rows the dispatch stays on HIP (within 1% at 2048 to 8192 rows).
  • Eager calls: at 645173655, gfx1250 also took the Triton kernel in eager mode, and each call took 34% to 37% more wall time (host-side Triton launch overhead). That regression is why 941a98479 makes gfx1250 graph-only. In eager mode the eligibility check in topk_gating still runs. At 645173655 the check added 4% to 5% per call above 1024 rows, where it also runs. Eager timing at 941a98479 is in the update at the end.
  • Correctness: ids and weights are bit-identical to HIP at every row count measured.

Update: re-measured at the current head 941a98479 on gfx1250

Same config and method: 5 rounds, median, same process, dispatch alternating with HIP. ids and weights are bit-identical to HIP at every row count in all 5 rounds.

rows eager path graph path graph: topk_gating vs HIP eager: topk_gating vs HIP topk_gating_fwd
1 HIP Triton -41.4% +10.1%
4 HIP Triton -40.0% +10.9%
16 HIP Triton -40.0% +9.7%
64 HIP Triton -39.4% +9.9%
128 HIP Triton -36.8% +10.8%
256 HIP Triton -36.2% +11.3%
512 HIP Triton -37.4% +10.9%
768 HIP Triton -29.1% +11.6%
1024 HIP Triton -35.8% +11.8%
2048 HIP HIP +4.3% (round-to-round spread about ±5%) +7.8%
4096 HIP HIP -1.1% +7.5%
8192 HIP HIP -1.0% +7.9%
  • Graph: the same as at 645173655. It is 29% to 41% faster for 1-1024 rows, and the same kernel (within noise) above 1024 rows.
  • Eager: gfx1250 now runs HIP in eager mode, and topk_gating() is +7.5% to +12% over a bare topk_gating_fwd call (table), against +34% to +37% at 645173655. I separately compared topk_gating() with the same call at the merge base 61b4e7bab (3 runs × 7 alternating samples of wall-clock time, median). It is +7% to +8.5% at 1-1024 rows and +4% at 4096 rows, and the merge base itself is 2% over topk_gating_fwd. The kernel is the same HIP kernel, so the difference is host-side, and most of it is the _can_use_sqrtsoftplus_384_topk check (timed by itself in a loop). So the eager regression is much smaller but not gone: 384-expert sqrtsoftplus eager calls still pay a small per-call host cost.

Update: eager host cost after 0d3cb7ed7 on gfx1250

0d3cb7ed7 caches the Triton module import and the arch table lookup in _can_use_sqrtsoftplus_384_topk per arch, and reads the logits shape once. The checks and their results are unchanged. I timed eager topk_gating() with the same config at three trees: the merge base 61b4e7bab, the previous head 941a98479 and this head. Each tree ran in its own process, 5 rounds with the tree order alternating, median. This is a different gfx1250 node and image from the run above, so the levels differ a little from the +7% to +8.5% above.

rows previous head vs merge base this head vs merge base this head vs previous head topk_gating() vs bare topk_gating_fwd in the same process: merge base / previous head / this head
1 +11.9% +8.6% -2.9% +1.6% / +9.7% / +6.2%
64 +10.7% +7.5% -2.9% +2.1% / +10.0% / +6.6%
512 +11.1% +6.8% -3.9% +1.8% / +10.5% / +6.3%
1024 +10.9% +6.7% -3.8% +1.9% / +10.3% / +6.0%
4096 +8.3% +5.3% -2.8% +2.2% / +8.1% / +5.3%
  • The check by itself (in a loop, rows above the limit so the capture query is not reached) takes about 58% less host time than at 941a98479.
  • The overhead that is left for 1-1024 rows is mostly the capture query (torch.cuda.is_current_stream_capturing()) and the shape checks. The dispatch needs these to tell an eager call from a capture.
  • The bare topk_gating_fwd call is about 3% slower in the two head processes than in the merge-base process. The head trees import the Triton module on their first call and the merge base never does. In a server Triton is already imported, so the last column is the cleaner comparison.
  • At this head on gfx1250, pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py tests/test_topk_gating_sqrtsoftplus_384_dispatch.py all passed.

@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip here is the gfx1250 pytest log of the whole op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py at head 941a98479b. The tree is checked out at that SHA, on one gfx1250 GPU (Triton from the gfx1250 image).

187 passed, 0 failed in 44.6 s. Per test function:

test passed
test_sqrtsoftplus_384_topk_matches_hip 180
test_sqrtsoftplus_384_topk_strided_logits 1
test_sqrtsoftplus_384_topk_rejects_a_bad_row_count 2
test_topk_gating_dispatch 2
test_topk_gating_graph_replay_with_a_changing_row_count 1
test_topk_gating_first_triton_launch_under_capture 1

This exercises the WAVES=4 / EPT=3 layout from SQRTSOFTPLUS_384_ARCHS["gfx1250"] and the wave-list merge on hardware. It also runs the first Triton launch inside graph capture (fresh process, empty cache), on gfx1250, which is graph-only. Separately, a timing script at this head confirmed that the dispatch takes Triton only under capture for 1-1024 rows and HIP in eager mode. The ids and weights matched HIP bit for bit at every row count, from 1 to 8192. The relative timings are in the updated performance comment.

Full log (gfx1250, head 941a984; `-v` lines and summary)
### tree h7846 sha 941a98479  gpu-arch gfx1250  date 2026-11-17T05:48:05Z
### cmd: python3 -m pytest -p no:cacheprovider op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py -v -rA
platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0 -- /usr/local/bin/python3
rootdir: /w/t/h7846
collecting ... collected 187 items
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-1-1] PASSED [  0%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-1-7] PASSED [  1%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-1-96] PASSED [  1%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-1-576] PASSED [  2%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-1--1] PASSED [  2%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-6-1] PASSED [  3%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-6-7] PASSED [  3%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-6-96] PASSED [  4%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-6-576] PASSED [  4%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-6--1] PASSED [  5%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-8-1] PASSED [  5%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-8-7] PASSED [  6%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-8-96] PASSED [  6%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-8-576] PASSED [  7%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-random-8--1] PASSED [  8%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-1-1] PASSED [  8%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-1-7] PASSED [  9%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-1-96] PASSED [  9%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-1-576] PASSED [ 10%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-1--1] PASSED [ 10%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-6-1] PASSED [ 11%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-6-7] PASSED [ 11%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-6-96] PASSED [ 12%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-6-576] PASSED [ 12%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-6--1] PASSED [ 13%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-8-1] PASSED [ 13%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-8-7] PASSED [ 14%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-8-96] PASSED [ 14%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-8-576] PASSED [ 15%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-ties-8--1] PASSED [ 16%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-1-1] PASSED [ 16%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-1-7] PASSED [ 17%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-1-96] PASSED [ 17%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-1-576] PASSED [ 18%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-1--1] PASSED [ 18%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-6-1] PASSED [ 19%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-6-7] PASSED [ 19%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-6-96] PASSED [ 20%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-6-576] PASSED [ 20%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-6--1] PASSED [ 21%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-8-1] PASSED [ 21%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-8-7] PASSED [ 22%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-8-96] PASSED [ 22%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-8-576] PASSED [ 23%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-nan-8--1] PASSED [ 24%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-1-1] PASSED [ 24%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-1-7] PASSED [ 25%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-1-96] PASSED [ 25%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-1-576] PASSED [ 26%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-1--1] PASSED [ 26%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-6-1] PASSED [ 27%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-6-7] PASSED [ 27%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-6-96] PASSED [ 28%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-6-576] PASSED [ 28%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-6--1] PASSED [ 29%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-8-1] PASSED [ 29%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-8-7] PASSED [ 30%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-8-96] PASSED [ 31%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-8-576] PASSED [ 31%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[none-constant-8--1] PASSED [ 32%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-1-1] PASSED [ 32%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-1-7] PASSED [ 33%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-1-96] PASSED [ 33%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-1-576] PASSED [ 34%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-1--1] PASSED [ 34%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-6-1] PASSED [ 35%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-6-7] PASSED [ 35%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-6-96] PASSED [ 36%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-6-576] PASSED [ 36%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-6--1] PASSED [ 37%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-8-1] PASSED [ 37%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-8-7] PASSED [ 38%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-8-96] PASSED [ 39%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-8-576] PASSED [ 39%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-random-8--1] PASSED [ 40%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-1-1] PASSED [ 40%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-1-7] PASSED [ 41%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-1-96] PASSED [ 41%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-1-576] PASSED [ 42%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-1--1] PASSED [ 42%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-6-1] PASSED [ 43%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-6-7] PASSED [ 43%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-6-96] PASSED [ 44%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-6-576] PASSED [ 44%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-6--1] PASSED [ 45%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-8-1] PASSED [ 45%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-8-7] PASSED [ 46%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-8-96] PASSED [ 47%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-8-576] PASSED [ 47%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-ties-8--1] PASSED [ 48%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-1-1] PASSED [ 48%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-1-7] PASSED [ 49%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-1-96] PASSED [ 49%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-1-576] PASSED [ 50%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-1--1] PASSED [ 50%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-6-1] PASSED [ 51%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-6-7] PASSED [ 51%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-6-96] PASSED [ 52%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-6-576] PASSED [ 52%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-6--1] PASSED [ 53%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-8-1] PASSED [ 54%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-8-7] PASSED [ 54%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-8-96] PASSED [ 55%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-8-576] PASSED [ 55%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-nan-8--1] PASSED [ 56%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-1-1] PASSED [ 56%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-1-7] PASSED [ 57%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-1-96] PASSED [ 57%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-1-576] PASSED [ 58%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-1--1] PASSED [ 58%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-6-1] PASSED [ 59%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-6-7] PASSED [ 59%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-6-96] PASSED [ 60%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-6-576] PASSED [ 60%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-6--1] PASSED [ 61%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-8-1] PASSED [ 62%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-8-7] PASSED [ 62%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-8-96] PASSED [ 63%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-8-576] PASSED [ 63%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[linear-constant-8--1] PASSED [ 64%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-1-1] PASSED [ 64%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-1-7] PASSED [ 65%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-1-96] PASSED [ 65%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-1-576] PASSED [ 66%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-1--1] PASSED [ 66%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-6-1] PASSED [ 67%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-6-7] PASSED [ 67%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-6-96] PASSED [ 68%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-6-576] PASSED [ 68%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-6--1] PASSED [ 69%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-8-1] PASSED [ 70%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-8-7] PASSED [ 70%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-8-96] PASSED [ 71%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-8-576] PASSED [ 71%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-random-8--1] PASSED [ 72%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-1-1] PASSED [ 72%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-1-7] PASSED [ 73%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-1-96] PASSED [ 73%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-1-576] PASSED [ 74%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-1--1] PASSED [ 74%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-6-1] PASSED [ 75%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-6-7] PASSED [ 75%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-6-96] PASSED [ 76%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-6-576] PASSED [ 77%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-6--1] PASSED [ 77%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-8-1] PASSED [ 78%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-8-7] PASSED [ 78%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-8-96] PASSED [ 79%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-8-576] PASSED [ 79%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-ties-8--1] PASSED [ 80%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-1-1] PASSED [ 80%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-1-7] PASSED [ 81%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-1-96] PASSED [ 81%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-1-576] PASSED [ 82%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-1--1] PASSED [ 82%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-6-1] PASSED [ 83%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-6-7] PASSED [ 83%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-6-96] PASSED [ 84%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-6-576] PASSED [ 85%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-6--1] PASSED [ 85%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-8-1] PASSED [ 86%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-8-7] PASSED [ 86%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-8-96] PASSED [ 87%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-8-576] PASSED [ 87%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-nan-8--1] PASSED [ 88%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-1-1] PASSED [ 88%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-1-7] PASSED [ 89%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-1-96] PASSED [ 89%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-1-576] PASSED [ 90%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-1--1] PASSED [ 90%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-6-1] PASSED [ 91%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-6-7] PASSED [ 91%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-6-96] PASSED [ 92%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-6-576] PASSED [ 93%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-6--1] PASSED [ 93%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-8-1] PASSED [ 94%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-8-7] PASSED [ 94%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-8-96] PASSED [ 95%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-8-576] PASSED [ 95%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_matches_hip[random-constant-8--1] PASSED [ 96%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_strided_logits PASSED [ 96%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_rejects_a_bad_row_count[empty] PASSED [ 97%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_sqrtsoftplus_384_topk_rejects_a_bad_row_count[int64] PASSED [ 97%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_topk_gating_dispatch[False] PASSED [ 98%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_topk_gating_dispatch[True] PASSED [ 98%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_topk_gating_graph_replay_with_a_changing_row_count PASSED [ 99%]
op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py::test_topk_gating_first_triton_launch_under_capture PASSED [100%]
============================= 187 passed in 44.58s =============================
### rc=0 end 2026-11-17T05:48:51Z

@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the eager host cost: 0d3cb7ed7 caches the Triton module import and the arch table lookup in _can_use_sqrtsoftplus_384_topk per arch, and reads the logits shape once. The checks and their results are the same. On CPU, the old and new predicates agree on every case of a grid over arch, capture state, row limits, dtypes, strides, shapes, bias kind, top-k, renorm and score function. A new CPU test, tests/test_topk_gating_sqrtsoftplus_384_dispatch.py, covers each term of the predicate and an arch switch between calls.

The gfx1250 eager timing against the merge base and the previous head is added at the end of #7846 (comment). The eager gap shrinks but does not close. What is left is mostly the capture query that the graph-only dispatch needs. At this head on gfx1250, the GPU test file and the new CPU test all passed. gfx950 has not been re-run at this head; the previous head's gfx950 results are in the description. Self-Review updated (Reviewed revision 0d3cb7ed7b). black 26.10.1 / ruff clean.

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

⚠️ Action required before merge (3)

  1. Rebase onto main and redo the gfx1250 entry against #7922. The PR conflicts with main (aiter/ops/topk.py now has @_route from #7874; the kernel, wrapper and op-test files also conflict). #7922 (merged today) moved the gfx1250 HIP path for 384 experts, top-k ≤ 8, ≤ 1024 rows to topk_gating_kernel_opt_vwave<384, WPT=2> (csrc/include/topk_gating_kernels.cuh:1805). Its header says this kernel is bit-identical to multiwave<384, 2>: 2 waves × 32 lanes × 6 experts, ties broken by e % 64. SQRTSOFTPLUS_384_ARCHS["gfx1250"] = (4, 32, 3) (aiter/ops/triton/moe/moe_routing/topk_gating.py:40) still follows the old multiwave<384, 4> layout, so captured gfx1250 calls no longer match HIP. A CPU port of both kernels' selection logic gives 99 of 336 rows with different ids or weights (the ties, NaN, random and constant cases). With (2, 32, 6), which the existing static asserts allow, it gives 0. Example: experts 1 and 64 tie; HIP now picks 64, this kernel picks 1.
    • The fix: use (2, 32, 6) for gfx1250. The vwave gate is get_gpu_arch() == "gfx1250", so check which HIP kernel gfx1250-strict runs before you change that entry too.
    • #7922 also made the HIP E=384 kernel about 2× faster on gfx1250. Keep gfx1250 in the table only if the Triton path still wins against it; otherwise drop the entry.
    • Then re-run test_topk_gating_sqrtsoftplus_384.py on gfx1250 and gfx950 at the rebased head. Update the PR body and the table comment at topk_gating.py:35 to match.
  2. Bring eager topk_gating back to the merge-base host cost. Your own gfx1250 numbers at 0d3cb7ed7 still show +6.7 to +8.6% per eager 384-expert sqrtsoftplus call at 1–1024 rows and +5.3% at 4096 rows. Eager calls never take the Triton path, and prefill runs eagerly, so this is a cost on the default path.
    • Make the reject cheap before any other work: test score_func, need_renorm and gating_output.shape[-1] == 384 inline at the call site (aiter/ops/topk.py:284).
    • Read the arch entry from one module-level value instead of calling get_gfx_runtime() and _sqrtsoftplus_384_arch() each time.
    • Query is_current_stream_capturing() last.
  3. Small cleanups. In sqrtsoftplus_384_topk (topk_gating.py:106-110), store get_gfx_runtime() in a variable instead of calling it twice. The output-tensor checks at topk.py:153-155 repeat the ones at topk.py:71-73 in _can_use_gfx1250_exact_sigmoid_topk; move both into one helper.

Re-reviewed at 0d3cb7e. Already fixed: the gfx1250 pytest log is posted (187 passed at 941a984; the GPU file and the new CPU test also passed at this head). aiter-bot Self-Review now passes at 0d3cb7e. Copilot's 3 items were fixed earlier. CI failures (MI35X shards 0/3/4/7 and the Test Gate) are Docker Hub pull-rate-limit errors, not this PR, but CI ran on a tree that main has since moved past. Step 0: this belongs in aiter, as requested in ATOM#3129.

@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-light-384 branch from 0d3cb7e to 5944ccd Compare November 17, 2026 12:17
@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks. All three items are addressed at 5944ccd27 (rebased onto main 0d894387b; the previous head is kept as bak/7846-pre1117w on the fork). All timings below are relative values.

1. Rebase and the gfx1250 entry

  • Rebased onto main. In aiter/ops/topk.py the 384-expert check now sits inside the native body of the @_route topk_gating from [Plugin] Route topk_gating and top_k_per_row_decode as custom ops #7874, after the HERD check and before topk_gating_fwd, so the plugin routing and the fake are unchanged. The op-test help text conflict (the unaligned section from [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922) is merged.
  • gfx1250-strict: topk_gating_vwave_arch() compares get_gpu_arch() (the gcnArchName before :) with "gfx1250". A gfx1250-strict device reports gfx1250-strict (csrc checks that string separately, e.g. in mha_bwd.cu), so it fails the vwave gate and still runs multiwave<384, 4> up to 1024 rows. Its entry stays (4, 32, 3).
  • gfx1250 with (2, 32, 6): on gfx1250, the whole test_topk_gating_sqrtsoftplus_384.py passed (200 passed, with the CPU dispatch test). So this layout is bit-identical to the vwave kernel, including the tie, NaN and constant cases. Under graph replay it is not faster. With op_tests/test_moe_topk_gating.py --section softplus-384 (1 to 1024 rows, top-k 6 and 8, median of 3 runs), Triton is 1% to 6% slower than HIP at top-k 6 and 6% to 9% slower at top-k 8 for 1 to 512 rows. At 1024 rows the HIP time switches between two levels from run to run, and Triton is about even with the faster level. So gfx1250 is removed from SQRTSOFTPLUS_384_ARCHS, and all gfx1250 calls keep HIP.
  • gfx950 at this head: the test file passes (197 passed, 26 skipped; the skips are the gfx1250-only sigmoid tests of test_topk_gating.py, which I added to the run). Graph replay, same sweep up to 2048 rows, median of 3 runs: at top-k 6, Triton is within about 2% of HIP at 1 to 256 rows and 2.5% / 6.5% / 9% faster at 512 / 1024 / 2048 rows. At top-k 8 it is 1.5% to 14% faster at every row count. There is no id or weight-bit mismatch in any config.
  • The table comment at topk_gating.py:35 and the PR body now describe gfx950 and gfx1250-strict, and say why gfx1250 is not in the table.

2. Eager host cost

  • At the call site, score_func == "sqrtsoftplus", need_renorm, num_shared_experts == 0 and gating_output.shape[-1] == 384 are checked inline. Every other call goes straight to HIP.
  • The arch entry is read from one module-level value, _sqrtsoftplus_384_arch. It is set at the first such call, so importing aiter still needs no GPU. get_gfx_runtime() and the per-arch cache are no longer called on each call.
  • About the order of the capture query: I first put is_current_stream_capturing() last, after the tensor checks. On gfx950 (graph-only, in the table) that made eager topk_gating() 13% to 14% slower than the merge base at 1 to 1024 rows. An eager call in range passes all the tensor checks before it reaches the capture query, so it pays for every check. The query now runs last among the cheap checks (after score function, renorm, shared columns, expert count, arch entry and row range) and before the tensor checks, so eager calls stop there. Each tree was timed in its own process, 6 rounds with the order alternating, median:
eager topk_gating() vs merge base 0d894387b 1 / 64 / 512 / 1024 rows 4096 rows
gfx1250, this head (not in the table) +0.4% to +1.5% +1.1% / +1.7% (top-k 6 / 8)
gfx950, this head +2.8% to +3.6% +1.0% / +1.2%
gfx950, capture query after the tensor checks +13.4% to +14.3% +1.7% / +1.8%

On gfx1250 the per-round spread of the merge base itself is about 1% to 2% (one round was 6% slower), so gfx1250 is within noise. Before this change the gfx1250 result was +5.3% to +8.6%. On gfx950 an eager call in range still costs one capture query plus the scalar checks. That is the cost of keeping eager calls on HIP on a graph-only arch.

3. Cleanups

  • sqrtsoftplus_384_topk stores get_gfx_runtime() in gfx and uses it for the lookup and the error message.
  • The output checks of _can_use_gfx1250_exact_sigmoid_topk and _can_use_sqrtsoftplus_384_topk are now one helper, _topk_outputs_ok. It keeps the row-stride check of the sigmoid path, which the 384 path now also gets. On gfx1250, op_tests/triton_tests/moe/moe_routing/test_topk_gating.py (the sigmoid specialization) passes at this head.

Tests at 5944ccd27

  • gfx950: pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py tests/test_topk_gating_sqrtsoftplus_384_dispatch.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py: 197 passed, 26 skipped.
  • gfx1250: the same command gave 34 passed, 189 skipped. The 384 file is skipped because gfx1250 is not in the table.
  • CPU (GPU-less container): python3 -m pytest -q tests --continue-on-collection-errors fails on the same set as the merge base (test_aot_drivers collection, test_mega_moe_gfx1250_recipe and test_plugin_routed_ops, all because there is no GPU arch to detect). I ran this on the rebased branch just before gfx1250 was removed from the table. That change only drops parametrized cases of the new CPU test, and the new CPU test passes at this head in the two GPU runs above.
  • New tests: test_topk_gating_keeps_hip_for_another_call (GPU) checks that the inline call-site checks keep a non-renormalized or sigmoid call on HIP under capture. test_the_arch_is_looked_up_once (CPU) checks that the arch is queried once and then read from the module-level value.
  • black 26.10.1 / ruff clean. The Self-Review section is updated to 5944ccd2714f, and main's pr_self_review.py reports 0 issues.
  • Not run: gfx1250-strict hardware. Its entry is the layout that passed the whole file on gfx1250 against multiwave<384, 4> at 941a98479.

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

⚠️ Action required before merge (3)

  1. Add a power-of-two assert for LANES in the kernel. _sqrtsoftplus_384_topk finds the lane that owns expert idx with idx & (LANES - 1) (owner mask, aiter/ops/triton/_triton_kernels/moe/moe_routing/topk_gating.py), but only asserts EPT in {3, 6} and WAVES * LANES * EPT == 384. A future table entry with a non-power-of-two lanes value would compile and take the weight from the wrong lane. Add tl.static_assert(LANES & (LANES - 1) == 0, ...) next to the two existing asserts.
  2. Make sqrtsoftplus_384_topk check its own tensor contract, or make it private. The wrapper (aiter/ops/triton/moe/moe_routing/topk_gating.py:81) is public, but only the topk_gating predicate checks gating_output.stride(1) == 1, shape[1] == 384, the dtypes and the output column stride. The kernel reads row_ptr + cols, so a direct caller with column-strided logits gets wrong ids and no error. Either raise ValueError on these in the wrapper, as it already does for num_valid_rows and the arch, or rename it _sqrtsoftplus_384_topk_launch and keep topk_gating as the only entry point.
  3. Let the required CI finish at 5944ccd27 and refresh the Self-Review. Triton Tests (MI35X) shards 0/2/3/5, the py3.12 wheel build and the Aiter Test run (its MI35X shard 0 runs tests/, which includes the new CPU dispatch test) are still pending. The aiter-bot Self-Review comment still reports revision 0d3cb7ed7b51.

Re-reviewed at 5944ccd. Already fixed: rebased onto main (merges cleanly). gfx1250 is out of the table (your call), and gfx1250-strict keeps (4, 32, 3), which matches HIP because the vwave gate is get_gpu_arch() == "gfx1250" (topk_gating_kernels.cuh:107-113). A CPU port of both kernels gives 0/504 mismatching rows for gfx950 (1,64,6) vs topk_gating_kernel_opt and for gfx1250-strict (4,32,3) vs multiwave<384,4>, including ties, NaN, ±inf and constant rows. Eager cost: call-site rejects, a module-level arch entry, and the capture query placed before the tensor checks. gfx1250 is now within noise; on gfx950 an eager call of at most 2048 rows still pays the capture query (+2.8–3.6% by your numbers), which is accepted as the cost of the graph-only dispatch. get_gfx_runtime() is read once in the wrapper, and the output checks share _topk_outputs_ok. Copilot's 3 items were fixed earlier.

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

⚠️ Correction to my review above: one more required change (1)

  1. Drop the torch.cuda.is_current_stream_capturing() query from the topk_gating dispatch and choose the Triton path another way. My review above called the remaining gfx950 eager cost acceptable; I withdraw that. The query runs on every eager call (aiter/ops/topk.py:154, called at :307-316), and your own table shows gfx950 eager calls of 1–1024 rows at +2.8–3.6% versus the merge base. That cost lands on every caller's default path, so it cannot stay. The Triton kernel is bit-identical to HIP for the table layouts (0/504 mismatches in our CPU port), so the choice does not need to depend on capture state. Make it static instead, for example: pick the path from the arch entry and the row bucket alone (Triton wherever it is faster for that shape, HIP otherwise), or let the caller ask for it with an explicit argument (the graph-capturing caller passes it; eager callers keep the HIP default and pay nothing). Either way the eager path should go back to the merge-base host cost.

The three items in my review above still stand.


Correction at 5944ccd.

@yhl-amd yhl-amd changed the title [Triton/Gluon] [gfx1250] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths [Triton/Gluon] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths Nov 17, 2026
@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Update at 7fbb94dcd (fast-forward from 5944ccd27; that head is kept on the fork as bak/7846-pre1117u):

  • gfx1250-strict removed from SQRTSOFTPLUS_384_ARCHS. Its Triton timing against the HIP kernel was never measured on hardware, so the table keeps only gfx950, the one arch where the graph timing was measured. gfx1250 and gfx1250-strict both keep the HIP kernel. The table comment and the sqrtsoftplus_384_topk docstring are updated to match, and so are the description and the title, which now says [gfx950] instead of [gfx1250] [gfx950].
  • Order of the eager checks is unchanged. The capture query stays after the scalar checks and before the tensor checks, as explained with data in my previous reply.

gfx950 at 7fbb94dcd (one idle GPU): pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py tests/test_topk_gating_sqrtsoftplus_384_dispatch.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py: 194 passed, 26 skipped. The skips are the gfx1250-only sigmoid cases. python op_tests/test_moe_topk_gating.py --section softplus-384 --num-tokens 1,2,4,...,1024,2048 --topk 6,8: 0 id and 0 weight-bit mismatches in all 24 configs, and the Triton kernel is not slower than HIP under graph replay at any of them, the same as on the previous head.

The PR Self-Review section is updated to 7fbb94dcd.

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

⚠️ Action required before merge (4)

  1. Remove torch.cuda.is_current_stream_capturing() from the topk_gating dispatch; this is still not done at 7fbb94dcd. aiter/ops/topk.py:154 still queries capture state on every eager in-range gfx950 call. Your 16:15 update keeps this order on purpose, but my correction at 5944ccd asked to remove the query, and that still stands. Your own data rules out a row-bucket-only choice: in eager mode the Triton launch costs more host time than the HIP kernel saves. So add an explicit argument, for example topk_gating(..., prefer_triton_384=False). The graph-capturing caller passes True, and every other caller keeps HIP. Test the argument first at the call site (topk.py:307), so eager callers do no extra work beyond what the merge base does. Then remove graph_only from SqrtSoftplus384Arch and change the tests that patch is_current_stream_capturing (tests/test_topk_gating_sqrtsoftplus_384_dispatch.py:34-49, test_topk_gating_sqrtsoftplus_384.py:139-160) to use the argument. Update the PR body and the table comment, which still describe capture-based dispatch.
  2. Add a power-of-two assert for LANES in the kernel. This is still missing. _sqrtsoftplus_384_topk finds the owning lane with idx & (LANES - 1) (_triton_kernels/moe/moe_routing/topk_gating.py:235), but only EPT in {3, 6} and WAVES*LANES*EPT == 384 are asserted (:173-174). Add tl.static_assert(LANES & (LANES - 1) == 0, ...).
  3. Make sqrtsoftplus_384_topk check its own tensor contract, or make it private. This is still not done. The wrapper (aiter/ops/triton/moe/moe_routing/topk_gating.py:100-112) checks only num_valid_rows and the arch. Its docstring lists limits (BF16 [rows, 384] with unit column stride, FP32 bias, FP32/INT32 outputs, top-k 1–8, max_rows) that only the topk_gating predicate enforces. A direct caller with column-strided logits gets wrong ids and no error. Raise ValueError on these, or rename the function _sqrtsoftplus_384_topk_launch.
  4. Let the required CI finish at the new head. At 7fbb94dcd, Triton Tests (MI35X) shards 0–7 and the py3.12 wheel build are still pending. The PR Self-Review run was cancelled, though the aiter-bot comment shows PASS at 7fbb94dcdcce.

Re-reviewed at 7fbb94d. Already fixed: gfx1250-strict is now out of the table, so only gfx950 is measured and enabled. No new getattr/hasattr/inspect/ImportError probing. Off gfx950 the eager cost is a cached None check. Earlier items (rebase, one arch table, _topk_outputs_ok, first launch under capture, gfx1250 log, Self-Review fields, Copilot's 3) remain fixed.

@yhl-amd

yhl-amd commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks. All four items of your 17:52Z review are addressed at 1974ec1e7 (one commit on top of 7fbb94dcd; old head kept as bak/7846-pre1118b on the fork). The PR body and the table comment are updated.

1. No capture query in the dispatch: explicit prefer_triton_384 argument

  • topk_gating(..., prefer_triton_384: bool = False). The argument is the first term of the dispatch condition at the call site, so a default call does one boolean test and then runs topk_gating_fwd exactly as on the merge base. With True, the existing call-site checks, the arch entry, the row range and the tensor contract decide; a call that does not fit still runs HIP, so True never changes a result.
  • torch.cuda.is_current_stream_capturing() is gone from aiter/ops/topk.py. SqrtSoftplus384Arch no longer has graph_only.
  • Tests no longer patch the capture query. tests/test_topk_gating_sqrtsoftplus_384_dispatch.py replaces both kernels with recorders and checks: only a call with prefer_triton_384=True runs Triton; a call outside the limits runs HIP even when it asks; a default call never reaches _can_use_sqrtsoftplus_384_topk (patched to fail) and does not even resolve the arch entry. In test_topk_gating_sqrtsoftplus_384.py, the bit-identity cases go through topk_gating(..., prefer_triton_384=True) and fail if HIP runs; the graph replay test and the fresh-process first-launch test capture with True and use default eager calls as the HIP reference (the latter still asserts that those eager calls compile nothing).
  • One consequence to flag: the argument changes the signature of the routed op, so @_route(op="topk_gating") moves to version=2 and tests/plugin_contracts.json records the new contract (same pattern as mla_sparse_prefill_v41 v2). v1 is not listed in supersedes: a v1 provider takes one argument fewer and the arity check rejects it. The Kernel Provider Interface job passes at the new head.

Which caller passes True. None in this PR, and this PR does not change ATOM. The intended one is ATOM's FusedMoE.select_experts in atom/model_ops/moe.py (the topk_gating(...) call in the scoring_func in ("sigmoid", "sqrtsoftplus") branch), which is where DeepSeek-V4.1's 384-expert sqrtsoftplus routing reaches aiter on the native ATOM path. The follow-up there, after ATOM's aiter pin includes this PR, is to pass prefer_triton_384=get_forward_context().in_hipgraph. ModelRunner.capture_model sets in_hipgraph=True through set_forward_context for its capture loop (warm-up forward included), and replay runs no Python, so only the captured decode graphs take the Triton kernel and eager prefill keeps HIP. The vLLM plugin path sets in_hipgraph=False because the frontend owns capture there, so it keeps HIP until it gets its own flag.

Eager cost against the merge base (default call, no argument; DSV4.1 router args; one GPU; five rounds, each round a fresh process per tree in rotation; median over rounds; the bare HIP binding is timed in the same process):

arch topk_gating() at 1974ec1e7 vs merge base 0d894387b same, previous head 7fbb94dcd per-round spread of the new head change of the part above the bare HIP binding
gfx950 +0.3% to +1.0% over 1–4096 rows, top-k 6 and 8 +3.9% to +6.7% −2.4% to +1.0% −0.2% to +0.8% of the call (median +0.4%)
gfx1250 +1.1% to +3.3% −0.5% to +2.1% −3.4% to +3.7% −0.3% to +1.1% of the call (median +0.5%)

On gfx1250 the bare HIP binding in the same processes was itself +0.4% to +2.8% slower for the new tree, so most of that column is process-to-process noise; the cost that topk_gating adds above HIP moved by well under 1% of the call on both arches. The small remaining positive bias is consistent with the extra argument in the op schema; it is inside the round-to-round spread.

Graph replay on gfx950 (op_tests/test_moe_topk_gating.py --section softplus-384, 1–2048 rows, top-k 6 and 8): 0 id and 0 weight-bit mismatches; Triton against HIP is −0.2% to −8.4% for top-k 6 (three shapes at +0.3% to +1.2%, inside noise) and −1.7% to −11.7% for top-k 8.

2. LANES power-of-two assert. Added next to the two existing asserts in _sqrtsoftplus_384_topk. It is written tl.static_assert((LANES & (LANES - 1)) == 0, ...): without the outer parentheses Python parses LANES & (LANES - 1) == 0 as LANES & ((LANES - 1) == 0), which is 0 for LANES == 64 and would reject the valid gfx950 entry.

3. sqrtsoftplus_384_topk is now private: _sqrtsoftplus_384_topk_launch. I chose the rename over wrapper-side ValueError checks because:

  • topk_gating(..., prefer_triton_384=True) is now the documented way to get this kernel, and it already holds the full contract check (_can_use_sqrtsoftplus_384_topk), with a HIP fallback instead of an error. Raising in a public wrapper would need a second copy of the same contract, which can drift from the dispatch, and on the opted-in path every check would run twice.
  • aiter/ops/triton/README.md says to launch a kernel only from its public wrapper and that tests call the wrapper. The GPU tests now go through topk_gating(..., prefer_triton_384=True) and assert that HIP did not run; the op-test section uses the same call and asserts that the dispatch takes Triton for each config. So both test the real entry point.
  • The launcher takes the arch entry from the dispatch (no second arch lookup) and keeps its num_valid_rows check, which the dispatch does not do; the GPU test for a bad num_valid_rows now reaches it through topk_gating. Its docstring says it is private and lists the limits the caller has checked.

4. CI at the new head. I will watch the required jobs at 1974ec1e7 and refresh the Self-Review if the bot does not pick up the new revision. If MI35X Standard shards 3/4 fail on op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py with CustomAllreduce having no attribute _is_gfx1250, that failure is on main and on other open aiter PRs too; this PR does not touch the allreduce code. A Docker Hub 429 gets a rerun of the failed jobs.

Validation at 1974ec1e7:

  • gfx950: pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py tests/test_topk_gating_sqrtsoftplus_384_dispatch.py tests/test_plugin_contracts.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py: all pass (only the gfx1250-only sigmoid cases skip). pytest tests: the same single failure as the merge base (test_mega_moe_gfx1250_recipe.py::test_layout), plus the new passing cases.
  • gfx1250: the same pytest command: all pass (the GPU file skips, since gfx1250 has no table entry).
  • black 26.10.1 and ruff 0.16.0 are clean on the changed files; the PR Self-Review section validates with 0 issues against main's pr_self_review.py.

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

⚠️ Action required before merge (3)

  1. Delete the kernel branches that no table entry can select. SQRTSOFTPLUS_384_ARCHS now has only gfx950: (1, 64, 6, 2048), so the EPT == 3 sort and head pick (aiter/ops/triton/_triton_kernels/moe/moe_routing/topk_gating.py:184-187, 218-221) and the multi-wave path (wave_v/w/i at :213-215, the else at :246-249, the wave merge at :251-273) never compile in production or in CI. Your Validation section lists them as unverified. Keep only the path that runs: tl.static_assert(WAVES == 1 and EPT == 6, ...) (or drop WAVES/EPT from the table). When gfx1250 or gfx942 gets a measured entry, that PR can add the branch back along with its own test.
  2. Fix the cache comment in aiter/ops/topk.py:126-128. It says later calls "neither import the Triton module nor query the arch", but every opted-in call still runs the function-level from .triton.moe.moe_routing.topk_gating import _sqrtsoftplus_384_topk_launch at :322-324. Say that only the arch query is cached.
  3. Let MI35X Standard Tests finish at 1974ec1e7. At this head, shards 0–7 of Standard Tests (1 GPU, MI35X) are still pending. Triton Tests (MI35X) shards 0–7, both wheel builds, Kernel Provider Interface, and Black/Ruff pass.

Re-reviewed at 1974ec1. Already fixed: torch.cuda.is_current_stream_capturing() and graph_only are gone. Dispatch is now static through topk_gating(..., prefer_triton_384=False), and that flag is the first term at topk.py:313, so a default call costs one bool test before running topk_gating_fwd as on the merge base (test_a_default_call_does_no_triton_check). The route is bumped to v2 and plugin_contracts.json is updated. The LANES power-of-two static_assert is in (:175). The launcher is private (_sqrtsoftplus_384_topk_launch) and topk_gating is its only entry point. The PR body and table comment are updated. Earlier items stay fixed: gfx950-only table, _topk_outputs_ok, first launch under capture, and Copilot's 3.

@yhl-amd

yhl-amd commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks. Your 04:56Z review is addressed at a935e8354 (one commit on top of 1974ec1e7; that head is kept as bak/7846-pre1118c on the fork). The PR body is updated.

1. Kernel branches that no table entry selects: removed. I took the second option, since with one entry the layout parameters had only one valid value:

  • _sqrtsoftplus_384_topk no longer has WAVES, LANES or EPT parameters. It has the one layout that gfx950 selects (topk_gating_kernel_opt: one wave of 64 lanes, six experts in each lane; LANES is a local tl.constexpr = 64). The three-expert sort network, the EPT == 3 head pick, the wave_v/w/i lists and the wave merge are gone; the code is one-dimensional over the 64 lanes. _pick3 stays only as the half of _pick6. The kernel repr drops the three keys.
  • SqrtSoftplus384Arch keeps only max_rows; the gfx950 entry is SqrtSoftplus384Arch(max_rows=2048). The table comment says that an arch whose HIP kernel has another layout needs its own kernel path and test before it can have an entry.
  • Because LANES is now the literal 64, the power-of-two static_assert from the last round went with the parameter; the owner mask is still idx & (LANES - 1).
  • The launcher no longer takes the arch entry, since it has nothing to read from it.
  • The arithmetic of the one-wave path is unchanged: the same sort, the same head pick, the same lowest-lane tie break and owner mask, and the weights summed in selection order. On gfx950 at a935e8354: the whole test_topk_gating_sqrtsoftplus_384.py passes with the CPU dispatch test and the plugin contract test, and --section softplus-384 over 1–2048 rows and top-k 6 and 8 has 0 id and 0 weight-bit mismatches. The graph timing is the same as at 1974ec1e7 within noise.

2. Cache comment in aiter/ops/topk.py: fixed. It now says that only the arch query is cached, and that each opted-in call still runs the function-level launcher import in topk_gating.

3. MI35X Standard Tests at 1974ec1e7. They finished. Standard (1 GPU, MI35X) shards 0, 1, 2 and 4–7 passed; shard 0 runs tests/, which includes the new CPU dispatch test. Shard 3 failed in one test only, op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py::test_matching_ranks_build[fused], with AttributeError: 'CustomAllreduce' object has no attribute '_is_gfx1250'. The same test fails the same way in the main push runs of Aiter Test at 88f8a5538 (runs 44186759543 and 44163212509); this PR does not touch the allreduce code. All Triton (MI35X) shards 0–7, both wheel builds, OPUS, Kernel Provider Interface and Black/Ruff passed at 1974ec1e7. I will watch the same jobs at a935e8354 and rerun only Docker Hub rate-limit failures.

black 26.10.1 and ruff 0.16.0 are clean on the changed files, and the Self-Review section validates with 0 issues at a935e8354 against main's pr_self_review.py.

@junhaha666 junhaha666 closed this Nov 18, 2026
@junhaha666 junhaha666 reopened this Nov 19, 2026
@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 7846 --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.

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

⚠️ Action required before merge (4)

  1. Keep topk_gating's default signature and route at v1; give the graph caller its own entry point. Adding prefer_triton_384 widens the aiter_routed::topk_gating custom-op schema (aiter/ops/topk.py:233-247, route v2). Every eager call parses, defaults and boxes the 10th argument, so every default caller on every arch pays extra host time: +50 to +290 ns per call (~1-3%) in two independent in-process A/Bs against the merge base (real route(), base and head on one pinned core, alternating order, head slower in every pair; base/base and head/head controls at noise). A 9-arg vs 10-arg signature-only variant reproduces the whole delta, so the cost is the schema, not the bool test. Your own 11-18 eager numbers show the same bias. The v2 bump also stops v1 plugin providers from serving default calls. My 11-17 ask for an explicit argument and my r40 note that a default call "costs one bool test" did not foresee this; sorry for the extra round. Fix: restore topk_gating and tests/plugin_contracts.json to the merge base (v1, fingerprint b6325c278faa3184), and add a separate aiter entry, e.g. topk_gating_sqrtsoftplus_384(...) with the 9-arg signature, that runs the call-site checks and _can_use_sqrtsoftplus_384_topk, launches Triton, and otherwise calls topk_gating (its own baseline entry if routed). A probe of this layout is back at control level.
  2. Cover the untested dispatch terms in tests/test_topk_gating_sqrtsoftplus_384_dispatch.py. 13 of 34 single-term deletions of the guard (topk.py:162, :313-318) survive every CPU and GPU test, and 8 of them would corrupt results or read/write out of bounds on the Triton path: e.g. num_shared_experts == 0, gating_output.shape[-1] == 384 (a 256-expert call with no bias reaches the 384-only kernel), the bias shape == (384,) / stride(0) == 1, the output column stride, and topk_ids.shape == (rows, topk). Add rejecting cases: experts=256 and 512 with bias="none", experts=384, shared=1, an fp32 bias of [383]/[192] and zeros(768)[::2], outputs with column stride 2, outputs with fewer rows than the logits. Commit 00062f8d says each term is covered; that is not true at head.
  3. Make HIP-only changes run the HIP/Triton bit-identity check, or correct the PR body. select_triton_tests.select() picks no tests for csrc/kernels/topk_gating_kernels.cu, csrc/include/topk_gating_kernels.cuh or aiter/ops/topk.py, and Standard Tests never run op_tests/triton_tests/, so a HIP-only PR (e.g. aiter#7838) would not run test_topk_gating_sqrtsoftplus_384.py. Either run the softplus-384 section by default on gfx950 in op_tests/test_moe_topk_gating.py, or say the check is caught only by the nightly / ci:triton-355 run.
  4. Nit: reword the commit messages, or squash before merge. The repo squashes with COMMIT_MESSAGES. a9d43667, 88549828, 5944ccd2, 00062f8d and 1974ec1e describe a gfx1250 Triton path, multiwave<384,4>, graph_only dispatch, an arch ValueError and EPT/LANES asserts; none exist at head.

Pre-existing (not required): aiter/plugin/README.md still says "Five ops are routed today". CI: Standard shard 1 hit the Docker Hub rate limit (please rerun); shard 3 fails test_flydsl_allreduce_rank_agreement (_is_gfx1250), as on main. Triton MI35X shards 0-7 pass.


Reviewed at a935e83 (deep; two independent full passes, 7 hunters, 10 verifiers, 2 C2 miss passes). Items 1-3 were missed by earlier rounds (the code is unchanged since r40). Already fixed: the EPT==3 / multi-wave branches are gone; the cache comment says only the arch query is cached; MI35X CI ran. Kernel bit identity against topk_gating_kernel_opt replayed on CPU: 0 mismatches for topk 1-8 with ties, NaN/±inf and pad rows. Copilot's 3 asks are fixed (moe_routing/topk_gating.py:99-104, test_moe_topk_gating.py:1233,1246); please resolve those outdated threads.

@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-light-384 branch from a935e83 to 8bc19ff Compare November 20, 2026 02:27
@yhl-amd yhl-amd changed the title [Triton/Gluon] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths [Triton/Gluon] [gfx950] topk_gating_sqrtsoftplus_384: light Triton top-k for 384-expert sqrtsoftplus routing under graph capture Nov 20, 2026
@yhl-amd

yhl-amd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks, and no problem about the extra round. All four items of your 11-19 17:27Z review are addressed at 8bc19ff6e. The branch is now one commit on top of the same merge base 0d894387b; the old head is kept as bak/7846-pre1120a on the fork. The PR body and title are updated.

1. topk_gating and its route are back to the merge base; the graph caller has its own entry.

  • topk_gating (signature, body and @_route(op="topk_gating", version=1)) and tests/plugin_contracts.json (fingerprint b6325c278faa3184) have no diff against 0d894387b. The topk.py diff only adds module-level helpers and the new function after the topk_softplus alias, so a default call runs the same code as on the merge base.
  • New topk_gating_sqrtsoftplus_384(...) in aiter/ops/topk.py, with the 9-argument signature of topk_gating, not routed (exported as aiter.topk_gating_sqrtsoftplus_384). It runs the call-site checks and _can_use_sqrtsoftplus_384_topk, then launches Triton; any other call goes to topk_gating with the same arguments. It also goes to topk_gating when the HERD opt-in (AITER_FLYDSL_USE_HERD) is on, so that path keeps its order. The predicate now accepts correction_bias=None as well as an empty tensor.
  • Re-measured on gfx950, eager default topk_gating() with DSV4.1 router args, at 8bc19ff6e against the merge base. Method: separate processes for the two trees on one pinned core, alternating order per round, ten rounds; the bare HIP binding topk_gating_fwd is timed in the same process.
    • What topk_gating() costs above the bare HIP binding in the same process changed by −0.14% to +0.12% of the call (12 shapes: 1–4096 rows, top-k 6 and 8). So it is at control level.
    • Whole-call medians differ by +1% to +3% between the two processes. The bare HIP binding, which is the same code in both trees, moves by the same amount. With base's module_moe_topk.so copied into the head tree (an identical binary), the gap is still the same as the bare-binding gap. The per-round spread is −4% to +4%. So I read that difference as process-to-process noise, not as an effect of this PR.
  • The intended caller is unchanged from my 11-18 note: ATOM's FusedMoE.select_experts (atom/model_ops/moe.py) calls aiter.topk_gating_sqrtsoftplus_384 instead of topk_gating when get_forward_context().in_hipgraph is set, after ATOM's aiter pin includes this PR. Eager callers keep calling topk_gating and pay nothing.

2. Untested dispatch terms: covered. tests/test_topk_gating_sqrtsoftplus_384_dispatch.py now drives the entry with recorders in place of both kernels and has one case per guard term that must reach HIP:

  • no renorm, sigmoid, softmax, one shared column, zero rows;
  • experts=256 and 512 with no bias;
  • FP16 logits; a BF16 bias; FP32 biases of [383], [192] and zeros(768)[::2];
  • top-k 0 and 9;
  • column-strided logits; [8, 1, 384] logits with unit stride on dim 1 (so only the ndim term rejects them);
  • weights or ids with column stride 2, with overlapping rows (expand), with fewer rows than the logits, or both with fewer rows;
  • FP16 weights, INT64 ids, 1-D ids, ids wider than the weights;
  • the HERD opt-in.

I also ran the deletion check myself: each of 29 single-term deletions of the guard, the predicate and _topk_outputs_ok, against the CPU dispatch test alone. All 29 are killed now. The first pass had 5 survivors (HERD, logits ndim, ids ndim, the (rows, topk) part of the shape chain, the weights dtype); I added the HERD case, the [8, 1, 384] logits, the 1-D ids, both outputs with fewer rows and the FP16 weights for those. The old commit message that claimed full coverage is gone with the squash.

3. HIP-only changes now run the bit-identity check. I took the first option: op_tests/test_moe_topk_gating.py runs the softplus-384 section by default on an arch in SQRTSOFTPLUS_384_ARCHS. --section now defaults to None, and the default list adds softplus-384 when get_gfx_runtime() is in the table. Standard Tests run that file on MI35X, so a HIP-only change such as #7838 compares topk_gating_fwd with the Triton kernel bit for bit. The section goes through topk_gating_sqrtsoftplus_384 and asserts that the dispatch takes Triton for each config. With the default grid (1, 64, 256 and 1024 rows; top-k 1, 2, 4, 6 and 8) on gfx950 it has 0 id and 0 weight-bit mismatches, and the full default run passes. The PR body also says that select_triton_tests does not pick the pytest file for csrc/ or aiter/ops/topk.py changes.

4. Commit messages. The seven commits are squashed into one, 8bc19ff6e. Its message describes only what is at head: the entry, the single-layout kernel, gfx950 only, the default section and the tests.

Also done: the three outdated Copilot threads are resolved. I did not touch aiter/plugin/README.md ("Five ops are routed today"), since this PR no longer changes a routed op.

Validation at 8bc19ff6e on gfx950:

  • pytest op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py tests/test_topk_gating_sqrtsoftplus_384_dispatch.py tests/test_plugin_contracts.py op_tests/triton_tests/moe/moe_routing/test_topk_gating.py: all pass; only the gfx1250-only sigmoid cases skip. The bit-identity cases, the graph replay with a changing num_valid_rows and the first compile inside capture go through the new entry and assert that HIP does not run.
  • pytest tests: the same single failure as the merge base (test_mega_moe_gfx1250_recipe.py::test_layout), plus the new passing cases.
  • python op_tests/test_moe_topk_gating.py with no arguments: all default sections pass, softplus-384 included.
  • black 26.10.1 and ruff 0.16.0 are clean; the Self-Review section validates with 0 issues against main's pr_self_review.py.

CI at a935e8354 matched your note: shard 1 hit the Docker Hub rate limit, and shard 3 failed only in test_flydsl_allreduce_rank_agreement (_is_gfx1250), as on main. I will watch the new head and rerun only rate-limit failures.

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

A direction change from our side; sorry for the churn after you just reworked this to a separate entry.

We'd like topk_gating to choose the Triton kernel internally again, as in your original version, but without torch.cuda.is_current_stream_capturing():

  • Drop topk_gating_sqrtsoftplus_384 and the prefer_triton_384 argument. topk_gating keeps its merge-base signature and v1 contract, and callers change nothing.
  • Inside topk_gating, route a call to the Triton kernel statically, from the arch table and the call's shape: gfx950 entry, renormalized 384-expert sqrtsoftplus, no shared columns, rows within the table limit. Route every other call to HIP as today. No capture-state query, no per-call env read.
  • Keep the static checks cheap and ordered so that a call that can't match (other arch, other expert count, other scoring) exits on the first test. Please post the default-call host cost against the merge base on gfx950 and one other arch.
  • Please also post eager timings for the shapes that now go to Triton, next to the graph-replay table you already have, so the eager trade-off is on record.
  • Keep the bit-identity test, the dispatch-term tests and items 2–4 of our last review (dispatch-term coverage, HIP-only changes running the bit-identity check, squash text).

@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-light-384 branch from 8bc19ff to 455c4e4 Compare November 20, 2026 10:35
@yhl-amd yhl-amd changed the title [Triton/Gluon] [gfx950] topk_gating_sqrtsoftplus_384: light Triton top-k for 384-expert sqrtsoftplus routing under graph capture [Triton/Gluon] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths Nov 20, 2026
@yhl-amd

yhl-amd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks, no problem. The 03:58Z direction is implemented at 455c4e485. It is again one commit on the merge base 0d894387b; the previous head is kept as bak/7846-pre1120b on the fork. The PR body and title are updated.

Dispatch

  • topk_gating_sqrtsoftplus_384 and prefer_triton_384 are gone. topk_gating keeps the merge-base signature and the v1 route, and tests/plugin_contracts.json has no diff, so callers change nothing.
  • topk_gating picks the kernel statically, after the existing HERD check and before topk_gating_fwd, in this order:
    1. The module-level arch entry. It starts as a truthy sentinel; the first call that reaches the predicate sets it to the gfx950 entry or to None. Off the table, every later call ends at this one test.
    2. score_func == "sqrtsoftplus", need_renorm, num_shared_experts == 0, gating_output.shape[-1] == 384.
    3. _can_use_sqrtsoftplus_384_topk: the row range (gfx950: 1 to 2048) and the tensor contract.
  • There is no capture-state query and no per-call environment read. Eager calls and calls under graph capture take the same path.

Default-call host cost against the merge base (gfx950 hardware; eager topk_gating(); separate processes per tree on one pinned core, order alternated per round, 8 rounds; the bare HIP binding topk_gating_fwd timed in the same process). "Above HIP" is the change in what topk_gating costs above the bare binding, as a share of the merge-base call:

calls path at head whole call vs merge base above HIP
arch off the table (cached entry set to None; DSV4.1 shapes 1–4096 rows, 256-expert sqrtsoftplus, softmax) first test, then HIP −0.4% to +0.5% −0.39% to +0.08%
gfx950, softmax, 384 experts arch test, score_func test, then HIP +0.6% to +0.7% +0.15% to +0.46%
gfx950, sqrtsoftplus, 256 experts the five cheap tests, then HIP +1.7% to +2.1% +0.66% to +0.97%
gfx950, DSV4.1 shape, 4096 rows (above max_rows) cheap tests and the predicate's row check, then HIP +3.4% to +4.0% +2.3% to +2.6%

There is no gfx1250 or other non-gfx950 GPU among the machines I may use, so the "other arch" row is gfx950 hardware with the cached entry set to None. That is exactly the state an off-table arch reaches after its first call, and its cost is at control level. The CPU dispatch test checks that such a call never reaches the predicate. In the gfx950 head processes the bare binding also ran +0.3% to +3% slower than in the base processes, so part of the whole-call column there is process-to-process noise; the "above HIP" column is the cost the dispatch adds.

Shapes that now take Triton: eager next to graph replay (gfx950, DSV4.1 router args with an FP32 bias; eager = wall clock per topk_gating() call, median of 8 rounds; graph = op_tests/test_moe_topk_gating.py --section softplus-384 at this head):

rows top-k eager Triton vs merge-base eager HIP graph replay Triton vs HIP
1 6 +24.2% −0.4%
1 8 +23.6% −1.4%
64 6 +24.7% +1.1%
64 8 +24.7% −3.6%
512 6 +25.6% −1.9%
512 8 +25.2% −8.5%
1024 6 +25.5% −5.5%
1024 8 +25.4% −12.7%
2048 6 +25.8% −9.2%
2048 8 +25.6% −3.5%

So in eager mode these calls pay about a quarter more per call. That is host time: the Triton launch path costs more than the HIP binding, and the kernel time is too small to hide it. Under graph replay, where decode runs, the Triton kernel is faster than or within noise of HIP. That is the trade-off of a static choice. Both graph runs (these 10 configs and the 20-config default grid) have 0 id and 0 weight-bit mismatches.

Items 2–4 of the previous review are kept.

  • Dispatch-term coverage. tests/test_topk_gating_sqrtsoftplus_384_dispatch.py now drives topk_gating with recorders in place of both kernels, with the same per-term cases as before. New checks: calls that cannot match (no renorm, sigmoid, softmax, a shared column, 256 or 512 experts) never reach the tensor checks, and an off-table arch stops at the cached None after one arch query. The 28 single-term deletions of the gate, the predicate and _topk_outputs_ok are all killed by the CPU test alone.
  • HIP-only changes run the bit-identity check. On an arch in the table, op_tests/test_moe_topk_gating.py runs softplus-384 by default.
  • Squash text. The single commit message describes only what is at head.

Validation at 455c4e485, gfx950

  • The four test files (test_topk_gating_sqrtsoftplus_384.py, the CPU dispatch test, tests/test_plugin_contracts.py, test_topk_gating.py) all pass; only the gfx1250-only sigmoid cases skip. The bit-identity cases now run eager topk_gating and assert that HIP does not run; graph replay and the first compile inside capture also go through topk_gating.
  • pytest tests: the same single failure as the merge base (test_mega_moe_gfx1250_recipe.py::test_layout).
  • python op_tests/test_moe_topk_gating.py with no arguments: all default sections pass.
  • black 26.10.1 and ruff 0.16.0 are clean; the Self-Review section validates with 0 issues.
  • gfx1250 was not run at this revision; off the table it takes the first-test exit measured above.

On CI: at 8bc19ff6e the 3.12 wheel build failed on a Docker Hub 429, and Triton shard 6 failed on a broken pip download. Both were rerun; the new head supersedes them. I will watch the new head and rerun only rate-limit or download failures.

@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-light-384 branch from 455c4e4 to 2273c95 Compare November 20, 2026 10:45
@yhl-amd

yhl-amd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: the Black check failed at 455c4e485 on one line in op_tests/test_moe_topk_gating.py (a topk_gating(...) call that fits on one line). Fixed at 2273c95c8 by amending the single commit; it is a formatting change only, and the code and the numbers above are unchanged. Black 26.10.1 and ruff 0.16.0 are now clean on all changed files. The previous head is kept as bak/7846-pre1120c.

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

⚠️ Action required before merge (7)

The static dispatch inside topk_gating, with no capture query, follows our 11-20 direction. Thanks for posting the cost tables. Kernel bit identity against topk_gating_kernel_opt was replayed on CPU: 0 mismatches over 4,500 fuzz cases (ties, NaN/±inf, lane exhaustion, pad rows, top-k 1-8).

  1. Resolve the arch entry on the first topk_gating call, not on the first 384-expert call. aiter/ops/topk.py:124-131, 145-149, 306-318. _sqrtsoftplus_384_arch leaves _UNSET (which is truthy) only from inside _can_use_sqrtsoftplus_384_topk. A process that never makes a renormalized 384-expert sqrtsoftplus call stays at _UNSET forever, so every sqrtsoftplus call runs all five tests, including gating_output.shape[-1] (~180 ns). Examples: gfx942/gfx1250 serving 256-expert DSV4-Flash, or any non-384 model. Three independent in-process A/Bs (base vs a same-file mutant, one pinned core, with controls) measured +235 to +273 ns per call on that default path; controls stayed within ±10 ns. The comments at :126-130 and :306-308 ("a call on any other arch ends here") are false in this state, and the CPU test test_an_arch_outside_the_table_stops_at_the_first_test passes only because its first call has 384 experts. Fix: at the top of the gate, if _sqrtsoftplus_384_arch is _UNSET: _sqrtsoftplus_384_arch = _runtime_sqrtsoftplus_384_arch(), then drop that step from the predicate. Measured at +13 to +22 ns vs main, with identical routes over 34,560 fuzzed calls per arch. Also add a CPU test whose first call is 256-expert.
  2. Make tests/test_topk_gating_sqrtsoftplus_384_dispatch.py run in CI. #8352 (11-20) removed the only pytest tests step. In run 44721913054 no job runs tests/, so the coverage of every dispatch term (our earlier item 2) is local only. Move the file to op_tests/ (split_tests.sh finds it there, and Standard Tests run it on every PR) and add if __name__ == "__main__": sys.exit(pytest.main([__file__, "-q"])), because aiter_test.sh runs op_tests files with python3 file.
  3. Add NaN, all-NaN, tie and no-bias rows to bench_sqrtsoftplus_384 (op_tests/test_moe_topk_gating.py:523). For a HIP-only PR (.cuh, .cu, topk.py), select_triton_tests picks nothing. That leaves this section as the only bit-identity check, and its input is _make_gating (unique finite values) plus a random bias. So #7838 would merge green while gfx950 HIP and Triton diverge, and the body's claim that "the bit-identity checks here have all-NaN rows" is false on that path. Add one all-NaN row, one row with NaN every 3rd column, and one constant row, and run each config both with and without a bias (None vs torch.empty(0) for HIP).
  4. Drop the per-call triton.next_power_of_2 and the function-local import on the Triton path. At aiter/ops/triton/moe/moe_routing/topk_gating.py:118, next_power_of_2 is a ConstexprFunction costing 1.7-3.4 µs per eager call, vs 35-90 ns for 1 << (topk - 1).bit_length(), which gives the same value for top-k 1..8. Also bind _sqrtsoftplus_384_topk_launch once instead of importing it inside topk_gating on each call (topk.py:319, ~0.6 µs). Both costs land on every eager prefill MoE layer on gfx950.
  5. Nit: keep --section-less runs working when no config fits (op_tests/test_moe_topk_gating.py:1152-1161, :1249-1253). On gfx950, --num-tokens 4096,16384 or --topk 16 with the default sections now raises ValueError after the softplus section, so softmax/nan/ties/eplb/shared/pad-rows/unaligned and the summary never run. Skip softplus-384 with a message when it was added by default, and raise only when the user named it.
  6. Nit: add one GPU case with strided outputs. Every Triton-path test allocates outputs as contiguous [rows, k], so a launcher that swapped stride_weights and stride_ids would pass. ATOM's fused-shared path passes total[:, :top_k] views, which reach this kernel. Slice weights and ids from [rows, k+2] buffers and compare bits against HIP.
  7. Nit: pass float(routed_scaling_factor) in the launcher. An int value compiles the scale as i32 and fails tl.math.div_rn ("Expected dtype ['fp32']"). Today only the _as_custom_op fallback can deliver an int, but the HIP path accepts one.

Not required: the HIP topk module is built -fgpu-flush-denormals-to-zero, while this Triton launch is IEEE. It differs only for nonzero denormal biases on zero-score experts or a scale below ~1e-33, so it is unreachable with real routers. allow_flush_denorm=True would make "bit-identical" hold by construction. CI: Standard shard 3 fails test_flydsl_allreduce_rank_agreement (_is_gfx1250), the same as on main. PR Self-Review was cancelled and needs a re-run. softplus-384 ran in shard 3 with 0 mismatches, and the new pytest ran on Triton shard 4 (189 passed).


Reviewed at 2273c95 (deep; two independent full passes, 3+3 hunters, 4 verifiers, C2 miss pass). Items 1, 4 and 6 are in code unchanged since a935e83, so earlier rounds missed them. Already fixed: v1 signature and contract restored (no prefer_triton_384, plugin_contracts.json unchanged); static dispatch without a capture query or env read; every single-term guard deletion is killed by the CPU test (when it runs); softplus-384 is on by default on gfx950; the squash text matches the head; Copilot's 3 asks.

topk_gating sends a renormalized 384-expert sqrtsoftplus call without shared
columns to a Triton kernel when the runtime arch has an entry in
SQRTSOFTPLUS_384_ARCHS and the call fits its limits: BF16 logits with unit
column stride, rows up to the entry's max_rows, an FP32 bias of [384] or
none, FP32/INT32 outputs of [rows, topk] with unit column stride, top-k 1 to
8. The choice is static, from the arch and the call's shape; it does not
read the capture state or the environment. Every other call runs HIP as
before. The signature and the routed contract of topk_gating do not change.

The first topk_gating call resolves the arch entry and binds the launcher,
whatever its shape; after it, a call on an arch that is not in the table ends
the dispatch at its first test.
The table has gfx950 only, up to 2048 rows; gfx1250 keeps HIP, since its
single-wave HIP kernel is at least as fast.

The Triton kernel uses the lane layout of topk_gating_kernel_opt: one wave
of 64 lanes, six experts in each lane, the same sort network, the same
lowest-lane tie break and the renorm sum in selection order. So the ids and
the weights are bit-identical to the HIP kernel. num_valid_rows is read on
the device.

The output checks of the gfx1250 sigmoid specialization and of this dispatch
share one helper. The softplus-384 section of op_tests/test_moe_topk_gating.py
compares the two kernels and times them under graph replay; it is in the
default sections on an arch in the table, so a HIP-only change also runs the
bit-identity check.

The section checks bit identity with a bias and with none, on its benchmark
rows and on all-NaN, NaN-every-third-column, constant and tied rows.

Tests: bit identity against the HIP binding over row counts, top-k, ties,
NaN/inf and constant rows, biases, pad rows and column-sliced outputs; graph
capture and replay with a changing num_valid_rows; the first compile inside
capture in a fresh process; and a CPU test of the dispatch with one case for
each term, under op_tests/ so that Standard Tests run it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-light-384 branch from 2273c95 to 9909b70 Compare November 21, 2026 02:30
@yhl-amd

yhl-amd commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip thanks. All seven items of your 11-20 16:41Z review are addressed at 9909b7002. It is one commit on the merge base 0d894387b; the previous head is kept as bak/7846-pre1121a on the fork. The PR body is updated.

1. The arch entry is resolved on the first topk_gating call that reaches the dispatch, whatever its shape.

  • At the top of the gate: arch = _sqrtsoftplus_384_arch; if arch is _UNSET: arch = _resolve_sqrtsoftplus_384(), then arch is not None and score_func == "sqrtsoftplus" and ....
  • _resolve_sqrtsoftplus_384() sets the cached entry (or None) and also binds the launcher (item 4). The predicate no longer resolves anything; it takes arch as its first argument.
  • The comments now describe this state.
  • New CPU tests:
    • test_an_arch_outside_the_table_stops_at_the_first_test has a first call with 256 experts, and another with softmax. It checks that the entry is resolved to None with one arch query, and that the next DSV4.1-shaped call never reaches the predicate.
    • test_a_first_call_of_another_shape_resolves_the_entry does the same on gfx950, and the later 384-expert call takes Triton.
  • Default-call host cost against the merge base, gfx950 hardware, eager topk_gating(), separate processes per tree on one pinned core, alternating order, 8 rounds. The figure is the change in what topk_gating costs above the bare HIP binding timed in the same process:
calls change vs merge base
off the table (cached entry None: DSV4.1 shapes 1–4096 rows, 256-expert sqrtsoftplus, softmax) −98 to +87 ns, control level
gfx950, softmax +10 to +21 ns
gfx950, 256-expert sqrtsoftplus +178 to +221 ns (the five cheap tests, including shape[-1])
gfx950, DSV4.1 shape at 4096 rows (predicate rejects on rows) +328 to +379 ns

As before, there is no non-gfx950 GPU among the machines I may use, so "off the table" is gfx950 with the cached entry set to None. That is the state any off-table arch reaches after its first call, now including a 256-expert-only process.

2. The dispatch test runs in CI. Moved to op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py, with if __name__ == "__main__": sys.exit(pytest.main([__file__, "-q"])). python3 op_tests/test_topk_gating_sqrtsoftplus_384_dispatch.py passes on its own. I reran the single-term deletion check against this file: 28 deletions of the gate, the predicate and _topk_outputs_ok, and all 28 are killed.

3. bench_sqrtsoftplus_384 covers NaN, ties and no bias. Every config now checks bits four ways:

  • with the random bias and with no bias (None for topk_gating, torch.empty(0) for topk_gating_fwd);
  • on the benchmark rows and on four special rows: all NaN, NaN in every third column, constant, and few distinct values (ties).

The mismatch columns sum all four checks. Graph timing stays with the bias. The section asserts that the dispatch takes Triton for each of these inputs, so the comparison cannot silently be HIP against HIP. The body's statement about all-NaN rows now holds on the HIP-only path too.

4. No per-call next_power_of_2 and no per-call import. TOPK_PAD=1 << (topk - 1).bit_length() gives the same values for top-k 1–8. The launcher is bound once, in _resolve_sqrtsoftplus_384(), and topk_gating calls the bound _sqrtsoftplus_384_launch. Eager topk_gating() on the shapes that take Triton went from +23.6–25.8% to +18.3–21.0% against the merge-base HIP call. That is +2.65 to +2.98 µs, all host time.

Updated eager vs graph table (gfx950; eager as above; graph = --section softplus-384, median of three runs):

rows top-k eager Triton vs merge-base eager HIP graph replay Triton vs HIP
1 6 +18.3% −0.3%
1 8 +18.5% −1.9%
64 6 +18.4% −0.4%
64 8 +18.7% −2.8%
512 6 +19.8% −1.6%
512 8 +19.2% −7.8%
1024 6 +19.9% −4.9%
1024 8 +20.2% −12.2%
2048 6 +21.0% −8.6%
2048 8 +20.6% −3.4%

One measurement note. With the inputs passed to run_perftest as tensor arguments, it rotates deep copies of them per iteration, which puts the HIP column at cold-cache times (Triton −24% to −35% at 512–2048 rows). The section binds its inputs with functools.partial instead, so this table is comparable with the earlier ones.

5. A --section-less run keeps working when no config fits. When softplus-384 was added by default, the section prints SKIP: ... and the other sections run. It raises only when named with --section. Checked on gfx950 with --num-tokens 4096 --num-experts 64 --topk 8 --dtype bf16: it skips softplus-384 and the other sections pass.

6. A GPU case with strided outputs. test_sqrtsoftplus_384_topk_strided_outputs slices weights from [64, 8] and ids from [64, 10] buffers. The two row strides differ, so a swap of stride_weights and stride_ids fails. It compares bits against HIP and checks that the columns after top-k are untouched.

7. float(routed_scaling_factor) in the launcher. Done.

Not done: allow_flush_denorm. As you note, the denormal difference cannot be reached with real routers. I did not want to change the kernel's float mode in this round without its own bit-identity run on denormal inputs. If you want it, I will add it together with such a case.

Validation on gfx950

  • At 9909b7002:
    • test_topk_gating_sqrtsoftplus_384.py plus the moved dispatch test: 230 passed.
    • python op_tests/test_moe_topk_gating.py with no arguments: all sections pass, and softplus-384 has 0 mismatches over the four checks per config.
    • The three graph runs above: 0 mismatches.
  • At 73f2e1949, which differs only in how the section passes its inputs to the graph timer:
    • the same pytest set plus tests/test_plugin_contracts.py and test_topk_gating.py passes;
    • pytest tests has the same single failure as the merge base;
    • the deletion check and the eager timings above.
  • black 26.10.1 and ruff 0.16.0 are clean, checked by exit code. The Self-Review section validates with 0 issues.

CI. Standard shard 3 at 2273c95c8 failed only in test_flydsl_allreduce_rank_agreement (_is_gfx1250), as on main. I will watch the new head and re-run the PR Self-Review once it starts.

@yhl-amd

yhl-amd commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

CI at 9909b7002: the three red jobs are not caused by this PR.

  • Triton Tests (MI35X) / Shard 7: timed out twice at the 60-minute test-step limit. This change touches aiter/ops/triton/, so the full Triton suite runs. Shard 7 of that split has none of this PR's tests: no topk_gating file, and the softplus-384 op-test section is not a pytest file. test_topk_gating_sqrtsoftplus_384.py ran in shard 4 and passed. Shard 7 runs the same first ten files as in main's full-suite runs (test_mha_with_pe, test_pa_mqa_logits_mxfp4, test_gemm_a8w8, test_rope, test_fused_gemm_afp4wfp4_mul_add, ...).
    • Main push run 44845350647 (df3e0b2f6) needed 51.7 of the 60 minutes: 18784 passed, 4074 skipped ... in 3100.74s. Its shard 7 job took 63 minutes.
    • Other full-suite shard 7 jobs today took 68 minutes (44857567663) and 77 minutes (44862100426).
    • In both of our attempts the time went to the same GEMM files on a slower runner: test_gemm_a8w8.py took 19.9 and 21.1 minutes, against 15.7 on main; test_fused_gemm_afp4wfp4_mul_add.py took 13.9 and 14.3, against 11.7. Attempt 2 then hit the limit at test_gemm_a8w8_per_token_scale.py.
  • Standard shard 7: op_tests/test_flydsl_hgemm.py fails changed-input graph with graph replay mismatch: 0.00043 (1 of 2280 elements). The same assertion fails in Aiter Test runs of five other PRs from 11-20/21 (44853054146, 44852601100, 44848304773, 44834463342, and this one); this PR does not touch hgemm or FlyDSL. This PR's op tests passed in other Standard shards: test_moe_topk_gating.py (softplus-384 included) in shard 3, and test_topk_gating_sqrtsoftplus_384_dispatch.py in shard 1.
  • Standard shard 4: test_flydsl_allreduce_rank_agreement (_is_gfx1250), as on main.

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

⚠️ Action required before merge (2)

All 7 items from the last review are fixed, thanks. But main has changed under this PR:

  1. Rebase onto main and re-time Triton against the new gfx950 HIP kernel. Keep the SQRTSOFTPLUS_384_ARCHS entry only where Triton still wins, otherwise close this PR in favour of #8258.
    • What changed: #8258 (9a6a02b, merged 11-23) fixed the slow path in HIP itself. On gfx950, sqrtsoftplus with 384 experts and top-k ≤ 8 now runs topk_gating_kernel_opt_vwave<384, WPT=1> in wave64, and it shifts each lane's list instead of reading it through a runtime cursor.
    • #8258's three-way MI355X table against this PR's Triton kernel:
      • eager GPU time: HIP is 13-19% faster;
      • unprofiled graph replay: HIP is 16-23% faster;
      • profiled graph: tied at 128-512 rows; at 2048 rows, top-k 8, HIP takes 4.39 µs and Triton 5.38 µs.
    • On top of that, the Triton path costs +2.65-2.98 µs of host time per eager call.
    • So after the clean auto-merge, every call this PR routes to Triton (gfx950, 1-2048 rows) is at best equal to HIP and usually slower. This is the same rule as our 11-17 gfx1250 ask: keep an entry only if Triton wins.
    • If an entry survives:
      • narrow max_rows to the range where Triton wins;
      • re-run bit identity against the vwave kernel;
      • fix the text that names topk_gating_kernel_opt as gfx950's HIP kernel (moe_routing/topk_gating.py:27-30, the kernel docstring, the squash message);
      • read gating_output.shape once in the gate. Today topk.py:317 reads shape[-1] and the predicate reads ndim and shape[0] again (:151-153). That is ~150-330 ns on every gfx950 384-expert call, about 9-20 µs per step at 61 layers. shape = gating_output.shape; len(shape) == 2 and shape[1] == 384; pass rows = shape[0]. Also drop the predicate's arch is None test, which can never decide.
  2. Nit: drop the Co-Authored-By: Claude … trailer from the squash message. aiter/ops/triton/README.md rule 29 asks for AI co-author lines to be removed, and this PR touches aiter/ops/triton/.

Root cause vs patch

This is a patch. The root problem was that gfx950's topk_gating_kernel_opt reads register lists at a runtime index in the k-way merge, and the Triton kernel's speed came from avoiding that with select chains. The clean root fix is a shift-based merge in HIP. It has now landed (#8258), and it needs no second kernel, arch table or default-path gate.


Reviewed at 9909b70 (deep re-review: two independent full passes; merges cleanly with main). Both passes found item 1 independently. It was missed by earlier rounds because #8258 landed after the last review.

Already fixed:

  • the arch is resolved on the first call;
  • the dispatch test runs in Standard shard 1 (41 passed);
  • the NaN/tie/no-bias rows (0 mismatches in shard 3);
  • no per-call next_power_of_2 or import;
  • the SKIP when no config fits;
  • the strided-output GPU case;
  • float(routed_scaling_factor).

Kernel bit identity against the merge-base HIP kernel was replayed on CPU: 0 mismatches over 1,500 cases, and a mutant gives 34. CI: the Standard shard 7 test_flydsl_hgemm failure is unrelated, and shard 4 appears to be the known test_flydsl_allreduce_rank_agreement failure (log truncated). Triton shards are green. No review threads are open.

@yhl-amd

yhl-amd commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR in favour of #8258, as suggested in the last review.

I rebased this branch onto main, which merged cleanly, and re-timed the Triton path on gfx950 against the new HIP kernel from #8258 (topk_gating_kernel_opt_vwave<384, WPT=1>, wave64). Results:

  • Bit identity: the Triton kernel is still bit-identical to the new HIP kernel. The GPU test file and the dispatch test pass, and the softplus-384 section shows 0 id and 0 weight-bit mismatches over 14 configs.
  • Graph replay (median of three runs, Triton against HIP):
    • 1–1024 rows: within −0.3% to +2.0%, a tie;
    • 2048 rows: Triton is 4.2% slower at top-k 6 and 19.8% slower at top-k 8.
  • Eager: a topk_gating() call that takes the Triton path is 12% to 17% slower than the same call on main, which runs HIP.

So no shape is left where Triton wins, and there is no SQRTSOFTPLUS_384_ARCHS entry worth keeping. One caveat: another job started on the same machine near the end of the measurement, so there may be a little CPU interference, mostly in the eager numbers. Its direction matches the three-way table in #8258.

The branch stays on the fork. Thanks for the reviews.

@yhl-amd yhl-amd closed this Nov 27, 2026
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.

5 participants