quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

Explicit operator representation on fermionic Fock spaces and RDM computation? #266

Closed cmendl closed 3 years ago

cmendl commented 6 years ago

Starting from the symbolic operator representation in OpenFermion, an interesting feature could be the explicit (sparse) matrix representation of the action of these operators on fermionic Fock spaces (using Slater determinants as basis functions). This idea has been worked out in https://arxiv.org/abs/1103.0872, with utility functions like getting p-marginals and the computation of reduced density matrices (RDMs). In particular, one could apply exact diagonalization to (toy) model problems and probe representability conditions.

kevinsung commented 6 years ago

I'm not sure what sparse matrix functionality you're referring to beyond those provided by functions that convert to sparse matrices and additional ones like jw_number_restrict_operator and jw_number_restrict_operator.

However, I like the idea (inspired by your reference) of having a data structure to symbolically manipulate Fock states! At first thought, I think we'd want more flexibility and memory efficiency than the implementation from FermiFab, though, even if it means more expensive operations. Thus, I think we should mirror the implementation of SymbolicOperator and store the required basis states "lazily". That is, we store the state using a terms dictionary whose keys are sets indicating the Fock basis vector and corresponding value equal to the coefficient. The default initialization would produce a terms dictionary with one entry equal to the empty set with coefficient 1, indicating the vacuum state.

cmendl commented 6 years ago

OK, thanks for the suggestion! The "lazy" storage seems to resemble a sparse vector or matrix representation, right?

By translating the FermiFab functionality to Python, one feature would then be the (symbolic) computation of p-marginals or RDMs given a (pure) input state as sparse vector. This is not implemented in OpenFermion yet, is it?

jarrodmcc commented 6 years ago

I don't know of anything currently in OpenFermion that has that functionality. We generally haven't gone to either the level of 1. fully symbolic manipulation (meaning string type coefficients instead of numerics) or 2. implementations of operators that are implicit (meaning the action of the operator on a vector is specified, but the full matrix representation of the operator is not). I think both have the potential to be useful if done well and would certainly be a welcome addition.

On Sat, Mar 24, 2018 at 2:50 PM, Christian B. Mendl < notifications@github.com> wrote:

OK, thanks for the suggestion! The "lazy" storage seems to resemble a sparse vector or matrix representation, right?

By translating the FermiFab functionality to Python, one feature would then be the (symbolic) computation of p-marginals or RDMs given a (pure) input state as sparse vector. This is not implemented in OpenFermion yet, is it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/quantumlib/OpenFermion/issues/266#issuecomment-375927437, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXFPALy-g8KBPfI9yqDk7YjUktkwLCKks5thr-rgaJpZM4Sx1Zx .

kevinsung commented 6 years ago

Yes, I guess my proposal is similar to a sparse vector representation but with the ability to interact with FermionOperators.

babbush commented 6 years ago

True symbolic representations are really hard. One could perhaps build on top of sympy?

On Sun, Mar 25, 2018, 14:48 Kevin J. Sung notifications@github.com wrote:

Yes, I guess my proposal is similar to a sparse vector representation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/quantumlib/OpenFermion/issues/266#issuecomment-376006376, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlTf-roSJ71ysySd6frVa6g1iAUW1Ftks5tiBCygaJpZM4Sx1Zx .

kevinsung commented 6 years ago

I think symbolic representations of numbers probably have no place in OpenFermion, but I can see the potential for symbolic representations of states with floating point coefficients. My ideas on this are half-baked though.

babbush commented 6 years ago

There is plenty of reasons to have symbolic representations of essentially everything in OpenFermion. This would make it a very versatile tool capable of deriving general closed form formulas. But it would also be a lot of work. For instance, having a fully symbolic form of FermionOperator would definitely be fun to play around with.

On Sun, Mar 25, 2018, 14:56 Kevin J. Sung notifications@github.com wrote:

I think symbolic representations of numbers probably have no place in OpenFermion, but I can see the potential for symbolic representations of states with floating point coefficients. My ideas on this are half-baked though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/quantumlib/OpenFermion/issues/266#issuecomment-376006844, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlTfz85DQ3ZTID35V-D6lbYApM0aLtEks5tiBJ6gaJpZM4Sx1Zx .

kevinsung commented 6 years ago

Sure, that would be really cool.

jarrodmcc commented 6 years ago

This is perhaps not the right place to mention it again, but I just want to emphasize having an implicit operator representation, sparse matrix representation, and "sparse vector" representation are all somewhat distinct and can be mixed and matched. For problems without additional structure or some restrictions, having sparse vectors specifically often adds more overhead than it gains in efficiency and should be avoided unless one has specific knowledge about the expected result. This is because the action of sparse matrices on vectors very quickly leads to totally filled vectors, where with a sparse representation you've lost all the efficiency of working on dense blocks of memory, and now have to store the redundant information of non-zero entries. Hence it's usually a factor of >10x slower and uses 2-3x the memory you would have used originally.

On Sun, Mar 25, 2018 at 3:17 PM, Kevin J. Sung notifications@github.com wrote:

Sure, that would be really cool.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/quantumlib/OpenFermion/issues/266#issuecomment-376008195, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXFPLL2jmNG5AaJbTsVgEA_VgA6J0Y7ks5tiBd1gaJpZM4Sx1Zx .

cmendl commented 6 years ago

@kevinsung Indeed I was also thinking of symbolic representation of states with floating-point coefficients...

ncrubin commented 3 years ago

@cmendl I wanted to gauge you interest in this again. I've certainly implemented lots of my own RDM utilities so maybe that means they should go into the library. I think if we are restricting ourselves to marginals of particle conserving operators then we can implement RDM generators the way that they do in chemistry FCI codes.

ncrubin commented 3 years ago

closing due to inactivity.