[New model][Multimodal] Add DeepSeek-V4-Flash-Vision-Exp support (#54566)

Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py
2026-09-02 11:09:09 -07:00
committed by GitHub
parent 488e6fd53c
commit 1356635d83
37 changed files with 2918 additions and 152 deletions
+22 -1
View File
@@ -2429,6 +2429,16 @@ class GPUModelRunner(
_bidi_sw = getattr(hf_text_config, "sliding_window", None)
_clamps_in_kernel = getattr(
self.model, "mm_prefix_clamp_sliding_window", False
) or getattr(hf_text_config, "mm_prefix_clamp_sliding_window", False)
# Some models (DeepSeek-V4 vision) define the bidirectional span
# over the whole sentinel block ([IMAGE_START, IMAGE_END]) rather
# than the embed tokens, and prepend a position-dependent
# alignment pad before the first sentinel. For those, derive the
# span from the full placeholder range and strip the pad.
# TODO(Isotr0py): Refactor mm_prefix_lm implementation
# for better readability and maintainability.
_span_pad_modulus = getattr(
hf_text_config, "mm_prefix_span_leading_pad_modulus", 0
)
for req_id in self.input_batch.req_ids:
image_doc_ranges = []
@@ -2437,7 +2447,18 @@ class GPUModelRunner(
if mm_feature.modality == "audio":
continue
pos_info = mm_feature.mm_position
img_doc_range = pos_info.extract_embeds_range()
if _span_pad_modulus:
pad = (
_span_pad_modulus - 1 - pos_info.offset % _span_pad_modulus
)
img_doc_range = [
(
pos_info.offset + pad,
pos_info.offset + pos_info.length - 1,
)
]
else:
img_doc_range = pos_info.extract_embeds_range()
for r in img_doc_range:
if (
not _clamps_in_kernel