Skip to content

Fix sub jet to return the computed result buffer#23

Merged
sigilante merged 1 commit into
mainfrom
sigilante/sub-return-buffer-fix
May 30, 2026
Merged

Fix sub jet to return the computed result buffer#23
sigilante merged 1 commit into
mainfrom
sigilante/sub-return-buffer-fix

Conversation

@sigilante
Copy link
Copy Markdown
Collaborator

Summary

sub:la x y silently returned an input instead of the difference. The ?axpy-based sub jets computed x - y into one buffer but returned the other.

  • lagoon/vere & vere64: PR Fix sub jets #20 corrected the ?axpy argument order (so x - y lands in x_bytes) but the function still returned y_bytes — the unmodified y.
  • maroon: never swapped — computed y - x and returned that.

All three jets now allocate x_bytes as the pinned output buffer and y_bytes as the plain input, run axpy(-1, y, x)x := -1*y + x = x - y, and return x_bytes.

Why it slipped through

Every existing sub test used the symmetric case 1 - 1 = 0, which passes under all failure modes (x, y, x-y, and y-x all equal 0 when x = y = 1).

Tests

Added asymmetric regression tests x=[5,2] - y=[3,1] = [2,1] across every precision variant (lagoon bloq 4/5/6/7, maroon 4/5/6). These distinguish the correct result [2,1] from each failure mode: returning y[3,1], returning x[5,2], computing y-x[-2,-1].

Verification

A standalone arm64 SoftBLAS reproduction of the corrected wiring (saxpy(-1, y, x) → return x) prints [2.0, 1.0], matching the test canon. Full end-to-end exercise against compiled jets in Vere is pending.

🤖 Generated with Claude Code

The ?axpy-based sub jets computed x - y into one buffer but returned the
other (unmodified) one, so `sub:la x y` silently returned an input rather
than the difference. PR #20 corrected the axpy argument order in
lagoon/vere and vere64 but not the return pointer; maroon was never
swapped and computed y - x.

All three jets now allocate x_bytes as the pinned output buffer and
y_bytes as the plain input, run axpy(-1, y, x) => x := x - y, and return
x_bytes.

Existing sub tests only covered the symmetric case 1 - 1 = 0, which
passes under every failure mode. Add asymmetric regression tests
(x=[5,2] - y=[3,1] = [2,1]) across all precision variants; these
distinguish the correct result from returning x, returning y, or
computing y - x.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sigilante sigilante merged commit 5586e90 into main May 30, 2026
@sigilante sigilante deleted the sigilante/sub-return-buffer-fix branch May 30, 2026 14:48
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