[Model][VLM] Add Qwen2.5-Omni model support (thinker only) (#15130)
Signed-off-by: fyabc <suyang.fy@alibaba-inc.com> Signed-off-by: Roger Wang <ywang@roblox.com> Co-authored-by: Roger Wang <136131678+ywang96@users.noreply.github.com> Co-authored-by: Roger Wang <ywang@roblox.com> Co-authored-by: Xiong Wang <wangxiongts@163.com>
This commit is contained in:
co-authored by
Roger Wang
Roger Wang
Xiong Wang
parent
5c9121203c
commit
2c1bd848a6
@@ -222,8 +222,7 @@ def patch_rope_scaling_dict(rope_scaling: Dict[str, Any]) -> None:
|
||||
logger.warning("Replacing legacy rope_type 'mrope' with 'default'")
|
||||
|
||||
|
||||
def uses_mrope(config: PretrainedConfig) -> bool:
|
||||
"""Detect if the model with this config uses M-ROPE."""
|
||||
def _uses_mrope(config: PretrainedConfig) -> bool:
|
||||
rope_scaling = getattr(config, "rope_scaling", None)
|
||||
if rope_scaling is None:
|
||||
return False
|
||||
@@ -231,6 +230,24 @@ def uses_mrope(config: PretrainedConfig) -> bool:
|
||||
return "mrope_section" in rope_scaling
|
||||
|
||||
|
||||
def uses_mrope(config: PretrainedConfig) -> bool:
|
||||
"""Detect if the model with this config uses M-ROPE."""
|
||||
return _uses_mrope(config) or thinker_uses_mrope(config)
|
||||
|
||||
|
||||
def thinker_uses_mrope(config: PretrainedConfig) -> bool:
|
||||
"""Detect if the model contains a thinker config and it uses M-ROPE."""
|
||||
thinker_config = getattr(config, "thinker_config", None)
|
||||
if thinker_config is None:
|
||||
return False
|
||||
|
||||
thinker_text_config = getattr(thinker_config, "text_config", None)
|
||||
if thinker_text_config is None:
|
||||
return False
|
||||
|
||||
return uses_mrope(thinker_text_config)
|
||||
|
||||
|
||||
def is_encoder_decoder(config: PretrainedConfig) -> bool:
|
||||
"""Detect if the model with this config is used as an encoder/decoder."""
|
||||
text_config = getattr(config, "text_config", None)
|
||||
@@ -740,6 +757,11 @@ def get_hf_text_config(config: PretrainedConfig):
|
||||
# if transformers config doesn't align with this assumption.
|
||||
assert hasattr(config.text_config, "num_attention_heads")
|
||||
return config.text_config
|
||||
elif hasattr(config, "thinker_config"):
|
||||
# TODO(suyang.fy): Refactor code.
|
||||
# For Qwen2.5-Omni, change hf_text_config to
|
||||
# thinker_config.text_config.
|
||||
return config.thinker_config.text_config
|
||||
else:
|
||||
return config
|
||||
|
||||
|
||||
Reference in New Issue
Block a user