Skip to content

Reject CSE k(T,P) results whose eigenvalues are below round-off (fixes flaky acetyl+O2_cse CI) - #3028

Open
rwest wants to merge 2 commits into
mainfrom
cse-roundoff-check
Open

rwest wants to merge 2 commits into
mainfrom
cse-roundoff-check

Conversation

@rwest

@rwest rwest commented Nov 5, 2026

Copy link
Copy Markdown
Member

Fixes the intermittent test/arkane/arkaneMainTest.py::TestArkaneExamples::test_arkane_examples failure that has hit main's nightly and unrelated PRs since about 31 October 2026:

NetworkError: Computed k(T,P) values for reaction hydroxyl + lactone <=> hydroperoxyl + ketene do not satisfy macroscopic equilibrium

Diagnosis

It's the CPU, not a dependency. I compared the conda package lists printed by 114 Ubuntu test jobs from 27 Oct to 4 Nov.

  • Passing and failing jobs from the same run have identical packages, except _x86_64-microarch-level: it is 4 (AVX-512) in every failing job.
  • All 12 failures ran on Ubuntu 26.04 images on v4 CPUs. None of the 27 v4 jobs on Ubuntu 24.04 failed, and no v3 job failed. The rollout of 26.04 runners lines up with the 31 October start.
  • Every failure is the same: acetyl+O2_cse at 302.47 K and 0.0125 bar, with exactly the same wrong Keq (1.299e-16, against 5.629e-17 expected).

The numbers are round-off everywhere, not only on the failing runners.

  • A dense symmetric eigensolver resolves eigenvalues only to about eps × max|eigenvalue|.
  • For this network at 302 K, max|eigenvalue| is about 2e11 s^-1, so that floor is about 5e-5 s^-1. Several chemically significant eigenvalues are 1e-4 to 2e-6 s^-1.
  • Locally, changing only the LAPACK driver (evr/evd/ev) or OPENBLAS_CORETYPE moves k(OH + lactone → …) from -325 to +22, and can flip an eigenvalue's sign.
  • On most CPUs the noise includes a negative coefficient. network.py then rejects the result quietly ("Negative rate coefficient generated; rejecting result"), which is why those jobs passed. On some AVX-512 runners the noise breaks detailed balance instead, and that raises NetworkError.

Change

apply_chemically_significant_eigenvalues_method (the Allen CSE) now checks the smallest chemically significant eigenvalue against CSE_EIGENVALUE_RTOL * max|eigenvalue|, with CSE_EIGENVALUE_RTOL = 1000 * eps. When there are no product channels, it skips the eigenvalue that is genuinely zero (mass conservation).

Below the threshold, it logs an error and returns zeros. That is what it already does when it can't separate the chemically significant eigenvalues from internal-energy relaxation.

Results over the example's 8×5 (T, P) grid:

  • Every condition the check keeps agrees across LAPACK drivers to within 8%, with no negative values and Keq within 7%.
  • Below about 10·eps the results are noise.
  • The threshold is somewhat conservative: 885 K, 1 bar was stable but is now rejected. The example keeps 6 of 40 points, versus about 17 before, most of which were noise.

Also in this PR:

  • Two functional tests in test/arkane/arkanePdepTest.py. The rejection test fails before this change on any CPU, because it calls the CSE function directly rather than relying on the negative-value check.
  • A short note in documentation/source/reference/pdep/methods.rst.

Testing (local, Intel i7 with AVX2, rmg_env18)

  • The new tests pass, including with OPENBLAS_CORETYPE=Sandybridge and Nehalem.
  • test/rmgpy/pdep passes (20 tests).
  • arkaneMainTest.py -k examples passes, and "Negative rate coefficient" no longer appears in its output.
  • Not tested on an AVX-512 runner. This PR's CI is the first check there, and it only lands on one some of the time.

Not in this PR

  • The Georgievskii CSE variant (get_rate_coefficients_CSE_Advanced) is unchanged. It probably has the same weakness, and CI doesn't exercise it.
  • Whether to narrow the acetyl+O2_cse example's T, P range.

I'm opening separate issues for both.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Fixes flaky acetyl+O2_cse CI failures by rejecting CSE k(T,P) results when the smallest chemically-significant eigenvalue is below an eigensolver round-off threshold, preventing detailed-balance / equilibrium violations caused by numerical noise.

Changes:

  • Add an eigenvalue “noise floor” check to apply_chemically_significant_eigenvalues_method, returning zeros when CSE eigenvalues are not resolved above round-off.
  • Add functional tests that assert round-off-dominated conditions are rejected and a high-(T,P) point satisfies detailed balance.
  • Document the CSE round-off limitation and rejection behavior.
File Description
rmgpy/​pdep/​cse.pyx Introduces eigenvalue-resolution thresholding to reject numerically unreliable CSE results.
test/​arkane/​arkanePdepTest.py Adds functional regression tests for rejection behavior and detailed-balance validation.
documentation/​source/​reference/​pdep/​methods.rst Notes eigensolver resolution limits and that rejected points yield zero k(T,P).

Review effort: Lite

Comment thread rmgpy/pdep/cse.pyx
Comment on lines +187 to +192
logging.error('Smallest chemically-significant eigenvalue ({0:.3g} s^-1) is not resolved above the round-off '
'level of the eigenvalue calculation ({1:.3g} s^-1) at {2:g} K and {3:g} bar, so the '
'chemically-significant eigenvalues method cannot compute k(T,P) here; rejecting result. '
'Consider the reservoir state or modified strong collision method for these '
'conditions.'.format(abs_omega[0], noise_floor, temperature, pressure * 1e-5))
return k, pa

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not changed: kept at error. A rejected point means no k(T,P) at that condition. The two existing rejection paths in the same code ("Could only identify N distinct eigenvalues" in cse.pyx and "Negative rate coefficient generated; rejecting result" in network.py) also log at error level, so this is consistent with them. Leaving the thread open for a maintainer to decide.

🤖 Addressed by Claude Code

Comment thread test/arkane/arkanePdepTest.py Resolved
Comment thread test/arkane/arkanePdepTest.py Resolved
rwest added a commit that referenced this pull request Nov 5, 2026
Review feedback on #3028. The documentation said the eigensolver limit
is about 1e-16 times the fastest rate, but the code rejects at
CSE_EIGENVALUE_RTOL = 1000 * eps (about 2e-13) times the largest
eigenvalue magnitude. State the actual criterion and why it has a
margin above machine epsilon.

In the new test, pick the PressureDependenceJob with isinstance rather
than by class name, and fail with a clear message if the example does
not contain exactly one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rwest and others added 2 commits November 6, 2026 09:15
The acetyl+O2_cse Arkane example has been failing intermittently in CI
since about 31 October 2026 with "Computed k(T,P) values for reaction
hydroxyl + lactone <=> hydroperoxyl + ketene do not satisfy macroscopic
equilibrium" at 302 K, 0.0125 bar. Conda package lists are identical in
passing and failing jobs; every failing job ran on an Ubuntu 26.04 image
on an x86_64-v4 (AVX-512) runner, and all failures give exactly the same
wrong Keq, so the numbers depend on the CPU's BLAS/LAPACK code path.

The cause is that the chemically-significant eigenvalues method is
being asked for eigenvalues it cannot resolve. A dense symmetric
eigensolver finds eigenvalues to an absolute accuracy of about
eps * max|eigenvalue|. For this network at 302 K that is ~5e-5 s^-1
(max|eigenvalue| ~2e11 s^-1), while several chemically-significant
eigenvalues are 1e-4 to 1e-6 s^-1. The resulting k(T,P) values are
round-off: changing only the LAPACK driver (evr/evd/ev) or the OpenBLAS
kernel changes k(OH + lactone -> ...) from -325 to +22. On most CPUs the
noise happened to include a negative coefficient, which network.py
quietly rejects; on some AVX-512 runners it instead broke detailed
balance, which raises NetworkError and fails the test.

Now the Allen CSE implementation checks the smallest chemically-
significant eigenvalue (excluding the zero, mass-conservation mode when
there are no product channels) against 1000 * eps * max|eigenvalue|.
Below that it logs an error and returns zeros, the same way it already
handles eigenvalues that cannot be separated from internal-energy
relaxation. Over the example's T,P grid, results kept by this check agree
between LAPACK drivers to within 8% with no negative values and Keq
within 7%; below about 10 * eps they are noise. The threshold is
somewhat conservative: a few conditions between 100 and 1000 * eps are
also rejected.

The Georgievskii CSE variant is not changed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review feedback on #3028. The documentation said the eigensolver limit
is about 1e-16 times the fastest rate, but the code rejects at
CSE_EIGENVALUE_RTOL = 1000 * eps (about 2e-13) times the largest
eigenvalue magnitude. State the actual criterion and why it has a
margin above machine epsilon.

In the new test, pick the PressureDependenceJob with isinstance rather
than by class name, and fail with a clear message if the example does
not contain exactly one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rwest
rwest force-pushed the cse-roundoff-check branch from 4dc8fc6 to c46f714 Compare November 6, 2026 14:15

This branch has not been deployed

No deployments
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.

2 participants