broccoli-ml 13.0.5__tar.gz → 13.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: broccoli-ml
3
- Version: 13.0.5
3
+ Version: 13.0.6
4
4
  Summary: Some useful Pytorch models, circa 2025
5
5
  License: MIT
6
6
  Author: Nicholas Bailey
@@ -200,26 +200,26 @@ class MHAttention(nn.Module):
200
200
  "`source_size` must be a tuple of 1, 2 or 3 integers"
201
201
  )
202
202
 
203
- q = rearrange(q, "b t (h d) -> b t h d", h=self.n_heads)
204
- k = rearrange(k, "b t (h d) -> b t h d", h=self.n_heads)
203
+ q = rearrange(q, "b t (h d) -> b h t d", h=self.n_heads)
204
+ k = rearrange(k, "b t (h d) -> b h t d", h=self.n_heads)
205
205
 
206
206
  q_util, q_img = (
207
- q[:, : self.utility_tokens, :, :],
208
- q[:, self.utility_tokens :, :, :],
207
+ q[:, :, : self.utility_tokens, :],
208
+ q[:, :, self.utility_tokens :, :],
209
209
  )
210
210
  k_util, k_img = (
211
- k[:, : self.utility_tokens, :, :],
212
- k[:, self.utility_tokens :, :, :],
211
+ k[:, :, : self.utility_tokens, :],
212
+ k[:, :, self.utility_tokens :, :],
213
213
  )
214
214
 
215
215
  q_img = rearrange(
216
216
  q_img,
217
- f"b ({spatial_dimension_names}) h d -> b {spatial_dimension_names} h d",
217
+ f"b h ({spatial_dimension_names}) d -> b h {spatial_dimension_names} d",
218
218
  **spatial_dimension_values,
219
219
  )
220
220
  k_img = rearrange(
221
221
  k_img,
222
- f"b ({spatial_dimension_names}) h d -> b {spatial_dimension_names} h d",
222
+ f"b h ({spatial_dimension_names}) d -> b h {spatial_dimension_names} d",
223
223
  **spatial_dimension_values,
224
224
  )
225
225
 
@@ -230,19 +230,19 @@ class MHAttention(nn.Module):
230
230
 
231
231
  q_img = rearrange(
232
232
  q_img,
233
- f"b {spatial_dimension_names} h d -> b ({spatial_dimension_names}) h d",
233
+ f"b h {spatial_dimension_names} d -> b h ({spatial_dimension_names}) d",
234
234
  )
235
235
  k_img = rearrange(
236
236
  k_img,
237
- f"b {spatial_dimension_names} h d -> b ({spatial_dimension_names}) h d",
237
+ f"b h {spatial_dimension_names} d -> b h ({spatial_dimension_names}) d",
238
238
  )
239
239
 
240
240
  # Re-combine the utility tokens and the RoPE-enhanced sequence tokens
241
- q = torch.cat([q_util, q_img], dim=1)
242
- k = torch.cat([k_util, k_img], dim=1)
241
+ q = torch.cat([q_util, q_img], dim=2)
242
+ k = torch.cat([k_util, k_img], dim=2)
243
243
 
244
- q = rearrange(q, "b t h d -> b t (h d)")
245
- k = rearrange(k, "b t h d -> b t (h d)")
244
+ q = rearrange(q, "b h t d -> b t (h d)")
245
+ k = rearrange(k, "b h t d -> b t (h d)")
246
246
 
247
247
  return q, k
248
248
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "broccoli-ml"
3
- version = "13.0.5"
3
+ version = "13.0.6"
4
4
  description = "Some useful Pytorch models, circa 2025"
5
5
  authors = [
6
6
  {name = "Nicholas Bailey"}
File without changes
File without changes