Fix 2 retry pipeline bugs on GPU#73
Merged
Merged
Conversation
The retry path in src/skala/pyscf/retry.py contained two
gpu4pyscf-incompatibilities that together caused single-point
calculations to fail on GPU but succeed on CPU for systems whose first
SCF call did not converge (see msr-ai4science/feynman#21391):
1. SCFState.post_cycle_callback asserted
isinstance(envs["norm_ddm"], (float, int))
but gpu4pyscf stores norm_ddm as a 0-d cupy.ndarray, so the assertion
fires on the first GPU SCF cycle. Coerce to a Python float instead so
downstream consumers see a uniform numeric type on both backends.
2. increment_level_shift did `if level_shift > 0`. CPU pyscf defaults
SCF.level_shift to 0, gpu4pyscf defaults it to None, so the
comparison raises TypeError on the GPU retry path. Treat None and 0
identically as "no level shift yet" and start from level_shift_init.
Verified by reproducing the original failure on all 8 GPU-failing
structures from feynman#21391 (CCoN, H2FeO2, H2Cl2Fe, CH3Cl, CH3Br,
C3H3IN2, H10N2O2Pt, C2H6O2Pd) and confirming they now succeed with
with_retry=True on cuda. Existing test_scf_retry.py still passes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
steph409
approved these changes
May 18, 2026
Member
|
Felix @pultar, you found a similar issue, so this should also fix the problem you observed. |
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.
The retry path in src/skala/pyscf/retry.py contained two gpu4pyscf incompatibilities that together caused single-point calculations to fail on GPU but succeed on CPU for systems whose first SCF call did not converge.
SCFState.post_cycle_callback asserted isinstance(envs["norm_ddm"], (float, int)) but gpu4pyscf stores norm_ddm as a 0-d cupy.ndarray, so the assertion fires on the first GPU SCF cycle. This PR always converts to float to make gpu4pyscf and pyscf compatible.
increment_level_shift did
if level_shift > 0. CPU pyscf defaults SCF.level_shift to 0, gpu4pyscf defaults it to None, so the comparison raises TypeError on the GPU retry path. This PR treats None and 0 identically as "no level shift yet" and start from level_shift_init.