Admit the value remaining after signed logsumexp cancellation
Use an independent reference for the remainder and sign after leading terms cancel. Do not replace NaN with an arbitrary zero.
When the small remainder matters
For signed weights, verify the mathematical remainder after cancellation, with log magnitude and sign treated separately. The largest term alone does not decide whether the answer is finite. Dropping the sign changes the original subtraction problem rather than stabilizing it. A table joining independently calculated log remainders with actual results defines the meaning of the Truthound check. [1, 2, 3]
Reported inputs with a finite remainder
SciPy #26340 reports NaN from logsumexp when equal large terms cancel despite a finite remainder. A follow-up contributor reports checks on 1.18.1 against a high-precision reference. This supports the reported cases, without establishing accuracy for every input or adoption of a fix. [1]
Record sign and magnitude separately
Retain input logs and weights and derive an independent reference including cancellation. Do not fill a nonfinite result with zero; admit a path only after magnitude and sign reconciliation. Operators prepare actual outputs and independently defined references in a table joined by calculation ID, keeping failures separate. [1, 3]
A reference leaving exp(1)
For illustrative logs [2,2,1] and signed weights [1,-1,1], exp(2)-exp(2)+exp(1)=exp(1). The expected log magnitude is independently 1 with positive sign. An actual magnitude of 1 passes; 0 fails. This fixture compares magnitude only; total cancellation to exactly 0 needs a different finite-log expectation. [1, 3]
The log-magnitude comparison
ColumnPairValidator in Truthound Python SDK 3.3.2 compares operator-prepared observed_log_magnitude and reference_log_magnitude values. Keep sign and nonfinite status in separate columns. Passing magnitude does not establish the sign or every input; Core does not calculate logsumexp or high-precision cancellation. [1, 2, 3]
High precision and shifted controls
Use high-precision references and shifted-input controls, choosing a verified path that preserves sign. Existing regression coverage of the same cancellation cases reduces the benefit of another audit. A shifted control is evidence about a defined invariance, not permission to change the signed weights. [1, 3]
Application conditions
Join signed weights, input logs, actual outputs, and an independent remainder reference by calculation ID.
Alternatives
Use high-precision references and shifted controls while preserving the sign.
Limitations
Magnitude agreement alone does not approve the sign, exact-zero sums, or every input.
Evidence
- Event checked
- Subject checked
- Modified
