Skip to content

test: add nan/inf clamp regression test for fused_topk_bias#40553

Merged
vadiklyutiy merged 1 commit into
vllm-project:mainfrom
jhaotingc:jhaotingc/issue_40457
Apr 22, 2026
Merged

test: add nan/inf clamp regression test for fused_topk_bias#40553
vadiklyutiy merged 1 commit into
vllm-project:mainfrom
jhaotingc:jhaotingc/issue_40457

Conversation

@jhaotingc
Copy link
Copy Markdown
Contributor

@jhaotingc jhaotingc commented Apr 21, 2026

Add test_fused_topk_bias_nan_inf_clamp to cover the same NaN/Inf scenario as test_fused_topk_nan_inf_clamp but for the fused_topk_bias entry point. On CUDA, fused_topk_bias routes through the same topk_softmax/topk_sigmoid kernels fixed in #39391 (lines 131/154 of topk_softmax_kernels.cu), so the clamp already applies.

Closes #40457

Purpose

PR #39391 fixed NaN/Inf gating logits producing duplicate expert IDs in fused_topk by clamping scores to 0 in topk_softmax_kernels.cu (lines 131/154 for the warp-level path, line 457 for the fallback path). However,
the regression test added in that PR only covered fused_topk. This PR adds the same nan/inf regression test for fused_topk_bias, which is used by DeepSeek-style models with e_score_correction_bias.

On CUDA, fused_topk_bias routes through the same topk_softmax / topk_sigmoid C++ kernels that were patched in #39391, so the clamp already applies. This PR confirms that coverage with an explicit test.

Test Plan

  • Added test_fused_topk_bias_nan_inf_clamp to
    tests/kernels/moe/test_fused_topk.py, parametrized over:
    • dtype: bfloat16, float16, float32
    • scoring_func: softmax, sigmoid
    • bad_value: NaN, Inf
    • num_experts: 6, 8, 16
    • topk: 3, 4
    • Total: 144 test cases
  • Verified the test is automatically collected by the existing
    Kernels MoE Test CI step (no .buildkite/ changes needed):
    # Simulate exactly what buildkite runs:
    pytest tests/kernels/moe --collect-only -q | grep nan_inf
    # Shows both test_fused_topk_nan_inf_clamp (added in #39391) and
    # test_fused_topk_bias_nan_inf_clamp (this PR) are collected
  • Ran the full test_fused_topk.py suite (720 tests) to check for regressions.

Test Result

nan/inf regression tests (144 cases)

Kernel clamp nan/inf tests passed nan/inf tests failed
Disabled (pre-#39391 behaviour) 36 108
Enabled (post-#39391, this PR) 144 0

Full test suite (720 cases, 2×H200, CUDA 13.0)

720 passed, 16 warnings in 104.91s

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Add test_fused_topk_bias_nan_inf_clamp to cover the same NaN/Inf
scenario as test_fused_topk_nan_inf_clamp but for the fused_topk_bias
entry point. On CUDA, fused_topk_bias routes through the same
topk_softmax/topk_sigmoid kernels fixed in vllm-project#39391 (lines 131/154 of
topk_softmax_kernels.cu), so the clamp already applies.

Closes vllm-project#40457

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Copy link
Copy Markdown

@claude claude Bot left a comment

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.

@jhaotingc
Copy link
Copy Markdown
Contributor Author

@claude review

@jhaotingc
Copy link
Copy Markdown
Contributor Author

cc @vadiklyutiy

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a regression test for the fused_topk_bias kernel to ensure that NaN or Inf values in gating logits do not lead to duplicate expert IDs or non-finite weights when expert score correction bias is present. I have no feedback to provide as there were no review comments.

@vadiklyutiy
Copy link
Copy Markdown
Member

I think we also should add this test to CI. I don't see the tests name or corresponding dir in .buildkite

@jhaotingc
Copy link
Copy Markdown
Contributor Author

I think we also should add this test to CI. I don't see the tests name or corresponding dir in .buildkite

Verified the test is automatically collected by the existing Kernels MoE Test CI step (no .buildkite/ changes needed):

# Simulate exactly what buildkite runs:
pytest tests/kernels/moe --collect-only -q | grep nan_inf
# Shows both test_fused_topk_nan_inf_clamp (added in #39391) and
# test_fused_topk_bias_nan_inf_clamp (this PR) are collected

Does this suffice? I'm not familiar with VLLM CI. Thanks.

@jhaotingc
Copy link
Copy Markdown
Contributor Author

@vadiklyutiy
Copy link
Copy Markdown
Member

Does this suffice? I'm not familiar with VLLM CI. Thanks.

Oops, missed it. All good.

@vadiklyutiy vadiklyutiy added ready ONLY add when PR is ready to merge/full CI is needed verified Run pre-commit for new contributors without triggering other tests labels Apr 22, 2026
@vadiklyutiy vadiklyutiy enabled auto-merge (squash) April 22, 2026 00:08
@vadiklyutiy vadiklyutiy merged commit 4679495 into vllm-project:main Apr 22, 2026
23 of 26 checks passed
Copilot AI pushed a commit to hongbolv/vllm that referenced this pull request Apr 22, 2026
…ject#40553)

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Co-authored-by: hongbolv <33214277+hongbolv@users.noreply.github.com>
baonudesifeizhai pushed a commit to baonudesifeizhai/vllm that referenced this pull request Apr 23, 2026
yzong-rh pushed a commit to yzong-rh/vllm that referenced this pull request Apr 23, 2026
…ject#40553)

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Signed-off-by: Yifan <yzong@redhat.com>
avinashsingh77 pushed a commit to avinashsingh77/vllm that referenced this pull request Apr 27, 2026
…ject#40553)

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
Lafunamor pushed a commit to Lafunamor/vllm that referenced this pull request May 1, 2026
…ject#40553)

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Signed-off-by: Adrian <info@zzit.ch>
Copilot AI pushed a commit to hongbolv/vllm that referenced this pull request May 7, 2026
…ject#40553)

Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
Co-authored-by: hongbolv <33214277+hongbolv@users.noreply.github.com>
weifang231 pushed a commit to weifang231/eb-vllm that referenced this pull request May 13, 2026
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
mfylcek pushed a commit to mfylcek/vllm that referenced this pull request May 19, 2026
jhu960213 pushed a commit to jhu960213/vllm that referenced this pull request May 20, 2026
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 verified Run pre-commit for new contributors without triggering other tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fused_topk to CI. Follow-up to 39391

2 participants