Skip to content

Commit c9b2b30

Browse files
committed
[None][fix] ModelingV2 GLM-5.3-Flash: refuse a request that carries media at admission
The target builds no vision tower, so its forward served such a request's text without the media. The request now fails alone, at admission, as it does on the family's other NVFP4 targets. Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
1 parent aeaddb7 commit c9b2b30

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

‎tensorrt_llm/_torch/modeling_v2/models/glm5_next/glm_5_3_flash_nvfp4__sm_10x__tp4/modeling.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
12288) and 288-expert MoE layers 3-44 (top 8 sigmoid noaux_tc routing, scale 2.5, one shared
1111
expert of 2048), clamped SwiGLU (10), and one MTP layer (index 45). Routed experts and the dense
1212
MLPs are W4A4 NVFP4; attention, router, shared experts and the whole MTP layer are BF16. The
13-
checkpoint is the text half of `Glm5NextForConditionalGeneration`; the vision tower is not built.
13+
checkpoint is the text half of `Glm5NextForConditionalGeneration`; the vision tower is not built,
14+
and a request that carries media is refused at admission (`validate_multimodal_request_data`).
1415
1516
A forward is one call into this target's step program (`csrc/`: the decoder layers, the
1617
vocabulary-parallel LM head and the MTP draft chain as CUDA kernels, built for sm_100a and sm_103a
@@ -119,6 +120,8 @@
119120
ATTN_TILED_MIN = 64
120121
# temperatures below this are greedy (the runtime's sampler threshold)
121122
GREEDY_TEMPERATURE = 1e-4
123+
# `multimodal_data` entries that carry media for an encoder, or encoder output in place of it
124+
MEDIA_KEYS = frozenset({"audio", "image", "video", "multimodal_embedding"})
122125

123126

124127
def _runtime_model_config(model_config: ModelConfig) -> ModelConfig:
@@ -1135,6 +1138,18 @@ def validate_request(self, request) -> None:
11351138
"Drop them from the request."
11361139
)
11371140

1141+
def validate_multimodal_request_data(self, mm_data: dict) -> None:
1142+
"""Admission check of a request's multimodal payload, run by the executor: a payload that
1143+
carries media is refused, as that request's own error. The target builds no vision tower,
1144+
so the forward would serve the request's text without the media. A payload without media
1145+
is admitted."""
1146+
media = sorted(key for key in MEDIA_KEYS if mm_data.get(key) is not None)
1147+
if media:
1148+
raise ValueError(
1149+
f"{type(self).__name__} serves this checkpoint's language model only and does not "
1150+
f"accept multimodal input; the request carries {', '.join(media)}"
1151+
)
1152+
11381153
def forward(
11391154
self,
11401155
attn_metadata: AttentionMetadata,

‎tests/unittest/_torch/modeling_v2/models/glm5_next/glm_5_3_flash_nvfp4__sm_10x__tp4/test_modeling_v2_glm5_next_validate_request.py‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
own processor) has nothing to edit; without MTP the forward computes each sequence's
88
last-token logits only, not the prompt's. Raised inside the step, either would fail
99
every active request. With MTP it also refuses the engine's guided decoder, which the
10-
step has no bitmask for. The checks read only host-side fields, so these run on fake
11-
objects: no GPU or engine.
10+
step has no bitmask for. It builds no vision tower, so it refuses a request that carries
11+
media, which the forward would serve as its text alone. The checks read only host-side
12+
fields, so these run on fake objects: no GPU or engine.
1213
"""
1314

1415
from __future__ import annotations
@@ -65,6 +66,33 @@ def test_with_mtp_context_logits_are_left_to_the_sampler():
6566
_admit(_request(context_logits=True), mtp=True)
6667

6768

69+
@pytest.mark.parametrize(
70+
"mm_data, carried",
71+
[
72+
({"image": {"pixel_values": None, "image_grid_thw": None}}, "image"),
73+
({"video": {"pixel_values_videos": None, "video_grid_thw": None}}, "video"),
74+
({"audio": object()}, "audio"),
75+
({"multimodal_embedding": object()}, "multimodal_embedding"),
76+
({"image": object(), "video": object()}, "image, video"),
77+
],
78+
ids=["image", "video", "audio", "embedding", "image-and-video"],
79+
)
80+
def test_media_is_refused(mm_data, carried):
81+
with pytest.raises(
82+
ValueError, match=f"does not accept multimodal input; the request carries {carried}$"
83+
):
84+
Shell.validate_multimodal_request_data(SimpleNamespace(), mm_data)
85+
86+
87+
@pytest.mark.parametrize(
88+
"mm_data",
89+
[{"image": None}, {"mrope_config": {"mrope_position_deltas": None}}],
90+
ids=["empty-media-entry", "no-media"],
91+
)
92+
def test_a_payload_without_media_is_admitted(mm_data):
93+
assert Shell.validate_multimodal_request_data(SimpleNamespace(), mm_data) is None
94+
95+
6896
def test_guided_decoding_is_refused():
6997
# The engine then fails startup with guided decoding and MTP, instead of the step running
7098
# without the grammar's bitmask.

0 commit comments

Comments
 (0)