Skip to content

[ROCm][CI] Add coverage for AiterExperts token padding: inf/nan garbage rows - #59334

Merged
AndreasKaratzas merged 8 commits into
vllm-project:mainfrom
divakar-amd:aiter-padding-4c
Oct 8, 2026
Merged

AndreasKaratzas merged 8 commits into
vllm-project:mainfrom
divakar-amd:aiter-padding-4c

Conversation

@divakar-amd

@divakar-amd divakar-amd commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Covers the HIP-graph token-padding portion of the "Test padding" ask in #54966: garbage/padding token rows in a captured graph bucket can carry inf/nan hidden_states, masked via the router's topk_ids=-1/topk_weights=0 contract (grouped_topk_router.py). This is a distinct mechanism from #53108 (which fixes AiterExperts zeroing valid rows when its input buffer is oversized relative to the real token count, an EP-dispatch buffer-sizing issue) -- no existing test proves AiterExperts handles the HIP-graph capture-bucket inf/nan case safely.

Adds test_aiter_moe_token_padding_garbage_rows, which simulates this contract at the tensor level (no real HIP-graph capture needed): fills a subset of rows with inf/-inf/nan and masks their routing, then verifies through AiterExperts that (1) no NaN/Inf leaks into the real rows' output, and (2) real rows' output matches reference_moe_impl computed only over those rows. Parametrized across 3 garbage-row patterns (single inf, single nan, multiple mixed) x 5 quant schemes iterExperts supports. Adds a skipped MXFP4 stub pending MI350/gfx950 hardware.

Stacked on #59333 (4b), since this reuses the _PADDING_* constants and Config.hidden_dim_unpadded plumbing added there. GitHub doesn't support a fork-only branch as a PR base against upstream, so this PR's base is main for now -- the diff currently includes both #59333's commit and this PR's own commit. Only the top commit (token padding: inf/nan garbage rows) needs review here; #59333's commit is under review in that PR. Once #59333 merges, I'll rebase this branch onto the updated main so the diff collapses to just this PR's change.

Test plan

VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_MOE=1 pytest -v -s tests/kernels/moe/test_modular_kernel_combinations.py -k token_padding

Plus a full-file regression run to confirm no regressions.

AI assistance disclosure

This PR was developed with assistance from Claude Code (Anthropic), including test design, implementation, and verification. All test results were independently run and reviewed by me.

@mergify mergify Bot added the rocm Related to AMD ROCm label Sep 30, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Sep 30, 2026
@mergify

mergify Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @divakar-amd.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

Covers step 4c of the "Test padding" ask in vllm-project#54966:
simulates the HIP-graph padding-token contract (grouped_topk_router.py
masking padding rows to topk_ids=-1 / topk_weights=0) at the tensor
level, without needing real HIP-graph capture. Fills a subset of rows'
hidden_states with inf/-inf/nan and masks their routing accordingly,
then verifies through AiterExperts that: (1) no NaN/Inf leaks into the
real (non-garbage) rows' output, and (2) the real rows' output matches
reference_moe_impl computed only over those rows. Parametrized across
3 garbage-row patterns (single inf, single nan, multiple mixed) x 5
quant schemes AiterExperts supports (unquantized + 4 fp8 variants).
Adds a skipped MXFP4 stub pending MI350/gfx950 hardware.

Builds on the Config.hidden_dim_unpadded /
intermediate_size_per_partition_unpadded plumbing and _PADDING_*
constants added in the 4b PR (stacked on that branch since this reuses
those constants directly).

Gated via require_aiter_moe / has_aiter(); inert when AITER isn't
available or off ROCm.

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
The outer @pytest.mark.skip already prevents this test from ever
running; the inner pytest.skip() call is unreachable dead code.

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
ref_out's typical magnitude here (~1e-3-1e-2) sits below the 3e-2 atol
used by both check_accuracy and torch.testing.assert_close, so a fully
zeroed-out mk_out -- e.g. a garbage row's inf/nan corrupting the real
rows via some leak the isfinite check doesn't catch (zero isn't
NaN/Inf) -- would still spuriously pass. Mirrors the same guard added
to the stacked 4b padding-matrix test (vllm-project#59333) for the same reason.

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
_TOKEN_PADDING_M/K/N duplicated _PADDING_M/_PADDING_K_PADDED/
_PADDING_N_PADDED's values under new names. Reusing the originals
avoids the two sets silently drifting out of sync.

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
AiterExperts falls back to AITER's dynamic per-tensor activation quant
for this scheme (rocm_aiter_moe.py ignores per_act_token_quant when
weights are per-tensor), whose scale is a max-abs reduction over the
whole batch. A real inf garbage row legitimately poisons that shared
scale, zeroing every real row's output -- not something AiterExperts
can be expected to isolate against today. Filed upstream as
ROCm/aiter#6275.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
Avoids re-deriving (per_out_ch_quant, per_act_token_quant, block_shape)
by hand -- matches the existing assert_aiter_quant_scheme_case() pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
@divakar-amd divakar-amd changed the title [ROCm] Test AiterExperts token padding: inf/nan garbage rows [ROCm][CI] Add coverage for AiterExperts token padding: inf/nan garbage rows Oct 8, 2026
The dropped lines duplicated what the test's own docstring already
says (what the HIP-graph padding contract simulates); keep only the
non-duplicated "why this is a valid comparison" rationale.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
@divakar-amd
divakar-amd marked this pull request as ready for review October 8, 2026 18:11
Copilot AI balanced review requested due to automatic review settings October 8, 2026 18:11

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@AndreasKaratzas

Copy link
Copy Markdown
Member

/ci run

@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #93671 for commit aa35b90f30cb.

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

The unquantized assertion branch is unreachable, and one quantized case uses the wrong weight-scale layout.

2 open findings
What changed in this PR

Adds ROCm CI coverage for AiterExperts handling of non-finite HIP-graph padding rows.

Changes:

  • Tests three Inf/NaN padding patterns across five quantization schemes.
  • Validates finite, non-degenerate real-row outputs against the reference implementation.
  • Adds a skipped MXFP4 placeholder.
File Description
tests/​kernels/​moe/​test_modular_kernel_combinations.py Adds token-padding test helpers, matrix coverage, and MXFP4 stub.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

f"degenerate/zeroed vs. reference (mean |ref_out|={ref_scale:.6f})."
)

if config.quant_config is not None:
"https://github.com/ROCm/aiter/issues/6275."
)

weights = WeightTensors.make(config)
@AndreasKaratzas
AndreasKaratzas merged commit 18751bc into vllm-project:main Oct 8, 2026
43 checks passed
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…ge rows (vllm-project#59334)

Signed-off-by: Divakar Verma <divakar.verma@amd.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants