Skip to content

test(gfx): the two-white allocator does not share the single-white defect (#4303) - #4314

Merged
zackees merged 3 commits into
masterfrom
test/4303-rgbww-does-not-share-the-defect
Sep 10, 2026
Merged

zackees merged 3 commits into
masterfrom
test/4303-rgbww-does-not-share-the-defect

Conversation

@zackees

@zackees zackees commented Sep 10, 2026

Copy link
Copy Markdown
Member

The remaining question on #4303, answered. Stacked on #4313 because it touches the same
test file; merge that first.

The question

#4313 fixed the single-white allocator's slack and deliberately left the two-white path
alone, because the defect had only been measured on the former and scaling RGBWW's slack on
a guess would change a shipped colour path without evidence. This is the evidence.

The answer: no, it does not share it

The defect is accepting a target whose RGB solve wants a drive outside [0, 1], clamping
it, and reporting the target reachable. allocateTwoWhiteDrivesQ16 never accepts one.

The vacuity guard is what makes that worth saying. On the same grid, 670 targets do
have a solve wanting an out-of-range drive — and all 670 are refused. Without pinning that,
"never accepts one" would hold equally well over an empty set, and would be a property of
the corpus rather than of the allocator. My first version of this probe reported
solve_wanted_out_of_range=0 and I nearly took it as the answer; it was.

Worst OKLab hue divergence over the 283 it accepts is 0.00096, against the single-white
path's 0.0197 before #4313 and 0.0034 after.

Why it holds — measured, because my first explanation was wrong

I assumed the reason was structural: kTwoWhiteBoundSlack is half the final check's
tolerance, so the bounds admit less than the check accepts. That is true, and it is not
the reason — making them equal changes nothing here.

What holds it is margin. Raising the slack and re-measuring:

slack targets accepted with an out-of-range solve
64 (shipped) 0
128 0
256 0
512 0
1024 3
2048 5
4096 11

So 64 sits a factor of eight below where the behaviour changes. A comfortable margin
rather than a guarantee — which is the useful thing to know before anyone widens it, and a
better answer than the mechanism I first assumed.

Scope

Test-only. No src/ change, and none needed: the conclusion is that RGBWW does not require
the #4313 treatment.

303/303 unit + 84/84 examples, bash lint clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

…ive units (#4303)

`allocateEmitterDrivesQ16` let each RGB drive fall 64 raw units outside
[0, 1] before refusing, then clamped it -- returning "reachable" and an
allocation that reproduces a different colour. The constant's own comment
sized it as "a quarter of one code at 8-bit output", which is true in drive
space and is not the space the cost is paid in.

One drive unit of an emitter is that emitter's XYZ column. The corpus
device's blue sits at xy = (0.15, 0.06), putting its Z at 13.17, so the same
64 units bought thirteen times the colour error there as on green. At
(0.55, 0.41) -- inside the hull, needing no compression -- blue solved to -62
and was clamped to 0: 0.0125 off in Z against a target Z of 0.0488, 26%, and
0.026 of OKLab hue.

Direction 2 of the four the issue lists, implemented and measured. The slack
is divided by each column's peak component at bind time, so the colour cost
of the allowance is the same on every channel: green keeps 64, red gets 33,
blue gets 5. No per-pixel work and no new matrix.

Measured over 291 in-gamut targets on the xy plane at Y = 0.5:

| | before | after |
|---|---:|---:|
| worst OKLab hue divergence | 0.0197 | **0.0034** |
| targets above 0.005 | 6 | **0** |
| targets above 0.010 | 2 | **0** |
| targets reported reachable | 291 | 283 |

The 8 are the cost, and they are not lost: the gamut mapper compresses them
into the hull instead of the allocator answering them wrongly. Pinned, so
that cost is visible and cannot grow unnoticed.

Three cases change, which is what they were built for. The RGBW hue case
bracketed its outlier from below with a message saying that if the anomaly
vanished, someone should find out why and re-pin -- it fired, and this is
that. It now holds one bound for all five targets. The mechanism case #4304
added becomes a regression guard on the mechanism rather than a record of the
defect. The extent case measures the absence with the same grid that measured
the presence.

The two-white RGBWW path is deliberately untouched. Its slack is still
uniform, because the defect was measured on the single-white allocation and
RGBWW holds hue under 0.02 on the same five targets that gave RGBW its 0.026
-- so it may not have the same problem, and scaling on a guess would be
changing a shipped colour path without evidence.

303/303 unit + 84/84 examples, `bash lint` clean.

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

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4941ec1d-6e5d-40dc-a65d-df9dc4a46b96

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 and others added 2 commits September 10, 2026 11:51
Review on #4313 asked whether `scaled` could overflow an i32 for a tiny
emitter luminance. It cannot -- `buildRgbSolveMatrixQ16`'s coefficient guard
refuses the profile first, measured at a luminance of 4.6e-5 and below, and
UBSan is silent on everything it accepts.

Chasing that found something the review did not name and I had missed. The
scaling *divides* by the column peak, so a dim emitter -- small column --
wants a **larger** slack. At a luminance of 1e-4 the three channels came out
at 330000, 640000 and 48608 raw units. 640000 is nearly ten in drive space,
so `drive > 65536 + 640000` accepts any drive at all and clamps it: the exact
defect this change exists to remove, an order of magnitude worse, for every
dim profile.

The slack now only ever narrows. 64 is the ceiling and the column decides how
far below it each channel sits. The corpus device is unaffected -- green sits
exactly at 64 and the others below -- so every measurement in this PR stands.
A case pins it, with a guard that dim profiles actually reach the slack
rather than all being refused earlier, and mutation-checked by removing the
ceiling: 66, 128 and 3300 against a bound of 64.

Also, from trying to write a standalone probe: `white_allocation.h` did not
compile as a translation unit's only include, spelling `EmitterProfile`
unqualified so it resolved only after some other header pulled in the `using`.
`gamut_map.h` had it too, and `colorimetric_response.h` was already fine. That
is the second and third instance after `device_solve.h`, so the
self-containment test now lists the group rather than taking them one incident
at a time -- which is how `gamut_map.h` turned up.

303/303 unit + 84/84 examples, `bash lint` clean.

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

The question #4303 was left with after #4313 fixed the single-white path.

It does not. The defect is accepting a target whose RGB solve wants a drive
outside [0, 1], clamping it, and reporting the target reachable.
`allocateTwoWhiteDrivesQ16` never accepts one, so its uniform slack never
decides feasibility and cannot buy a colour error.

The vacuity guard is the part that makes that worth saying. On the same grid,
670 targets *do* have a solve wanting an out-of-range drive -- all 670 are
refused. Without pinning that, "never accepts one" would hold just as well
over an empty set and would be a property of the corpus rather than of the
allocator. Worst OKLab hue divergence over the 283 it accepts is 0.00096,
against the single-white path's 0.0197 before #4313 and 0.0034 after.

Why it holds is measured, not reasoned, because the first explanation was
wrong. `kTwoWhiteBoundSlack` is half the final check's tolerance, so the
bounds admit less than the check accepts -- true, and not the reason: making
them equal changes nothing. Raising the slack instead:

    64 (shipped)   0 accepted with an out-of-range solve
    128            0
    256            0
    512            0
    1024           3
    2048           5
    4096          11

So 64 sits a factor of eight below where the behaviour changes. A comfortable
margin rather than a structural guarantee, which is the useful thing to know
before widening it.

303/303 unit + 84/84 examples, `bash lint` clean. Test-only; the src change
this builds on is #4313.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
@zackees
zackees force-pushed the test/4303-rgbww-does-not-share-the-defect branch from f548b61 to be1348c Compare September 10, 2026 18:52
@zackees
zackees changed the base branch from fix/4303-colour-scaled-allocation-slack to master September 10, 2026 18:52
@zackees
zackees merged commit 6d54da4 into master Sep 10, 2026
1 check passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 10, 2026
@zackees
zackees deleted the test/4303-rgbww-does-not-share-the-defect branch November 5, 2026 05:53
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.

1 participant