[Bugfix] Preserve prompt token usage details (#5181)
Signed-off-by: Ian Eaves <ian.k.eaves@gmail.com>
This commit is contained in:
1 parent
37c11e6e4f
commit
5730af0a95
9 files changed
+418
-257
No files matched your search
@@ -149,10 +149,19 @@ def _run_prefix_cache_check(openai_client, request_config: dict):
|
||||
2. The number of cached tokens is divisible by the block size used in
|
||||
test_params, because currently upstream vLLM does not cache partial
|
||||
blocks.
|
||||
3. The first request also reports prompt token details; details must be
|
||||
present whenever --enable-prompt-tokens-details is on, even when zero
|
||||
tokens are cached. (An exact cached_tokens == 0 check would be
|
||||
order-dependent here: the module-scoped server may have already cached
|
||||
the shared system-prompt blocks from earlier tests.)
|
||||
|
||||
Returns the (first, second) responses for additional per-test assertions.
|
||||
"""
|
||||
openai_client.send_omni_request(request_config, request_num=1)[0]
|
||||
first_response = openai_client.send_omni_request(request_config, request_num=1)[0]
|
||||
cached_response = openai_client.send_omni_request(request_config, request_num=1)[0]
|
||||
|
||||
assert first_response.cached_tokens is not None
|
||||
|
||||
# Ensure that we have a prefix cache hit on the second request and that only the last
|
||||
# partial block is uncached (since currently we don't cache partial blocks).
|
||||
num_cached_tokens = cached_response.cached_tokens
|
||||
@@ -163,6 +172,8 @@ def _run_prefix_cache_check(openai_client, request_config: dict):
|
||||
assert num_cached_tokens % BLOCK_SIZE == 0
|
||||
assert (num_cached_tokens + num_uncached_tokens) == num_prompt_tokens
|
||||
|
||||
return first_response, cached_response
|
||||
|
||||
|
||||
@pytest.mark.advanced_model
|
||||
@pytest.mark.core_model
|
||||
@@ -195,7 +206,10 @@ def test_thinker_prefix_caching_text_output(omni_server, openai_client) -> None:
|
||||
"stream": False,
|
||||
"modalities": ["text"],
|
||||
}
|
||||
_run_prefix_cache_check(openai_client, request_config)
|
||||
first_response, _ = _run_prefix_cache_check(openai_client, request_config)
|
||||
|
||||
assert first_response.multimodal_tokens is not None
|
||||
assert first_response.multimodal_tokens.get("image", 0) > 0
|
||||
|
||||
|
||||
@pytest.mark.advanced_model
|
||||
|
||||
Reference in new issue
Block a user