runtime: an issue may omit trailing optional operands

e28cf86 made timestep_embed's curve `table` an optional WEIGHT operand but left the
arity check demanding exact equality with the schema, so every sinusoidal issuer —
qwenimage21, minimaxh3's full-form path — died at step 0: engine_e2e_test has been red
since that commit. The check now accepts a count at or above the last REQUIRED operand
and nulls the dropped schema slots, which is what rad_abi.h promises ("an absent
optional operand is a null RadTensor.data") and what every shim already branches on
(r4d_opt(), rad_args_have(), libref's finish(); the curve kernel still requires the
table when curve > 0). Only TRAILING optionals: an omitted optional before a required
operand would shift positions, which is the miscount the check exists to catch.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-22 00:57:42 -05:00
1 parent d480a47bef
commit 80b13b49d8
3 files changed
+31 -6

No files matched your search

+9
View File
@@ -313,6 +313,15 @@ int Ctx::bind_ops() {
p.n_bands = (int32_t)oi.bands.size();
p.plan_off = (int32_t)issue_table_.size();
p.n_opd_schema = oi.schema ? (int32_t)oi.schema->n_operands : -1;
p.n_opd_required = -1;
if (oi.schema) {
/* One past the last required operand: everything after it is optional and may be
* omitted at issue. An optional operand before a required one is not omittable --
* that would shift positions, which is what the arity check guards. */
for (int o = 0; o < oi.schema->n_operands; ++o)
if (!oi.schema->operands[o].optional) p.n_opd_required = o + 1;
if (p.n_opd_required < 0) p.n_opd_required = 0; /* an all-optional schema */
}
/* Matched by name once here, not on the issue path; see OpPlan::billed. */
p.billed = (oi.op == "all_reduce");
p.collective = p.billed;