Use head_dim in config if exists (#2622)

This commit is contained in:
Xiang Xu 2024-01-27 10:30:49 -08:00 committed by GitHub
parent beb89f68b4
commit 220a47627b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -213,6 +213,8 @@ class ModelConfig:
return self.hf_config.hidden_size return self.hf_config.hidden_size
def get_head_size(self) -> int: def get_head_size(self) -> int:
if hasattr(self.hf_config, "head_dim"):
return self.hf_config.head_dim
# FIXME(woosuk): This may not be true for all models. # FIXME(woosuk): This may not be true for all models.
return self.hf_config.hidden_size // self.hf_config.num_attention_heads return self.hf_config.hidden_size // self.hf_config.num_attention_heads