-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Speedup speculative decoding by implementing fr-spec
#24343
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
base: main
Are you sure you want to change the base?
Conversation
fr-spec to speedup speculative decoding
|
This pull request has merge conflicts that must be resolved before it can be |
|
This pull request has merge conflicts that must be resolved before it can be |
|
I fixed a couple of issues with the previous benchmark. Turns out, we were compute bound, not memory bound. I re-ran the benchmark and got:
Like before, I benchmarked vanilla, eagle-2, and fr-spec on mt-bench with llama-3.1-8b-instruct on 100 prompts. Speculative Decoding Benchmark Results
Commands to reproduce the table
Observations:
I made several fixes:
|
| old_weight = self.model.lm_head.weight | ||
|
|
||
| # In-place pruning of the weight | ||
| self.model.lm_head.weight.data = self.model.lm_head.weight.data[self.pruned_vocab].clone().detach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are selcting part of the indices you should ensure that self.model.lm_head.weight.data[self.pruned_vocab].clone().detach() is contiguous.
I guess self.model.lm_head.weight.data[self.pruned_vocab].clone().detach().contiguous() should work.
Look at
https://docs.pytorch.org/docs/stable/generated/torch.Tensor.contiguous.html#torch-tensor-contiguous
|
@jmamou I added a print to the code self.model.lm_head.weight.data = self.model.lm_head.weight.data[self.pruned_vocab].clone().detach()
print(self.model.lm_head.weight.data.is_contiguous())ran the cmd VLLM_USE_V1=1 python3 examples/offline_inference/spec_decode.py \
--dataset-name hf \
--dataset-path philschmid/mt-bench \
--num-prompts 100 \
--compilation-config '{"level": "0"}' \
--max-num-seqs 1 \
--num-spec-tokens 1 \
--draft-vocab-frequency-path 'thunlp/LLaMA3-Instruct-8B-FR-Spec/freq_32768.pt' \
--draft-vocab-frequency-keep-threshold 0.25and got the output For more details, see this pytorch PR. |
|
Documentation preview: https://vllm--24343.org.readthedocs.build/en/24343/ |
Forward ratios: Complete benchmark: My intuition is that (i) large batches evaluated on datasets with (ii) long inputs that induce (iii) long outputs (e.g., GovReport, BookSum) are more likely to demonstrate significant improvements, based on this microbenchmark: #24506 (comment). |
Implement FR-Spec: Accelerating Large-Vocabulary Language Models via Frequency-Ranked Speculative Sampling to speedup speculative decoding. @keyboardAnt @Achazwl @jmamou.
Purpose
Test Plan
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.