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

[Speculative decoding] [Bugfix] Fix overallocation in ngram + spec logprobs #4672

Merged
merged 1 commit into from
May 8, 2024

Conversation

cadedaniel
Copy link
Collaborator

@cadedaniel cadedaniel commented May 8, 2024

There's a bug introduced in my spec logprobs PR that only shows up for ngram. We missed it because the ngram tests weren't actually running until recently (#4551).

The bug is that the output logprob tensor of shape (batch_size, num_speculation, vocab_size, sizeof(float32)) is returned once per step, instead of slicing it into (batch_size, 1, vocab_size, sizeof(float32)) views. The spec decode framework does a torch.stack to make contiguous the logprobs of all steps; this caused quadratic memory allocation in num_steps. for a high enough batch size it can cause ooms (e.g. 64).

This is fixed by appropriately slicing the output logprobs.

Copy link
Collaborator

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Good catch!

@cadedaniel cadedaniel changed the title [WIP] Fix overallocation in ngram + spec logprobs [Speculative decoding] [Bugfix] Fix overallocation in ngram + spec logprobs May 8, 2024
@cadedaniel cadedaniel marked this pull request as ready for review May 8, 2024 21:00
@simon-mo simon-mo enabled auto-merge (squash) May 8, 2024 21:01
Copy link
Collaborator

@LiuXiaoxuanPKU LiuXiaoxuanPKU left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@simon-mo simon-mo merged commit 8b9241b into vllm-project:main May 8, 2024
54 of 55 checks passed
z103cb pushed a commit to z103cb/opendatahub_vllm that referenced this pull request May 9, 2024
robertgshaw2-neuralmagic pushed a commit to neuralmagic/nm-vllm that referenced this pull request May 19, 2024
dtrifiro pushed a commit to dtrifiro/vllm that referenced this pull request May 21, 2024
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.

None yet

4 participants