---
id: pr-vllm-39391
repo: vllm-project/vllm
pr: 39391
title: 'fix: clamp NaN/Inf in topk_softmax to prevent duplicate expert IDs'
author: jhaotingc
date: '2026-04-21'
url: https://github.com/vllm-project/vllm/pull/39391
source_category: upstream-code
architectures:
- sm90
tags:
- CUDA kernel
- MoE kernel
- arch_pipeline
- attention_kv
- csrc kernel
- moe_routing
- topk
techniques:
- async-copy
- kernel-fusion
- pipeline-stages
hardware_features:
- fp8
- tma
kernel_types:
- attention
- moe
- runtime
- softmax
languages:
- cuda-cpp
- cute-dsl
captured_at: '2026-05-16'
status: merged
merge_sha: 28c222157bbf54881385aae4a102fd04178312be
inclusion_reason: Separate routing, permutation, top-k, and expert GEMM costs; keep tail-token and expert-layout tests attached to the idea.
changed_paths:
- csrc/moe/topk_softmax_kernels.cu
- tests/kernels/moe/test_fused_topk.py
artifact_dir: evidence/pull-bundles/vllm/gh-39391
head_ref_oid: 619d86180f373247d0cd9c6b182be1e2f5ce7b8a
---
# fix: clamp NaN/Inf in topk_softmax to prevent duplicate expert IDs

- Repository: `vllm-project/vllm`
- PR: [39391](https://github.com/vllm-project/vllm/pull/39391)
- Decision: `Separate routing, permutation, top-k, and expert GEMM costs; keep tail-token and expert-layout tests attached to the idea.`
- Reason: Separate routing, permutation, top-k, and expert GEMM costs; keep tail-token and expert-layout tests attached to the idea.

## Changed Paths

- `csrc/moe/topk_softmax_kernels.cu`
- `tests/kernels/moe/test_fused_topk.py`

## Evidence Bundle

`evidence/pull-bundles/vllm/gh-39391`
