harness = _Harness(engine=<python.core.async_engine.AsyncLLMEngine object at 0xfffe26f51b40>, loop=<_UnixSelectorEventLoop runni..., 1)], [('serving-req-8', False, 1)], [('serving-req-8', False, 1)], [('serving-req-8', False, 1)]], cache_hits=[0, 1])
def test_prefix_cache_reuses_prefix_and_preserves_output(harness):
"""A repeated long prompt hits the prefix cache without changing output."""
harness.reset()
prompt_len = len(harness.engine.tokenizer.encode(LONG_PROMPT))
assert prompt_len > PAGE_SIZE, (
f"Prefix-cache test needs a prompt longer than one {PAGE_SIZE}-token "
f"block, got {prompt_len} tokens."
)
assert prompt_len + LONG_NEW_TOKENS <= MAX_SEQ_LEN
# Cold run publishes the prefix blocks; hot run must reuse them.
cold = harness.run(_collect(harness.engine, LONG_PROMPT, LONG_NEW_TOKENS))
hits_after_cold = max(harness.cache_hits, default=0)
hot = harness.run(_collect(harness.engine, LONG_PROMPT, LONG_NEW_TOKENS))
> assert hot == cold, (
f"Prefix-cache hit changed greedy output:\n"
f"cold: {cold}\n"
f"hot: {hot}"
)
E AssertionError: Prefix-cache hit changed greedy output:
E cold: [17, 10, 17, 28, 19, 13, 220, 17]
E hot: [17, 15, 17, 18, 12, 15, 19, 12]
E assert [17, 15, 17, 18, 12, 15, ...] == [17, 10, 17, 28, 19, 13, ...]
E
E At index 1 diff: 15 != 10
E
E Full diff:
E [
E 17,
E - 10,
E ? ^
E + 15,
E ? ^
E 17,
E - 28,
E ? ^
E + 18,
E ? ^
E + 12,
E + 15,
E 19,
E - 13,
E ? ^
E + 12,
E ? ^
E - 220,
E - 17,
E ]
Diagnosis
test_prefix_cache_reuses_prefix_and_preserves_output fails in CI
Description
test_prefix_cache_reuses_prefix_and_preserves_output fails in CI stochastically
Command or Request
No response
Environment
CI env
Host Platform
Linux (aarch64)
Device / Platform
CI
Model
Qwen3
Logs
Additional Context
https://github.com/hw-native-sys/pypto-serving/actions/runs/28588930341/job/84767344063