Skip to content

Commit e2c14af

Browse files
lno: compatibility with pyscf >= 2.14 and NumPy 2 in lnoccsd
- 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.
1 parent f55abdb commit e2c14af

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎pyscf/lno/lnoccsd.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ def ao2mo(self, mo_coeff=None):
396396
class _DFChemistsERIs(_ChemistsERIs):
397397
def _contract_vvvv_t2(self, mycc, t2, direct=False, out=None, verbose=None):
398398
assert(not direct)
399+
# pyscf >= 2.14 changed the signature to (mycc, mol, vvL, VVL, t2, out, verbose);
400+
# with the six-argument call t2 arrives as `out` and the DF-LNO path crashes.
401+
import inspect
402+
if len(inspect.signature(dfccsd._contract_vvvv_t2).parameters) >= 7:
403+
return dfccsd._contract_vvvv_t2(mycc, self.mol, self.vvL, self.vvL, t2, out, verbose)
399404
return dfccsd._contract_vvvv_t2(mycc, self.mol, self.vvL, t2, out, verbose)
400405
def _make_df_eris(cc, mo_coeff=None):
401406
from pyscf.ao2mo import _ao2mo
@@ -467,7 +472,9 @@ def _make_df_eris(cc, mo_coeff=None):
467472
return eris
468473

469474
def _cp(a):
470-
return np.array(a, copy=False, order='C')
475+
# NumPy 2 raises on copy=False when a copy is unavoidable (e.g. an h5py slice on the
476+
# out-of-core path); np.asarray keeps the NumPy 1.x meaning.
477+
return np.asarray(a, order='C')
471478

472479
class MODIFIED_DFCCSD_complex:
473480
pass

0 commit comments

Comments
 (0)