Skip to content

Commit 388f75d

Browse files
authored
Merge branch 'main' into add-ministral-3-3b-vlm-olive-recipe
2 parents 0f8d8ab + c35d0c1 commit 388f75d

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies = [
1616
"huggingface_hub",
1717
"numpy>=1.24.0",
1818
"onnx_ir>=0.1.0",
19-
"onnx-shape-inference>=0.1.7",
19+
"onnx-shape-inference>=0.1.9",
2020
"onnxscript>=0.7.0",
2121
"safetensors",
2222
"torch>=2.1.0",

‎src/mobius/functions/linear_attention.py‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,30 +109,24 @@ def linear_attention(
109109
uses_decay = update_rule in ("gated", "gated_delta")
110110
uses_beta = update_rule in ("delta", "gated_delta")
111111

112-
# --- Define function inputs (conditional on update_rule) ---
113-
# TODO: Investigate relaxing onnx-shape-inference's strict arity check
114-
# to allow trailing optional inputs, enabling a single 6-input signature.
115-
# The function is specialized per-model: only inputs actually used
116-
# by this update_rule variant are declared. Call sites (e.g.
117-
# Mamba2Block with "gated") pass exactly the declared number of args.
112+
# --- Define function inputs ---
113+
# Always declare the full 6-input signature:
114+
# (query, key, value, past_state, decay, beta).
115+
# Update-rule-specific paths inside the function body ignore unused
116+
# trailing inputs so every variant exposes the same ir.Function
117+
# interface. Call sites that don't need trailing inputs (decay, beta)
118+
# simply omit them — onnx-shape-inference >=0.1.9 accepts trailing
119+
# optional inputs (matching ONNX C++ behavior).
118120
inputs: list[ir.Value] = [
119121
ir.Value(name="query"), # (B, T, q_num_heads * d_k)
120122
ir.Value(name="key"), # (B, T, q_num_heads * d_k)
121123
ir.Value(name="value"), # (B, T, kv_num_heads * d_v)
122124
ir.Value(name="past_state"),
125+
ir.Value(name="decay"),
126+
ir.Value(name="beta"),
123127
]
124-
if uses_decay:
125-
inputs.append(ir.Value(name="decay"))
126-
if uses_beta:
127-
inputs.append(ir.Value(name="beta"))
128128

129-
def body(op, *args):
130-
query_v, key_v, value_v, past_state_v = args[:4]
131-
idx = 4
132-
decay_v = args[idx] if uses_decay else None
133-
if uses_decay:
134-
idx += 1
135-
beta_v = args[idx] if uses_beta else None
129+
def body(op, query_v, key_v, value_v, past_state_v, decay_v, beta_v):
136130

137131
# --- Reshape 3D → 4D using head counts ---
138132
b_dim = op.Shape(query_v, start=0, end=1)

0 commit comments

Comments
 (0)