NetKet 3.12.1__tar.gz → 3.12.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {netket-3.12.1 → netket-3.12.2}/PKG-INFO +3 -3
- {netket-3.12.1 → netket-3.12.2}/netket/_version.py +2 -2
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/driver/vmc_srt.py +5 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_utils_random.py +20 -7
- {netket-3.12.1 → netket-3.12.2}/netket/jax/sharding.py +6 -2
- {netket-3.12.1 → netket-3.12.2}/netket/logging/json_log.py +1 -1
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/preconditioner.py +16 -9
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/sr.py +6 -8
- {netket-3.12.1 → netket-3.12.2}/netket/utils/mpi/gpu_autorank_util.py +2 -2
- {netket-3.12.1 → netket-3.12.2}/netket/utils/mpi/primitives.py +9 -3
- {netket-3.12.1 → netket-3.12.2}/netket/utils/seed.py +1 -1
- {netket-3.12.1 → netket-3.12.2}/netket/utils/struct/fields.py +4 -2
- {netket-3.12.1 → netket-3.12.2}/netket/utils/struct/pytree.py +81 -11
- {netket-3.12.1 → netket-3.12.2}/pyproject.toml +2 -2
- {netket-3.12.1 → netket-3.12.2}/.gitignore +0 -0
- {netket-3.12.1 → netket-3.12.2}/LICENSE +0 -0
- {netket-3.12.1 → netket-3.12.2}/README.md +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/callbacks/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/callbacks/convergence_stopping.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/callbacks/earlystopping.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/callbacks/invalidlossstopping.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/callbacks/timeout.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/driver/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/driver/abstract_variational_driver.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/driver/steady_state.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/driver/vmc.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/driver/vmc_common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/errors.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/exact.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/driver/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/driver/tdvp.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/driver/tdvp_common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/driver/tdvp_schmitt.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/dynamics/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/dynamics/_rk_solver.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/dynamics/_rk_solver_structures.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/dynamics/_rk_tableau.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/hilbert/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/hilbert/spin_orbital_fermions.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/logging/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/logging/hdf5_log.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/models/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/models/fast_rnn.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/models/rnn.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/rnn/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/rnn/cells.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/rnn/layers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/rnn/layers_fast.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/nn/rnn/ordering.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/observable/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/observable/renyi2/S2_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/observable/renyi2/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/observable/renyi2/exact.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/observable/renyi2/expect.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/_fermion_operator_2nd_base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/_fermion_operator_2nd_jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/_fermion_operator_2nd_numba.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/_fermion_operator_2nd_utils.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/fermion.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/operator/pyscf.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/qsr/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/qsr/dataset.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/qsr/driver.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/qsr/logic_helpers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/metropolis.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/metropolis_pmap.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/metropolis_pt.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/rules/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/sampler/rules/fermion_2nd.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/vqs/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/experimental/vqs/io.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/_lattice_edge_logic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/abstract_graph.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/common_lattices.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/graph.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/lattice.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/graph/space_group.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/abstract_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/continuous_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/custom_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/discrete_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/doubled_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/fock.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/homogeneous.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/constraints/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/constraints/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/constraints/sum.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/unconstrained.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/index/uniform_tensor.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/particle.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/qubit.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/custom.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/doubled.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/fock.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/particle.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/qubit.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/spin.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/random/tensor_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/spin.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/tensor_hilbert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/hilbert/tensor_hilbert_discrete.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_chunk_utils.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_expect.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_grad.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_jacobian/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_jacobian/default_mode.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_jacobian/jacobian_dense.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_jacobian/jacobian_pytree.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_jacobian/logic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_math.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_scanmap.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_sort.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_utils_dtype.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_utils_tree.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_vjp.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_vjp_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/jax/_vmap_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/logging/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/logging/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/logging/runtime_log.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/logging/state_log.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/logging/tensorboard.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/README.md +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/autoreg.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/deepset.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/equivariant.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/fast_autoreg.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/full_space.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/gaussian.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/jastrow.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/mlp.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/ndm.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/rbm.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/slater.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/tensor_networks/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/tensor_networks/mpdo.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/tensor_networks/mps.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/models/utils.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/activation.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/blocks/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/blocks/deepset.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/blocks/mlp.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/blocks/symmetry_sum.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/deprecation.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/fast_masked_linear.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/initializers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/masked_linear.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/symmetric_linear.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/nn/utils.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_abstract_observable.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_abstract_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_abstract_super_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_bose_hubbard/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_bose_hubbard/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_bose_hubbard/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_bose_hubbard/numba.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_continuous_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_discrete_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_discrete_operator_jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_graph_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_hamiltonian.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_heisenberg.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_ising/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_ising/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_ising/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_ising/numba.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_kinetic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_lazy.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_liouvillian.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/compile_helpers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/convert.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/helpers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_local_operator/numba.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_pauli_strings/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_pauli_strings/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_pauli_strings/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_pauli_strings/numba.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_potential.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/_sumoperators.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/boson.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/operator/spin.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/linear_operator.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/default.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_jacobian_common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_jacobian_dense.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_jacobian_pytree.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_jacobian_pytree_logic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_onthefly.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/qgt/qgt_onthefly_logic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/solver/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/optimizer/solver/solvers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/autoreg.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/exact.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/metropolis.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/metropolis_numpy.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/continuous_gaussian.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/custom_numpy.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/exchange.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/fixed.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/hamiltonian.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/hamiltonian_numpy.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/langevin.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/local.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/local_numpy.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/multiple.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/sampler/rules/tensor.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/stats/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/stats/_autocorr.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/stats/mc_stats.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/stats/mc_stats_old.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/stats/mpi_stats.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/_common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/_cpu_info.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/_mpi_info.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/check_mpi.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/tools/info.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/_dependencies_check.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/array.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/config_flags.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/deprecation.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/dispatch.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/display/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/display/repr.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/float.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/_group.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/_permutation_group.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/_point_group.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/_semigroup.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/axial.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/cubic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/icosa.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/group/planar.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/history.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/holomorphic.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/model_frameworks/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/model_frameworks/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/model_frameworks/flax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/model_frameworks/haiku.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/model_frameworks/jax.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/moduletools.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/mpi/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/mpi/mpi.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/numbers.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/optional_deps.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/partial.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/_version.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/alias.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/autoreload.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/dispatcher.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/function.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/method.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/overload.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/parametric.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/promotion.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/py.typed +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/repr.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/resolver.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/signature.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/type.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/plum/util.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/static_number.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/static_range.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/struct/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/struct/dataclass.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/struct/utils.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/summation.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/timing.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/types.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/utils/version_check.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/base.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/deprecated.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/experimental.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/full_summ/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/full_summ/expect.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/full_summ/state.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/common.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/kernels.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_mixed_state/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_mixed_state/expect.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_mixed_state/expect_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_mixed_state/state.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/__init__.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect_forces.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect_forces_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect_grad.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/expect_grad_chunked.py +0 -0
- {netket-3.12.1 → netket-3.12.2}/netket/vqs/mc/mc_state/state.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: NetKet
|
|
3
|
-
Version: 3.12.
|
|
3
|
+
Version: 3.12.2
|
|
4
4
|
Summary: Netket : Machine Learning toolbox for many-body quantum systems.
|
|
5
5
|
Project-URL: homepage, https://www.netket.org
|
|
6
6
|
Project-URL: documentation, https://netket.readthedocs.io/en/latest/#
|
|
@@ -25,7 +25,7 @@ Requires-Dist: igraph<0.12.0,>=0.10.0
|
|
|
25
25
|
Requires-Dist: jax<0.5,>=0.4.16
|
|
26
26
|
Requires-Dist: jaxlib<0.5,>=0.4.16
|
|
27
27
|
Requires-Dist: numba4jax<0.1,>=0.0.10.post1
|
|
28
|
-
Requires-Dist: numba<0.
|
|
28
|
+
Requires-Dist: numba<0.61,>=0.52
|
|
29
29
|
Requires-Dist: numpy~=1.20
|
|
30
30
|
Requires-Dist: optax<0.3,>=0.1.3
|
|
31
31
|
Requires-Dist: orjson<4,>=3.4
|
|
@@ -63,7 +63,7 @@ Requires-Dist: openfermion>=1.0.0; extra == 'extra'
|
|
|
63
63
|
Requires-Dist: qutip>=4; extra == 'extra'
|
|
64
64
|
Requires-Dist: tensorboardx>=2.0.0; extra == 'extra'
|
|
65
65
|
Provides-Extra: mpi
|
|
66
|
-
Requires-Dist: mpi4jax<0.
|
|
66
|
+
Requires-Dist: mpi4jax<0.6,>=0.3.9; extra == 'mpi'
|
|
67
67
|
Requires-Dist: mpi4py<4,>=3.0.1; extra == 'mpi'
|
|
68
68
|
Provides-Extra: pyscf
|
|
69
69
|
Requires-Dist: pyscf>=2.0; extra == 'pyscf'
|
|
@@ -90,6 +90,11 @@ def SRt(
|
|
|
90
90
|
matrix_side
|
|
91
91
|
) # * shift diagonal regularization
|
|
92
92
|
aus_vector = solver_fn(matrix, dv)
|
|
93
|
+
# some solvers return a tuple, some others do not.
|
|
94
|
+
# We check and try to support both
|
|
95
|
+
if isinstance(aus_vector, tuple):
|
|
96
|
+
aus_vector, _ = aus_vector
|
|
97
|
+
|
|
93
98
|
aus_vector = aus_vector.reshape(mpi.n_nodes, -1)
|
|
94
99
|
aus_vector, token = mpi.mpi_scatter_jax(aus_vector, token=token)
|
|
95
100
|
else:
|
|
@@ -17,7 +17,7 @@ from typing import Optional
|
|
|
17
17
|
|
|
18
18
|
import jax
|
|
19
19
|
|
|
20
|
-
from netket.utils import random_seed, mpi
|
|
20
|
+
from netket.utils import random_seed, mpi, config
|
|
21
21
|
from netket.utils.mpi import MPI_jax_comm
|
|
22
22
|
from netket.utils.types import PRNGKeyT, SeedT
|
|
23
23
|
|
|
@@ -30,16 +30,29 @@ def PRNGKey(
|
|
|
30
30
|
The same seed will be distributed to all processes.
|
|
31
31
|
"""
|
|
32
32
|
if seed is None:
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
seed = random_seed()
|
|
34
|
+
|
|
35
|
+
if isinstance(seed, int):
|
|
36
|
+
# We can't sync the PRNGKey, so we can only sinc integer seeds
|
|
37
|
+
# see https://github.com/google/jax/pull/16511
|
|
38
|
+
if config.netket_experimental_sharding and jax.process_count() > 1:
|
|
39
|
+
# TODO: use stable jax function
|
|
40
|
+
from jax.experimental import multihost_utils
|
|
41
|
+
|
|
42
|
+
seed = int(
|
|
43
|
+
multihost_utils.broadcast_one_to_all(
|
|
44
|
+
seed, is_source=jax.process_index() == root
|
|
45
|
+
).item()
|
|
46
|
+
)
|
|
47
|
+
|
|
35
48
|
key = jax.random.PRNGKey(seed)
|
|
36
49
|
else:
|
|
37
50
|
key = seed
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
if not config.netket_experimental_sharding:
|
|
53
|
+
key = jax.tree_util.tree_map(
|
|
54
|
+
lambda k: mpi.mpi_bcast_jax(k, root=root, comm=comm)[0], key
|
|
55
|
+
)
|
|
43
56
|
return key
|
|
44
57
|
|
|
45
58
|
|
|
@@ -283,13 +283,17 @@ def gather(x):
|
|
|
283
283
|
elif isinstance(x.sharding, jax.sharding.GSPMDSharding):
|
|
284
284
|
# x.sharding.device_set has arbitrary order
|
|
285
285
|
# Hardcode all devices until I figure out a way to deduce the order from x
|
|
286
|
-
out_shardings =
|
|
286
|
+
out_shardings = (
|
|
287
|
+
PositionalSharding(jax.devices()).replicate().reshape((1,) * x.ndim)
|
|
288
|
+
)
|
|
289
|
+
# TODO support gspmdsharding in numba wrapper and use this
|
|
287
290
|
# out_shardings = x.sharding.get_replicated(jax.devices())
|
|
288
291
|
elif isinstance(x.sharding, PositionalSharding):
|
|
289
292
|
out_shardings = x.sharding.replicate()
|
|
290
293
|
else:
|
|
291
294
|
raise NotImplementedError(
|
|
292
|
-
|
|
295
|
+
"Gather is only compatible with PositionalSharding and GSPMDSharding,"
|
|
296
|
+
f" but array has {x.sharding}. Please open a feature request."
|
|
293
297
|
)
|
|
294
298
|
return jax.jit(_identity, out_shardings=out_shardings)(x)
|
|
295
299
|
# TODO support gspmdsharding in numba wrapper and use this
|
|
@@ -208,7 +208,7 @@ class JsonLog(RuntimeLog):
|
|
|
208
208
|
if self._steps_notflushed_write > 0:
|
|
209
209
|
self.flush()
|
|
210
210
|
if hasattr(self, "_steps_notflushed_pars"):
|
|
211
|
-
if self._steps_notflushed_pars > 0:
|
|
211
|
+
if self._steps_notflushed_pars > 0 and self._save_params:
|
|
212
212
|
self.flush()
|
|
213
213
|
|
|
214
214
|
def __repr__(self):
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
from typing import Callable, Optional, Any
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
|
-
from dataclasses import dataclass
|
|
19
18
|
from textwrap import dedent
|
|
20
19
|
|
|
21
20
|
from netket.utils.types import PyTree, Scalar
|
|
22
|
-
from netket.utils import warn_deprecation, timing
|
|
21
|
+
from netket.utils import warn_deprecation, timing, struct
|
|
23
22
|
from netket.vqs import VariationalState
|
|
24
23
|
|
|
25
24
|
from .linear_operator import LinearOperator, SolverT
|
|
@@ -43,8 +42,7 @@ def identity_preconditioner(
|
|
|
43
42
|
return gradient
|
|
44
43
|
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
class AbstractLinearPreconditioner:
|
|
45
|
+
class AbstractLinearPreconditioner(struct.Pytree, mutable=True):
|
|
48
46
|
"""Base class for a Linear Preconditioner solving a system :math:`Sx = F`.
|
|
49
47
|
|
|
50
48
|
A LinearPreconditioner modifies the gradient :math:`F` in such a way that the new
|
|
@@ -66,7 +64,7 @@ class AbstractLinearPreconditioner:
|
|
|
66
64
|
|
|
67
65
|
"""
|
|
68
66
|
|
|
69
|
-
solver: SolverT
|
|
67
|
+
solver: SolverT = struct.field(serialize=False)
|
|
70
68
|
"""Function used to solve the linear system."""
|
|
71
69
|
|
|
72
70
|
solver_restart: bool = False
|
|
@@ -76,13 +74,23 @@ class AbstractLinearPreconditioner:
|
|
|
76
74
|
x0: Optional[PyTree] = None
|
|
77
75
|
"""Solution of the last linear system solved."""
|
|
78
76
|
|
|
79
|
-
info: Any = None
|
|
77
|
+
info: Any = struct.field(serialize=False, default=None)
|
|
80
78
|
"""Additional information returned by the solver when solving the last linear system."""
|
|
81
79
|
|
|
82
|
-
_lhs: LinearOperator = None
|
|
80
|
+
_lhs: LinearOperator = struct.field(serialize=False, default=None)
|
|
83
81
|
"""LHS of the last linear system solved."""
|
|
84
82
|
|
|
85
83
|
def __init__(self, solver, *, solver_restart=False):
|
|
84
|
+
"""
|
|
85
|
+
Constructs the structure holding the parameters for using the
|
|
86
|
+
linear preconditioner.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
solver: A callable that solves a linear system of equations.
|
|
90
|
+
solver_restart: If False uses the last solution of the linear
|
|
91
|
+
system as a starting point for the solution of the next
|
|
92
|
+
(default=False).
|
|
93
|
+
"""
|
|
86
94
|
self.solver = solver
|
|
87
95
|
self.solver_restart = solver_restart
|
|
88
96
|
|
|
@@ -119,8 +127,7 @@ class AbstractLinearPreconditioner:
|
|
|
119
127
|
|
|
120
128
|
|
|
121
129
|
# This exists for backward compatibility
|
|
122
|
-
|
|
123
|
-
class LinearPreconditioner(AbstractLinearPreconditioner):
|
|
130
|
+
class LinearPreconditioner(AbstractLinearPreconditioner, mutable=True):
|
|
124
131
|
lhs_constructor: LHSConstructorT
|
|
125
132
|
"""Constructor of the LHS of the linear system starting from the variational state."""
|
|
126
133
|
|
|
@@ -16,17 +16,15 @@ from typing import Callable, Optional
|
|
|
16
16
|
|
|
17
17
|
import jax
|
|
18
18
|
|
|
19
|
-
from dataclasses import dataclass
|
|
20
|
-
|
|
21
19
|
from netket.vqs import VariationalState
|
|
22
20
|
from netket.utils.types import Scalar, ScalarOrSchedule
|
|
21
|
+
from netket.utils import struct
|
|
23
22
|
|
|
24
23
|
from .qgt import QGTAuto
|
|
25
24
|
from .preconditioner import AbstractLinearPreconditioner
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
class SR(AbstractLinearPreconditioner):
|
|
27
|
+
class SR(AbstractLinearPreconditioner, mutable=True):
|
|
30
28
|
r"""
|
|
31
29
|
Stochastic Reconfiguration or Natural Gradient preconditioner for the gradient.
|
|
32
30
|
|
|
@@ -63,18 +61,18 @@ class SR(AbstractLinearPreconditioner):
|
|
|
63
61
|
|
|
64
62
|
"""
|
|
65
63
|
|
|
66
|
-
diag_shift: ScalarOrSchedule = 0.01
|
|
64
|
+
diag_shift: ScalarOrSchedule = struct.field(serialize=False, default=0.01)
|
|
67
65
|
"""Diagonal shift added to the S matrix. Can be a Scalar value, an
|
|
68
66
|
`optax <https://optax.readthedocs.io>`_ schedule or a Callable function."""
|
|
69
67
|
|
|
70
|
-
diag_scale: Optional[ScalarOrSchedule] = None
|
|
68
|
+
diag_scale: Optional[ScalarOrSchedule] = struct.field(serialize=False, default=None)
|
|
71
69
|
"""Diagonal shift added to the S matrix. Can be a Scalar value, an
|
|
72
70
|
`optax <https://optax.readthedocs.io>`_ schedule or a Callable function."""
|
|
73
71
|
|
|
74
|
-
qgt_constructor: Callable = None
|
|
72
|
+
qgt_constructor: Callable = struct.static_field(default=None)
|
|
75
73
|
"""The Quantum Geometric Tensor type or a constructor."""
|
|
76
74
|
|
|
77
|
-
qgt_kwargs: dict = None
|
|
75
|
+
qgt_kwargs: dict = struct.field(serialize=False, default=None)
|
|
78
76
|
"""The keyword arguments to be passed to the Geometric Tensor constructor."""
|
|
79
77
|
|
|
80
78
|
def __init__(
|
|
@@ -42,9 +42,9 @@ def autoset_default_gpu(COMM: Optional["mpi4py.MPI.Intracomm"], verbose: bool =
|
|
|
42
42
|
code does not run.
|
|
43
43
|
"""
|
|
44
44
|
devices = jax.devices()
|
|
45
|
-
if len(devices) > 1 and any(d.
|
|
45
|
+
if len(devices) > 1 and any(d.platform == "gpu" for d in devices):
|
|
46
46
|
local_rank = get_local_rank(COMM)
|
|
47
|
-
jax.config.
|
|
47
|
+
jax.config.update("jax_default_device", devices[local_rank])
|
|
48
48
|
logger = logging.getLogger()
|
|
49
49
|
logger.info(
|
|
50
50
|
f"Determined that rank {COMM.Get_rank()} will be using GPU[{local_rank}/{len(devices)}]"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import numpy as np
|
|
16
|
+
import jax
|
|
16
17
|
import jax.numpy as jnp
|
|
17
18
|
|
|
18
19
|
from .mpi import n_nodes, MPI, MPI_py_comm, MPI_jax_comm
|
|
@@ -271,11 +272,16 @@ def mpi_bcast_jax(x, *, token=None, root, comm=MPI_jax_comm):
|
|
|
271
272
|
return mpi4jax.bcast(x, token=token, root=root, comm=comm)
|
|
272
273
|
|
|
273
274
|
|
|
274
|
-
def mpi_allgather(x, *,
|
|
275
|
+
def mpi_allgather(x, *, comm=MPI_py_comm):
|
|
275
276
|
if n_nodes == 1:
|
|
276
|
-
return x
|
|
277
|
+
return x
|
|
277
278
|
else:
|
|
278
|
-
|
|
279
|
+
if isinstance(x, (np.ndarray, jax.Array)):
|
|
280
|
+
out = np.empty((n_nodes,) + x.shape, dtype=x.dtype)
|
|
281
|
+
comm.Allgather(np.asarray(x), out)
|
|
282
|
+
return out
|
|
283
|
+
else:
|
|
284
|
+
return comm.allgather(x)
|
|
279
285
|
|
|
280
286
|
|
|
281
287
|
def mpi_gather_jax(x, *, token=None, root: int = 0, comm=MPI_jax_comm):
|
|
@@ -51,17 +51,19 @@ jax.tree_util.register_pytree_node(
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def field(pytree_node=True, serialize=
|
|
54
|
+
def field(pytree_node=True, serialize=None, cache=False, **kwargs):
|
|
55
55
|
"""Mark a field of a dataclass or PyTree to be:
|
|
56
56
|
|
|
57
57
|
Args:
|
|
58
58
|
pytree_node: a leaf node in the pytree representation of this dataclass.
|
|
59
59
|
If False this must be hashable
|
|
60
60
|
serialize: If True the node is included in the serialization.
|
|
61
|
-
In general you should not specify this.
|
|
61
|
+
In general you should not specify this. (Defaults to value of pytree_node)
|
|
62
62
|
cache: If True this node is a cache and will be reset every time
|
|
63
63
|
fields are modified.
|
|
64
64
|
"""
|
|
65
|
+
if serialize is None:
|
|
66
|
+
serialize = pytree_node
|
|
65
67
|
return dataclasses.field(
|
|
66
68
|
metadata={"pytree_node": pytree_node, "serialize": serialize, "cache": cache},
|
|
67
69
|
**kwargs,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import inspect
|
|
3
3
|
import typing as tp
|
|
4
|
+
from typing import Any, Callable
|
|
4
5
|
from abc import ABCMeta
|
|
5
6
|
from copy import copy
|
|
6
7
|
from functools import partial
|
|
@@ -20,6 +21,10 @@ store the topmost non-dataclass class in a mro.
|
|
|
20
21
|
"""
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
def identity(x):
|
|
25
|
+
return x
|
|
26
|
+
|
|
27
|
+
|
|
23
28
|
class PytreeMeta(ABCMeta):
|
|
24
29
|
"""
|
|
25
30
|
Metaclass for PyTrees, takes care of initializing and turning
|
|
@@ -28,13 +33,25 @@ class PytreeMeta(ABCMeta):
|
|
|
28
33
|
|
|
29
34
|
def __call__(cls: type[P], *args: tp.Any, **kwargs: tp.Any) -> P:
|
|
30
35
|
obj: P = cls.__new__(cls, *args, **kwargs)
|
|
36
|
+
|
|
37
|
+
# set things before init
|
|
38
|
+
vars_dict = vars(obj)
|
|
39
|
+
|
|
40
|
+
# Set 'default' values
|
|
41
|
+
for field in obj._pytree__cachedprop_fields:
|
|
42
|
+
vars_dict[field] = Uninitialized
|
|
43
|
+
|
|
44
|
+
for field, default_fn in cls._pytree__default_setters.items():
|
|
45
|
+
if field not in vars_dict:
|
|
46
|
+
vars_dict[field] = default_fn()
|
|
47
|
+
|
|
31
48
|
obj.__dict__["_pytree__initializing"] = True
|
|
32
49
|
try:
|
|
33
50
|
obj.__init__(*args, **kwargs)
|
|
34
51
|
finally:
|
|
35
52
|
del obj.__dict__["_pytree__initializing"]
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
# set things after init
|
|
38
55
|
if obj._pytree__class_dynamic_nodes:
|
|
39
56
|
vars_dict["_pytree__node_fields"] = tuple(
|
|
40
57
|
sorted(
|
|
@@ -46,9 +63,6 @@ class PytreeMeta(ABCMeta):
|
|
|
46
63
|
else:
|
|
47
64
|
vars_dict["_pytree__node_fields"] = cls._pytree__data_fields
|
|
48
65
|
|
|
49
|
-
for field in obj._pytree__cachedprop_fields:
|
|
50
|
-
vars_dict[field] = Uninitialized
|
|
51
|
-
|
|
52
66
|
return obj
|
|
53
67
|
|
|
54
68
|
|
|
@@ -126,12 +140,15 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
126
140
|
class_vars = vars(cls)
|
|
127
141
|
setter_descriptors = set()
|
|
128
142
|
static_fields = _inherited_static_fields(cls)
|
|
143
|
+
noserialize_fields = _inherited_noserialize_fields(cls)
|
|
129
144
|
|
|
130
|
-
# add special static fields
|
|
145
|
+
# add special static fields that are in the instance, not in the class
|
|
131
146
|
static_fields.add("_pytree__node_fields")
|
|
147
|
+
noserialize_fields.add("_pytree__node_fields")
|
|
132
148
|
|
|
133
149
|
# new
|
|
134
150
|
data_fields = _inherited_data_fields(cls)
|
|
151
|
+
default_setters = _inherited_defaults_setters(cls) # _pytree__default_setters
|
|
135
152
|
cached_prop_fields = set()
|
|
136
153
|
|
|
137
154
|
for field, value in class_vars.items():
|
|
@@ -146,6 +163,18 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
146
163
|
):
|
|
147
164
|
data_fields.add(field)
|
|
148
165
|
|
|
166
|
+
if isinstance(value, dataclasses.Field) and not value.metadata.get(
|
|
167
|
+
"serialize", True
|
|
168
|
+
):
|
|
169
|
+
noserialize_fields.add(field)
|
|
170
|
+
|
|
171
|
+
# default setters
|
|
172
|
+
if isinstance(value, dataclasses.Field):
|
|
173
|
+
if value.default is not dataclasses.MISSING:
|
|
174
|
+
default_setters[field] = partial(identity, value.default)
|
|
175
|
+
elif value.default_factory is not dataclasses.MISSING:
|
|
176
|
+
default_setters[field] = value.default_factory
|
|
177
|
+
|
|
149
178
|
# add setter descriptors
|
|
150
179
|
if hasattr(value, "__set__"):
|
|
151
180
|
setter_descriptors.add(field)
|
|
@@ -187,14 +216,18 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
187
216
|
data_fields = tuple(sorted(data_fields))
|
|
188
217
|
cached_prop_fields = tuple(sorted(cached_prop_fields))
|
|
189
218
|
cached_prop_fields = tuple(_cache_name(f) for f in cached_prop_fields)
|
|
219
|
+
default_setters = MappingProxyType(default_setters)
|
|
190
220
|
|
|
191
221
|
static_fields = tuple(sorted(static_fields))
|
|
222
|
+
noserialize_fields = tuple(sorted(noserialize_fields))
|
|
192
223
|
|
|
193
224
|
# init class variables
|
|
194
225
|
cls._pytree__initializing = False
|
|
195
226
|
cls._pytree__class_is_mutable = mutable
|
|
196
227
|
cls._pytree__static_fields = static_fields
|
|
228
|
+
cls._pytree__noserialize_fields = noserialize_fields
|
|
197
229
|
cls._pytree__setter_descriptors = frozenset(setter_descriptors)
|
|
230
|
+
cls._pytree__default_setters = default_setters
|
|
198
231
|
|
|
199
232
|
# new
|
|
200
233
|
cls._pytree__class_dynamic_nodes = dynamic_nodes
|
|
@@ -234,8 +267,8 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
234
267
|
|
|
235
268
|
serialization.register_serialization_state(
|
|
236
269
|
cls,
|
|
237
|
-
partial(cls._to_flax_state_dict, cls.
|
|
238
|
-
partial(cls._from_flax_state_dict, cls.
|
|
270
|
+
partial(cls._to_flax_state_dict, cls._pytree__noserialize_fields),
|
|
271
|
+
partial(cls._from_flax_state_dict, cls._pytree__noserialize_fields),
|
|
239
272
|
)
|
|
240
273
|
|
|
241
274
|
def __pre_init__(self, *args, **kwargs):
|
|
@@ -320,21 +353,21 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
320
353
|
|
|
321
354
|
@classmethod
|
|
322
355
|
def _to_flax_state_dict(
|
|
323
|
-
cls,
|
|
356
|
+
cls, noserialize_field_names: tuple[str, ...], pytree: "Pytree"
|
|
324
357
|
) -> dict[str, tp.Any]:
|
|
325
358
|
from flax import serialization
|
|
326
359
|
|
|
327
360
|
state_dict = {
|
|
328
361
|
name: serialization.to_state_dict(getattr(pytree, name))
|
|
329
362
|
for name in pytree.__dict__
|
|
330
|
-
if name not in
|
|
363
|
+
if name not in noserialize_field_names
|
|
331
364
|
}
|
|
332
365
|
return state_dict
|
|
333
366
|
|
|
334
367
|
@classmethod
|
|
335
368
|
def _from_flax_state_dict(
|
|
336
369
|
cls,
|
|
337
|
-
|
|
370
|
+
noserialize_field_names: tuple[str, ...],
|
|
338
371
|
pytree: P,
|
|
339
372
|
state: dict[str, tp.Any],
|
|
340
373
|
) -> P:
|
|
@@ -344,7 +377,7 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
344
377
|
state = state.copy() # copy the state so we can pop the restored fields.
|
|
345
378
|
updates = {}
|
|
346
379
|
for name in pytree.__dict__:
|
|
347
|
-
if name in
|
|
380
|
+
if name in noserialize_field_names:
|
|
348
381
|
continue
|
|
349
382
|
if name not in state:
|
|
350
383
|
raise ValueError(
|
|
@@ -435,6 +468,23 @@ def _inherited_static_fields(cls: type) -> set[str]:
|
|
|
435
468
|
return static_fields
|
|
436
469
|
|
|
437
470
|
|
|
471
|
+
def _inherited_noserialize_fields(cls: type) -> set[str]:
|
|
472
|
+
"""
|
|
473
|
+
Returns the set of noserialize fields of base classes
|
|
474
|
+
of the input class
|
|
475
|
+
"""
|
|
476
|
+
noserialize_fields = set()
|
|
477
|
+
for parent_class in cls.mro():
|
|
478
|
+
if parent_class is not cls and parent_class is not Pytree:
|
|
479
|
+
if issubclass(parent_class, Pytree):
|
|
480
|
+
noserialize_fields.update(parent_class._pytree__noserialize_fields)
|
|
481
|
+
elif dataclasses.is_dataclass(parent_class):
|
|
482
|
+
for field in dataclasses.fields(parent_class):
|
|
483
|
+
if not field.metadata.get("serialize", True):
|
|
484
|
+
noserialize_fields.add(field.name)
|
|
485
|
+
return noserialize_fields
|
|
486
|
+
|
|
487
|
+
|
|
438
488
|
def _inherited_data_fields(cls: type) -> set[str]:
|
|
439
489
|
"""
|
|
440
490
|
Returns the set of data fields of base classes
|
|
@@ -470,3 +520,23 @@ def _inherited_cachedproperty_fields(cls: type) -> set[str]:
|
|
|
470
520
|
if isinstance(field, CachedProperty):
|
|
471
521
|
cachedproperty_fields.add(field.name)
|
|
472
522
|
return cachedproperty_fields
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
def _inherited_defaults_setters(cls: type) -> set[Callable[[], Any]]:
|
|
526
|
+
"""
|
|
527
|
+
Returns the set of default setters of base classes
|
|
528
|
+
of the input class.
|
|
529
|
+
"""
|
|
530
|
+
default_setters = {}
|
|
531
|
+
for parent_class in cls.mro():
|
|
532
|
+
if parent_class is not cls and parent_class is not Pytree:
|
|
533
|
+
if issubclass(parent_class, Pytree):
|
|
534
|
+
default_setters.update(parent_class._pytree__default_setters)
|
|
535
|
+
elif dataclasses.is_dataclass(parent_class):
|
|
536
|
+
for field in dataclasses.fields(parent_class):
|
|
537
|
+
if field.default is not dataclasses.MISSING:
|
|
538
|
+
default_setters[field.name] = lambda: field.default
|
|
539
|
+
elif field.default_factory is not dataclasses.MISSING:
|
|
540
|
+
default_setters[field.name] = field.default_factory
|
|
541
|
+
|
|
542
|
+
return default_setters
|
|
@@ -35,7 +35,7 @@ dependencies = [
|
|
|
35
35
|
"scipy>=1.5.3, <2",
|
|
36
36
|
"tqdm>=4.60, <5",
|
|
37
37
|
"rich>=10.0",
|
|
38
|
-
"numba>=0.52, <0.
|
|
38
|
+
"numba>=0.52, <0.61",
|
|
39
39
|
"igraph>=0.10.0, <0.12.0",
|
|
40
40
|
"jax>=0.4.16, <0.5",
|
|
41
41
|
"jaxlib>=0.4.16, <0.5",
|
|
@@ -56,7 +56,7 @@ dependencies = [
|
|
|
56
56
|
[project.optional-dependencies]
|
|
57
57
|
mpi = [
|
|
58
58
|
"mpi4py>=3.0.1, <4",
|
|
59
|
-
"mpi4jax>=0.3.9, <0.
|
|
59
|
+
"mpi4jax>=0.3.9, <0.6"
|
|
60
60
|
]
|
|
61
61
|
pyscf = [
|
|
62
62
|
"sparse>=0.12.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|