-
-
Notifications
You must be signed in to change notification settings - Fork 20.6k
[Feature] Universal speculative decoding for heterogeneous vocabularies (TLI) #38174
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
Merged
ywang96
merged 21 commits into
vllm-project:main
from
wan-danfeng:feat/universal-draft-tli
Jul 2, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
10cf5f8
[Feature] Universal speculative decoding for heterogeneous vocabulari…
wonderful199082 6896cbd
fix: raise ValueError when tokenizer lacks unk_token_id in VocabMapping
wan-danfeng 90d145c
fix: remove stray colon in universal_draft condition
wan-danfeng 3bc2b3b
vocab_mapping: fix unk fallback, dynamic space prefix, remove redunda…
wan-danfeng eb4b2f1
spec_decode: merge UniversalDraftModelProposer into DraftModelProposer
wan-danfeng 9c012e9
Remove redundant functions
wan-danfeng 996ffee
chore: address pre-commit warnings
wan-danfeng aa804d7
fix: add use_heterogeneous_vocab flag instead of universal_vocab method
wan-danfeng 53179f5
fix: remove redundant function
wan-danfeng 7b40ced
fix: pre-commit
wan-danfeng dc05e7f
fix: vocab mapping in probabilistic sampling
wan-danfeng d8161db
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng 6ab7a00
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng 03fa9d8
Update vllm/v1/worker/gpu_model_runner.py
wan-danfeng 4b82b77
fix: validate greedy draft sampling only when TLI is enabled and add …
wan-danfeng 6b568aa
doc: pre-commit check
wan-danfeng e595009
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng 3f9a0f1
Merge branch 'main' into feat/universal-draft-tli
benchislett 1323c52
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng 461d8dd
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng a71ce73
Merge branch 'main' into feat/universal-draft-tli
wan-danfeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import pytest | ||
| from transformers import AutoTokenizer | ||
|
|
||
| from vllm.v1.spec_decode.vocab_mapping import _detect_space_prefix | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model_name,expected_prefix", | ||
| [ | ||
| # BPE tokenizer (GPT-2 family) uses Ġ (U+0120) | ||
| ("HuggingFaceTB/SmolLM2-135M-Instruct", ("Ġ",)), | ||
| # SentencePiece tokenizer (LLaMA family) uses ▁ (U+2581) | ||
| ("TinyLlama/TinyLlama-1.1B-Chat-v1.0", ("▁",)), | ||
| # BPE tokenizer (Qwen family) uses Ġ (U+0120) | ||
| ("Qwen/Qwen2.5-0.5B-Instruct", ("Ġ",)), | ||
| ], | ||
| ) | ||
| def test_detect_space_prefix_real_tokenizers(model_name, expected_prefix): | ||
| tokenizer = AutoTokenizer.from_pretrained(model_name) | ||
| result = _detect_space_prefix(tokenizer) | ||
| assert result == expected_prefix, ( | ||
| f"{model_name}: expected {expected_prefix!r}, got {result!r}" | ||
| ) | ||
|
|
||
|
|
||
| def test_detect_space_prefix_fallback_on_failure(): | ||
| """When tokenizer lacks encode(), fall back to both known prefixes.""" | ||
|
|
||
| class BrokenTokenizer: | ||
| def encode(self, text, **kwargs): | ||
| raise RuntimeError("broken") | ||
|
|
||
| result = _detect_space_prefix(BrokenTokenizer()) | ||
| assert result == ("Ġ", "▁") | ||
|
|
||
|
|
||
| def test_detect_space_prefix_empty_encode(): | ||
| """When encode returns empty list, fall back.""" | ||
|
|
||
| class EmptyTokenizer: | ||
| def encode(self, text, **kwargs): | ||
| return [] | ||
|
|
||
| result = _detect_space_prefix(EmptyTokenizer()) | ||
| assert result == ("Ġ", "▁") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.