[Model] Add DiffusionGemma Support (#45163)
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Co-authored-by: Martin Kukla <martin.kukla@cantab.net> Co-authored-by: Matthew Bonanni <mbonanni@redhat.com> Co-authored-by: Dipika Sikka <dsikka@redhat.com> Co-authored-by: NickLucche <nlucches@redhat.com> Co-authored-by: jiahanc <173873397+jiahanc@users.noreply.github.com> Co-authored-by: Alec Kohlhoff <134344302+aleckohlhoff@users.noreply.github.com> Co-authored-by: Porras Huang <20535584+porrashuang@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: scoootscooob <167050519+scoootscooob@users.noreply.github.com>
This commit is contained in:
co-authored by
Martin Kukla
Matthew Bonanni
Dipika Sikka
NickLucche
jiahanc
Alec Kohlhoff
Porras Huang
Claude
scoootscooob
parent
1ce3cdc5c1
commit
eb28452b10
@@ -87,6 +87,7 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
|
||||
ops_colqwen3="OpsColQwen3Config",
|
||||
qwen3_vl_nemotron_embed="Qwen3VLNemotronEmbedConfig",
|
||||
cosmos3_omni="Cosmos3Config",
|
||||
diffusion_gemma="DiffusionGemmaConfig",
|
||||
deepseek_vl_v2="DeepseekVLV2Config",
|
||||
deepseek_v32="DeepseekV3Config",
|
||||
deepseek_v4="DeepseekV4Config",
|
||||
|
||||
@@ -26,6 +26,8 @@ _CLASS_TO_MODULE: dict[str, str] = {
|
||||
"OpsColQwen3Config": "vllm.transformers_utils.configs.colqwen3",
|
||||
"Qwen3VLNemotronEmbedConfig": "vllm.transformers_utils.configs.colqwen3",
|
||||
"Cosmos3Config": "vllm.transformers_utils.configs.cosmos3",
|
||||
"DiffusionGemmaConfig": "vllm.transformers_utils.configs.diffusion_gemma",
|
||||
"DiffusionGemmaTextConfig": "vllm.transformers_utils.configs.diffusion_gemma",
|
||||
"DeepseekVLV2Config": "vllm.transformers_utils.configs.deepseek_vl2",
|
||||
"DeepseekV4Config": "vllm.transformers_utils.configs.deepseek_v4",
|
||||
"DotsOCRConfig": "vllm.transformers_utils.configs.dotsocr",
|
||||
@@ -97,6 +99,8 @@ __all__ = [
|
||||
"OpsColQwen3Config",
|
||||
"Qwen3VLNemotronEmbedConfig",
|
||||
"Cosmos3Config",
|
||||
"DiffusionGemmaConfig",
|
||||
"DiffusionGemmaTextConfig",
|
||||
"DeepseekVLV2Config",
|
||||
"DeepseekV3Config",
|
||||
"DeepseekV4Config",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
from typing import Any
|
||||
|
||||
from transformers import PretrainedConfig
|
||||
from transformers.models.gemma4.configuration_gemma4 import Gemma4VisionConfig
|
||||
|
||||
|
||||
def _init_text_config(self: PretrainedConfig, **kwargs: Any) -> None:
|
||||
PretrainedConfig.__init__(self, **kwargs)
|
||||
# DiffusionGemma always uses MoE and K=V sharing for full_attention
|
||||
# layers. The HF reference removed these config fields entirely.
|
||||
if getattr(self, "num_experts", None):
|
||||
self.enable_moe_block = True
|
||||
self.attention_k_eq_v = True
|
||||
|
||||
|
||||
class DiffusionGemmaTextConfig(PretrainedConfig):
|
||||
model_type = "diffusion_gemma_text"
|
||||
|
||||
def __init__(self, **kwargs: Any):
|
||||
_init_text_config(self, **kwargs)
|
||||
|
||||
|
||||
class DiffusionGemmaConfig(PretrainedConfig):
|
||||
model_type = "diffusion_gemma"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text_config: dict[str, Any] | None = None,
|
||||
canvas_length: int = 256,
|
||||
self_conditioning_size: int | None = None,
|
||||
**kwargs: Any,
|
||||
):
|
||||
self.text_config = DiffusionGemmaTextConfig(**(text_config or {}))
|
||||
self.canvas_length = canvas_length
|
||||
self.self_conditioning_size = self_conditioning_size
|
||||
vision_config = kwargs.pop("vision_config", None)
|
||||
if isinstance(vision_config, dict):
|
||||
self.vision_config = Gemma4VisionConfig(**vision_config)
|
||||
else:
|
||||
self.vision_config = vision_config
|
||||
self.audio_config = None
|
||||
PretrainedConfig.__init__(self, **kwargs)
|
||||
@@ -582,6 +582,7 @@ MODEL_ARCH_CONFIG_CONVERTORS = {
|
||||
"cohere_asr": CohereAsrModelArchConfigConvertor,
|
||||
"dbrx": DbrxModelArchConfigConvertor,
|
||||
"deepseek_mtp": DeepSeekMTPModelArchConfigConvertor,
|
||||
"diffusion_gemma_text": Gemma4ModelArchConfigConvertor,
|
||||
"ernie_mtp": ErnieMTPModelArchConfigConvertor,
|
||||
"falcon": FalconModelArchConfigConvertor,
|
||||
"falcon_mamba": MambaModelArchConfigConvertor,
|
||||
|
||||
Reference in New Issue
Block a user