Skip to content

Commit

Permalink
Fix min_p sampling crash when using flashinfer backend
Browse files Browse the repository at this point in the history
  • Loading branch information
zifeitong committed Jan 30, 2025
1 parent 9602c2a commit a3660e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/sglang/srt/layers/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def forward(
if sampling_info.need_min_p_sampling:
probs = top_k_renorm_prob(probs, sampling_info.top_ks)
probs = top_p_renorm_prob(probs, sampling_info.top_ps)
batch_next_token_ids, success = min_p_sampling_from_probs(
batch_next_token_ids = min_p_sampling_from_probs(
probs, uniform_samples, sampling_info.min_ps
)
else:
Expand All @@ -95,9 +95,9 @@ def forward(
filter_apply_order="joint",
)

if self.use_nan_detectioin and not torch.all(success):
logger.warning("Detected errors during sampling!")
batch_next_token_ids = torch.zeros_like(batch_next_token_ids)
if self.use_nan_detectioin and not torch.all(success):
logger.warning("Detected errors during sampling!")
batch_next_token_ids = torch.zeros_like(batch_next_token_ids)

elif global_server_args_dict["sampling_backend"] == "pytorch":
# A slower fallback implementation with torch native operations.
Expand Down

0 comments on commit a3660e3

Please sign in to comment.