Add guarded GPU support for geometry engines - #125
Merged
Merged
Conversation
… probe tests tests/test_est_cross_device_probe.py::test_force_cpu_true_sets_disable_gpu_env calls quantui.benchmarks._calibration_worker in-process to check that force_cpu=True sets QUANTUI_DISABLE_GPU=1 before any PySCF import. The worker sets that var directly on the real os.environ (by design, so a freshly-imported gpu_offload module sees it) rather than through monkeypatch, so nothing reverted it once the test's spy short-circuited the rest of the worker body. Every later test in the same pytest-xdist worker process inherited a permanently GPU-disabled environment. That was latent and harmless until this PR's new tests/test_pyfock_gpu.py added two tests that assert a fake CuPy device is detected — they never touch QUANTUI_DISABLE_GPU themselves, so a leaked "1" from the earlier test silently changed their expected outcome. Only Python 3.10's CI job happened to schedule the leaking test and the new probe tests onto the same xdist worker, which is why 3.9/3.11 stayed green while 3.10 failed with "QUANTUI_DISABLE_GPU is set in the environment" instead of the fake device tuple. Fix: wrap the worker call in try/finally and pop the var afterward. Plain os.environ.pop, not a second monkeypatch.delenv — delenv would have recorded the leaked "1" as the value to restore at teardown, reintroducing the exact same leak (verified both ways in isolation before landing this). Also hardened the two new PyFock probe tests to delenv the var defensively on entry, so this class of cross-test pollution can't silently change their result again. Verified: ran the leaking test immediately followed by the new PyFock probe tests in a single serial process — reproduced the exact CI failure before this change, confirmed clean after. Full suite (pytest -m "not network", Python 3.10, matching CI) passes with no other regressions. Contributions: - Claude (Sonnet 5): code edits, review, and conceptual discussion - Jonathan Schultz: overall vision, planning, review, and orchestration Co-authored-by: Jonathan Schultz <nccu-schultz-lab@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation