Skip to content

test(preopt): skip GFN-FF tests when libxtb can't load under parallel load - #56

Merged
jonathanschultzNU merged 1 commit into
mainfrom
claude/xtb-gfnff-test-skip-on-load-flake
Aug 20, 2026
Merged

test(preopt): skip GFN-FF tests when libxtb can't load under parallel load#56
jonathanschultzNU merged 1 commit into
mainfrom
claude/xtb-gfnff-test-skip-on-load-flake

Conversation

@NCCU-Schultz-Lab

Copy link
Copy Markdown
Collaborator

Summary

Fixes flaky local failures of the GFN-FF (xtb) pre-optimization tests under pytest -n auto. Test-only change — preopt.py is untouched, and CI is unaffected.

Under heavy parallel load (~18 xdist workers), conda's libxtb shared library intermittently fails its first dlopen in whichever worker runs the GFN-FF relaxation tests, raising xtb C extension unimportable, cannot use C-API at run time. This turned test_relaxes_distorted_metal and test_trajectory_multiframe_ends_at_kept_geometry into flaky failures in the full suite only — they pass when the file is run alone, CI's pip-wheel xtb is unaffected, and the app itself already degrades to an honest no-op. So this is local test noise, not a product bug.

xtb_only now gates on _gfnff_runnable() — one real minimal GFN-FF run, cached per worker process:

  • If libxtb won't load, the GFN-FF tests skip cleanly with an honest reason instead of failing.
  • If it does load, the extension is primed (cached import), so the run-time flake can't recur for the rest of that worker's tests.
  • A genuine GFN-FF regression still fails normally: the extension loads, the tests run, and their assertions catch it.

This also supersedes an earlier "broken C-API" hypothesis, which was a misread — import xtb.libxtb and a real GFN-FF run both succeed here; the cause is dlopen contention under parallel load, not a broken extension.

Test plan

  • tests/test_preopt_gfnff.py alone — all pass.
  • Full pytest -m "not network" under -n auto2573 passed, 29 skipped, 0 failed (previously 2 hard failures; the GFN-FF tests now skip cleanly in a worker where libxtb won't load).
  • ruff + black clean.

Under `pytest -n auto`, conda's libxtb shared library intermittently
fails its first dlopen in a worker and raises "xtb C extension
unimportable, cannot use C-API" at run time, turning two GFN-FF
relaxation tests into flaky failures. It reproduces only under heavy
local parallel load — CI's pip-wheel xtb is unaffected, and the app
itself degrades to an honest no-op, so this is test noise, not a bug.

Gate `xtb_only` on `_gfnff_runnable()`: one real minimal GFN-FF run,
cached per worker process. If libxtb won't load, the tests skip cleanly
with an honest reason; if it does load, the extension is primed so the
run-time flake can't recur for the rest of that worker's tests. A genuine
GFN-FF regression still surfaces (extension loads, tests run, assertions
fail). preopt.py is unchanged.

Note: the earlier "broken C-API" read was a misdiagnosis — `import
xtb.libxtb` and a real GFN-FF run both succeed here; the actual cause is
parallel-load dlopen contention.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jonathanschultzNU
jonathanschultzNU merged commit 5282996 into main Aug 20, 2026
5 checks passed
@jonathanschultzNU
jonathanschultzNU deleted the claude/xtb-gfnff-test-skip-on-load-flake branch August 20, 2026 23:57
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