Git Product home page Git Product logo

Comments (17)

msricher avatar msricher commented on July 28, 2024 2

I don't think we should include fanpt now, since it doesn't work, and its just Ramon's draft implementation.

We also need to make sure that the open-shell method we include actually does work.

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024 1

There is a pull request that merged the fanci py pyci
The only question is if you want to have 2 different folders for tests on pyci and fanci. Let me tag you at pull request.
But yes, they are merged. I was talking to @gabrielasd if we can remove the dependency on solver for FanCI, though.
If you approve this pull request, we can start working on separating fanci functionality from optimizers

from pyci.

gabrielasd avatar gabrielasd commented on July 28, 2024

The repo for FanCI is https://github.com/QuantumElephant/FanCI.
We can take the master branch from there to be the one we port (it is the latest one, although there are few unmerged branches)

We have to put the methods there as a module of PyCI. Probably it can be just copying the folder fanci and put it under the pyci folder in this repo.

Do not include the fanpt module or its tests (files starting with test_fanpt)

Tentative tasks:

  • Copy fanci folder to pyci (the call to the fanci methods would look like pyci.fanci)
  • Move FanCI tests to PyCI test folder
  • Fix the imports so that things work

from pyci.

gabrielasd avatar gabrielasd commented on July 28, 2024

@msricher do we include the fanpt module too?

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

@msricher Do you want to have to separate folders for test? One just for pyci and one for fanci, or I should merge everything in one folder?

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

Also, running tests on Fanpy are very slow. Is it expected behaviour?

from pyci.

msricher avatar msricher commented on July 28, 2024

Oh, yes, the FanPy is very slow. I can speed it up by removing the logic for frozen parameters which we don't use.

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

Okay, cool
It seems like 2 tests are failing too, but the rest are fine

__________________________________________________________ test_4e_5mos_pccds_overlap ___________________________________________________________

dummy_ham = <pyci.pyci.secondquant_op object at 0x7fe56d8c8270>

    def test_4e_5mos_pccds_overlap(dummy_ham):
        pccsd = pCCDS(dummy_ham, 2, 2, nproj=None)
        nparams = pccsd.nocc_up * pccsd.nvir_up + pccsd.wfn.nocc * pccsd.wfn.nvir
        params = np.arange(nparams, dtype=pyci.c_double) + 1
    
        mat_s = params[pccsd.nocc_up * pccsd.nvir_up:].reshape(pccsd.wfn.nocc, pccsd.wfn.nvir)
        mat_p = params[:pccsd.nocc_up * pccsd.nvir_up].reshape(pccsd.wfn.nocc_up, pccsd.wfn.nvir_up)
    
        # Reference occs
        # alphas: [11000]
        # betas:  [11000]
        occsv = np.array([[[0,1],[0,1]]])
        ovl = pccsd.compute_overlap(params, occsv)
        assert np.allclose(ovl[0], 1.)
        # Exc=1, seniority=2
        # alphas: [11000]
        # betas:  [10100]
        occsv = np.array([[[0,1],[0,2]]])
        ovl = pccsd.compute_overlap(params, occsv)
        assert np.allclose(ovl[0], mat_s[3,3])
        # Exc=2, seniority=0
        # alphas: [10100]
        # betas:  [10100]
        occsv = np.array([[[0,2],[0,2]]])
        ovl = pccsd.compute_overlap(params, occsv)
        expected = mat_p[1,0] + (mat_s[1,0]*mat_s[3,3] + mat_s[1,3]*mat_s[3,0])
>       assert np.allclose(ovl[0], expected)
E       assert False
E        +  where False = <function allclose at 0x7fe5ec0fc430>(4.0, 768.0)
E        +    where <function allclose at 0x7fe5ec0fc430> = np.allclose

pyci/test_fanci/test_pccds.py:59: AssertionError
__________________________________________________________ test_2e_5mos_pccds_overlap ___________________________________________________________

dummy_ham = <pyci.pyci.secondquant_op object at 0x7fe5e2cb1f70>

    def test_2e_5mos_pccds_overlap(dummy_ham):
        pccsd = pCCDS(dummy_ham, 1, 1, nproj=None)
        nparams = pccsd.nocc_up * pccsd.nvir_up + pccsd.wfn.nocc * pccsd.wfn.nvir
        params = np.arange(nparams, dtype=pyci.c_double) + 1
    
        mat_s = params[pccsd.nocc_up * pccsd.nvir_up:].reshape(pccsd.wfn.nocc, pccsd.wfn.nvir)
        mat_p = params[:pccsd.nocc_up * pccsd.nvir_up].reshape(pccsd.wfn.nocc_up, pccsd.wfn.nvir_up)
    
        # Reference occs
        # alphas: [10000]
        # betas:  [10000]
        occsv = np.array([[[0],[0]]])
        ovl = pccsd.compute_overlap(params, occsv)
        print(ovl)
        assert np.allclose(ovl[0], 1.)
        # Exc=1, seniority=2
        # alphas: [10000]
        # betas:  [01000]
        occsv = np.array([[[0],[1]]])
        ovl = pccsd.compute_overlap(params, occsv)
        print(mat_s[1,4], ovl[0])
        assert np.allclose(ovl[0], mat_s[1,4])
        # Exc=1, seniority=2
        # alphas: [01000]
        # betas:  [10000]
        occsv = np.array([[[1],[0]]])
        ovl = pccsd.compute_overlap(params, occsv)
        print(mat_s[0,0], ovl[0])
        assert np.allclose(ovl[0], mat_s[0,0])
        # Exc=1, seniority=2
        # alphas: [01000]
        # betas:  [00100]
        occsv = np.array([[[1],[2]]])
        ovl = pccsd.compute_overlap(params, occsv)
        expected = mat_s[0,0]*mat_s[1,5] + mat_s[0,5]*mat_s[1,0]
        print(expected, ovl[0])
>       assert np.allclose(ovl[0], expected)
E       assert False
E        +  where False = <function allclose at 0x7fe5ec0fc430>(0.0, 220.0)
E        +    where <function allclose at 0x7fe5ec0fc430> = np.allclose

pyci/test_fanci/test_pccds.py:130: AssertionError

from pyci.

msricher avatar msricher commented on July 28, 2024

hmm, yeah, at the time we stopped working on this, there was difficulty with the optimization for pCCD+S.

Are you working on this, already, then? I was going to start on the weekend. Let me know.

If you want to go ahead with it, then I can just remove the active/frozen parameter stuff myself later.

from pyci.

gabrielasd avatar gabrielasd commented on July 28, 2024

I think we have a couple minor issues associated with deprecation of NumPy alias for bool and int variables in the fanci module, specifically here:
np.bool in fanci.py (lines 222, 225, 232)
np.int in apig (lines 200, 201)

I tried building PyCI after the merge in a different virtual env, and the tests for apig were failing because of these. My test venv has NumPy 1.26.3, and apparently after version 1.24 they removed these alias.

Michelle since you may change the use of masked parameters, and that is where I saw the np.bool being used, I won't change this now.

The other thing I remember is, I had to install the library for the stochastic optimized, cma. So maybe this should also be added to the dependencies listed on PyCI Readme.

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

I specified the version of numpy in the make file, so I’m surprised it’s not working

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

NVM, i specified the version in the .yml file, not the make file
I’ll fix it

as for the cma dependency, I think if we move the optimization outside of pyci, than we can get rid of any cma too

from pyci.

msricher avatar msricher commented on July 28, 2024

I merged a version with frozen params and fanpt removed, and cma added to requirements.

It seems like both pCCDS + determinant ratio works already! Did we do this sometime in the past few years, @gabrielasd? They're a bit slow, though, but I think that's fine for a proof-of-concept. What do you think @PaulWAyers?

from pyci.

PaulWAyers avatar PaulWAyers commented on July 28, 2024

I agree. Det. ratio is also nice since it works both for open-shell and closed-shell (odd vs. even number of determinants).

from pyci.

gabrielasd avatar gabrielasd commented on July 28, 2024

@msricher, on my side I haven't work on them for quite some time, so I need to refresh my mind on their status.
What I remember about our current pCCDS implementation, though, is that it only supports closed-shell cases; and I think it is the same for the determinant ratio one.

from pyci.

msricher avatar msricher commented on July 28, 2024

Well, open-shell singlets are supported. And that's good enough for me, for now.

from pyci.

msricher avatar msricher commented on July 28, 2024

This is complete. I may port some FanCI functionality to C++ eventually, and we may add more FanCI wfns, but the two (PyCI,FanCI) are integrated now.

from pyci.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.