Repository navigation
Description
Split out of #4364, which I closed with the two tractable items while this one was still open. The diagnostic added there has now identified it exactly.
What CI reports
FAILED ci/tests/test_color_reference_corpus.py::TestColorReferenceCorpus::test_serialized_golden_validation_reports_stage_and_delta_e_budgets
ValueError: stage physical_drive differs from reference for bt2020-rgbww-05:
max abs error 1.58114e-08 exceeds 1e-12
On the machine that generated the artifact the same recomputation is bit-identical — max_stage_abs_error is exactly 0.0 — so the 1e-12 budget is never approached locally and had never been exercised.
The mechanism
It is not libm noise. 1.58114e-08 is sqrt(2.5e-16), to every digit reported:
sqrt(2.5e-16) = 1.5811388300841896e-08
bt2020-rgbww-05 carries a residual in its white channels that is numerically zero:
emitter_light = [0.0, 0.024837358375285, 0.006868489198229, 0.0, 1e-15]
dimmed_light = [0.0, 0.00620933959382125, 0.00171712229955725, 0.0, 2.5e-16]
physical_drive = [0.0, 0.07879936290238171, 0.00171712229955725, 0.0, 2.5e-16]
apply_brightness_then_inverse_response is (light * brightness) ** (1.0 / exponent), and the corpus assigns exponents = (1, 2, 1, 2, 1). Index 3 therefore takes a square root, and its light is exactly 0.0 here. On the runner it is not exactly zero — a residual of ~1e-15 lands there instead — and:
| light | drive |
|---|---|
| 0.0 | 0.0 |
| 1e-16 | 1.0e-08 |
| 2.5e-16 | 1.58e-08 |
The derivative of sqrt at 1e-16 is 5e7. So a last-bit difference in a quantity that is already numerically zero is amplified by eight orders into drive space, and the 1e-12 absolute budget catches it.
Why the budget is measuring the wrong thing here
A drive of 1.58e-08 and a drive of 0.0 are the same drive. Both quantize to 0 at 8 or 16 bits; no emitter distinguishes them. The comparison is failing on amplified noise, not on a difference in the rendered result.
But the residual itself is also not right. 26 of 380 vectors carry sub-1e-9 nonzero entries in emitter_light/dimmed_light, and 10 in physical_drive; the smallest is 1.206e-20. Those are solver residue, not allocations — nothing can be driven at 1e-20.
Two fixes, and they are not equivalent
-
Snap sub-epsilon residuals to zero in the reference. The contract already asks for this in as many words — P5/P7 must publish "deterministic tie-breaks", and the numerical-admission section requires that "inverse response uses a deterministic policy for plateaus". A residual that is zero on one machine and 1e-15 on another is exactly the non-determinism those clauses exist to forbid. Cost: the golden corpus regenerates, so this is a reviewable data change touching the artifact every later phase is measured against.
-
Make the validator's tolerance fit the transform — compare in light space, or use a mixed absolute/relative criterion in drive space. Cheaper, and defensible on the grounds above that the two drives are the same drive. But on its own it leaves the reference emitting 1e-20 "allocations" and leaves the artifact machine-specific in the stages that are not square-rooted.
(1) is the one that makes the reference reproducible; (2) only stops the checker noticing. I lean to (1), possibly with (2) as well, but regenerating the corpus is a decision about the program's baseline artifact rather than a bug fix, so I am filing rather than doing it.
Not urgent, but not cosmetic
This blocks #4360 — the CI gate that would run ci/tests on pull requests cannot go green while it fails — and it means the corpus can only be revalidated on the machine that produced it.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 11, 2026
Measured the blast radius of fix (1), because "snap sub-epsilon residuals" is only safe if noise and signal are actually separable. They are, cleanly.
There is a three-order gap
Counting the 7,436 nonzero entries across all 380 vectors by magnitude:
Nothing at all lies between 1e-12 and 1e-9. So a threshold anywhere in that gap partitions the corpus unambiguously: 102 entries are solver residue, and the next real value is three orders above the largest of them.
The six entries that appear between 1e-9 and 1e-8 are not a counterexample — they are the
sqrtimages of that residue.sqrt(1e-16) = 1e-8. Snapping the light-space stages removes them too, becausesqrt(0) = 0.That is the whole defect in one shape: 102 noise values in light space, six of which the inverse response lifts into the range where an absolute 1e-12 budget can see them.
Why I am still not doing it here
The artifact is not only consumed by Python.
ci/color_reference_export.pyemits a C++ reference-vector table fromci/golden/color-reference-v1.json, andtests/fl/gfx/pipeline.cppmeasures the embedded implementation against it. Regenerating the corpus therefore also regenerates the C++ table that every ΔE budget assertion is scored against.The values that change are all physically zero, so no assertion should move — but "should not" is a prediction about the program's baseline artifact, and verifying it is the work, not the edit. That is a maintainer call rather than something to slip in behind a bloat fix.
What I can say with confidence: the threshold is not a judgement call. Any value in [1e-12, 1e-9] does the same thing, and the corpus says so itself.
fix(color): snap sub-epsilon solver residue so the corpus revalidates…