[Feature][Model Loader] Apply model-owned MTP shard selection to RunAI ModelStreamer (#60759)

Signed-off-by: 浩韵 <zuohaiyu.zhy@alibaba-inc.com>
Co-authored-by: Kevin H. Luu <khluu000@gmail.com>
This commit is contained in:
Haiyu Zuo
2026-10-15 12:23:11 +08:00
committed by GitHub
co-authored by Kevin H. Luu
parent 833665cded
commit ff5a91a456
6 changed files with 724 additions and 13 deletions
+9 -2
View File
@@ -141,6 +141,13 @@ _language_model_by_module: "weakref.WeakKeyDictionary[nn.Module, VllmModel]" = (
)
def _is_language_model(model: object) -> TypeIs[VllmModel]:
# Text towers can use config/position_ids signatures and omit loader hooks.
return callable(getattr(model, "embed_input_ids", None)) and callable(
getattr(model, "forward", None)
)
@runtime_checkable
class SupportsMultiModalEmbeddings(Protocol):
"""The interface for models that can merge external multimodal embeddings."""
@@ -284,14 +291,14 @@ class SupportsMultiModal(SupportsMultiModalEmbeddings, Protocol):
mod = getattr(mod, attr)
candidate: object = mod
if candidate is not self_module and isinstance(candidate, VllmModel):
if candidate is not self_module and _is_language_model(candidate):
_language_model_by_module[self_module] = candidate
return candidate
# Fallback
for mod in self_module.children():
candidate = mod
if isinstance(candidate, VllmModel):
if _is_language_model(candidate):
_language_model_by_module[self_module] = candidate
return candidate