Skip to content

render: re-bless lua_perf_grid references after deterministic sun admission - #5107

Merged
jakildev merged 1 commit into
masterfrom
claude/5047-relua-perf-grid-rebless
Nov 17, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/5047-relua-perf-grid-rebless

Conversation

@jakildev

@jakildev jakildev commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Nondeterminism source removed: #5022's arrival-ordered sun-face record reservation (texels whose sun-face record is lost depend on GPU arrival order). PR #5063 (652d2a309) removed it. Master has been deterministic since then, but it disagreed with the old references, which were one sample of the race. This PR re-blesses the references from that deterministic output.

Test plan

All runs on macOS, Apple M4 Max, Metal, macos-debug Debug tree, pickup master 345dbbf25 (contains #5063 652d2a309, #5064 fdec08e9c and #5070 edf66e34a), 2026-11-16, each wrapped in caffeinate -d -i -u, display awake (Discovered 1 display monitors).

  • Before: 10 consecutive python3 scripts/render-verify.py --target IRLuaPerfGrid runs on 652d2a309^ (72ee536d5) against the old references gave 1/10 failing runs:

    run 1: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 2: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 3: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 4: fit_grid FAIL 99.999 39 68.14|zoom1_origin FAIL 99.9993 39 70.13| [render-verify] 2 of 2 checks FAIL
    run 5: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 6: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 7: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 8: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 9: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 10: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    
  • After: 10 consecutive runs of the same command on the pickup tree after the re-bless gave 0/10 failing runs:

    run 1: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 2: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 3: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 4: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 5: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 6: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 7: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 8: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 9: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    run 10: fit_grid PASS 100.0 0 inf|zoom1_origin PASS 100.0 0 inf| [render-verify] all 2 checks PASS
    
  • 40-shot same-pose probe, frames non-modal / total (one md5 per frame):

    arm 652d2a309^ 652d2a309 pickup 345dbbf25
    normal frame 6/80 (2 variants) 0/80 0/80 (+0/40 from the frozen snapshot)
    shadow overlay 11/80 (4 variants) 0/40 0/80
    light_level overlay 4/40 0/40 0/40
    ao overlay 0/40 0/40 0/40
    unlit overlay 0/40 0/40 0/40

    The ao (880de5dd…) and unlit (41cc8a7e…) hashes are equal across all three trees. The normal (2b939d0d…), shadow (99cb968c…) and light_level (c9b67498…) hashes are equal between 652d2a309 and the pickup tree.

  • The old committed zoom1_origin.png and fit_grid.png are byte-identical (md5 29ba155b…) to the 652d2a309^ modal frame. They were one sample of the race's common state.

  • The new modal frame vs the old reference differs by 96 px, max delta 39, bbox (1036,530)–(1771,723) inclusive: the same value the plan measured.

  • After --update-references, both blessed PNGs have md5 2b939d0d…, equal to each other and to the probe's modal frame on the same build.

  • render-verify --all before the re-bless on the pickup tree, and again after it (see the No collateral row).

  • git status --short before commit: only the three affected files.

Acceptance evidence

Criterion Check run Observed
Plan phase 0: the post-#5063 pickup tree gives 80/80 byte-identical frames over two processes 40-shot LPG_PROBE=1 probe, 2 processes, fleet-run IRLuaPerfGrid --auto-screenshot 10 --wave-amplitude 0 pickup 345dbbf25: 40 2b939d0d… + 40 2b939d0d… = 80/80 (shadow overlay also 80/80, 99cb968c…)
Plan phase 0: a master-parent control (652d2a309^) gives ≥ 1 non-modal frame in 80 same probe on the 72ee536d5 snapshot 6/80 non-modal (39+1, 35+4+1); shadow overlay 11/80
Plan: the delta is shadow visibility only (old vs new tree byte-identical under unlit and ao) probe with LPG_OVERLAY=unlit / ao on 652d2a309^ and 652d2a309 unlit 41cc8a7e… 40/40 in both; ao 880de5dd… 40/40 in both (and on pickup)
Plan (as corrected on #5047): new-vs-old normal frame diff recorded; every differing pixel lies inside a pixel whose light_level-overlay value differs between the two trees (old tree: its modal frame under that overlay), with ao byte-identical; the binary shadow-overlay count is recorded as information stdlib PNG diff (scripts/render-compare.py read_png) of the 652d2a309^ modal frame vs the 652d2a309 modal frame per arm, intersected with the normal-frame diff Met. Normal diff 96 px, max 39, bbox (1036,530)–(1771,723). 96/96 inside the light_level diff (old modal 7a387c5e… 36/40 vs new c9b67498… 40/40), which is exactly those 96 px. ao 40/40 identical (880de5dd…), so the light_level (ao × sun-shadow) delta is sun-shadow. Information: 80/96 inside the binary shadow-overlay diff; the other 16 px (8×2 block at x 1764–1771, y 530–531) are below the 0.999 mask threshold in both trees, visibility 0.29 → 0
Plan correction 1: the pickup tree's normal frame is byte-identical to 652d2a309's probe on both both 2b939d0d… (80/80 each). #5064 and #5070 are output-neutral here, so nothing needs a bisect
Issue criterion 1 / Plan: render-verify --target IRLuaPerfGrid passes 2 of 2 at max delta 0 in 10 consecutive runs on macOS Metal python3 scripts/render-verify.py --target IRLuaPerfGrid ×10 after the re-bless 10/10 [render-verify] all 2 checks PASS, fit_grid PASS 100.0 0 inf, zoom1_origin PASS 100.0 0 inf (all 10 lines in the Test plan)
Issue criterion 2 / Plan: the PR names the source and gives before/after counts the same 10-run loop, and the probe Source: #5022's arrival-ordered sun-face record reservation, removed by #5063 (652d2a309). Loop before (652d2a309^) 1/10 failing runs → after 0/10. Probe frames before 6/80 → after 0/80
Plan: no collateral. render-verify --all per-target verdicts are no worse than the pickup tree's own sweep before the re-bless; IRPerfGrid stays 21/21 python3 scripts/render-verify.py --all before and after the re-bless, same engine tree Before: 13 demos, 323 checks, 24 FAIL (IRLuaPerfGrid FAIL (2 of 2), IRShapeDebug FAIL (20 of 148), IRVoxelEditor FAIL (2 of 2)). After: 22 FAIL (IRLuaPerfGrid PASS, the same IRShapeDebug 20/148 and IRVoxelEditor 2/2). The failing shot names are identical before and after (comm of the two lists is empty apart from fit_grid/zoom1_origin), so those two targets are pre-existing master failures. IRPerfGrid all 21 checks PASS both times. 0 LOCK-FAILED / NO-DISPLAY in either log

Plan departures

Notes for reviewer

The probe was a local, uncommitted, env-gated edit to main_lua.cpp: LPG_PROBE=1 swaps kShots for 40 identical zoom-1 shots, and LPG_OVERLAY=<mode> calls IRRender::setDebugOverlay before gameLoop. It was run as --auto-screenshot 10 --wave-amplitude 0, the manifest's args. git status shows only the three affected files.

Closes #5047

🤖 Generated with Claude Code

…ission

The IRLuaPerfGrid render-verify gate flaked because sun-face record
admission depended on GPU arrival order: a few texels on one screen line
randomly lost their record and read as shadowed. With admission now
deterministic, master renders those texels shadowed on every frame.
The old references hold the lit sample of the race, so the gate failed
2 of 2 on every run.

Re-bless both macos-debug PNGs from the deterministic frame. Compared
with the old reference it differs in 96 px (max delta 39), all of them
sun-shadow. AO and the unlit colours are byte-identical between the two
trees. The manifest notes now record when and why the references were
blessed, so a later sun-face admission change that moves these texels
reads as expected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 16, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: re-bless lua_perf_grid references after deterministic sun admission

Verdict: needs-fix

The re-bless is narrowly scoped: the manifest retains its exact thresholds, shot order, arguments, and macOS-only coverage, while the two committed PNGs are byte-identical to each other. The visual reference is a coherent grid capture, and the supplied before/after run evidence supports the deterministic post-#5063 output.

Needs-fix

  • creations/demos/lua_perf_grid/test/references/manifest.json — The approved issue plan's shadow-attribution acceptance criterion requires every normal-frame differing pixel to lie within a pixel that differs in the shadow overlay. The PR records that this holds for only 80 of 96 pixels; the remaining 16 are unchanged-magenta shadow-overlay pixels that differ only in continuous light_level. The light_level evidence plausibly demonstrates a sun-shadow-only delta, but it does not meet the literal approved criterion. Either provide evidence that satisfies the binary-overlay criterion or reconcile the acceptance criterion through the issue's reviewed plan before requesting re-review.

Acceptance (issue #5047)

Criterion Status Evidence
Post-#5063 output is deterministic; pre-#5063 control is non-modal Met PR records 80/80 matching pickup frames and 6/80 non-modal control frames.
Re-blessed images are the modal deterministic frame and match each other Met Both committed PNGs have the same blob and SHA-256 in this head; PR records the matching modal hash.
Old/new output is identical under unlit and ao Met PR records 40/40 matching hashes for both overlays.
Every normal-frame delta is inside a changed shadow-overlay pixel Unmet PR records 80/96 for the binary shadow overlay, despite 96/96 in continuous light_level.
Ten macOS Metal render-verifies pass at max delta 0 Met All ten summary lines report both shots passing at delta 0.
Source and before/after counts are recorded Met The body identifies arrival-ordered admission removed by #5063 and gives 1/10 before, 0/10 after.
No collateral; IRPerfGrid remains 21/21 Met Pickup-tree before/after all-sweeps retain the same unrelated failures and IRPerfGrid passes 21/21.

Checks

  • linux-build, perf-gate, and render-harness-tests were still in progress when reviewed; no failing completed check was present.

🤖 Reviewed by Codex (GPT-5, runtime codex; review-pr skill)
Opus recheck not required.

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-xeon-6975p-c-03-0-vga

Perf gate — seeding new baseline

No baseline at /home/runner/work/_temp/perf-baseline/docs/perf/baseline_latest/linux-x86_64-xeon-6975p-c-03-0-vga/. The next master push from this host will seed one. Gate is informational this PR.

@jakildev

Copy link
Copy Markdown
Owner Author

NEEDS-DESIGN

Contract break. #5047's plan has the acceptance criterion "The delta is shadow visibility only". Its last clause, "Every differing pixel lies inside a pixel whose shadow-overlay value differs between the two trees", cannot be met for this delta, because the shadow overlay is binary. The review on this head graded that row unmet, correctly. I can't amend my way to a pass: no evidence would satisfy the clause as worded, and a worker cannot write the ## Plan corrections that would change it.

Why the premise is false (measured).

  • DebugOverlayMode::SHADOW (3) draws surfaceShadowDebugColor(shadow), which is visibility >= 0.999 ? black : magenta (engine/render/src/shaders/metal/ir_surface_lighting.metal:11-13, called from c_lighting_to_trixel_body.metal:308). A texel that is already partly shadowed in both trees and gets darker cannot change its overlay value.
  • I re-derived the diff from the committed refs on this head (git show origin/master: vs HEAD: of zoom1_origin.png, decoded with scripts/render-compare.py read_png). Result: 96 px, max 39, bbox (1036,530)–(1771,723), the same as the PR body.
    • 80 px are scaled by ×0.62 (0.619–0.627 per channel). That is the lit→shadowed flip, and the binary overlay sees it.
    • 16 px are the 8×2 block at x 1764–1771, y 530–531. Every one goes (38,101,79)→(32,86,67), ×0.84–0.85. That is a partly shadowed texel getting darker. It is magenta in both trees, so it is invisible to the clause.
  • What the clause is for (a sun-shadow-only delta) is already shown on this head by the probe arms in the PR body:
    • ao overlay: byte-identical across 652d2a309^, 652d2a309 and the pickup tree.
    • unlit overlay: byte-identical across the same three trees.
    • light_level overlay (ao × shadow, continuous, c_lighting_to_trixel_body.metal:304-306): its old-vs-new diff is exactly the 96 px.

Questions.

  • Which wording should replace the clause? Options (I recommend A):
    • A. "Every differing normal-frame pixel lies inside a pixel whose light_level-overlay value differs between the two trees, and the ao overlay is byte-identical between them." Since light_level = ao × shadow and AO is unchanged, a light_level delta is a sun-shadow delta. Already met: 96/96, ao 40/40 identical. Limit: it proves the shadow factor changed, not that the binary lit/shadowed state flipped.
    • B. Keep the binary shadow overlay, but exempt pixels that are below the 0.999 threshold in both trees, provided their light_level value differs. Met: 80 flips + 16 deepened. This says the same thing as A in more words.
    • C. Keep the clause as written. The PR cannot pass it, and IRLuaPerfGrid render-verify intermittently fails one shot at max delta 39 #5047 needs a different fix, but none is known: the deterministic frame really does deepen that block.
  • Whoever answers: please land the answer as a ## Plan corrections comment on IRLuaPerfGrid render-verify intermittently fails one shot at max delta 39 #5047, carrying the replaced clause verbatim. review-acceptance grades only the issue's ## Plan + ## Plan corrections, so an answer posted only on this PR loops back to the same needs-fix.

Nothing needs to be pushed for A or B: the references, manifest and evidence on head 3536ca100 stand. The resuming worker re-grades the row in the body and re-requests review.

— worker (pool-2, feedback dispatch)

@jakildev jakildev added fleet:design-blocked Worker escalated for architectural input mid-task; architect should respond fleet:reviewing-mac-pool-7 and removed fleet:needs-fix Fleet reviewer found issues — author must address fleet:amending-mac-pool-2 labels Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Architect direction

Decision: option A. The clause moves to the continuous light_level overlay. B says the same thing with a case split, and C is rejected.

The replaced clause. In #5047's criterion "The delta is shadow visibility only", second sub-bullet, the last sentence

Every differing pixel lies inside a pixel whose shadow-overlay value differs between the two trees.

becomes

Every differing pixel lies inside a pixel whose light_level-overlay value differs between the two trees (for the old tree, its modal frame under that overlay). The ao overlay is byte-identical between the two trees (the sub-bullet above), so a light_level (ao × sun-shadow) difference is a sun-shadow visibility difference. The PR also records how many of the differing pixels lie inside the binary shadow-overlay difference, as information and not as a pass condition.

The two trees stay 652d2a309^ and 652d2a309, as item 1 of the plan-review corrections set them. Nothing else in the criterion changes. The same text is now a ## Plan corrections comment on #5047, which is what review-acceptance grades.

Why.

  • The criterion is named "the delta is shadow visibility only". DebugOverlayMode::SHADOW is a two-colour mask: surfaceShadowDebugColor returns black at visibility ≥ 0.999 and magenta below it (ir_surface_lighting.metal:11, ir_surface_lighting.glsl:11). A texel whose visibility changes without crossing 0.999 is a visibility change the mask cannot show. The old sentence therefore tested the mask's threshold, and it fails a delta the criterion exists to accept.
  • LIGHT_LEVEL paints ao × shadow as a continuous value (c_lighting_to_trixel_body.metal:304-306). With the ao overlay identical, a light_level difference at a pixel can only come from the sun-shadow factor. The new sentence fails closed: where ao is 0 the overlay reads 0 in both trees, so a differing pixel there would count as unexplained.
  • C keeps a sentence that no correct re-bless of this frame can pass. The plan's Decisions already put the correctness of shadows at exhausted-pool texels out of scope (the render: make sun record admission deterministic under pool exhaustion (static-scene shadow flicker) #5022 lineage), so IRLuaPerfGrid render-verify intermittently fails one shot at max delta 39 #5047 has no fix to make for a texel that got darker.

What I re-derived (this macOS host, 2026-11-16, master 345dbbf25, PR head 3536ca100):

Check Result
Old vs new committed reference (origin/master: vs 3536ca100:), both PNGs 96 px, max delta 39, bbox (1036,530)–(1771,723). Six 8×2 blocks: five scale by ×0.62 (80 px), one by ×0.84–0.85 (16 px at x 1764–1771, y 530–531)
Your saved probe frames in /private/tmp/pool-3-5047/runs, parent-* modal vs 5063-* normal diff 96 px. shadow diff 80 px. light_level diff 96 px, the same pixel set as the normal diff. ao diff 0. unlit diff 0
The 16 px shadow is magenta in both trees. light_level goes (74,74,255) → (0,0,255) with ao (0,255,0), so visibility goes 0.29 → 0
The 80 px shadow goes black → magenta. light_level goes (255,255,255) → (0,0,255), so visibility goes 1 → 0
Cross-check against surfaceSunFactor The 80 px give (1 − ambient) · lambert / ambient ≈ 0.61. That predicts ×0.85 for a 0.29 → 0 change. The committed references show ×0.842–0.851 on those 16 px

I did not re-run the probe on the GPU. The overlay rows are my own diff of your saved frames. Their parent-normal and 5063-normal modal hashes equal the committed old and new references (29ba155b…, 2b939d0d…).

On resume. Nothing needs to be pushed.

This decision is local to #5047's criterion, so it has no docs/design/ page. Read this direction alongside #5047's ## Plan and both ## Plan corrections comments before resuming.

— design-answerer (pool-7, dispatched architect)

@jakildev jakildev added fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file and removed fleet:design-blocked Worker escalated for architectural input mid-task; architect should respond fleet:reviewing-mac-pool-7 labels Nov 16, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: re-bless lua_perf_grid references after deterministic sun admission

Verdict: approve

This is a focused three-file re-bless: both committed macOS references have the same MD5 (2b939d0df4b9619b0288ce6071b7782e), and the manifest retains the two-shot, zero-tolerance contract. The plan correction on issue #5047 replaces the binary-shadow-mask clause; the recorded continuous light_level evidence now satisfies the corrected attribution criterion.

Acceptance (issue #5047)

Criterion Grade Basis
Post-#5063 pickup is deterministic; parent control is non-modal met The PR records 80/80 identical pickup frames and 6/80 non-modal parent frames.
Delta is sun-shadow visibility only met The current plan correction requires 96/96 normal-frame pixels within changed light_level; the PR records that result plus byte-identical AO and unlit overlays.
Ten macOS Metal render-verifies pass at max delta 0 met The PR supplies ten all 2 checks PASS summaries; the manifest still gates two shots at zero tolerance.
Nondeterminism source and before/after counts are recorded met The PR identifies arrival-ordered sun-face admission and records 1/10 before, 0/10 after, plus 6/80 to 0/80 probe results.
No collateral; IRPerfGrid remains 21/21 met The PR records same-tree before/after sweeps, removes only the two target failures, and retains IRPerfGrid 21/21.

Checks

  • linux-build, format, header, instruction, and PR-close checks are green.
  • render-harness-tests is red only for the pre-existing scripts/verify_common.py fleet import contract failure; this PR does not touch that script or its tests.

🤖 Reviewed by Codex (GPT-5, runtime codex; review-pr skill)
Opus recheck not required.

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge and removed fleet:reviewing-mac-pool-4 labels Nov 16, 2026
@jakildev jakildev removed the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed design direction (option A, ## Plan corrections on #5047). No push was needed; head 3536ca100 is unchanged.

  • ## Acceptance evidence: the attribution row now grades the corrected sentence as met. 96/96 differing normal-frame pixels lie inside the light_level-overlay diff (old tree's modal frame 7a387c5e… 36/40 vs c9b67498… 40/40), and ao is 40/40 byte-identical (880de5dd…). The 80/96 binary shadow-overlay count stays in the row as information. I re-derived all of these numbers on this host from the saved probe frames.
  • ## Plan departures: the third item is marked resolved and points at the plan correction.
  • fleet:design-unblocked cleared. The latest review (15:43) already approves against the corrected plan, so fleet:approved stays.
  • The red render-harness-tests check is the pre-existing verify_common.py import contract failure tracked in scripts: render-harness dependency contract red on master since #5078 (verify_common imports fleet) #5088. It is not this PR's.

— worker (pool-3, feedback dispatch)

@jakildev
jakildev merged commit c7c84e4 into master Nov 17, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRLuaPerfGrid render-verify intermittently fails one shot at max delta 39

1 participant