Symbolic discrete operators for NetKet #2217
waleed-sh
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
As a show and tell, I wanted to share a small project I've been working on which shows the power and flexibility of NetKet's modular API and also might be useful to the broader NetKet community. It's a way to build NetKet discrete operators using [d]eclarative [s]ymbolic [l]anguage (DSL), and it’s called nkDSL.
Basically you describe how the operator acts and then it gets "compiled" to a
DiscreteJaxOperatorcompatible with NetKet. This is really possible thanks to NetKet’s API, which makes integrations like this easy to do. For example it makes use of NetKet’s machinery to add and multiply discrete operators to make things more friendly, so doingA @ BandA + Bworks thanks to NetKet’sProductOperatorandSumOperator.For example, an Ising Hamiltonian can be written as:
And now
His a subclass ofDiscreteJaxOperatorwith a workingget_conn_paddedfunction and so it can be used in NetKet's VMC and co.A bosonic number operator for example would simply be
Right now, it works for the
DiscreteJaxOperator, and therefore any Hilbert space compatible with it.Not all operators should be constructed using this DSL... It cannot handle really complicated operators yet, but I tried to make the ability to add to the DSL easy so it can be expanded if needed. It’s intended for operators which are too difficult/memory consuming to write as local operators, and would be too much work to write as a discrete operator by hand using JAX and have to worry about batch dimensions, indexing, etc.
This started as a personal project and is now public since I thought someone might benefit from it. It is however an alpha release, I am sure not everything is thought through still, and it has to be really tested out, but I do verify results against native NetKet implementations and exact diagonalisation as a correctness baseline.
If this sounds interesting, please have a look! I would really appreciate any feedback, suggestions and help!
The documentation is here, the repo is here, and here are some tutorials.
All reactions