Skip to content

Commit

Permalink
[TPU][Bugfix] Fix next_token_ids shape (vllm-project#8128)
Browse files Browse the repository at this point in the history
  • Loading branch information
WoosukKwon authored Sep 3, 2024
1 parent f1575dc commit 0af3abe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vllm/worker/tpu_model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def _execute_model(*args):
batch_idx += 1
else:
for seq_id in seq_ids:
next_token_id = next_token_ids[batch_idx][0]
next_token_id = next_token_ids[batch_idx]
seq_outputs.append(
SequenceOutput(seq_id, next_token_id,
{next_token_id: zero_logprob}))
Expand Down Expand Up @@ -722,6 +722,9 @@ def forward(
sampled_token_ids = torch.multinomial(probs,
num_samples,
replacement=True)
if num_samples == 1:
argmax_token_ids = argmax_token_ids.squeeze(dim=-1)
sampled_token_ids = sampled_token_ids.squeeze(dim=-1)
next_token_ids = torch.where(t != 0, sampled_token_ids,
argmax_token_ids)
return next_token_ids
Expand Down

0 comments on commit 0af3abe

Please sign in to comment.