Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix min_tokens when eos_token_id is None #4389

Merged
merged 4 commits into from
Apr 27, 2024

Conversation

njhill
Copy link
Collaborator

@njhill njhill commented Apr 26, 2024

Fixes #4365

Also fix re-use of index variable i within inner loop.

Co-authored-by: DefTruth <31974251+deftruth@users.noreply.github.com>
@njhill njhill requested a review from simon-mo April 26, 2024 04:07
Comment on lines 170 to 177
for j, seq_id in enumerate(seq_ids):
seq_data = sampling_metadata.seq_data[seq_id]
if len(seq_data.output_token_ids) < min_tokens:
seqs_to_penalize.append(i)
seqs_to_penalize.append(j)

if seqs_to_penalize:
# convert to the index into logits
seqs_to_penalize = [start_idx + i for i in seqs_to_penalize]
# use set() to remove any duplicates
token_ids_to_penalize = set(sampling_params.stop_token_ids +
[sampling_params.eos_token_id])
seqs_to_penalize = [start_idx + j for j in seqs_to_penalize]
Copy link
Collaborator

Choose a reason for hiding this comment

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

wait I don't understand the both i -> j here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@simon-mo there is an outer loop over the sequence groups enumerated with index i and within that two separate loops that now each use index j (well this one is actually a comprehension)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could change this one to k just to be clearer? but they don't overlap so I think it's ok like this too...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@simon-mo let me know if you're good with this, I think this is ready to merge if so!

@simon-mo simon-mo merged commit 81661da into vllm-project:main Apr 27, 2024
48 checks passed
@njhill njhill deleted the fix_none_eos_token branch April 27, 2024 16:53
robertgshaw2-neuralmagic pushed a commit to neuralmagic/nm-vllm that referenced this pull request May 6, 2024
)

Co-authored-by: DefTruth <31974251+deftruth@users.noreply.github.com>
z103cb pushed a commit to z103cb/opendatahub_vllm that referenced this pull request May 7, 2024
)

Co-authored-by: DefTruth <31974251+deftruth@users.noreply.github.com>
mawong-amd pushed a commit to ROCm/vllm that referenced this pull request Jun 3, 2024
)

Co-authored-by: DefTruth <31974251+deftruth@users.noreply.github.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
3 participants