Skip to content

Errors when running UHF AFM states with density fitting and minimal fragments #83

@cjcscott

Description

@cjcscott

Hello! This is an issue for discussion of the test failures in #69; I didn't want to confuse the discussion there so thought a different place to discuss would be useful. I was going to add a PR for discussion and a fix, but I'm currently unsure of the best way to nicely fix this.

The test failures are interesting; it's the test from the spin-symmetry-broken UHF fix I merged a while back but it didn't come up till now due to the tests not running for all PRs at that point. I can't reproduce it on my local or zombie python installs (aka all tests pass for me), both of which used the setup.py for all dependencies and seem to be within what we support, but @abhishekkhedkar09 has successfully reproduced it.

It looks to be an error coming from within the pyscf UCCSD ao2mo functionality when called within a UCISD calculation to generate an initial UFCI guess. The explicit error from the logs is

>           Lvv[blk] = lib.pack_tril(Lpq[:,va,va].reshape(-1,nvira,nvira))
E           ValueError: cannot reshape array of size 0 into shape (0,0)

../../../.local/lib/python3.7/site-packages/pyscf/cc/uccsd.py:1004: ValueError

and the relevant end of the stack trace is

vayesta/solver/fci.py:256: in get_cisd_init_guess
    return super().get_cisd_init_guess()
vayesta/solver/fci.py:102: in get_cisd_init_guess
    cisd.kernel()
vayesta/solver/cisd.py:22: in kernel
    if eris is None: eris = self.get_eris()
vayesta/solver/ccsd.py:91: in get_eris
    self.eris = self.base.get_eris_object(self.solver)
vayesta/core/util.py:439: in wrapped
    res = func(self, *args, **kwargs)
vayesta/core/qemb/uqemb.py:196: in get_eris_object
    eris = postscf_ao2mo(postscf, fock=fock, mo_energy=mo_energy, e_hf=e_hf)
vayesta/core/ao2mo/postscf_ao2mo.py:69: in postscf_ao2mo
    eris = postscf.ao2mo(mo_coeff)
../../../.local/lib/python3.7/site-packages/pyscf/ci/ucisd.py:947: in ao2mo
    return uccsd._make_df_eris_outcore(self, mo_coeff)

This looks to arise when inferring one shape dimension when another is specified to be zero size for an array of zero size, which makes sense since the obvious approach to calculate this would result in zero divided by zero and that index of the shape doesn't actually change the size of resulting matrix. As a minimal example consider the following:

In [1]: import numpy as np

In [2]: t = np.zeros((0,0))

In [3]: t.reshape(0,0)
Out[3]: array([], shape=(0, 0), dtype=float64)

In [4]: t.reshape(0,10)
Out[4]: array([], shape=(0, 10), dtype=float64)

In [5]: t.reshape(-1,10)
Out[5]: array([], shape=(0, 10), dtype=float64)

In [6]: t.reshape(-1,0)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-133516b31434> in <module>
----> 1 t.reshape(-1,0)

ValueError: cannot reshape array of size 0 into shape (0)

The neatest solution would be changing the call in pyscf to
> Lvv[blk] = lib.pack_tril(Lpq[:,va,va].reshape(Lpq.shape[0],nvira,nvira))
but given this is very edge case I don't know if that's likely to be accepted.
Otherwise I guess catching this error in this edge case might be an OK modification? However, I wanted to discuss with others first.

My initial guess on why I can't reproduce it is that I have a .pyscf_conv.py set up to set a very large maximum memory, which might mean that only incore eris are used and so if the issue is within uccsd._make_df_eris_outcore I don't ever encounter it. However, initial tests with Abhi suggest he still gets failure with this modification so who knows.

Anyway, any help on what a nice fix would look like would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions