Skip to content

Commit 647d31e

Browse files
authored
bugfix: Change default index in routingTopKExperts (#1347)
## 📌 Description When all expert scores are `NaN` or `-INFINITY` the default expert index is returned which is currently -1, and this causes an illegal memory access, changed the default index to 0. Signed-off-by: Amir Klein <[email protected]>
1 parent 0c9a92c commit 647d31e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

csrc/trtllm_fused_moe_routing_kernel.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ __forceinline__ __device__ void routingTopKExperts(cg::thread_block_tile<WarpSiz
561561
DataType const* ptrScores) {
562562
DataType minScore = DataType{-INFINITY};
563563
DataType maxScore = minScore;
564-
int32_t maxExpertIdx{-1};
564+
int32_t maxExpertIdx{0};
565565
using DataTypeVec = std::conditional_t<sizeof(DataType) == 2, float2, float4>;
566566

567567
// Non-vectorized loading: directly access ptrScores with expertIdx

0 commit comments

Comments
 (0)