Skip to content

dasLLAMA tests: the rope cross-layout cell bounds the two layouts at one ulp - #3942

Merged
borisbat merged 2 commits into
masterfrom
bbatkin/rope-ulp-bar
Sep 5, 2026
Merged

dasLLAMA tests: the rope cross-layout cell bounds the two layouts at one ulp#3942
borisbat merged 2 commits into
masterfrom
bbatkin/rope-ulp-bar

Conversation

@borisbat

@borisbat borisbat commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

test_rope.das has been red under -jit since 2026-09-02: its cross-layout cell asserted that the packed rope row and the two-tab tables agree bit for bit at fscale 1. Since the JIT put aarch64 vector sin and cos on the inline vecmath polynomial, the packed builder's single loop vectorizes onto that rail while the two-tab builder's nested loop stays on scalar libm, and 2 to 7 of 128 elements differ by one ulp. Interp and -O0 are identical. The cell now bounds the difference at 1 ulp, with a 2-ulp poison as the control the checklist asks of a loosened bar. The multiplication-order contract the module header states is untouched, and the frozen CPU parity fixtures pass unchanged (23 of 23 small tier).

Where to look: modules/dasLLAMA/tests/test_rope.das, test_rope_gen_cross_layout.

Validation, claims, ledger

Validation

  • test_rope.das 28/28 under -jit and on the interpreter; red before on the one cell under -jit -O3 only. The dasLLAMA model-free suite is not a CI step, which is how the red went unseen; preflight --only dasllama-model-free is its home.

Not done

  • The packed row (the device kernels' layout) has carried the 1-ulp shift since the JIT change; the frozen GPU-side parity arms were not re-run for this PR.

🤖 Generated with Claude Code

…one ulp

Under -jit the packed row's single loop vectorizes onto the aarch64 polynomial sin/cos rail while the two-tab builder's nested loop stays on scalar libm, so 2 to 7 of 128 elements differ in the last bit; interp and -O0 agree bit for bit. The multiplication-order contract still holds at fscale 1; a 2-ulp poison is the bar's control.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 5, 2026 08:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The newly added ulps_apart and poison-control logic compute ULP distance via raw bit subtraction, which is incorrect across negative values and can overflow, making the updated test potentially flaky or misleading.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the dasLLAMA RoPE test suite to account for JIT-only last-bit drift between the packed-row and two-tab table builders by relaxing a cross-layout equality assertion from bit-identical to “within 1 ULP” at fscale=1.

Changes:

  • Introduces an ulps_apart helper and updates test_rope_gen_cross_layout to assert worst <= 1 ULP instead of exact equality.
  • Adds a “2-ULP poison” control assertion intended to ensure the loosened tolerance still rejects a clearly-wrong result.
File summaries
File Description
modules/dasLLAMA/tests/test_rope.das Adjusts the cross-layout RoPE test to compare within a ULP tolerance and adds a poison control check.
Review details

Suppressed comments (1)

modules/dasLLAMA/tests/test_rope.das:144

  • The poison control currently bumps the raw IEEE bits (reinterpret<int>(ct[3]) + 2), which is only guaranteed to be a +2 ULP step for a subset of positive, non-edge values. Once ULP distance is computed in ordered-float space, generate the poison in that same space so it stays a true 2-ULP offset regardless of sign.
        //! the bar's control: a cos value 2 ulps off its table twin lands outside it
        let poisoned = unsafe(reinterpret<float>(unsafe(reinterpret<int>(ct[3])) + 2))
        t |> success(ulps_apart(poisoned, ct[3]) > 1, "a 2-ulp poison lands outside the bar")
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread modules/dasLLAMA/tests/test_rope.das Outdated
Raw bit subtraction is not a distance across the sign bit and can overflow between far bit patterns; a cos near zero can land on either side between the two builders. The rank mirrors a negative float's bits below zero, so the two zeros coincide and a difference across the sign counts the values it spans; two cells pin both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 5, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is confined to test logic and adds a clearly bounded tolerance with explicit controls to prevent masking real regressions.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@borisbat
borisbat merged commit f1aa429 into master Sep 5, 2026
30 checks passed
@borisbat
borisbat deleted the bbatkin/rope-ulp-bar branch September 5, 2026 12:07
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.

2 participants