Skip to content

test(golden): floor near-zero noise in gr_numcompare (fixes rho false-fail)#169

Merged
marjohma merged 1 commit into
mainfrom
golden/near-zero-floor
Jul 1, 2026
Merged

test(golden): floor near-zero noise in gr_numcompare (fixes rho false-fail)#169
marjohma merged 1 commit into
mainfrom
golden/near-zero-floor

Conversation

@marjohma

@marjohma marjohma commented Jul 1, 2026

Copy link
Copy Markdown
Member

Problem

The golden job fails on the fortnum-migration PRs (first seen on #140) with exactly one quantity over tolerance:

electromagnetic/out/m-6_n2/fields/rho.dat: max_rel=3.803e-01 FAIL

Every other quantity — all fields, all kernels, all of QL-Balance and KiLCA — passes, most at 0.000e+00.

Root cause — a comparator artifact, not a code regression

gr_numcompare.py judged every array element by relative diff with only a 1e-12 absolute floor. rho (charge density) is an oscillatory m=6 radial profile: max|rho| ≈ 96, but at its zero crossings the values are O(1e-12) floating-point noise. A last-bit difference between two builds there (fortnum vs GSL — or even two GSL versions) is a negligible absolute diff but tens of percent relative.

Reproduced locally by building both baseline (GSL) and the fortnum branch, running the KIM electromagnetic case, and diffing rho.dat element-by-element:

idx ref (GSL) cur (fortnum) abs diff rel diff
5 (physical) 3.1738e-06 3.1738e-06 6.5e-15 2e-09 ✓
125 (near-zero) -6.03e-14 3.04e-13 3.6e-13 0.34
126 (near-zero) 1.35e-12 1.92e-12 5.6e-13 0.24

Max absolute diff across all 128 elements: 5.87e-13 — ~13 digits of agreement. The physical rho profile is identical; only noise-level zero-crossings diverge, and only in relative terms. Whether a given zero-element trips the bar is a coin flip on the reference build's last bits — GSL-2.8 vs fortnum passes locally, CI's GSL-2.4 vs fortnum fails. That is the signature of a tolerance artifact, not a regression. Same physics as #164, on a quantity gr_numcompare cannot exclude.

Fix

Skip elements where both the reference and current value are at or below a near-zero floor (default 1e-9, overridable via arg 5). The floor sits 3 orders below the smallest physically meaningful value in the golden set (1e-6) and 3 orders above the noise (1e-12), so it floors only genuine noise and never masks a real divergence on a physical value.

  • rho.dat (and the many-zero kernel files) now pass on real output with a (N near-zero skipped) annotation.
  • Adds two unit tests: near-zero noise is skipped; a real divergence on a physical element still fails.

Refs #164. Unblocks the fortnum-migration golden gate (#140#150).

gr_numcompare judged every element by relative diff with only a 1e-12
absolute floor. Oscillatory fields have zero crossings that come out as
O(1e-12) floating-point noise -- e.g. KIM's charge density rho is O(1e2)
physically but ~1e-12 at its crossings. A last-bit difference between two
builds there (fortnum vs GSL, or even two GSL versions) is a negligible
absolute diff but tens of percent relative, so the KIM electromagnetic
golden failed on rho alone while every physical quantity matched to ~1e-14.
Reproduced locally: rho agrees to 5.9e-13 absolute (13 digits); pass/fail
flips purely on which GSL version builds the baseline.

Skip elements where both reference and current value are at or below a
near-zero floor (default 1e-9, arg 5) -- 3 orders below the smallest real
value in the golden set (~1e-6), so it never masks a physical divergence.
Adds two unit tests (noise skipped; real divergence still fails).

Refs #164.
@marjohma marjohma merged commit 0fb4f29 into main Jul 1, 2026
2 checks passed
@marjohma marjohma deleted the golden/near-zero-floor branch July 1, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant