Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down