-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Model] Add num_cached_tokens for PoolingRequestOutput #27378
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| import pytest | ||
| import torch | ||
|
|
||
| from vllm import TokensPrompt | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model", | ||
| ["Qwen/Qwen3-0.6B"], | ||
| ) | ||
| @torch.inference_mode | ||
| def test_embed_models(hf_runner, vllm_runner, model: str): | ||
| n_prompt_tokens = [55, 56, 57] | ||
| token_prompts = [[1024 + i for i in range(n)] for n in n_prompt_tokens] | ||
|
|
||
| with vllm_runner( | ||
| model, | ||
| max_model_len=128, | ||
| enforce_eager=True, | ||
| runner="pooling", | ||
| enable_chunked_prefill=False, | ||
| enable_prefix_caching=False, | ||
| ) as vllm_model: | ||
| pooling_outputs = vllm_model.llm.encode( | ||
| [TokensPrompt(prompt_token_ids=t) for t in token_prompts], | ||
| pooling_task="token_embed", | ||
| ) | ||
|
|
||
| for n, output in zip(n_prompt_tokens, pooling_outputs): | ||
| assert len(output.prompt_token_ids) == n | ||
| assert output.num_cached_tokens == 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1078,6 +1078,9 @@ def encode( | |
| PoolingRequestOutput[Any]( | ||
| request_id="", | ||
| outputs=processed_outputs, | ||
| num_cached_tokens=getattr( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the result of io_processor might not have this value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please unblock Language Models Test (Extended Pooling) and Language Models Test (MTEB) to check for CI failures in the main branch that still need to be fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I think we should make this a property of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| processed_outputs, "num_cached_tokens", 0 | ||
| ), | ||
| prompt_token_ids=[], | ||
| finished=True, | ||
| ) | ||
|
|
||
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.
Should we check that initially the number of cached tokens is zero?