Skip to content

Fix AB13CD MAXIT exit and GAMMA**2 FMA divergence from Fortran - #23

Merged
jamestjsp merged 2 commits into
mainfrom
fix/ab13cd-fortran-parity
Oct 12, 2026
Merged

jamestjsp merged 2 commits into
mainfrom
fix/ab13cd-fortran-parity

Conversation

@jamestjsp

Copy link
Copy Markdown
Owner

What

Follow-up to #20 (DLAPY2). Two more AB13CD divergences from the Fortran reference:

  • MAXIT exit unreachable: while (iter < MAXIT) + post-loop if (iter > MAXIT) never set INFO=2. C fell out with GAMMAU=0, returning gammal/2 with INFO=0. Now mirrors Fortran label 120 (increment, check, INFO=2).
  • FMA contraction: clang fused gamma*gamma - x into fnmsub (both diagonal shifts). gfortran -O3 reference hoists GAMMA**2 and rounds it first. Bits changed DPOTRF/DPOSV/DGEES inputs → INFO 0↔2 flips, hnorm off up to ~50%. Fixed via separate gamma2 statement.
  • Wrapper: py_ab13cd fpeak initialized; previously stack garbage returned on INFO≠0.

Evidence

Random differential sweep vs libslicot (Accelerate both sides, wrapper LDWORK/LCWORK; n≤6, m,p≤2, tol=1e-9; half shifted-random, half lightly damped modes 1e-7..1e-1 under similarity):

  • seed 0 before: 715 non-bitwise / 105 significant
  • each fix reverted alone (seed 0): MAXIT 47, DLAPY2 37, FMA 41 significant
  • all fixes: 0 / 0 over 15,000 cases (seeds 0–4), bitwise

Tests

tests/python/test_ab13cd_fortran_reference.py: +4 seeded cases (maxit_info2, dlapy2_omega, gamma2_rounding, gamma2_dpotrf_info) in the NPZ fixture; now also compares INFO (incl. INFO=2) and FPEAK. 3 of 4 fail on prior ab13cd.c.

Reviewer notes

  • Bitwise parity is for this build (gfortran -O3 reference, clang fp-contract=on). Differential tests use rtol=1e-10.
  • Full suite with CTRLSYS_FORTRAN_REFERENCE_LIB set: 11 pre-existing reference-diff failures (ab09jd, ab13fd, mb03zd, mb04ad/dp/ed/tb, sb04od, sb10dd, sg02nd, tg01jy); none touch AB13CD.
  • AB13DD has same FMA class at many sites; filed ergo HHJNJ5 (commit 2), not fixed here.
  • ASAN Docker run not done.

🤖 Generated with Claude Code

jamestjsp and others added 2 commits October 11, 2026 19:30
- loop never hit INFO=2 at MAXIT; returned gammal/2 with INFO=0
- gamma*gamma - x contracted to fnmsub; reference rounds GAMMA**2 first
- wrapper: init fpeak (garbage on INFO!=0)
- 4 seeded Fortran differential cases; 15k random sweep now bitwise

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T00:33:56.300410Z 4e25905 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jamestjsp
jamestjsp enabled auto-merge (squash) October 12, 2026 00:31
@jamestjsp
jamestjsp merged commit bbc279d into main Oct 12, 2026
3 checks passed
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