Remove numba4jax, numba callback closures from operators #1747
+24
−193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wrote Numba4jax to allow HamiltonianSampler to work with operators back when jax could not call back into python.
This necessitated also to introduce those pesky
get_conn_flattened_closure
functions that returned numba closures such thatnumba4jax
could embed them in ajax.jit
context.This was all shaky and ugly, plus I know that it often crashes on GPUs (@inailuig you confirm, right?)
This PR removes completely
numba4jax
dependency from netket, which was only used inHamiltonianSampler
rules replacing it with a callback into python. I am not planning on supporting numba4jax in the future if possible, and this buys me more time.This implementation is a bit slower than before on CPU (though for large models this should be negligible), and works fine on GPU (before it was crashing).
Testing should be done to ensure that this is ok.
Another plus of this PR is that it removes those closure functions from operators, and makes it easier to define a custom operator that works fine with Hamiltonian samplers (while before it was actually complicated, as those closure are not documented and hard to create)