Skip to content

fix(color): snap sub-epsilon solver residue so the corpus revalidates anywhere (#4370) - #4385

Merged
zackees merged 1 commit into
masterfrom
fix/4370-corpus-reproducible
Sep 12, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/4370-corpus-reproducible

Conversation

@zackees

@zackees zackees commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Closes #4370. Unblocks #4360.

The golden corpus could only be revalidated on the machine that generated it. CI:

stage physical_drive differs from reference for bt2020-rgbww-05:
max abs error 1.58114e-08 exceeds 1e-12

It was never libm noise

1.58114e-08 is sqrt(2.5e-16) to every digit shown. bt2020-rgbww-05 carries a residual that is numerically zero — emitter_light[4] = 1e-15 — and the inverse response takes a square root on odd indices:

light drive
0.0 0.0
1e-16 1.0e-08
2.5e-16 1.58e-08

sqrt has a derivative of 5e7 at 1e-16. A last-bit difference in a quantity that is already zero is amplified eight orders into drive space, where a 1e-12 absolute budget catches it. On the generating machine the recomputation is bit-identical, so the budget had never been exercised and the amplification never showed.

The threshold is not a judgement call

The solve now zeroes residue below 1e-12. Across the corpus's 7,436 nonzero entries:

threshold entries below
1e-12 102
1e-10 102
1e-09 102
1e-08 108

Nothing lies between 1e-12 and 1e-9, so any cut inside that gap partitions identically. The six entries in 1e-9..1e-8 are the sqrt images of the same residue and disappear with it.

This is what the contract already asks for — P5/P7 must publish "deterministic tie-breaks", and the numerical-admission section requires "a deterministic policy" of the inverse response. A residual that is 0.0 on one machine and 1e-15 on another is exactly the non-determinism those clauses forbid.

Blast radius, measured

  • 78 corpus entries change, all to 0.0; largest change 5.48e-08, every one an amplified residual. No real value moves.
  • 3 literals in the exported C++ table: 1e-15 and 4e-15 → 0.0.

One assertion moved, in the right direction

below_floor in tests/fl/gfx/pipeline.cpp was 8, now 5. Three of those eight were excluded from the ΔE budget only because their reference asked for 1e-15 of light — nonzero, below one Q16 unit, so sub_ulp fired. Zero is representable, so those three are now measured like any other vector. They meet the budget, which is why worst_de_above_floor and worst_luminance are unchanged and nothing below that line moved. Fewer exclusions is the improvement, not lost coverage.

Verification

max_stage_abs_error is still 0.0 here — bit-identical as before — and no longer depends on the machine. bash lint, bash test --py --clean and bash test --cpp --clean all clean on exit code; 305/305 unit, 84/84 examples.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Summary by CodeRabbit

  • Bug Fixes
    • Improved color conversion consistency by eliminating negligible floating-point residue from device drive values.
    • Updated color reference results to report exact zero where no measurable output is produced.
    • Improved streaming pipeline budget measurements for near-zero light levels, ensuring valid results are evaluated consistently.

… anywhere (#4370)

The golden corpus could only be revalidated on the machine that generated it.
CI reported:

    stage physical_drive differs from reference for bt2020-rgbww-05:
    max abs error 1.58114e-08 exceeds 1e-12

Not libm noise. 1.58114e-08 is sqrt(2.5e-16) to every digit. That vector's
white channels carry a residual that is numerically zero -- emitter_light[4]
is 1e-15 -- and the inverse response takes a square root on odd indices.
sqrt has a derivative of 5e7 at 1e-16, so a last-bit difference in a quantity
that is already zero is amplified eight orders into drive space, where a 1e-12
absolute budget sees it.

So the solve now zeroes residue below 1e-12. The threshold is not a judgement
call: across the corpus's 7,436 nonzero entries, 102 fall below 1e-12 and the
next real value is above 1e-9 -- a clean three-order gap, so any cut inside it
partitions identically. This is the "deterministic tie-breaks" the contract
asks P5/P7 to publish, and the "deterministic policy" its numerical-admission
section requires of the inverse response.

Blast radius, measured rather than predicted: 78 corpus entries change, all to
0.0, the largest by 5.48e-08 and every one of them an amplified residual. The
exported C++ table changes three literals, 1e-15 and 4e-15 to 0.0.

One assertion moved, and in the right direction. `below_floor` in
tests/fl/gfx/pipeline.cpp was 8; it is now 5. Three of those eight were
excluded from the dE budget only because their reference asked for 1e-15 of
light -- nonzero, below one Q16 unit, so `sub_ulp` fired. Zero is
representable, so those three are now measured like any other vector, and they
meet the budget: worst dE2000 and worst luminance are unchanged, which is why
nothing else below it moved.

Corpus now recomputes bit-identically here as before -- max_stage_abs_error
0.0 -- and no longer depends on the last bit of the machine that produced it.
Unblocks #4360.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c3d5afb7-bc2e-4134-9826-14e662416652

📥 Commits

Reviewing files that changed from the base of the PR and between 8b96581 and c03ecd4.

📒 Files selected for processing (4)
  • ci/color_reference.py
  • ci/golden/color-reference-v1.json
  • tests/fl/gfx/pipeline.cpp
  • tests/fl/gfx/test_utils/color_reference_vectors.hpp

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The solver now snaps drives below 1e-12 to zero in both solve paths. Golden color references, Display P3 fixtures, and the A1 budget expectation reflect the normalized outputs.

Changes

Drive zero snapping

Layer / File(s) Summary
Snap solver drive outputs
ci/color_reference.py
Adds _DRIVE_EPSILON and _snap_drives. Both direct and mapped solve results pass through the helper.
Update reference vectors
ci/golden/color-reference-v1.json, tests/fl/gfx/test_utils/color_reference_vectors.hpp
Replaces sub-epsilon residual values with exact 0.0 values.
Adjust pipeline budget validation
tests/fl/gfx/pipeline.cpp
Changes the expected below-floor count from 8 to 5 while keeping the vector count at 76.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: snapping sub-epsilon solver residue to make corpus validation reproducible. It is specific and directly related to the pull request.
Linked Issues check ✅ Passed Issue #4370 requires deterministic handling of sub-epsilon solver residues and reproducible golden data. ci/color_reference.py defines _DRIVE_EPSILON = 1e-12 and applies _snap_drives to both dir…
Out of Scope Changes check ✅ Passed The changed files support Issue #4370. The JSON corpus, C++ reference vectors, and below_floor expectation update are required to align validation fixtures with the deterministic zero-residue policy…
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4370-corpus-reproducible

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit e83e110 into master Sep 12, 2026
27 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 12, 2026
@zackees
zackees deleted the fix/4370-corpus-reproducible branch November 5, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

P5: the golden corpus is not reproducible off the generating machine — sqrt amplifies a 1e-16 solver residual into 1.6e-8

1 participant