[Misc] Clean up more utils (#27567)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-10-27 23:30:38 +08:00
committed by GitHub
parent 3b96f85c36
commit 6ebffafbb6
24 changed files with 282 additions and 315 deletions

View File

@@ -1618,6 +1618,29 @@ class ModelConfig:
"""Extract the HF encoder/decoder model flag."""
return is_encoder_decoder(self.hf_config)
@property
def uses_alibi(self) -> bool:
cfg = self.hf_text_config
return (
getattr(cfg, "alibi", False) # Falcon
or "BloomForCausalLM" in self.architectures # Bloom
or getattr(cfg, "position_encoding_type", "") == "alibi" # codellm_1b_alibi
or (
hasattr(cfg, "attn_config") # MPT
and (
(
isinstance(cfg.attn_config, dict)
and cfg.attn_config.get("alibi", False)
)
or (
not isinstance(cfg.attn_config, dict)
and getattr(cfg.attn_config, "alibi", False)
)
)
)
)
@property
def uses_mrope(self) -> bool:
return uses_mrope(self.hf_config)