Skip to content

Commit 72499e3

Browse files
justinchubyCopilot
andcommitted
Fix ReduceSumSquare: use axes as input tensor per ONNX spec
Per ONNX opset 18+, ReduceSumSquare axes is an optional input tensor, not an attribute. Changed axes=[-1] (keyword arg → attribute) to [-1] (positional arg → input tensor) to match the spec. Affected files: - _gated_deltanet.py: L2 normalization of Q and K (2 sites) - qwen3_tts_tokenizer.py: nearest-neighbor codebook lookup (2 sites) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent c1cdd3b commit 72499e3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/mobius/components/_gated_deltanet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ def forward(
212212
# TODO: Use op.LpNormalization directly once ORT >=1.25 supports it.
213213
q_4d = op.Reshape(query, qk_4d_shape) # (B, T, num_k_heads, head_k_dim)
214214
q_l2 = op.Sqrt(
215-
op.ReduceSumSquare(q_4d, axes=[-1], keepdims=1)
215+
op.ReduceSumSquare(q_4d, [-1], keepdims=1)
216216
) # (B, T, num_k_heads, 1) — L2 norm per head
217217
query = op.Reshape(op.Div(q_4d, q_l2), qk_3d_shape) # (B, T, key_dim)
218218

219219
k_4d = op.Reshape(key, qk_4d_shape) # (B, T, num_k_heads, head_k_dim)
220220
k_l2 = op.Sqrt(
221-
op.ReduceSumSquare(k_4d, axes=[-1], keepdims=1)
221+
op.ReduceSumSquare(k_4d, [-1], keepdims=1)
222222
) # (B, T, num_k_heads, 1) — L2 norm per head
223223
key = op.Reshape(op.Div(k_4d, k_l2), qk_3d_shape) # (B, T, key_dim)
224224

src/mobius/models/qwen3_tts_tokenizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ def forward(self, op: builder.OpBuilder, x: ir.Value):
593593
embedding = self.codebook(op)
594594

595595
# Find nearest: ||x - e||² = ||x||² - 2*x·e^T + ||e||²
596-
x_sq = op.ReduceSumSquare(x_t, axes=[-1], keepdims=1) # (B,T,1)
596+
x_sq = op.ReduceSumSquare(x_t, [-1], keepdims=1) # (B,T,1)
597597
e_sq = op.ReduceSumSquare(
598-
op.Unsqueeze(embedding, [0]), axes=[-1], keepdims=0
598+
op.Unsqueeze(embedding, [0]), [-1], keepdims=0
599599
) # (1, codebook_size)
600600
dot = op.MatMul(x_t, op.Transpose(embedding, perm=[1, 0]))
601601
distances = op.Add(op.Sub(x_sq, op.Mul(dot, op.Constant(value_float=2.0))), e_sq)

0 commit comments

Comments
 (0)