You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Molecular density-fitted SCF (.density_fit()) crashes with RuntimeError: failed in cart2sph kernel for lanthanide elements whose orbital basis contains g functions (l=4) — e.g. Eu with def2-TZVP. The auto-generated DF auxiliary basis for such a system reaches l=8, and the molecular DF path (gpu4pyscf/df/int3c2e.py) calls cart2sph(..., ang=lk) with that high angular momentum, which the cart2sph CUDA kernel cannot handle.
This appears to be the molecular-path analogue of #761, which fixed the same "lanthanide g-shells → auxbasis reaches l=8" problem for the periodic path by raising L_AUX_MAX. The molecular DF path seems not to have received an equivalent fix, and instead of a graceful assert it fails inside the CUDA kernel.
CPU PySCF runs the identical system fine.
GPU without density fitting (direct SCF) also gets past this point (no cart2sph error) — so the gap is specific to the DF integral transform, consistent with the core DFT path supporting high l (up to i, Support I orbital in DFT #340).
Minimal reproducer
importreimportbasis_set_exchangeasbsefrompyscfimportgtofromgpu4pyscf.dftimportrks# PySCF's built-in library has no Eu def2-TZVP, so fetch it (basis + ECP) from BSE.nw=bse.get_basis("def2-tzvp", elements=["Eu"], fmt="nwchem", header=False)
m=re.search(r"(?im)^\s*ECP\s*$", nw)
basis= {"Eu": gto.basis.parse(nw[: m.start()])}
ecp= {"Eu": gto.basis.parse_ecp(nw[m.start():])}
mol=gto.M(atom="Eu 0 0 0", basis=basis, ecp=ecp, spin=7, verbose=4)
# orbital lmax = 4 (g); auto DF aux lmax = 8mf=rks.RKS(mol, xc="pbe").density_fit()
mf.kernel() # -> RuntimeError: failed in cart2sph kernel
(The same failure occurs for a real Eu coordination complex at wB97M-V/def2-TZVPD — that was the original context; the single atom is the minimal trigger.)
Traceback
File ".../gpu4pyscf/df/df.py", line 282, in cholesky_eri_gpu
File ".../gpu4pyscf/df/df.py", line 339, in _cderi_task
File ".../gpu4pyscf/df/int3c2e.py", line 1527, in get_int3c2e_slice
int3c_blk = cart2sph(int3c_blk, axis=0, ang=lk, out=out)
File ".../gpu4pyscf/lib/cupy_helper.py", line 615, in cart2sph
raise RuntimeError('failed in cart2sph kernel')
RuntimeError: failed in cart2sph kernel
Diagnostics
For the reproducer:
orbital basis lmax = 4 (g functions on Eu; all lighter atoms are ≤ f)
auto DF auxiliary basis lmax = 8 (via pyscf.df.addons.make_auxmol) — the ang=lk passed into cart2sph reaches this value
CPU PySCF: builds and runs (this system has 762 basis functions, matching the reference)
GPU direct SCF (no .density_fit()): does not hit the cart2sph error
Expected behavior
Density-fitted SCF should support auxiliary-basis angular momenta produced by lanthanide (g-function) orbital bases — i.e. the molecular DF cart2sph should handle ang up to at least 8, mirroring the L_AUX_MAX fix in #761 for the periodic path (or fall back gracefully).
Describe the bug
Molecular density-fitted SCF (
.density_fit()) crashes withRuntimeError: failed in cart2sph kernelfor lanthanide elements whose orbital basis contains g functions (l=4) — e.g. Eu withdef2-TZVP. The auto-generated DF auxiliary basis for such a system reaches l=8, and the molecular DF path (gpu4pyscf/df/int3c2e.py) callscart2sph(..., ang=lk)with that high angular momentum, which thecart2sphCUDA kernel cannot handle.This appears to be the molecular-path analogue of #761, which fixed the same "lanthanide g-shells → auxbasis reaches l=8" problem for the periodic path by raising
L_AUX_MAX. The molecular DF path seems not to have received an equivalent fix, and instead of a graceful assert it fails inside the CUDA kernel.cart2spherror) — so the gap is specific to the DF integral transform, consistent with the core DFT path supporting highl(up to i, Support I orbital in DFT #340).Minimal reproducer
(The same failure occurs for a real Eu coordination complex at
wB97M-V/def2-TZVPD— that was the original context; the single atom is the minimal trigger.)Traceback
Diagnostics
For the reproducer:
lmax = 4(g functions on Eu; all lighter atoms are ≤ f)lmax = 8(viapyscf.df.addons.make_auxmol) — theang=lkpassed intocart2sphreaches this value.density_fit()): does not hit thecart2spherrorExpected behavior
Density-fitted SCF should support auxiliary-basis angular momenta produced by lanthanide (g-function) orbital bases — i.e. the molecular DF
cart2sphshould handleangup to at least 8, mirroring theL_AUX_MAXfix in #761 for the periodic path (or fall back gracefully).Environment
gpu4pyscf-cuda12x1.7.4pyscf2.13.1cupy-cuda12x14.1.1Related
L_AUX_MAX.