[BUG]: vLLM disaggregated decode reuses KV from a different request's image for non-Qwen vision models
Describe the Bug
In disaggregated prefill/decode serving with the vLLM backend, the decode worker can serve KV that was computed from a different request's image. The model then answers about that other image, with HTTP 200, no error and no log line. The decode prefix cache is shared by every request on the worker, so this crosses request and user boundaries.
It affects non-Qwen vision models. Qwen-VL has a dedicated guard (construct_qwen_decode_mm_data, whose docstring already describes this hazard: "causing decode to incorrectly reuse cached KV from different images").
Mechanism on main:
VllmMultimodalRequestProcessor.prepare_input,DisaggregationMode.DECODE, non-Qwen branch: usesexpanded_prompt_token_idsand setshas_mm_data = False, somulti_modal_datastaysNone(introduced by #7827 to avoid re-downloading images on decode).build_tokens_promptstill setsmulti_modal_uuidsfrom the forwarded hashes, but vLLM ignores them whenmulti_modal_datais absent:vllm/renderers/base.py::_process_tokensfalls back totokens_input(prompt_token_ids).- With no
mm_features, vLLM'sgenerate_block_hash_extra_keysadds no multimodal keys, so decode's KV block hashes cover token ids only. Image placeholder tokens are the same for any two images of the same size. - Two requests with the same text and same-size images therefore hash identically on decode, and the second one matches the first one's cached blocks.
Steps to Reproduce
Unit level (no GPU, no network). Against components/src/dynamo/vllm/multimodal_utils/request_processor.py; it fails today.
components/src/dynamo/vllm/tests/multimodal_utils/)from types import SimpleNamespace
from unittest.mock import AsyncMock
import pytest
from dynamo.common.constants import DisaggregationMode
from dynamo.vllm.multimodal_utils import request_processor as mod
def _processor(*, model: str) -> mod.VllmMultimodalRequestProcessor:
return mod.VllmMultimodalRequestProcessor(
model=model,
enable_multimodal=True,
enable_frontend_decoding=False,
image_loader=SimpleNamespace(load_image_batch=AsyncMock(return_value=[])),
video_loader=SimpleNamespace(load_video_batch=AsyncMock(return_value=[])),
audio_loader=SimpleNamespace(
load_audio_batch=AsyncMock(return_value=[]),
load_audio=AsyncMock(return_value=None),
),
use_unified_vision_chunk=False,
)
async def _prepare_prompt(processor, request, request_id, context, mode):
processor.validate_multimodal_request(request)
prepared = await processor.prepare_input(request, request_id, context, mode)
return prepared.pre_rendered_prompt or processor.build_tokens_prompt(
prepared.request,
prepared.multi_modal_data,
prepared.mm_processor_kwargs,
)
async def _decode_prompt(mm_hash: str):
"""A non-Qwen decode request as the frontend forwards it: same text, one image."""
return await _prepare_prompt(
_processor(model="llava-hf/llava-1.5-7b-hf"),
{
"token_ids": [1, 2],
"multi_modal_data": {
"image_url": [{"Url": f"https://example.com/{mm_hash}.png"}]
},
"extra_args": {"mm_hashes": [mm_hash]},
"prefill_result": {
"disaggregated_params": {
"embedding_params": {"expanded_prompt_token_ids": [1, 99, 99, 2]}
}
},
},
f"request-{mm_hash}",
None,
DisaggregationMode.DECODE,
)
def _engine_cache_identity(prompt) -> tuple:
"""What vLLM folds into the KV block hash for this prompt's media.
vLLM reads multi_modal_uuids only when multi_modal_data is present
(renderers/base.py::_process_tokens); a pre-rendered MultiModalInput carries
mm_hashes; cache_salt is applied either way.
"""
salt = prompt.get("cache_salt")
if prompt.get("type") == "multimodal":
return ("mm_hashes", repr(prompt.get("mm_hashes")), salt)
if prompt.get("multi_modal_data"):
return ("multi_modal_uuids", repr(prompt.get("multi_modal_uuids")), salt)
return ("tokens_only", None, salt)
@pytest.mark.asyncio
async def test_non_qwen_decode_keeps_distinct_images_distinct():
a = await _decode_prompt("a1b2c3d4e5f60718")
b = await _decode_prompt("f0e1d2c3b4a59687")
assert _engine_cache_identity(a) != _engine_cache_identity(b), (
"two different images give the decode engine the same cache identity "
f"({_engine_cache_identity(a)}); with identical token ids their KV block "
"hashes collide and decode can serve one request's image KV to the other"
)FAILED test_non_qwen_decode_keeps_distinct_images_distinct
AssertionError: two different images give the decode engine the same cache identity (('tokens_only', None, None)); with identical token ids their KV block hashes collide and decode can serve one request's image KV to the otherEnd to end.
- Serve a non-Qwen vision model with the vLLM backend as 1 prefill + 1 decode,
--enable-multimodal,--kv-transfer-config='{"kv_connector":"NixlConnector","kv_role":"kv_both"}', prefix caching on (default). We useddeepseek-ai/DeepSeek-V4.1-Flash. - Run the script below against the frontend. It sends N requests with identical text and N different images, each showing a distinct 4-digit code, and checks that each answer names its own code.
- Compare with
UNIQUE=1(a unique text prefix per request) and with the same model served aggregated.
mm_burst.py#!/usr/bin/env python3
"""N chat requests: identical text, N different images, each with a distinct code.
Usage: mm_burst.py <frontend-url> <model> [n=24] (WORKERS=1 for sequential)"""
import base64, concurrent.futures as cf, io, json, os, random, sys, time, urllib.request
from PIL import Image, ImageDraw, ImageFont
url, model = sys.argv[1].rstrip("/"), sys.argv[2]
n = int(sys.argv[3]) if len(sys.argv) > 3 else 24
WORDS = ["HARBOR", "MAPLE", "ORBIT", "CANYON", "VIOLET", "TUNDRA", "SILVER", "MEADOW"]
try:
FONT = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 72)
except OSError:
FONT = ImageFont.load_default()
def one(i):
rnd = random.Random(i)
code, word = f"{rnd.randint(1000, 9999)}", WORDS[i % len(WORDS)]
img = Image.new("RGB", (640 + 8 * i, 240), "white")
d = ImageDraw.Draw(img)
d.text((40, 40), f"CODE {code}", fill="black", font=FONT)
d.text((40, 140), word, fill=(0, 0, 200), font=FONT)
buf = io.BytesIO(); img.save(buf, format="PNG")
prefix = f"Request {i}. " if os.environ.get("UNIQUE") else ""
body = {"model": model, "max_tokens": 40, "temperature": 0, "messages": [{"role": "user", "content": [
{"type": "text", "text": prefix + "What 4-digit code and what word are written in this image? Answer as: code=<digits> word=<word>"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64," + base64.b64encode(buf.getvalue()).decode()}}]}]}
req = urllib.request.Request(f"{url}/v1/chat/completions", data=json.dumps(body).encode(),
headers={"Content-Type": "application/json"})
t0 = time.time()
with urllib.request.urlopen(req, timeout=300) as r:
msg = json.loads(r.read())["choices"][0]["message"].get("content") or ""
return code in msg and word.lower() in msg.lower(), time.time() - t0, msg[:40]
workers = int(os.environ.get("WORKERS", n))
with cf.ThreadPoolExecutor(workers) as ex:
res = list(ex.map(one, range(n)))
print(f"correct={sum(r[0] for r in res)}/{n} (workers={workers}, unique_text={bool(os.environ.get('UNIQUE'))})")
for ok, _, msg in res:
if not ok:
print(" miss:", msg)python mm_burst.py http://<frontend>:<port> <model> 24 # concurrent
WORKERS=1 python mm_burst.py http://<frontend>:<port> <model> 8 # sequential
UNIQUE=1 python mm_burst.py http://<frontend>:<port> <model> 24 # unique text per requestExpected Behavior
Every answer names the code from its own image, as it does when the same model is served aggregated. Decode must never reuse KV computed from a different request's media; its block hashes should carry the same per-image identity that prefill uses.
Actual Behavior
| run | correct |
|---|---|
| P/D, 24 concurrent, identical text | 1 / 24; answers name codes and words from other requests' images |
| P/D, 8 sequential, identical text | 1 / 8, ~0.30 s each (prefix-cache hits) |
| P/D, 24 concurrent, unique text per request | 24 / 24 |
| aggregated, same model, identical text | 19 / 24; all codes correct, the misses are formatting |
Worker counters around the sequential run: decode prefix_cache_hits +1024 / queries +1736 and external_prefix_cache_hits +712; prefill prefix_cache_hits +0. Decode found the block-aligned span covering the image placeholders in its own cache and pulled only the tail from prefill.
Environment
- ai-dynamo 1.5.0 (vLLM backend), vLLM 0.29.1rc1, torch 2.13.0 (CUDA 13.0)
- Python 3.12.3, Ubuntu 24.04.4 LTS, x86_64
- NVIDIA B300, driver 590.48.01
- The affected code path is unchanged on
mainas of 2026-09-28.
Additional Context
- Related: #7827 introduced the decode-side media skip. #15166 (draft) forwards a prefill-resolved identity to decode, but on the non-Qwen path it still reaches vLLM as
multi_modal_uuidswithoutmulti_modal_data, so this bug is unaffected. #15100 is the same class of silent wrong-image bug inImageLoader. - Suggested fix: on non-Qwen decode, pass a pre-rendered
MultiModalInputbuilt from the forwardedmm_hashes,mm_placeholdersandexpanded_token_ids, withmm_kwargsitems set toNone. This is the same construction_receive_mm_kwargsalready does for aggregated workers, minus the pixels. vLLM acceptsNoneitems (MultiModalKwargsOptionalItems;inject_into_mm_cacheskips them), and the encoder never runs for spans delivered as KV. Decode then gets the same positional per-image keys as prefill and still skips the download. It needs two guardrails:mm_processor_cache_gb=0on multimodal decode workers (the LRU receiver cache raises onNoneitems it does not hold), and a fail-closed uniquecache_saltwhen a request's identity or placeholders are missing. - Other backends: SGLang is not affected; its disaggregated decode passes the image URLs again. TensorRT-LLM appears to have the same shape (decode passes
multi_modal_data=None, and the transceiver skips blocks the generation side already holds) but we have not reproduced it there.
Happy to send a PR for the vLLM path.
Source: ai-dynamo/dynamo