# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/zaya/modular_zaya.py. # Do NOT edit this file manually as any edits will be overwritten by the generation of # the file from the modular. If any change should be done, please apply the change to the # modular_zaya.py file directly. One of our CI enforces this. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # Copyright 2026 Zyphra and the HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from typing import Any, Literal from huggingface_hub.dataclasses import strict from ...configuration_utils import PreTrainedConfig from ...modeling_rope_utils import RopeParameters from ...utils import auto_docstring @auto_docstring(checkpoint="Zyphra/ZAYA1-8B") @strict class ZayaConfig(PreTrainedConfig): r""" lm_head_bias (`bool`, *optional*, defaults to `False`): Whether to add a bias to the language modeling head. router_hidden_size (`int`, *optional*, defaults to 256): Hidden size used by the ZAYA router. cca_time0 (`int`, *optional*, defaults to 2): First temporal parameter of the CCA projection. cca_time1 (`int`, *optional*, defaults to 2): Second temporal parameter of the CCA projection. ```python >>> from transformers import ZayaConfig, ZayaModel >>> configuration = ZayaConfig() >>> model = ZayaModel(configuration) >>> configuration = model.config ``` """ model_type = "zaya" keys_to_ignore_at_inference = ["past_key_values"] base_model_ep_plan = { "layers.*.mlp.gate": "ep_router", "layers.*.mlp.experts.gate_up_proj": "grouped_gemm", "layers.*.mlp.experts.down_proj": "grouped_gemm", "layers.*.mlp.experts": "moe_tp_experts", } vocab_size: int = 262272 hidden_size: int = 2048 num_hidden_layers: int = 40 num_attention_heads: int = 8 num_key_value_heads: int = 2 hidden_act: str = "silu" max_position_embeddings: int = 131072 initializer_range: float = 0.02 rms_norm_eps: float = 1e-5 use_cache: bool = True tie_word_embeddings: bool = True rope_parameters: RopeParameters | dict | None = None sliding_window: int | None = None attention_dropout: float | int = 0.0 moe_intermediate_size: int = 2048 num_experts_per_tok: int = 1 num_experts: int = 16 output_router_logits: bool = False layer_types: list[str] | None = None pad_token_id: int | None = 0 bos_token_id: int | None = 2 eos_token_id: int | list[int] | None = 106 # Zaya-specific attention head_dim: int = 128 attention_bias: bool = False lm_head_bias: bool = False router_hidden_size: int = 256 cca_time0: int = 2 cca_time1: int = 2 def __post_init__(self, **kwargs): self.layer_types = ["hybrid"] * self.num_hidden_layers if self.layer_types is None else list(self.layer_types) default_rope_params: dict[Literal["hybrid", "hybrid_sliding"], dict[str, Any]] = { "hybrid": { "rope_type": "default", "rope_theta": 5_000_000.0, "partial_rotary_factor": 0.5, }, "hybrid_sliding": { "rope_type": "default", "rope_theta": 10_000.0, "partial_rotary_factor": 0.5, }, } if self.rope_parameters is None: self.rope_parameters = default_rope_params super().__post_init__(**kwargs, ignore_keys_at_rope_validation={"hybrid", "hybrid_sliding"}) def convert_rope_params_to_dict(self, **kwargs): # No legacy flat RoPE format is supported here; conversion writes the nested ZAYA layer-type format directly. return kwargs def validate_architecture(self): """Part of ``@strict``-powered validation.""" if self.num_experts_per_tok != 1: raise ValueError("ZAYA currently supports `num_experts_per_tok=1` only.") if self.num_attention_heads % self.num_key_value_heads != 0: raise ValueError("`num_attention_heads` must be a multiple of `num_key_value_heads`.") if "hybrid_sliding" in self.layer_types and self.sliding_window is None: raise ValueError("`sliding_window` must be set when `layer_types` contains `hybrid_sliding`.") __all__ = ["ZayaConfig"]