[Fix] [NPU] scope: fix dtype error in sampling backend ascend (#39609)

Co-authored-by: ronnie_zheng <zl19940307@163.com>
Co-authored-by: Артем Савкин <58187114+OrangeRedeng@users.noreply.github.com>
This commit is contained in:
Makcum888e
2026-10-22 04:34:29 +03:00
committed by GitHub
co-authored by ronnie_zheng Артем Савкин
parent aa10927271
commit 4049941a82
+1
View File
@@ -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)