diff --git a/tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py b/tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py index 786c953b0fdf..0e1ec5f566a0 100644 --- a/tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py +++ b/tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py @@ -612,20 +612,29 @@ def sample( generator: Optional[torch.Generator] = None, group_metadata: StrategyMetadata | None = None, ) -> tuple[torch.Tensor, Optional[torch.Tensor]]: - logits = self._prepare_logits_with_temperature( - logits, group_logit_indices, self._temperature - ) - new_tokens = flashinfer.sampling.sampling_from_logits( + new_tokens, _ = self._sample_with_probs( logits, - # NB: Leveraging 'indices' would require applying temperature+softmax before batching, - # because 'flashinfer.sampling.softmax' has no 'indices' argument; but that would - # compute unnecessarily softmax also for situations allowing - # flashinfer.sampling...._sampling_from_logits. - # indices=group_logit_indices, - deterministic=True, + group_logit_indices=group_logit_indices, + top_k=None, + top_p=None, + temperature=self._temperature, generator=generator, - check_nan=self._flashinfer_check_nans(logits), ) + # FIXME: https://nvbugs/5791242 + # logits = self._prepare_logits_with_temperature( + # logits, group_logit_indices, self._temperature + # ) + # new_tokens = flashinfer.sampling.sampling_from_logits( + # logits, + # # NB: Leveraging 'indices' would require applying temperature+softmax before batching, + # # because 'flashinfer.sampling.softmax' has no 'indices' argument; but that would + # # compute unnecessarily softmax also for situations allowing + # # flashinfer.sampling...._sampling_from_logits. + # # indices=group_logit_indices, + # deterministic=True, + # generator=generator, + # check_nan=self._flashinfer_check_nans(logits), + # ) return new_tokens, None class BeamSearchSampleOnly(BeamSearchMixin, StrategyImplSampleOnly):