Skip to content

Recent PySCF version 2.11.0 breaks PBC Cholesky #17

Description

@bkesk

As of PySCF version 2.11.0, the PBC Cholesky implementation in the afqmctools PySCF interface produces a Cholesky vectors with an unexpected shape.

    @pytest.mark.mpi
    @pytest.mark.skipif(no_mpi,reason="requires mpi4py")
    def test_modified_cholesky(self,setup,diamond,diamond_lda):
        from pyscf.pbc import df, tools
        cell = diamond
        mf,kpts = diamond_lda
        mydf = df.FFTDF(cell,kpts)
        comm = MPI.COMM_WORLD
    
        nmo_max = setup['nmo_max']
        nkpts = setup['nkpts']
        nmo_pk = setup['nmo_pk']
    
        nmo_tot = np.sum(nmo_pk)
        maxvecs = 20 * nmo_tot
        part = sc.Partition(
            comm=comm,
            maxvecs=maxvecs,
            nmo_tot=nmo_tot,
            nmo_max=nmo_max,
            nkpts=nkpts
            )
        gmap, Qi, ngs = sc.generate_grid_shifts(cell)
        X = [np.identity(C.shape[0]) for C in mf.mo_coeff]
        xik, xlj = sc.gen_orbital_products(cell, mydf, X,
                                           nmo_pk, ngs, part, kpts,
                                           nmo_max)
        kconserv = tools.get_kconserv(cell, kpts)
        solver = sc.Cholesky(part, kconserv, 1e-3, verbose=False)
        chol = solver.run(comm, xik, xlj, part, kpts,
                          nmo_pk, nmo_max, Qi, gmap)
    
        assert chol.shape == (4,64,53)
        assert np.isclose(np.max(np.abs(chol)),0.8077979869286759)
       assert len(chol[abs(chol)>1e-10]) == 6047

produces

>       assert len(chol[abs(chol)>1e-10]) == 6047
E       assert 6229 == 6047
E        +  where 6229 = len(array([-1.33363765e-14+4.20980784e-08j,  1.51173409e-09+3.05194614e-09j,\n        2.62971880e-14+4.20981441e-08j, ...,\n        1.99111350e-01-3.11225821e-10j,  4.55662019e-02+3.87804484e-07j,\n        1.93246101e-01+2.98462973e-32j], shape=(6229,)))

Triage is to look into what changes happened in PySCF. Cholesky is deterministic so we should get the same number of Cholesky vectors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions