Skip to content

lagoon: fix reduction-jet result shape to match +scalar-to-ray#68

Merged
sigilante merged 1 commit into
mainfrom
sigilante/fix-reduction-rank1-shape
Jun 29, 2026
Merged

lagoon: fix reduction-jet result shape to match +scalar-to-ray#68
sigilante merged 1 commit into
mainfrom
sigilante/fix-reduction-rank1-shape

Conversation

@sigilante

Copy link
Copy Markdown
Collaborator

The i754 reduction jets box their scalar result with a hardcoded ray shape that's correct for only one rank, so the jet silently disagrees with the Hoon on the result meta:

op jet shape +scalar-to-ray (Hoon)
min/max ~[1 1] all-1s of input rank — ~[1] for a vector
dot ~[len 1] ~[1] for rank-1 inputs
cumsum ~[1] wrong for a rank-2 matrix

+scalar-to-ray sets the shape to (reap (lent shape) 1) — all-1s of the input's rank. The fix adds a _la_scalar_box helper (all-1s of rank) and routes cumsum/min/max/dot through it, matching the Hoon for every rank. trace (always rank-2 → ~[1 1]) and diag (returns a vector, ~[len 1]) are correct as-is and untouched.

Found while jetting the %int2 reductions (#67): the %int2 path already boxes via the rank-correct shape and matches its Hoon; this brings the i754 (and any other scalar-reducing) path in line. The data/value is unchanged — only the boxed meta shape is corrected.

🤖 Generated with Claude Code

…anks)

The i754 reduction jets boxed their scalar result with a hardcoded shape that
was correct for only one rank: min/max used ~[1 1] (wrong for a rank-1 vector),
dot used ~[len 1], and cumsum used ~[1] (wrong for a rank-2 matrix).  The Hoon
+scalar-to-ray boxes to an all-1s shape of the INPUT's rank (reap (lent shape)
1), so e.g. (min vector) should be ~[1], not ~[1 1] -- a silent jet/Hoon
mismatch on the meta.

Add a _la_scalar_box helper (all-1s of the input rank) and route cumsum, min,
max, and dot through it, so the boxed shape matches the Hoon for every rank.
trace (always rank-2) and diag (returns a vector, not a scalar) are unaffected
and left as-is.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sigilante
sigilante merged commit 68bf87e into main Jun 29, 2026
@sigilante
sigilante deleted the sigilante/fix-reduction-rank1-shape branch June 29, 2026 15:23
sigilante added a commit to urbit/vere that referenced this pull request Jun 29, 2026
Rename the rank-correct boxing helper introduced for %int2 (_la_int2_box ->
_la_scalar_box, it was already kind-neutral) and route the i754
cumsum/min/max/dot cases through it too, so their boxed scalar result matches
the Hoon +scalar-to-ray (all-1s of the input rank) instead of the prior
hardcoded ~[1 1] / ~[len 1] / ~[1].  Carries urbit/numerics#68 into the runtime.
trace (always rank-2) keeps ~[1 1] and is unaffected.

Verified on a hoon-135 fakezod: i754 min/max/cumsum/dot now match the unjetted
Hoon (were mismatched on the boxed shape), and the %int2 reductions still match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sigilante added a commit to urbit/vere that referenced this pull request Jun 29, 2026
Rename the rank-correct boxing helper introduced for %int2 (_la_int2_box ->
_la_scalar_box, it was already kind-neutral) and route the i754
cumsum/min/max/dot cases through it too, so their boxed scalar result matches
the Hoon +scalar-to-ray (all-1s of the input rank) instead of the prior
hardcoded ~[1 1] / ~[len 1] / ~[1].  Carries urbit/numerics#68 into the runtime.
trace (always rank-2) keeps ~[1 1] and is unaffected.

Verified on a hoon-135 fakezod: i754 min/max/cumsum/dot now match the unjetted
Hoon (were mismatched on the boxed shape), and the %int2 reductions still match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sigilante added a commit that referenced this pull request Jun 29, 2026
Mirror the vere change (urbit/vere): Lagoon %int2 cases for gth/gte/lth/lte,
cumsum, dot, min/max, argmin/argmax -- native per-lane two's-complement, signed
compares via the matching signed C type, scalar reductions boxed per
+scalar-to-ray.  Reuses the _la_scalar_box helper added by #68 (forward-index
argmin/argmax and the rank-correct scalar shape), so int2 and i754 reductions
share one boxing helper.  Verified jet == %int2 Hoon on a hoon-135 fakezod.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant