[Refactor] Remove dead code multiple places (#61843)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2026-10-16 15:01:07 +00:00
committed by GitHub
parent 8a6c0449b3
commit 8e25bbca19
10 changed files with 14 additions and 168 deletions
-10
View File
@@ -483,16 +483,6 @@ class TopKTopPSampler(nn.Module):
return xpu_sample(logits, k, p, self.logprobs_mode)
# Note: this is a workaround for
# https://github.com/pytorch/pytorch/pull/151218
@torch.compile(dynamic=True, backend=current_platform.simple_compile_backend)
def compiled_random_sample(logits: torch.Tensor) -> torch.Tensor:
probs = logits.softmax(dim=-1, dtype=torch.float32)
q = torch.empty_like(probs)
q.exponential_()
return probs.div(q).argmax(dim=-1).view(-1)
def apply_top_k_top_p(
logits: torch.Tensor, k: torch.Tensor | None, p: torch.Tensor | None
) -> torch.Tensor: