Skip to content

noun: Lagoon %int2 comparison + reduction array jets - #1048

Open
sigilante wants to merge 2 commits into
sigilante/twoc-jetsfrom
sigilante/twoc-int2-cmp-reduce
Open

noun: Lagoon %int2 comparison + reduction array jets#1048
sigilante wants to merge 2 commits into
sigilante/twoc-jetsfrom
sigilante/twoc-int2-cmp-reduce

Conversation

@sigilante

@sigilante sigilante commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1047. Hoon/master side: urbit/numerics#67.

Extends the Lagoon array jets with %int2 cases beside %i754 for the comparison and reduction ops (no GEMM):

  • gth/gte/lth/lte — per-lane signed (two's-complement) compare → 1/0 ray.
  • cumsum — full wrapping sum → scalar ray.
  • dot — sum of products (wrapping) → scalar ray.
  • min/max — extremum by two's-complement order → scalar ray.
  • argmin/argmax — forward ravel-index of the first extremum (bare index).

Native per lane (8…128-bit, no GMP); signed compares reinterpret the lane as the matching signed C type. Scalar reductions box via a _la_scalar_box helper = +scalar-to-ray's shape (all-1s of the input rank).

Also fixes the i754 reduction-jet result shape (carries urbit/numerics#68 into the runtime): cumsum/min/max/dot shared the same _la_scalar_box helper, replacing the prior hardcoded ~[1 1]/~[len 1]/~[1] that only matched one rank — a silent jet/Hoon mismatch on the boxed meta. trace (always rank-2) and diag (returns a vector) are correct as-is.

Verified jet == numerics Hoon on a hoon-135 fakezod across native widths incl. 128-bit, ties, and negatives — for both %int2 and (now) %i754 reductions.

🤖 Generated with Claude Code

sigilante and others added 2 commits June 29, 2026 09:43
Extend the Lagoon array jets with %int2 cases beside %i754 for the comparison
and reduction ops (no GEMM):

  gth/gte/lth/lte  -- per-lane signed (two's-complement) compare -> 1/0 ray
  cumsum           -- full wrapping sum -> scalar ray
  dot              -- sum of products (wrapping) -> scalar ray
  min/max          -- extremum by two's-complement order -> scalar ray
  argmin/argmax    -- forward ravel-index of the first extremum

Native per lane (8..128-bit, no GMP); signed compares reinterpret the lane as
the matching signed C type.  Scalar reductions box via +scalar-to-ray's shape
(all-1s of the input rank); argmin/argmax return the bare index.

Verified jet == numerics %int2 Hoon on a hoon-135 fakezod across native widths
incl. 128-bit, ties, and negatives.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
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