Skip to content

Conversation

@Chenyaaang
Copy link
Collaborator

@Chenyaaang Chenyaaang commented Sep 9, 2025

Description

Fix TPU structured decoding and sampler

  1. Same as [TPU] Fix tpu structured decoding in mixed batches vllm#24458, when there are guided and non-guided requests in the same batch, scheduler_output.grammar_bitmask only contains the entries for guided requests, sort the guided requests and use cumulative index to avoid index out of bound error.
  2. The sampler should be only applied to temperature > 0, for requests with temperature < 0, they should apply the all-greedy results, otherwise,
    logits /= temperatures will flip the result, causing error (e.g. result is !!!!!!!!, where ! refers to token 0).

Tests

Checklist

Before submitting this PR, please make sure:

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have made or will make corresponding changes to any relevant documentation.

Signed-off-by: Chenyaaang <chenyangli@google.com>
@github-actions
Copy link

github-actions bot commented Sep 9, 2025

Description

Start with a short description of what the PR does and how this is a change from
the past.

The rest of the description includes relevant details and context, examples:

  • why is this change being made,
  • the problem being solved and any relevant context,
  • why this is a good solution,
  • some information about the specific implementation,
  • shortcomings of the solution and possible future improvements.

If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/123456
FIXES: #123456

Tests

Please describe how you tested this change, and include any instructions and/or
commands to reproduce.

Checklist

Before submitting this PR, please make sure:

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have made or will make corresponding changes to any relevant documentation.

Copy link
Collaborator

@yaochengji yaochengji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@Chenyaaang Chenyaaang merged commit d460ea9 into main Sep 9, 2025
2 of 3 checks passed
mask_index = scheduler_output.structured_output_request_ids.get(
req_id)
if mask_index is None:
sorted_struct_requests = sorted(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chenyaaang would be good to have a comment here what's happening here and below

utkarshsharma1 pushed a commit that referenced this pull request Sep 14, 2025
Signed-off-by: Chenyaaang <chenyangli@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants