lno: compatibility with pyscf >= 2.14 (dfccsd._contract_vvvv_t2 signature) and NumPy 2 (_cp) - #212
thebreadishard wants to merge 1 commit into
Conversation
- DFLNOCCSD._contract_vvvv_t2: pyscf 2.14 changed dfccsd._contract_vvvv_t2 to a seven-argument signature (mycc, mol, vvL, VVL, t2, out, verbose). The old six-argument call shifted the arguments, so t2 arrived as out and every DF-LNO-CCSD run crashed. The call now adapts to the installed signature. - _cp: np.array(a, copy=False, ...) raises under NumPy 2 when a copy is unavoidable, which it is for an h5py slice on the out-of-core path (max_memory below the fragment's Lov block). np.asarray keeps the intended behaviour on both NumPy 1 and 2. Both fixes have been running in production LNO-CCSD(T) calculations on benzene and naphthalene (cc-pVDZ/cc-pVTZ, pyscf 2.14.0, NumPy 2) since 2026-09-10.
|
Can you show simple example inputs that raise the two errors you describe, assuming pyscf 2.14.0 and numpy 2 are installed? On my machine, which has pyscf 2.14.0 and numpy 2.2.5, all the lno tests pass without incident, including the "main" block of |
| # pyscf >= 2.14 changed the signature to (mycc, mol, vvL, VVL, t2, out, verbose); | ||
| # with the six-argument call t2 arrives as `out` and the DF-LNO path crashes. | ||
| import inspect | ||
| if len(inspect.signature(dfccsd._contract_vvvv_t2).parameters) >= 7: |
There was a problem hiding this comment.
I think it is better to simply inspect the version of PySCF directly, which would both render the commentary in lines 399 and 400 unnecessary and make it clear that if something similar happens in the future, it's probably because the calling signature was changed (if it changed in the past, it might change in the future).
MatthewRHermes
left a comment
There was a problem hiding this comment.
Please add regression tests for these two bugs, since currently the entire test suite passes on pyscf:master with PySCF 2.14.0 and NumPy 2 installed.
Summary
Two small compatibility fixes in
pyscf/lno/lnoccsd.py, both hit in production LNO-CCSD(T) runs (benzene and naphthalene, cc-pVDZ/cc-pVTZ, pyscf 2.14.0, NumPy 2):DFLNOCCSD/_DFChemistsERIs._contract_vvvv_t2: pyscf 2.14 changeddfccsd._contract_vvvv_t2to(mycc, mol, vvL, VVL, t2, out=None, verbose=None). The existing six-argument call shifts the arguments (t2 arrives asout) and every DF-LNO-CCSD run fails. The call now inspects the installed signature and passesvvLtwice on pyscf ≥ 2.14, keeping the old call for older pyscf._cp:np.array(a, copy=False, order='C')raises under NumPy 2 when a copy is unavoidable, which happens on the out-of-core path when the fragment'sLovblock is an h5py slice (max_memorybelow its size).np.asarray(a, order='C')keeps the NumPy 1.x meaning.Test plan
python -m py_compile pyscf/lno/lnoccsd.pypyscf/lno/testsuite in a clean environment (Python 3.12, pyscf 2.14.0, NumPy 2.5.3, this branch built from source against the installed pyscf headers withCMAKE_CONFIGURE_ARGS=-DPYSCF_SOURCE_DIR=<site-packages>/pyscf,BUILD_OCCRI=OFF): 5 passed in 183 s,pytest -q pyscf/lno/test.🤖 Generated with Claude Code