From 4049941a82befbab1be84bbe8a6bad8903ad969f Mon Sep 17 00:00:00 2001 From: Makcum888e <79456407+Makcum888e@users.noreply.github.com> Date: Thu, 22 Oct 2026 04:34:29 +0300 Subject: [PATCH] [Fix] [NPU] scope: fix dtype error in sampling backend ascend (#39609) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ronnie_zheng Co-authored-by: Артем Савкин <58187114+OrangeRedeng@users.noreply.github.com> --- python/sglang/srt/layers/sampler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/sglang/srt/layers/sampler.py b/python/sglang/srt/layers/sampler.py index 7d3a34ab1a..d44d697a0b 100644 --- a/python/sglang/srt/layers/sampler.py +++ b/python/sglang/srt/layers/sampler.py @@ -874,6 +874,7 @@ def top_k_top_p_min_p_sampling_from_logits_ascend( """ # torch_npu.npu_top_k_top_p requires top_k value range in [1, 1024] if hasattr(torch_npu, "npu_top_k_top_p") and npu_top_k_top_p_eligible: + top_ps = top_ps.to(logits.dtype) logits_top_k_top_p = torch_npu.npu_top_k_top_p(logits, top_ps, top_ks) probs_top_k_top_p = logits_top_k_top_p.softmax(dim=-1)