fit: gauge-fix the log-brightness of a free-pixel Image #519
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 389 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.357
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #519"
general
weight: 0.35
claude[bot]
What
fitgauge-fixes thelog_brightnessof every free-pixelImagetologof its pixel fluxes (Σ exp = 1), so the lit pixels no longer depend on rounding or platform.Why
Imagefluxes aresoftmax(log_brightness), so a constant added tolog_brightnessis an exact null direction of every loss. On virgil-validation'stest_l_curvefixture (8×8, TSV, LM, float64, jax 0.12.0.1) the lit pixels sat at about 4e5 (3.6e10 on jax 0.11.2). L-BFGS and Adam, plain orprecondition="diag", already stayed off the direction;_Metric's projection is unchanged.Pixels whose optimum is zero flux have no finite
log_brightnessand legitimately fit towards-inf(a boundary optimum). They are not clamped (an earlier commit on this branch floored them; reverted on review of the vv investigation, virgil-validation#180). Gauging by log total flux keeps the lit pixels near 0 whatever the dark ones do. This is noted inImage's docstring.How (
src/virgil/fitting.py)_recentre, applied to the start, each LM chunk and the result (every method):x ← x − logsumexp(x)over the supported finite pixels.-infpixels stay-inf.log Σ exp(x), which turns the constant null direction into a well-conditioned one. It is zero at the gauge, so the loss and the stopping test do not see it._gauge_masks, as before).GaussianFieldlatents and proper priors are untouched.Image's docstring anddesign/fit_preconditioning.md(d); CHANGELOG line.Checks
test_l_curvelogic with this branch, by hand: κ−2 ≤ 2e-3 (limit 0.02), residual gradient ≤ 1.1e-7 (limit 1e-5), χ² equalslc.chi2to 1e-8. The lit pixels sit at about -4; dark ones reach -1e9 (rounding), as expected.tests/test_fit_precondition.py:_recentrechanges no loss, fixeslogsumexp = 0, keeps dark and-infpixels; for LM, L-BFGS, L-BFGS+diag and Adam+diag the fit is finite,logsumexp(x) = 0, pixels brighter than 1e-8 of the peak are above -25, and the model's brightness issoftmax(x); for LM, a start shifted by 1e5 gives the same loss, the same brightness (atol 1e-7) and the samelog_brightnesson pixels brighter than 1e-3 of the peak (atol 1e-4). The thresholds are justified in the test: a pixel's log gradient is proportional to its flux, so a stopped fit fixes it only to aboutgtol / flux. About 13 s.test_the_optimum_and_the_gradient_norm_are_unchangedasserted the mean log-brightness stays at 0; it now asserts the log flux is 0.tests/test_ensemble.py::test_rotated_member_is_rendered_onto_the_common_grid_without_croppingfails with and without this change (a float32 sum); not touched.Innovations register
None: gauge fixing an invariant parameterization (log-softmax normalization) is established practice, so no entry is needed.
🤖 Generated with Claude Code