From e1cd6c205e8f9a88b50ea5c78653a74b6cd8281e Mon Sep 17 00:00:00 2001 From: Jackie2049 Date: Wed, 15 Jul 2026 09:50:03 +0800 Subject: [PATCH] fix(lora): use block_n=32 on sm_90 to avoid lora_expand NaN On sm_90 (Hopper GPUs), the Triton lora_expand kernel with BLOCK_N=128 causes NaN outputs due to OOB tile reads when N is not aligned to 128. This is documented in issue #48590. Use BLOCK_N=32 on sm_90 (detected via current_platform.has_device_capability(90)) as a safe default that avoids the NaN while maintaining reasonable performance. BLOCK_N=128 is preserved on all other architectures. Refs: vllm-project/vllm#48590 Co-Authored-By: Claude Opus 4.6 --- vllm/lora/ops/triton_ops/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vllm/lora/ops/triton_ops/utils.py b/vllm/lora/ops/triton_ops/utils.py index dd4c0d2097cf..a2d2bf9b2464 100644 --- a/vllm/lora/ops/triton_ops/utils.py +++ b/vllm/lora/ops/triton_ops/utils.py @@ -260,9 +260,15 @@ def get_lora_op_configs( "split_k": 1, } else: + # On sm_90 (Hopper), BLOCK_N=128 causes NaN in lora_expand due to + # Triton OOB tile reads when N is not aligned to 128 (issue #48590). + # Use BLOCK_N=32 on sm_90 to avoid this. + default_block_n = 128 + if current_platform.is_cuda() and current_platform.has_device_capability(90): + default_block_n = 32 default = { "block_m": 64, - "block_n": 64 if num_slices > 1 else 128, + "block_n": 64 if num_slices > 1 else default_block_n, "block_k": 32, "num_warps": 4, "num_ctas": 1,