# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/blueberry/modular_blueberry.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_blueberry.py file directly. One of our CI enforces this. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # Copyright 2026 Dustin Loring 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 huggingface_hub.dataclasses import strict from transformers.configuration_utils import PreTrainedConfig from transformers.modeling_rope_utils import RopeParameters from transformers.utils import auto_docstring @auto_docstring(checkpoint="CrowdMind/Blueberry-base") @strict class BlueberryConfig(PreTrainedConfig): r""" num_unique_layers (`int`, *optional*, defaults to 8): Number of distinct decoder blocks. `num_hidden_layers` counts their executions, including repeated passes. loop_repeats (`int`, *optional*, defaults to 3): Total passes through the middle half of the decoder blocks. loop_gate (`bool`, *optional*, defaults to `True`): Whether to learn a per-token mix of the prelude and previous pass at loop boundaries. window_pattern (`str`, *optional*, defaults to `"SSSL"`): Pattern tiled across distinct blocks. `S` uses a short sliding window and `L` uses full causal attention. The final block always uses full attention. sliding_window (`int`, *optional*): Short attention window including the current token. Defaults to the quarter-context window rounded up to a multiple of 128 predecessors, plus the current token. value_gate_channels (`int`, *optional*, defaults to 12): Number of hidden channels used by each attention value gate. smear_gate_channels (`int`, *optional*, defaults to 24): Number of token embedding channels used by the previous-token mixing gate. """ model_type = "blueberry" vocab_size: int = 32768 hidden_size: int = 512 intermediate_size: int | None = None num_unique_layers: int = 8 num_attention_heads: int = 4 num_key_value_heads: int | None = None hidden_act: str = "relu2" max_position_embeddings: int = 2048 rope_parameters: RopeParameters | dict | None = None loop_repeats: int = 3 loop_gate: bool = True window_pattern: str = "SSSL" sliding_window: int | None = None value_gate_channels: int = 12 smear_gate_channels: int = 24 final_logit_softcapping: float = 15.0 use_cache: bool = True bos_token_id: int | None = None eos_token_id: int | list[int] | None = None pad_token_id: int | None = None tie_word_embeddings: bool = False def __post_init__(self, **kwargs): self.intermediate_size = self.intermediate_size if self.intermediate_size is not None else 4 * self.hidden_size if self.num_key_value_heads is None: self.num_key_value_heads = self.num_attention_heads if self.rope_parameters is None: self.rope_parameters = {"rope_type": "default", "rope_theta": 100_000.0} if self.sliding_window is None: self.sliding_window = ((self.max_position_embeddings + 511) // 512) * 128 + 1 self.window_pattern = self.window_pattern.upper() super().__post_init__(**kwargs) @property def loop_start(self): return self.num_unique_layers // 4 @property def layer_indices(self): indices = tuple(range(self.num_unique_layers)) loop_end = self.loop_start + self.num_unique_layers // 2 return ( indices[: self.loop_start] + indices[self.loop_start : loop_end] * self.loop_repeats + indices[loop_end:] ) @property def num_hidden_layers(self): return len(self.layer_indices) @property def layer_types(self): if not self.window_pattern: return [] types = [ "sliding_attention" if self.window_pattern[index % len(self.window_pattern)] == "S" else "full_attention" for index in self.layer_indices ] # The last cache slot holds full attention KV and the previous unsmeared token embedding. return types[:-1] + ["hybrid"] def has_value_embedding(self, layer_idx): return layer_idx % 2 == (self.num_unique_layers - 1) % 2 def validate_architecture(self): if self.num_unique_layers < 1 or self.loop_repeats < 1: raise ValueError("Blueberry requires at least one decoder block and one loop pass.") if self.loop_repeats > 1 and (self.num_unique_layers < 4 or self.num_unique_layers % 2): raise ValueError("Multiple loop passes require an even number of distinct blocks of at least four.") if self.loop_gate and self.loop_repeats == 1: raise ValueError("The loop gate requires at least two loop passes.") if not self.window_pattern or set(self.window_pattern) - {"S", "L"}: raise ValueError("`window_pattern` must contain one or more S or L characters.") if self.sliding_window < 1: raise ValueError("`sliding_window` must be positive.") if ( self.num_attention_heads < 1 or self.hidden_size % (2 * self.num_attention_heads) or self.num_key_value_heads < 1 or self.num_attention_heads % self.num_key_value_heads ): raise ValueError("Blueberry requires an even head dimension and valid grouped heads.") if not (0 < self.value_gate_channels <= self.hidden_size and 0 < self.smear_gate_channels <= self.hidden_size): raise ValueError("Gate channel counts must be positive and at most hidden_size.") __all__ = ["BlueberryConfig"]