[Refactor] Standardize data entry key names to {type}.{qualifier} format (#1829)

Signed-off-by: Divyansh Singhvi <divyanshsinghvi@gmail.com>
Signed-off-by: dsinghvi <divyanshsinghvi@gmail.com>
Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
Co-authored-by: Zhou Taichang <tzhouam@connect.ust.hk>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
authored and GitHub committed 2026-04-25 18:15:38 +08:00
1 parent 755a2d9d96
commit 2390350533
41 files changed
+1192 -569

No files matched your search

+14 -12
View File
@@ -16,6 +16,7 @@ from vllm.v1.engine.output_processor import (
from vllm.v1.engine.parallel_sampling import ParentRequest
from vllm.v1.metrics.stats import IterationStats
from vllm_omni.data_entry_keys import unflatten_payload
from vllm_omni.outputs import OmniRequestOutput
logger = init_logger(__name__)
@@ -56,23 +57,21 @@ class OmniRequestState(RequestState):
return x
if isinstance(payload, dict):
# Keep payload flat (dotted keys like "hidden_states.layer_0")
# during accumulation so that all values are tensors/scalars and
# the merge logic below works correctly. Unflatten happens
# later in _consolidate_multimodal_tensors after concatenation.
incoming: dict[str, Any] = {}
target_key = self.mm_type or "hidden"
for k, v in payload.items():
# Normalize producer keys to the modality name.
# AR runners produce {"hidden": ...} and generation
# runners produce {"model_outputs": ...}; remap both
# to the semantic modality key (e.g. "audio", "latent").
if k == "model_outputs":
k = target_key
elif k == "hidden" and target_key != "hidden":
k = target_key
if isinstance(v, dict):
incoming[k] = {str(sk): _to_cpu(sv) for sk, sv in v.items()}
else:
incoming[k] = _to_cpu(v)
incoming[k] = _to_cpu(v)
else:
key = self.mm_type or "hidden"
incoming = {key: _to_cpu(payload)}
@@ -80,20 +79,16 @@ class OmniRequestState(RequestState):
if self.mm_accumulated is None:
self.mm_accumulated = incoming
else:
# Merge keys; accumulate tensors in lists for deferred concatenation
for k, v in incoming.items():
if k not in self.mm_accumulated:
self.mm_accumulated[k] = v
else:
existing = self.mm_accumulated[k]
if isinstance(v, torch.Tensor) and isinstance(existing, torch.Tensor):
# Use list accumulation to avoid O(n²) repeated concatenation
self.mm_accumulated[k] = [existing, v]
elif isinstance(v, torch.Tensor) and isinstance(existing, list):
# Append to existing list
existing.append(v)
elif isinstance(v, dict) and isinstance(existing, dict):
# Merge nested dicts with list accumulation for tensors
for sk, sv in v.items():
if sk not in existing:
existing[sk] = sv
@@ -140,6 +135,13 @@ class OmniRequestState(RequestState):
except Exception:
logger.exception("Error consolidating multimodal tensors")
# Restore nested structure from flat dotted keys now that all tensor
# lists have been concatenated into single tensors.
try:
self.mm_accumulated = unflatten_payload(self.mm_accumulated)
except Exception:
logger.exception("Error unflattening consolidated multimodal tensors")
# Override: do not route to pooling-only path; always create completion
# outputs, and attach pooling_result into the CompletionOutput.
def make_request_output(