Skip to content

l2_ref: preserve signed-zero interval endpoints - #1315

Closed
Maxrio9 wants to merge 1 commit into
ashhart:mainfrom
Maxrio9:fix/l2-interval-signed-zero
Closed

Maxrio9 wants to merge 1 commit into
ashhart:mainfrom
Maxrio9:fix/l2-interval-signed-zero

Conversation

@Maxrio9

@Maxrio9 Maxrio9 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Fixes #1309. Preserve both signed-zero endpoints when the float64 L2 reference orders an interval whose ends compare equal to zero. This prevents an x86_64 reference interval from rejecting the exact +0 returned by the Dory activation kernels.

The change touches only the reference helper and a raw-bit regression. Same-sign zeros retain their signs; NaN handling, nonzero bounds, kernels and contract tolerances are unchanged.

Receipt

  • Environment: base 67cc8fbce879e2d0dd74b94ebb8848b134478ee4, native version 1.1.4, Zig 0.17.0, Linux x86_64 and aarch64; device checks on RTX PRO 4500 Blackwell (SM120), CUDA compiler 13.0.88. No checkpoint/model revision applies to these synthetic kernel/reference tests.
  • Pre-submission refresh: main advanced to release 1.1.5 at 84e0d560; this release changes version/docs only. zig/ and build.zig are unchanged from the tested base, and the branch merges cleanly. The test receipts remain labelled native 1.1.4.
  • Exactness and decode/prompt speed: n/a; the repository call sites are the three CUDA L2 contract test files; core also re-exports the reference. No runtime call sites were found.
  • Regression: the new test fails before the change on x86_64 and passes after on both architectures. The standalone reference suite has 5 passing tests, 0 failed, 0 skipped after the fix on each architecture. A separate original-source probe also fails in x86_64 Debug, ReleaseSafe and ReleaseFast; aarch64 ReleaseFast passes.
  • A minimal diagnostic wrapper around unchanged Dory registrations, gates, seed and fatbins reports DIAGNOSTIC SUMMARY kernels=2 passed=2 failed=0 controls=4 caught=4 missed=0. Before the correction: 0 kernels passed, 2 failed, with all 4 controls caught in each of two isolated runs. These are wrapper summaries, not full official-runner summaries.
  • Full host suite: zig build test -j2 --summary all passes on both architectures, each with 366/366 steps succeeded, 4,197 passed, 17 skipped, 0 failed. The aggregate reports 17 skips on each architecture; its log explicitly identifies unavailable libjpeg-turbo and libwebp pixel cases, but does not enumerate every skipped test.
  • Candidate binding: the overlaid file used to build the GPU runner has SHA256 e0c2ced997f66016d4a26022fa66f8fbd9eab0d7cec5b0f3b6c78ae9e94a7c1d, matching zig/src/core/l2_ref.zig in commit a3ce6a2f3d1d65094dcf32452fb8e8a4ce826814.
  • Official CUDA runner: all six registrations using l2_ref passed gates 1–4: tf_l2_rows (plain and add), tf_slerp_rows, tf_qk_rows_l2, tf_gate_l2_rows and tf_swiglu_l2_rows. Their planted controls remained caught.
  • Full sweep is incomplete: exit 136 (SIGFPE, confirmed by the kernel divide-error trap) after 2,297 seconds, before its one-hour limit and without a SUMMARY line. It stopped after the window_rows decode-256 registration; the next registration prepares a zero-prefix prompt. The trap maps to contract_window_rows.zig:183, whose decode-position fixture evaluates modulo zero for that prompt. Those files do not use l2_ref; an isolated wrapper reproduced the crash twice with the original, unchanged window_rows fixture. This separate fixture bug (reported as kernel-contract: window_rows prompt fixture computes modulo zero for empty prefixes #1316; fixed by draft cuda tests: guard prompt positions in window rows fixtures #1318) does not establish an incorrect model or GPU-kernel result. Two Qwen attention nonfinite failures were followed immediately by matching registered KNOWN lines; no other unexpected failure lines were emitted before the crash. This is not a complete GPU-suite pass or device qualification.
  • Follow-up official run with both corrections: exit 124 at its 3,600-second guard (3,611.8 seconds including teardown), without a final SUMMARY. It passed the former zero-prefix crash and stopped after repeat cuda wide branch dim512 GQA16 mode1. The emitted lines contain 1,197 PASS, 82 caught corruption controls, two immediately matching registered KNOWN nonfinite cases and 43 N/A gate entries; no unexpected non-control FAIL or missed/error control was emitted. These are partial emitted-line counts, not a full-suite kernel summary. No global pass or device qualification is claimed. The immutable image was sha256:3e80f691fe02f524b29e677173a9b62e460b21c1487b8eb867dd135b81f9f105; driver 615.78.08, NVCC 13.0.88, RTX PRO 4500 SM120. The combined runner includes fixture commit 7b04b5edcba1e146cc98c5bcbf14965917c6beca, file SHA256 c940ab265f2e2afe48d88ca5ce442295f434f4cd2e6214dc24c63761bd11660c, and unmerged l2_ref: preserve signed-zero interval endpoints #1315 commit a3ce6a2f3d1d65094dcf32452fb8e8a4ce826814, reference file SHA256 e0c2ced997f66016d4a26022fa66f8fbd9eab0d7cec5b0f3b6c78ae9e94a7c1d. This is combined-run evidence, not a fixture-candidate-alone full-suite pass.
  • Other interval joins were inspected. A scratch zero/underflow slerp grid at the contract epsilon (1e-6) contained its exact points in all 28,672 cases on each architecture. An instrumented ARM replay evaluated 73,728 positive-epsilon finite zero-padding corners (corner evaluations, not cases); all 112 excluded zero-epsilon NaN misses had exactly zero row sum of squares. This does not qualify zero-epsilon normalization, which has a separate singularity.
  • Lean checker: 434 inherited findings at the pinned baseline and candidate, 0 new. git diff --check passes.
  • Not run: Metal and HIP device checks; suitable devices are unavailable. ARM CPU tests do not qualify either GPU backend.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (n/a: reference-only)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (n/a: reference-only)
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (n/a: no kernel change)
  • Prompt processing is no slower than the last release. (n/a: reference-only)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

@ashhart

ashhart commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Landed on main (84e0d56..24072ec), with you as author. Thank you for the precise fix and test. This closes #1309.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 25, 2026
@ashhart ashhart added the landed Landed on main by the maintainers; the commits keep the contributor's authorship label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

l2_ref: signed-zero interval collapse on x86_64 rejects exact +0 in Dory contracts

2 participants