NetKet 3.18__tar.gz → 3.18.1__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.18 → netket-3.18.1}/PKG-INFO +1 -1
- {netket-3.18 → netket-3.18.1}/netket/_version.py +2 -2
- {netket-3.18 → netket-3.18.1}/netket/operator/_fermion2nd/base.py +39 -3
- {netket-3.18 → netket-3.18.1}/netket/operator/_fermion2nd/jax.py +1 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_fermion2nd/numba.py +1 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/metropolis.py +5 -2
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/nnx.py +15 -2
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/fields.py +25 -6
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/pytree.py +26 -6
- {netket-3.18 → netket-3.18.1}/.gitignore +0 -0
- {netket-3.18 → netket-3.18.1}/LICENSE +0 -0
- {netket-3.18 → netket-3.18.1}/README.md +0 -0
- {netket-3.18 → netket-3.18.1}/hatch.toml +0 -0
- {netket-3.18 → netket-3.18.1}/netket/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/callbacks/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/callbacks/convergence_stopping.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/callbacks/early_stopping.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/callbacks/invalid_loss_stopping.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/callbacks/timeout.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/driver/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/driver/abstract_variational_driver.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/driver/steady_state.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/driver/vmc.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/driver/vmc_common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/errors.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/exact.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/driver/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/driver/tdvp.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/driver/tdvp_common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/driver/tdvp_schmitt.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/driver/vmc_srt.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_integrator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_integrator_params.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_integrator_state.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_rk/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_rk/_solver.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_rk/_tableau.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_solver.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/dynamics/_utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/geometry/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/geometry/cell.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/hilbert/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/hilbert/continuous_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/hilbert/particle.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/hilbert/random/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/hilbert/random/particle.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/logging/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/logging/hdf5_log.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/models/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/models/fast_rnn.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/models/rnn.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/rnn/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/rnn/cells.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/rnn/layers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/rnn/layers_fast.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/nn/rnn/ordering.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/renyi2/S2_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/renyi2/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/renyi2/exact.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/renyi2/expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/variance/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/variance/exact.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/variance/expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/observable/variance/variance_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_normal_order_utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/_conversion.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/_fermihubbard.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/_kernels.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/_operator_data.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_particle_number_conserving_fermionic/_operators.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/_pyscf_utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/fermion.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/operator/pyscf.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/qsr/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/qsr/dataset.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/qsr/driver.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/qsr/logic_helpers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/sampler/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/sampler/rules/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/vqs/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/experimental/vqs/io.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/_lattice_draw.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/_lattice_edge_logic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/abstract_graph.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/common_lattices.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/graph.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/lattice.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/graph/space_group.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/abstract_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/constraint/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/constraint/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/constraint/multiple.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/constraint/sum.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/constraint/sum_partition.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/discrete_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/doubled_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/fock.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/homogeneous.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/constrained_generic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/constrained_sum.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/constrained_sum_partitions.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/unconstrained.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/index/uniform_tensor.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/qubit.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/doubled.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/fock.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/homogeneous.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/qubit.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/random/tensor_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/spin.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/spin_orbital_fermions.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/tensor_hilbert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/hilbert/tensor_hilbert_discrete.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_chunk_utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_grad.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_jacobian/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_jacobian/default_mode.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_jacobian/jacobian_dense.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_jacobian/jacobian_pytree.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_jacobian/logic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_math.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_scanmap.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_sort.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_sparse.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_utils_dtype.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_utils_random.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_utils_tree.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_vjp.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_vjp_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/_vmap_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/jax/sharding.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/json_log.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/runtime_log.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/state_log.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/logging/tensorboard.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/README.md +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/autoreg.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/deepset.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/equivariant.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/fast_autoreg.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/full_space.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/gaussian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/jastrow.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/mlp.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/ndm.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/rbm.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/slater.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/tensor_networks/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/tensor_networks/mpdo.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/tensor_networks/mps.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/models/utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/activation.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/blocks/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/blocks/deepset.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/blocks/mlp.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/blocks/symmetry_sum.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/fast_masked_linear.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/masked_linear.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/symmetric_linear.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/nn/utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_abstract_observable.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_abstract_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_abstract_super_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_bose_hubbard/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_bose_hubbard/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_bose_hubbard/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_bose_hubbard/numba.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_continuous_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_discrete_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_discrete_operator_jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_fermion2nd/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_fermion2nd/utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_graph_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_hamiltonian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_heisenberg.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_ising/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_ising/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_ising/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_ising/numba.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_kinetic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_lazy.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_liouvillian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/compile_helpers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/convert.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/helpers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_local_operator/numba.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_pauli_strings/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_pauli_strings/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_pauli_strings/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_pauli_strings/numba.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_potential.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/_sumoperators.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/boson.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/fermion.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/operator/spin.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/linear_operator.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/preconditioner.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/default.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_jacobian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_jacobian_common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_jacobian_dense.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_jacobian_pytree.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_onthefly.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/qgt/qgt_onthefly_logic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/solver/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/solver/solvers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/optimizer/sr.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/autoreg.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/exact.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/metropolis_numpy.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/parallel_tempering.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/continuous_gaussian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/custom_numpy.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/exchange.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/fermion_2nd.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/fixed.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/hamiltonian.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/hamiltonian_numpy.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/langevin.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/local.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/local_numpy.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/multiple.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/sampler/rules/tensor.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/stats/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/stats/_autocorr.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/stats/mc_stats.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/stats/mc_stats_old.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/stats/mpi_stats.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/_common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/_cpu_info.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/_mpi_info.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/check_mpi.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/tools/info.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/_dependencies_check.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/_serialization.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/api_utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/array.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/config_flags.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/deprecation.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/dispatch.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/display/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/display/repr.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/float.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/_group.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/_permutation_group.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/_point_group.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/_semigroup.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/axial.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/cubic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/icosa.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/group/planar.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/history/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/history/accum.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/history/history.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/history/history_dict.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/holomorphic.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/equinox.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/flax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/haiku.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/jax.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/model_frameworks/nnx_wrapped.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/moduletools.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/mpi/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/mpi/gpu_autorank_util.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/mpi/mpi.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/mpi/primitives.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/numbers.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/optional_deps.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/partial.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/seed.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/static_number.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/static_range.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/dataclass.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/pytree_serialization_sharding.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/struct/utils.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/summation.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/timing.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/types.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/utils/version_check.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/base.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/full_summ/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/full_summ/expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/full_summ/state.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/common.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/kernels.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_mixed_state/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_mixed_state/expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_mixed_state/expect_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_mixed_state/state.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/__init__.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect_forces.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect_forces_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect_grad.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/expect_grad_chunked.py +0 -0
- {netket-3.18 → netket-3.18.1}/netket/vqs/mc/mc_state/state.py +0 -0
- {netket-3.18 → netket-3.18.1}/pyproject.toml +0 -0
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
import warnings
|
|
15
|
+
from textwrap import dedent
|
|
14
16
|
|
|
17
|
+
from numbers import Number
|
|
15
18
|
|
|
16
19
|
import numpy as np
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
import jax
|
|
19
22
|
|
|
20
23
|
from netket.utils.types import DType
|
|
21
24
|
from netket.operator import DiscreteOperator, Transpose
|
|
@@ -24,7 +27,8 @@ from netket.hilbert import AbstractHilbert
|
|
|
24
27
|
from netket.utils.numbers import is_scalar, dtype as _dtype
|
|
25
28
|
from netket.utils.optional_deps import import_optional_dependency
|
|
26
29
|
|
|
27
|
-
from netket.hilbert import SpinOrbitalFermions
|
|
30
|
+
from netket.hilbert import Fock, SpinOrbitalFermions
|
|
31
|
+
|
|
28
32
|
|
|
29
33
|
from .utils import (
|
|
30
34
|
_convert_terms_to_spin_blocks,
|
|
@@ -137,7 +141,39 @@ class FermionOperator2ndBase(DiscreteOperator):
|
|
|
137
141
|
|
|
138
142
|
def _setup(self, force: bool = False):
|
|
139
143
|
"""Analyze the operator strings and precompute arrays for get_conn inference"""
|
|
140
|
-
|
|
144
|
+
if jax.process_index() == 0:
|
|
145
|
+
if (
|
|
146
|
+
isinstance(self.hilbert, SpinOrbitalFermions)
|
|
147
|
+
and self.hilbert.n_fermions_per_spin is not None
|
|
148
|
+
):
|
|
149
|
+
warnings.warn(
|
|
150
|
+
dedent(
|
|
151
|
+
"""
|
|
152
|
+
WARNING: Initializing `netket.operator.FermionOperator2nd` for a Hilbert space with a fixed number of fermions.
|
|
153
|
+
Consider using `netket.experimental.operator.ParticleNumberAndSpinConservingFermioperator2nd` to reduce the number of connected elements and
|
|
154
|
+
considerably reduce the computational cost.
|
|
155
|
+
You can convert this operator by calling `netket.experimental.operator.ParticleNumberAndSpinConservingFermioperator2nd.from_fermionoperator2nd`.
|
|
156
|
+
"""
|
|
157
|
+
),
|
|
158
|
+
stacklevel=2,
|
|
159
|
+
)
|
|
160
|
+
elif (
|
|
161
|
+
isinstance(self.hilbert, SpinOrbitalFermions)
|
|
162
|
+
and self.hilbert.n_fermions is not None
|
|
163
|
+
) or (
|
|
164
|
+
isinstance(self.hilbert, Fock) and self.hilbert.n_particles is not None
|
|
165
|
+
):
|
|
166
|
+
warnings.warn(
|
|
167
|
+
dedent(
|
|
168
|
+
"""
|
|
169
|
+
WARNING: Initializing `netket.operator.FermionOperator2nd` for a Hilbert space with a fixed number of fermions.
|
|
170
|
+
Consider using `netket.experimental.operator.ParticleNumberConservingFermioperator2nd` to reduce the number of connected elements and
|
|
171
|
+
considerably reduce the computational cost.
|
|
172
|
+
You can convert this operator by calling `netket.experimental.operator.ParticleNumberConservingFermioperator2nd.from_fermionoperator2nd`.
|
|
173
|
+
"""
|
|
174
|
+
),
|
|
175
|
+
stacklevel=2,
|
|
176
|
+
)
|
|
141
177
|
|
|
142
178
|
@classmethod
|
|
143
179
|
def from_openfermion(
|
|
@@ -558,6 +558,7 @@ class FermionOperator2ndJax(FermionOperator2ndBase, DiscreteJaxOperator):
|
|
|
558
558
|
def _setup(self, force: bool = False):
|
|
559
559
|
"""Analyze the operator strings and precompute arrays for get_conn inference"""
|
|
560
560
|
if force or not self._initialized:
|
|
561
|
+
super()._setup(self)
|
|
561
562
|
# TODO ideally we would set dagger_dtype to the same as x
|
|
562
563
|
# however, unfortunately, the dtype of the states in netket
|
|
563
564
|
# is stored in the sampler and not in hilbert, so we don't know it at this stage
|
|
@@ -52,6 +52,7 @@ class FermionOperator2nd(FermionOperator2ndBase):
|
|
|
52
52
|
def _setup(self, force: bool = False):
|
|
53
53
|
"""Analyze the operator strings and precompute arrays for get_conn inference"""
|
|
54
54
|
if force or not self._initialized:
|
|
55
|
+
super()._setup(self)
|
|
55
56
|
# following lists will be used to compute matrix elements
|
|
56
57
|
# they are filled in _add_term
|
|
57
58
|
out = _pack_internals(self._operators, self._dtype)
|
|
@@ -314,11 +314,14 @@ class MetropolisSampler(Sampler):
|
|
|
314
314
|
)
|
|
315
315
|
n_chains_per_rank = n_chains // device_count()
|
|
316
316
|
|
|
317
|
-
if
|
|
317
|
+
if (
|
|
318
|
+
chunk_size is not None
|
|
319
|
+
and n_chains_per_rank > chunk_size
|
|
320
|
+
and n_chains_per_rank % chunk_size != 0
|
|
321
|
+
):
|
|
318
322
|
raise ValueError(
|
|
319
323
|
f"Chunk size must divide number of chains per rank, {n_chains_per_rank}"
|
|
320
324
|
)
|
|
321
|
-
self.chunk_size = chunk_size
|
|
322
325
|
|
|
323
326
|
super().__init__(
|
|
324
327
|
hilbert=hilbert,
|
|
@@ -17,12 +17,24 @@ from functools import partial
|
|
|
17
17
|
|
|
18
18
|
import sys
|
|
19
19
|
|
|
20
|
+
from netket.utils.version_check import module_version
|
|
21
|
+
|
|
20
22
|
from .base import ModuleFramework, framework
|
|
21
23
|
|
|
22
24
|
if TYPE_CHECKING:
|
|
23
25
|
from flax import nnx
|
|
24
26
|
|
|
25
27
|
|
|
28
|
+
def _get_graphdef_type(graphdef):
|
|
29
|
+
# TODO: Once we require Jax 0.10.6 (probably once we require jax 0.7)
|
|
30
|
+
# drop this check
|
|
31
|
+
if module_version("flax") >= (0, 10, 6):
|
|
32
|
+
assert len(graphdef.nodes) > 0
|
|
33
|
+
return graphdef.nodes[0].type
|
|
34
|
+
else:
|
|
35
|
+
return graphdef.type
|
|
36
|
+
|
|
37
|
+
|
|
26
38
|
# expose jax-stax as a flax module
|
|
27
39
|
class NNXWrapper:
|
|
28
40
|
name: str = "NNX"
|
|
@@ -68,14 +80,15 @@ class NNXWrapper:
|
|
|
68
80
|
return nnx_module
|
|
69
81
|
|
|
70
82
|
def __getattr__(self, name):
|
|
71
|
-
if hasattr(self.graphdef
|
|
83
|
+
if hasattr(_get_graphdef_type(self.graphdef), name):
|
|
72
84
|
return partial(self.apply, method=name)
|
|
73
85
|
raise AttributeError(
|
|
74
86
|
f"'{type(self).__name__}' (and the wrapped '{self.graphdef.type}') object has no attribute '{name}'"
|
|
75
87
|
)
|
|
76
88
|
|
|
77
89
|
def __repr__(self):
|
|
78
|
-
|
|
90
|
+
typ = _get_graphdef_type(self.graphdef)
|
|
91
|
+
return f"NNXWrapper(wrapped_class={typ}, ...)"
|
|
79
92
|
|
|
80
93
|
|
|
81
94
|
@framework
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
Common utilities to define fields and properties of netket dataclasses
|
|
17
17
|
and Pytrees.
|
|
18
18
|
"""
|
|
19
|
-
|
|
20
19
|
from functools import partial
|
|
21
20
|
|
|
22
21
|
import dataclasses
|
|
@@ -55,6 +54,7 @@ jax.tree_util.register_pytree_node(
|
|
|
55
54
|
|
|
56
55
|
def field(
|
|
57
56
|
pytree_node: bool = True,
|
|
57
|
+
pytree_ignore: bool = False,
|
|
58
58
|
serialize: bool | None = None,
|
|
59
59
|
serialize_name: str | None = None,
|
|
60
60
|
cache: bool = False,
|
|
@@ -65,7 +65,13 @@ def field(
|
|
|
65
65
|
|
|
66
66
|
Args:
|
|
67
67
|
pytree_node: a leaf node in the pytree representation of this dataclass.
|
|
68
|
-
If False this must be hashable
|
|
68
|
+
If False this must be hashable.
|
|
69
|
+
pytree_ignore: If True this field is ignored by the pytree metadata and will be
|
|
70
|
+
excluded from the pytree flattening/unflattening process. This means the field
|
|
71
|
+
will not appear in the flattened representation when calling `jax.tree_util.tree_flatten()`
|
|
72
|
+
or similar pytree operations. This is useful for caches, temporary data, or other
|
|
73
|
+
fields that should not be passed forward during pytree transformations.
|
|
74
|
+
When True, pytree_node must be False.
|
|
69
75
|
serialize: If True the node is included in the serialization.
|
|
70
76
|
In general you should not specify this. (Defaults to value of pytree_node).
|
|
71
77
|
serialize_name: If specified, it's the name under which this attribute is serialized.
|
|
@@ -80,9 +86,14 @@ def field(
|
|
|
80
86
|
serialize = pytree_node
|
|
81
87
|
if sharded is True:
|
|
82
88
|
sharded = ShardedFieldSpec()
|
|
89
|
+
if pytree_ignore and pytree_node:
|
|
90
|
+
raise ValueError(
|
|
91
|
+
"Cannot set both `pytree_node=True` and `pytree_ignore=True`. Pytreenode must be False if pytree_ignore is True."
|
|
92
|
+
)
|
|
83
93
|
|
|
84
94
|
metadata = {
|
|
85
95
|
"pytree_node": pytree_node,
|
|
96
|
+
"ignore": pytree_ignore,
|
|
86
97
|
"serialize": serialize,
|
|
87
98
|
"cache": cache,
|
|
88
99
|
"sharded": sharded,
|
|
@@ -104,11 +115,12 @@ class CachedProperty:
|
|
|
104
115
|
but must be cached.
|
|
105
116
|
"""
|
|
106
117
|
|
|
107
|
-
def __init__(self, method, pytree_node=False):
|
|
118
|
+
def __init__(self, method, pytree_node=False, pytree_ignore=False):
|
|
108
119
|
self.name = method.__name__
|
|
109
120
|
self.cache_name = _cache_name(self.name)
|
|
110
121
|
self.method = method
|
|
111
122
|
self.pytree_node = pytree_node
|
|
123
|
+
self.pytree_ignore = pytree_ignore
|
|
112
124
|
self.type = method.__annotations__.get("return", MISSING)
|
|
113
125
|
self.doc = method.__doc__
|
|
114
126
|
|
|
@@ -131,7 +143,7 @@ class CachedProperty:
|
|
|
131
143
|
)
|
|
132
144
|
|
|
133
145
|
|
|
134
|
-
def property_cached(fun=None, pytree_node=False):
|
|
146
|
+
def property_cached(fun=None, pytree_node=False, pytree_ignore=False):
|
|
135
147
|
"""Decorator to make the method behave as a property but cache the resulting value and
|
|
136
148
|
clears it upon replace.
|
|
137
149
|
|
|
@@ -139,7 +151,14 @@ def property_cached(fun=None, pytree_node=False):
|
|
|
139
151
|
pytree_node: a leaf node in the pytree representation of this dataclass.
|
|
140
152
|
If False this must be hashable
|
|
141
153
|
"""
|
|
154
|
+
if pytree_ignore and pytree_node:
|
|
155
|
+
raise ValueError(
|
|
156
|
+
"Cannot set both `pytree_node=True` and `pytree_ignore=True`. Pytreenode must be False if pytree_ignore is True."
|
|
157
|
+
)
|
|
158
|
+
|
|
142
159
|
if fun is None:
|
|
143
|
-
return partial(
|
|
160
|
+
return partial(
|
|
161
|
+
property_cached, pytree_node=pytree_node, pytree_ignore=pytree_ignore
|
|
162
|
+
)
|
|
144
163
|
|
|
145
|
-
return CachedProperty(fun, pytree_node=pytree_node)
|
|
164
|
+
return CachedProperty(fun, pytree_node=pytree_node, pytree_ignore=pytree_ignore)
|
|
@@ -137,6 +137,7 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
137
137
|
_pytree__fields: dict[str, dataclasses.Field]
|
|
138
138
|
_pytree__static_fields: tuple[str, ...]
|
|
139
139
|
_pytree__node_fields: tuple[str, ...]
|
|
140
|
+
_pytree__ignored_fields: tuple[str, ...]
|
|
140
141
|
_pytree__setter_descriptors: frozenset[str]
|
|
141
142
|
|
|
142
143
|
_pytree__cachedprop_fields: tuple[str, ...]
|
|
@@ -147,7 +148,7 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
147
148
|
# gather class info
|
|
148
149
|
class_vars = vars(cls)
|
|
149
150
|
setter_descriptors = set()
|
|
150
|
-
all_fields, data_fields, static_fields = _inherited_fields(cls)
|
|
151
|
+
all_fields, data_fields, static_fields, ignored_fields = _inherited_fields(cls)
|
|
151
152
|
|
|
152
153
|
# new
|
|
153
154
|
default_setters = _inherited_defaults_setters(cls) # _pytree__default_setters
|
|
@@ -166,7 +167,10 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
166
167
|
all_fields[field] = value
|
|
167
168
|
_is_pytree_node = value.metadata.get("pytree_node", True)
|
|
168
169
|
if not _is_pytree_node:
|
|
169
|
-
|
|
170
|
+
if value.metadata.get("ignore", False):
|
|
171
|
+
ignored_fields.add(field)
|
|
172
|
+
else:
|
|
173
|
+
static_fields.add(field)
|
|
170
174
|
elif _is_pytree_node:
|
|
171
175
|
data_fields.add(field)
|
|
172
176
|
|
|
@@ -192,6 +196,8 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
192
196
|
# setattr(cls, _cache_name(field), Uninitialized)
|
|
193
197
|
if class_vars[field].pytree_node:
|
|
194
198
|
data_fields.add(_cache_name(field))
|
|
199
|
+
elif class_vars[field].pytree_ignore:
|
|
200
|
+
ignored_fields.add(_cache_name(field))
|
|
195
201
|
else:
|
|
196
202
|
static_fields.add(_cache_name(field))
|
|
197
203
|
cached_prop_fields = cached_prop_fields.union(
|
|
@@ -242,13 +248,16 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
242
248
|
pass
|
|
243
249
|
|
|
244
250
|
# new
|
|
245
|
-
init_fields = tuple(
|
|
251
|
+
init_fields = tuple(
|
|
252
|
+
sorted(data_fields.union(static_fields).union(ignored_fields))
|
|
253
|
+
)
|
|
246
254
|
data_fields = tuple(sorted(data_fields))
|
|
247
255
|
cached_prop_fields = tuple(sorted(cached_prop_fields))
|
|
248
256
|
cached_prop_fields = tuple(_cache_name(f) for f in cached_prop_fields)
|
|
249
257
|
default_setters = MappingProxyType(default_setters)
|
|
250
258
|
|
|
251
259
|
static_fields = tuple(sorted(static_fields))
|
|
260
|
+
ignored_fields = tuple(sorted(ignored_fields))
|
|
252
261
|
noserialize_fields = tuple(sorted(noserialize_fields))
|
|
253
262
|
serialize_rename_fields = tuple(
|
|
254
263
|
sorted(compute_serialize_rename_fields(all_fields))
|
|
@@ -260,6 +269,7 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
260
269
|
cls._pytree__class_is_mutable = mutable
|
|
261
270
|
cls._pytree__fields = all_fields
|
|
262
271
|
cls._pytree__static_fields = static_fields
|
|
272
|
+
cls._pytree__ignored_fields = ignored_fields
|
|
263
273
|
cls._pytree__noserialize_fields = noserialize_fields
|
|
264
274
|
cls._pytree__serialize_rename_fields = serialize_rename_fields
|
|
265
275
|
cls._pytree__sharded_fields = sharded_fields
|
|
@@ -357,6 +367,10 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
357
367
|
raise KeyError(
|
|
358
368
|
f"Missing static field {e} in PyTree {cls.__name__} while flattening."
|
|
359
369
|
) from e
|
|
370
|
+
|
|
371
|
+
# drop ignored keys
|
|
372
|
+
for ignored_field in pytree._pytree__ignored_fields:
|
|
373
|
+
all_vars.pop(ignored_field, None)
|
|
360
374
|
if with_key_paths:
|
|
361
375
|
node_values = tuple(
|
|
362
376
|
(jax.tree_util.GetAttrKey(field), all_vars.pop(field))
|
|
@@ -549,7 +563,7 @@ class Pytree(metaclass=PytreeMeta):
|
|
|
549
563
|
|
|
550
564
|
def _inherited_fields(
|
|
551
565
|
cls: type,
|
|
552
|
-
) -> tuple[dict[str, dataclasses.Field], set[str], set[str]]:
|
|
566
|
+
) -> tuple[dict[str, dataclasses.Field], set[str], set[str], set[str]]:
|
|
553
567
|
"""
|
|
554
568
|
Returns the set of all fields (static and data) fields from
|
|
555
569
|
base classes.
|
|
@@ -557,6 +571,7 @@ def _inherited_fields(
|
|
|
557
571
|
fields = {}
|
|
558
572
|
data_fields = set()
|
|
559
573
|
static_fields = set()
|
|
574
|
+
ignored_fields = set()
|
|
560
575
|
|
|
561
576
|
for parent_class in cls.mro():
|
|
562
577
|
if parent_class is not cls and parent_class is not Pytree:
|
|
@@ -564,17 +579,22 @@ def _inherited_fields(
|
|
|
564
579
|
fields.update(parent_class._pytree__fields)
|
|
565
580
|
data_fields.update(parent_class._pytree__data_fields)
|
|
566
581
|
static_fields.update(parent_class._pytree__static_fields)
|
|
582
|
+
ignored_fields.update(parent_class._pytree__ignored_fields)
|
|
567
583
|
elif dataclasses.is_dataclass(parent_class):
|
|
568
584
|
for field in dataclasses.fields(parent_class):
|
|
569
585
|
fields[field.name] = field
|
|
570
586
|
|
|
571
587
|
_is_pytree_node = field.metadata.get("pytree_node", True)
|
|
588
|
+
_ignore_node = field.metadata.get("struct_ignore", False)
|
|
572
589
|
if _is_pytree_node:
|
|
573
590
|
data_fields.add(field.name)
|
|
574
591
|
else:
|
|
575
|
-
|
|
592
|
+
if _ignore_node:
|
|
593
|
+
ignored_fields.add(field.name)
|
|
594
|
+
else:
|
|
595
|
+
static_fields.add(field.name)
|
|
576
596
|
|
|
577
|
-
return fields, data_fields, static_fields
|
|
597
|
+
return fields, data_fields, static_fields, ignored_fields
|
|
578
598
|
|
|
579
599
|
|
|
580
600
|
def _inherited_noserialize_fields(cls: type) -> set[str]:
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|