-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Added the option of returning hidden states #15434
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
Closed
Settheworldonfireiii
wants to merge
24
commits into
vllm-project:main
from
Settheworldonfireiii:main
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0b50102
removed v1
Settheworldonfireiii 54be999
Update vllm/engine/llm_engine.py
Settheworldonfireiii f1ef852
Update vllm/outputs.py
Settheworldonfireiii d8fad3d
Update vllm/outputs.py
Settheworldonfireiii bc20a00
Update vllm/outputs.py
Settheworldonfireiii 808bf9e
Update vllm/engine/llm_engine.py
Settheworldonfireiii 1edd330
added test and customized/restored llm_engine.py
Settheworldonfireiii 92c64ca
fixed none device issue
Settheworldonfireiii 0db7e4e
fixed hidden_states to if hidden_states is not None
Settheworldonfireiii 1b9926e
change 3D tensor to temporary store hidden states in llm engine to a …
Settheworldonfireiii 69e3593
locally passed all stuff
Settheworldonfireiii ec04c07
locally passed all stuff
Settheworldonfireiii 9ba998f
locally passed all stuff
Settheworldonfireiii 944b438
locally passed all stuff
Settheworldonfireiii 79eba9a
correct yapf and ruff
Settheworldonfireiii 46c29df
fixed ruff
Settheworldonfireiii 0fd0d2a
fixed line 1175 in llm_engine.py
Settheworldonfireiii 9e36cf1
fixed llm engine hidden_states associated with value
Settheworldonfireiii 131ceb2
fixed llm engine hidden_states associated with value
Settheworldonfireiii dc4f311
fixed llm engine hidden_states associated with value
Settheworldonfireiii 3944594
fixed llm engine hidden_states associated with value
Settheworldonfireiii 1cea671
fixed styling : brace
Settheworldonfireiii 320694c
removed redundant files
Settheworldonfireiii eda3470
fixed yapf
Settheworldonfireiii 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import pytest | ||
import torch | ||
|
||
from vllm import LLM, SamplingParams | ||
|
||
|
||
@pytest.mark.skip_global_cleanup | ||
def test_return_hidden_states(): | ||
model = LLM("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B") | ||
sampling_params = SamplingParams(skip_special_tokens=False, | ||
return_hidden_states=True) | ||
prompt = "Now, tell me about Aspect's experiment \ | ||
related to EPR and quantum physics" | ||
|
||
o = model.generate( | ||
prompt, | ||
sampling_params=sampling_params, | ||
) | ||
|
||
assert isinstance(o[0].hidden_states, torch.Tensor) |
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
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
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.
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.
this will not work. you are putting
return_hidden_states
as a request-level parameter, which means you can get a mixture of a batch, some of them requires token output, while some of them requires hidden state output. This cannot be handled well.I don't think we will accept this feature. If you really want to use it, you can just change the code in
vllm/worker/model_runner.py
to write the tensor output to a file, and you just read the file directly.A similar ask is to get attention masks from vllm, which we will not accept, either.
We might accept them as a tutorial, saying that, this feature will not be supported in vllm, but you want to have it, here is how you can modify vllm's code to achieve it, just for your own usage.