@@ -89,22 +89,30 @@ def __init__(
8989 # Q projection is DOUBLED — half query, half gate.
9090 # HF: nn.Linear(hidden, num_heads * head_dim * 2, bias=False)
9191 self .q_proj = Linear (
92- model_dim , num_heads * head_dim * 2 , bias = False ,
92+ model_dim ,
93+ num_heads * head_dim * 2 ,
94+ bias = False ,
9395 init_fn = qkv_proj_init_fn ,
9496 )
9597
9698 self .k_proj = Linear (
97- model_dim , num_key_value_heads * head_dim , bias = False ,
99+ model_dim ,
100+ num_key_value_heads * head_dim ,
101+ bias = False ,
98102 init_fn = qkv_proj_init_fn ,
99103 )
100104
101105 self .v_proj = Linear (
102- model_dim , num_key_value_heads * head_dim , bias = False ,
106+ model_dim ,
107+ num_key_value_heads * head_dim ,
108+ bias = False ,
103109 init_fn = qkv_proj_init_fn ,
104110 )
105111
106112 self .output_proj = Linear (
107- num_heads * head_dim , model_dim , bias = False ,
113+ num_heads * head_dim ,
114+ model_dim ,
115+ bias = False ,
108116 init_fn = output_proj_init_fn ,
109117 )
110118
@@ -163,12 +171,8 @@ def forward(
163171 k_rot = k [..., :encoding_dim ]
164172 k_pass = k [..., encoding_dim :]
165173
166- q_rot = self .pos_encoder (
167- q_rot , seqs_layout , state_bag = state_bag
168- )
169- k_rot = self .pos_encoder (
170- k_rot , keys_layout , state_bag = state_bag
171- )
174+ q_rot = self .pos_encoder (q_rot , seqs_layout , state_bag = state_bag )
175+ k_rot = self .pos_encoder (k_rot , keys_layout , state_bag = state_bag )
172176
173177 q = torch .cat ([q_rot , q_pass ], dim = - 1 )
174178 k = torch .cat ([k_rot , k_pass ], dim = - 1 )
@@ -198,9 +202,7 @@ def forward(
198202
199203 # -- Scaled dot-product attention --
200204 # q, k, v: (B, S, H, D)
201- attn_output , _ = self .sdpa (
202- q , seqs_layout , k , keys_layout , v , bias_cache
203- )
205+ attn_output , _ = self .sdpa (q , seqs_layout , k , keys_layout , v , bias_cache )
204206
205207 # -- Output gating --
206208 # attn_output: (B, S, H, D) -> (B, S, H * D)
0 commit comments