NetKet 3.19.1__tar.gz → 3.19.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.
Files changed (357) hide show
  1. {netket-3.19.1 → netket-3.19.2}/PKG-INFO +2 -2
  2. {netket-3.19.1 → netket-3.19.2}/netket/_src/ngd/sr.py +4 -7
  3. {netket-3.19.1 → netket-3.19.2}/netket/_src/ngd/srt.py +6 -6
  4. {netket-3.19.1 → netket-3.19.2}/netket/_src/ngd/srt_onthefly.py +26 -23
  5. {netket-3.19.1 → netket-3.19.2}/netket/_version.py +2 -2
  6. {netket-3.19.1 → netket-3.19.2}/netket/driver/abstract_variational_driver.py +2 -3
  7. {netket-3.19.1 → netket-3.19.2}/netket/errors.py +6 -1
  8. {netket-3.19.1 → netket-3.19.2}/netket/experimental/qsr/driver.py +1 -2
  9. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/discrete_hilbert.py +1 -1
  10. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/homogeneous.py +2 -2
  11. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/base.py +2 -3
  12. {netket-3.19.1 → netket-3.19.2}/netket/jax/_chunk_utils.py +1 -3
  13. {netket-3.19.1 → netket-3.19.2}/netket/jax/_grad.py +4 -0
  14. {netket-3.19.1 → netket-3.19.2}/netket/jax/_jacobian/jacobian_pytree.py +4 -3
  15. {netket-3.19.1 → netket-3.19.2}/netket/jax/_jacobian/logic.py +16 -1
  16. {netket-3.19.1 → netket-3.19.2}/netket/jax/_ntk/logic.py +29 -21
  17. {netket-3.19.1 → netket-3.19.2}/netket/jax/_scanmap.py +4 -3
  18. {netket-3.19.1 → netket-3.19.2}/netket/jax/_utils_random.py +9 -22
  19. {netket-3.19.1 → netket-3.19.2}/netket/jax/_vjp_chunked.py +1 -8
  20. {netket-3.19.1 → netket-3.19.2}/netket/jax/_vmap_chunked.py +1 -9
  21. netket-3.19.1/netket/jax/sharding/fixed_sharding_decorator.py → netket-3.19.2/netket/jax/sharding.py +256 -61
  22. {netket-3.19.1 → netket-3.19.2}/netket/nn/utils.py +1 -2
  23. {netket-3.19.1 → netket-3.19.2}/netket/operator/_kinetic.py +0 -2
  24. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/jax.py +3 -2
  25. {netket-3.19.1 → netket-3.19.2}/netket/sampler/autoreg.py +1 -3
  26. {netket-3.19.1 → netket-3.19.2}/netket/sampler/exact.py +2 -3
  27. {netket-3.19.1 → netket-3.19.2}/netket/sampler/metropolis_numpy.py +1 -2
  28. {netket-3.19.1 → netket-3.19.2}/netket/stats/mc_stats.py +3 -0
  29. {netket-3.19.1 → netket-3.19.2}/netket/utils/_dependencies_check.py +3 -2
  30. {netket-3.19.1 → netket-3.19.2}/netket/utils/config_flags.py +8 -44
  31. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/pytree.py +1 -1
  32. {netket-3.19.1 → netket-3.19.2}/netket/utils/types.py +0 -1
  33. {netket-3.19.1 → netket-3.19.2}/netket/vqs/full_summ/state.py +11 -24
  34. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/state.py +29 -30
  35. {netket-3.19.1 → netket-3.19.2}/pyproject.toml +2 -4
  36. netket-3.19.1/netket/jax/sharding/__init__.py +0 -56
  37. netket-3.19.1/netket/jax/sharding/debug.py +0 -48
  38. netket-3.19.1/netket/jax/sharding/fixed_sharding_utils.py +0 -180
  39. netket-3.19.1/netket/jax/sharding/flexible_sharding.py +0 -59
  40. netket-3.19.1/netket/utils/iterators.py +0 -6
  41. {netket-3.19.1 → netket-3.19.2}/.gitignore +0 -0
  42. {netket-3.19.1 → netket-3.19.2}/LICENSE +0 -0
  43. {netket-3.19.1 → netket-3.19.2}/README.md +0 -0
  44. {netket-3.19.1 → netket-3.19.2}/netket/__init__.py +0 -0
  45. {netket-3.19.1 → netket-3.19.2}/netket/_src/ngd/kwargs.py +0 -0
  46. {netket-3.19.1 → netket-3.19.2}/netket/_src/ngd/sr_srt_common.py +0 -0
  47. {netket-3.19.1 → netket-3.19.2}/netket/_src/operator/hpsi_utils.py +0 -0
  48. {netket-3.19.1 → netket-3.19.2}/netket/callbacks/__init__.py +0 -0
  49. {netket-3.19.1 → netket-3.19.2}/netket/callbacks/convergence_stopping.py +0 -0
  50. {netket-3.19.1 → netket-3.19.2}/netket/callbacks/early_stopping.py +0 -0
  51. {netket-3.19.1 → netket-3.19.2}/netket/callbacks/invalid_loss_stopping.py +0 -0
  52. {netket-3.19.1 → netket-3.19.2}/netket/callbacks/timeout.py +0 -0
  53. {netket-3.19.1 → netket-3.19.2}/netket/driver/__init__.py +0 -0
  54. {netket-3.19.1 → netket-3.19.2}/netket/driver/steady_state.py +0 -0
  55. {netket-3.19.1 → netket-3.19.2}/netket/driver/vmc.py +0 -0
  56. {netket-3.19.1 → netket-3.19.2}/netket/exact.py +0 -0
  57. {netket-3.19.1 → netket-3.19.2}/netket/experimental/__init__.py +0 -0
  58. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/__init__.py +0 -0
  59. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/infidelity_sr.py +0 -0
  60. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/tdvp.py +0 -0
  61. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/tdvp_common.py +0 -0
  62. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/tdvp_schmitt.py +0 -0
  63. {netket-3.19.1 → netket-3.19.2}/netket/experimental/driver/vmc_sr.py +0 -0
  64. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/__init__.py +0 -0
  65. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_integrator.py +0 -0
  66. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_integrator_params.py +0 -0
  67. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_integrator_state.py +0 -0
  68. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_rk/__init__.py +0 -0
  69. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_rk/_solver.py +0 -0
  70. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_rk/_tableau.py +0 -0
  71. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_solver.py +0 -0
  72. {netket-3.19.1 → netket-3.19.2}/netket/experimental/dynamics/_utils.py +0 -0
  73. {netket-3.19.1 → netket-3.19.2}/netket/experimental/geometry/__init__.py +0 -0
  74. {netket-3.19.1 → netket-3.19.2}/netket/experimental/geometry/cell.py +0 -0
  75. {netket-3.19.1 → netket-3.19.2}/netket/experimental/hilbert/__init__.py +0 -0
  76. {netket-3.19.1 → netket-3.19.2}/netket/experimental/hilbert/continuous_hilbert.py +0 -0
  77. {netket-3.19.1 → netket-3.19.2}/netket/experimental/hilbert/particle.py +0 -0
  78. {netket-3.19.1 → netket-3.19.2}/netket/experimental/hilbert/random/__init__.py +0 -0
  79. {netket-3.19.1 → netket-3.19.2}/netket/experimental/hilbert/random/particle.py +0 -0
  80. {netket-3.19.1 → netket-3.19.2}/netket/experimental/logging/__init__.py +0 -0
  81. {netket-3.19.1 → netket-3.19.2}/netket/experimental/logging/hdf5_log.py +0 -0
  82. {netket-3.19.1 → netket-3.19.2}/netket/experimental/models/__init__.py +0 -0
  83. {netket-3.19.1 → netket-3.19.2}/netket/experimental/models/fast_rnn.py +0 -0
  84. {netket-3.19.1 → netket-3.19.2}/netket/experimental/models/rnn.py +0 -0
  85. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/__init__.py +0 -0
  86. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/rnn/__init__.py +0 -0
  87. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/rnn/cells.py +0 -0
  88. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/rnn/layers.py +0 -0
  89. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/rnn/layers_fast.py +0 -0
  90. {netket-3.19.1 → netket-3.19.2}/netket/experimental/nn/rnn/ordering.py +0 -0
  91. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/__init__.py +0 -0
  92. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/infidelity/__init__.py +0 -0
  93. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/infidelity/exact.py +0 -0
  94. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/infidelity/expect.py +0 -0
  95. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/infidelity/infidelity_operator.py +0 -0
  96. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/renyi2/S2_operator.py +0 -0
  97. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/renyi2/__init__.py +0 -0
  98. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/renyi2/exact.py +0 -0
  99. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/renyi2/expect.py +0 -0
  100. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/variance/__init__.py +0 -0
  101. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/variance/exact.py +0 -0
  102. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/variance/expect.py +0 -0
  103. {netket-3.19.1 → netket-3.19.2}/netket/experimental/observable/variance/variance_operator.py +0 -0
  104. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/__init__.py +0 -0
  105. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_normal_order_utils.py +0 -0
  106. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/__init__.py +0 -0
  107. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/_conversion.py +0 -0
  108. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/_fermihubbard.py +0 -0
  109. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/_kernels.py +0 -0
  110. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/_operator_data.py +0 -0
  111. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_particle_number_conserving_fermionic/_operators.py +0 -0
  112. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/_pyscf_utils.py +0 -0
  113. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/fermion.py +0 -0
  114. {netket-3.19.1 → netket-3.19.2}/netket/experimental/operator/pyscf.py +0 -0
  115. {netket-3.19.1 → netket-3.19.2}/netket/experimental/qsr/__init__.py +0 -0
  116. {netket-3.19.1 → netket-3.19.2}/netket/experimental/qsr/dataset.py +0 -0
  117. {netket-3.19.1 → netket-3.19.2}/netket/experimental/qsr/logic_helpers.py +0 -0
  118. {netket-3.19.1 → netket-3.19.2}/netket/experimental/sampler/__init__.py +0 -0
  119. {netket-3.19.1 → netket-3.19.2}/netket/experimental/sampler/rules/__init__.py +0 -0
  120. {netket-3.19.1 → netket-3.19.2}/netket/experimental/vqs/__init__.py +0 -0
  121. {netket-3.19.1 → netket-3.19.2}/netket/experimental/vqs/io.py +0 -0
  122. {netket-3.19.1 → netket-3.19.2}/netket/graph/__init__.py +0 -0
  123. {netket-3.19.1 → netket-3.19.2}/netket/graph/_lattice_draw.py +0 -0
  124. {netket-3.19.1 → netket-3.19.2}/netket/graph/_lattice_edge_logic.py +0 -0
  125. {netket-3.19.1 → netket-3.19.2}/netket/graph/abstract_graph.py +0 -0
  126. {netket-3.19.1 → netket-3.19.2}/netket/graph/common_lattices.py +0 -0
  127. {netket-3.19.1 → netket-3.19.2}/netket/graph/graph.py +0 -0
  128. {netket-3.19.1 → netket-3.19.2}/netket/graph/lattice.py +0 -0
  129. {netket-3.19.1 → netket-3.19.2}/netket/graph/space_group.py +0 -0
  130. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/__init__.py +0 -0
  131. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/abstract_hilbert.py +0 -0
  132. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/constraint/__init__.py +0 -0
  133. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/constraint/base.py +0 -0
  134. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/constraint/multiple.py +0 -0
  135. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/constraint/sum.py +0 -0
  136. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/constraint/sum_partition.py +0 -0
  137. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/doubled_hilbert.py +0 -0
  138. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/fock.py +0 -0
  139. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/__init__.py +0 -0
  140. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/base.py +0 -0
  141. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/constrained_generic.py +0 -0
  142. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/constrained_sum.py +0 -0
  143. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/constrained_sum_partitions.py +0 -0
  144. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/unconstrained.py +0 -0
  145. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/index/uniform_tensor.py +0 -0
  146. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/qubit.py +0 -0
  147. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/__init__.py +0 -0
  148. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/doubled.py +0 -0
  149. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/fock.py +0 -0
  150. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/homogeneous.py +0 -0
  151. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/qubit.py +0 -0
  152. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/random/tensor_hilbert.py +0 -0
  153. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/spin.py +0 -0
  154. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/spin_orbital_fermions.py +0 -0
  155. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/tensor_hilbert.py +0 -0
  156. {netket-3.19.1 → netket-3.19.2}/netket/hilbert/tensor_hilbert_discrete.py +0 -0
  157. {netket-3.19.1 → netket-3.19.2}/netket/jax/__init__.py +0 -0
  158. {netket-3.19.1 → netket-3.19.2}/netket/jax/_expect.py +0 -0
  159. {netket-3.19.1 → netket-3.19.2}/netket/jax/_jacobian/__init__.py +0 -0
  160. {netket-3.19.1 → netket-3.19.2}/netket/jax/_jacobian/default_mode.py +0 -0
  161. {netket-3.19.1 → netket-3.19.2}/netket/jax/_jacobian/jacobian_dense.py +0 -0
  162. {netket-3.19.1 → netket-3.19.2}/netket/jax/_math.py +0 -0
  163. {netket-3.19.1 → netket-3.19.2}/netket/jax/_ntk/__init__.py +0 -0
  164. {netket-3.19.1 → netket-3.19.2}/netket/jax/_ntk/utils.py +0 -0
  165. {netket-3.19.1 → netket-3.19.2}/netket/jax/_sort.py +0 -0
  166. {netket-3.19.1 → netket-3.19.2}/netket/jax/_sparse.py +0 -0
  167. {netket-3.19.1 → netket-3.19.2}/netket/jax/_utils_dtype.py +0 -0
  168. {netket-3.19.1 → netket-3.19.2}/netket/jax/_utils_tree.py +0 -0
  169. {netket-3.19.1 → netket-3.19.2}/netket/jax/_vjp.py +0 -0
  170. {netket-3.19.1 → netket-3.19.2}/netket/logging/__init__.py +0 -0
  171. {netket-3.19.1 → netket-3.19.2}/netket/logging/base.py +0 -0
  172. {netket-3.19.1 → netket-3.19.2}/netket/logging/json_log.py +0 -0
  173. {netket-3.19.1 → netket-3.19.2}/netket/logging/runtime_log.py +0 -0
  174. {netket-3.19.1 → netket-3.19.2}/netket/logging/state_log.py +0 -0
  175. {netket-3.19.1 → netket-3.19.2}/netket/logging/tensorboard.py +0 -0
  176. {netket-3.19.1 → netket-3.19.2}/netket/models/README.md +0 -0
  177. {netket-3.19.1 → netket-3.19.2}/netket/models/__init__.py +0 -0
  178. {netket-3.19.1 → netket-3.19.2}/netket/models/autoreg.py +0 -0
  179. {netket-3.19.1 → netket-3.19.2}/netket/models/deepset.py +0 -0
  180. {netket-3.19.1 → netket-3.19.2}/netket/models/equivariant.py +0 -0
  181. {netket-3.19.1 → netket-3.19.2}/netket/models/fast_autoreg.py +0 -0
  182. {netket-3.19.1 → netket-3.19.2}/netket/models/full_space.py +0 -0
  183. {netket-3.19.1 → netket-3.19.2}/netket/models/gaussian.py +0 -0
  184. {netket-3.19.1 → netket-3.19.2}/netket/models/jastrow.py +0 -0
  185. {netket-3.19.1 → netket-3.19.2}/netket/models/mlp.py +0 -0
  186. {netket-3.19.1 → netket-3.19.2}/netket/models/ndm.py +0 -0
  187. {netket-3.19.1 → netket-3.19.2}/netket/models/rbm.py +0 -0
  188. {netket-3.19.1 → netket-3.19.2}/netket/models/slater.py +0 -0
  189. {netket-3.19.1 → netket-3.19.2}/netket/models/tensor_networks/__init__.py +0 -0
  190. {netket-3.19.1 → netket-3.19.2}/netket/models/tensor_networks/mpdo.py +0 -0
  191. {netket-3.19.1 → netket-3.19.2}/netket/models/tensor_networks/mps.py +0 -0
  192. {netket-3.19.1 → netket-3.19.2}/netket/models/utils.py +0 -0
  193. {netket-3.19.1 → netket-3.19.2}/netket/nn/__init__.py +0 -0
  194. {netket-3.19.1 → netket-3.19.2}/netket/nn/activation.py +0 -0
  195. {netket-3.19.1 → netket-3.19.2}/netket/nn/blocks/__init__.py +0 -0
  196. {netket-3.19.1 → netket-3.19.2}/netket/nn/blocks/deepset.py +0 -0
  197. {netket-3.19.1 → netket-3.19.2}/netket/nn/blocks/mlp.py +0 -0
  198. {netket-3.19.1 → netket-3.19.2}/netket/nn/blocks/symmetry_sum.py +0 -0
  199. {netket-3.19.1 → netket-3.19.2}/netket/nn/fast_masked_linear.py +0 -0
  200. {netket-3.19.1 → netket-3.19.2}/netket/nn/masked_linear.py +0 -0
  201. {netket-3.19.1 → netket-3.19.2}/netket/nn/symmetric_linear.py +0 -0
  202. {netket-3.19.1 → netket-3.19.2}/netket/operator/__init__.py +0 -0
  203. {netket-3.19.1 → netket-3.19.2}/netket/operator/_abstract_observable.py +0 -0
  204. {netket-3.19.1 → netket-3.19.2}/netket/operator/_abstract_operator.py +0 -0
  205. {netket-3.19.1 → netket-3.19.2}/netket/operator/_abstract_super_operator.py +0 -0
  206. {netket-3.19.1 → netket-3.19.2}/netket/operator/_bose_hubbard/__init__.py +0 -0
  207. {netket-3.19.1 → netket-3.19.2}/netket/operator/_bose_hubbard/base.py +0 -0
  208. {netket-3.19.1 → netket-3.19.2}/netket/operator/_bose_hubbard/jax.py +0 -0
  209. {netket-3.19.1 → netket-3.19.2}/netket/operator/_bose_hubbard/numba.py +0 -0
  210. {netket-3.19.1 → netket-3.19.2}/netket/operator/_continuous_operator.py +0 -0
  211. {netket-3.19.1 → netket-3.19.2}/netket/operator/_discrete_operator.py +0 -0
  212. {netket-3.19.1 → netket-3.19.2}/netket/operator/_discrete_operator_jax.py +0 -0
  213. {netket-3.19.1 → netket-3.19.2}/netket/operator/_fermion2nd/__init__.py +0 -0
  214. {netket-3.19.1 → netket-3.19.2}/netket/operator/_fermion2nd/base.py +0 -0
  215. {netket-3.19.1 → netket-3.19.2}/netket/operator/_fermion2nd/jax.py +0 -0
  216. {netket-3.19.1 → netket-3.19.2}/netket/operator/_fermion2nd/numba.py +0 -0
  217. {netket-3.19.1 → netket-3.19.2}/netket/operator/_fermion2nd/utils.py +0 -0
  218. {netket-3.19.1 → netket-3.19.2}/netket/operator/_graph_operator.py +0 -0
  219. {netket-3.19.1 → netket-3.19.2}/netket/operator/_hamiltonian.py +0 -0
  220. {netket-3.19.1 → netket-3.19.2}/netket/operator/_heisenberg.py +0 -0
  221. {netket-3.19.1 → netket-3.19.2}/netket/operator/_ising/__init__.py +0 -0
  222. {netket-3.19.1 → netket-3.19.2}/netket/operator/_ising/base.py +0 -0
  223. {netket-3.19.1 → netket-3.19.2}/netket/operator/_ising/jax.py +0 -0
  224. {netket-3.19.1 → netket-3.19.2}/netket/operator/_ising/numba.py +0 -0
  225. {netket-3.19.1 → netket-3.19.2}/netket/operator/_lazy.py +0 -0
  226. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_liouvillian.py +0 -0
  227. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/__init__.py +0 -0
  228. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/base.py +0 -0
  229. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/compile_helpers.py +0 -0
  230. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/convert.py +0 -0
  231. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/helpers.py +0 -0
  232. {netket-3.19.1 → netket-3.19.2}/netket/operator/_local_operator/numba.py +0 -0
  233. {netket-3.19.1 → netket-3.19.2}/netket/operator/_pauli_strings/__init__.py +0 -0
  234. {netket-3.19.1 → netket-3.19.2}/netket/operator/_pauli_strings/base.py +0 -0
  235. {netket-3.19.1 → netket-3.19.2}/netket/operator/_pauli_strings/jax.py +0 -0
  236. {netket-3.19.1 → netket-3.19.2}/netket/operator/_pauli_strings/numba.py +0 -0
  237. {netket-3.19.1 → netket-3.19.2}/netket/operator/_potential.py +0 -0
  238. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/__init__.py +0 -0
  239. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/base.py +0 -0
  240. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/continuous.py +0 -0
  241. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/discrete_jax_operator.py +0 -0
  242. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/discrete_operator.py +0 -0
  243. {netket-3.19.1 → netket-3.19.2}/netket/operator/_sum/operator.py +0 -0
  244. {netket-3.19.1 → netket-3.19.2}/netket/operator/boson.py +0 -0
  245. {netket-3.19.1 → netket-3.19.2}/netket/operator/fermion.py +0 -0
  246. {netket-3.19.1 → netket-3.19.2}/netket/operator/spin.py +0 -0
  247. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/__init__.py +0 -0
  248. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/linear_operator.py +0 -0
  249. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/preconditioner.py +0 -0
  250. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/__init__.py +0 -0
  251. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/common.py +0 -0
  252. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/default.py +0 -0
  253. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_jacobian.py +0 -0
  254. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_jacobian_common.py +0 -0
  255. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_jacobian_dense.py +0 -0
  256. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_jacobian_pytree.py +0 -0
  257. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_onthefly.py +0 -0
  258. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/qgt/qgt_onthefly_logic.py +0 -0
  259. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/solver/__init__.py +0 -0
  260. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/solver/solvers.py +0 -0
  261. {netket-3.19.1 → netket-3.19.2}/netket/optimizer/sr.py +0 -0
  262. {netket-3.19.1 → netket-3.19.2}/netket/sampler/__init__.py +0 -0
  263. {netket-3.19.1 → netket-3.19.2}/netket/sampler/base.py +0 -0
  264. {netket-3.19.1 → netket-3.19.2}/netket/sampler/metropolis.py +0 -0
  265. {netket-3.19.1 → netket-3.19.2}/netket/sampler/parallel_tempering.py +0 -0
  266. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/__init__.py +0 -0
  267. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/base.py +0 -0
  268. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/continuous_gaussian.py +0 -0
  269. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/custom_numpy.py +0 -0
  270. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/exchange.py +0 -0
  271. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/fermion_2nd.py +0 -0
  272. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/fixed.py +0 -0
  273. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/hamiltonian.py +0 -0
  274. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/hamiltonian_numpy.py +0 -0
  275. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/langevin.py +0 -0
  276. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/local.py +0 -0
  277. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/local_numpy.py +0 -0
  278. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/multiple.py +0 -0
  279. {netket-3.19.1 → netket-3.19.2}/netket/sampler/rules/tensor.py +0 -0
  280. {netket-3.19.1 → netket-3.19.2}/netket/stats/__init__.py +0 -0
  281. {netket-3.19.1 → netket-3.19.2}/netket/stats/_autocorr.py +0 -0
  282. {netket-3.19.1 → netket-3.19.2}/netket/stats/mc_stats_old.py +0 -0
  283. {netket-3.19.1 → netket-3.19.2}/netket/stats/mpi_stats.py +0 -0
  284. {netket-3.19.1 → netket-3.19.2}/netket/tools/__init__.py +0 -0
  285. {netket-3.19.1 → netket-3.19.2}/netket/tools/_common.py +0 -0
  286. {netket-3.19.1 → netket-3.19.2}/netket/tools/_cpu_info.py +0 -0
  287. {netket-3.19.1 → netket-3.19.2}/netket/tools/check_mpi.py +0 -0
  288. {netket-3.19.1 → netket-3.19.2}/netket/tools/djaxrun.py +0 -0
  289. {netket-3.19.1 → netket-3.19.2}/netket/tools/info.py +0 -0
  290. {netket-3.19.1 → netket-3.19.2}/netket/utils/__init__.py +0 -0
  291. {netket-3.19.1 → netket-3.19.2}/netket/utils/_serialization.py +0 -0
  292. {netket-3.19.1 → netket-3.19.2}/netket/utils/api_utils.py +0 -0
  293. {netket-3.19.1 → netket-3.19.2}/netket/utils/array.py +0 -0
  294. {netket-3.19.1 → netket-3.19.2}/netket/utils/deprecation.py +0 -0
  295. {netket-3.19.1 → netket-3.19.2}/netket/utils/dispatch.py +0 -0
  296. {netket-3.19.1 → netket-3.19.2}/netket/utils/display/__init__.py +0 -0
  297. {netket-3.19.1 → netket-3.19.2}/netket/utils/display/repr.py +0 -0
  298. {netket-3.19.1 → netket-3.19.2}/netket/utils/float.py +0 -0
  299. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/__init__.py +0 -0
  300. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/_group.py +0 -0
  301. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/_permutation_group.py +0 -0
  302. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/_point_group.py +0 -0
  303. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/_semigroup.py +0 -0
  304. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/axial.py +0 -0
  305. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/cubic.py +0 -0
  306. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/icosa.py +0 -0
  307. {netket-3.19.1 → netket-3.19.2}/netket/utils/group/planar.py +0 -0
  308. {netket-3.19.1 → netket-3.19.2}/netket/utils/history/__init__.py +0 -0
  309. {netket-3.19.1 → netket-3.19.2}/netket/utils/history/accum.py +0 -0
  310. {netket-3.19.1 → netket-3.19.2}/netket/utils/history/history.py +0 -0
  311. {netket-3.19.1 → netket-3.19.2}/netket/utils/history/history_dict.py +0 -0
  312. {netket-3.19.1 → netket-3.19.2}/netket/utils/holomorphic.py +0 -0
  313. {netket-3.19.1 → netket-3.19.2}/netket/utils/jax.py +0 -0
  314. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/__init__.py +0 -0
  315. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/base.py +0 -0
  316. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/equinox.py +0 -0
  317. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/flax.py +0 -0
  318. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/haiku.py +0 -0
  319. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/jax.py +0 -0
  320. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/nnx.py +0 -0
  321. {netket-3.19.1 → netket-3.19.2}/netket/utils/model_frameworks/nnx_wrapped.py +0 -0
  322. {netket-3.19.1 → netket-3.19.2}/netket/utils/moduletools.py +0 -0
  323. {netket-3.19.1 → netket-3.19.2}/netket/utils/mpi/__init__.py +0 -0
  324. {netket-3.19.1 → netket-3.19.2}/netket/utils/mpi/mpi.py +0 -0
  325. {netket-3.19.1 → netket-3.19.2}/netket/utils/mpi/primitives.py +0 -0
  326. {netket-3.19.1 → netket-3.19.2}/netket/utils/numbers.py +0 -0
  327. {netket-3.19.1 → netket-3.19.2}/netket/utils/optional_deps.py +0 -0
  328. {netket-3.19.1 → netket-3.19.2}/netket/utils/partial.py +0 -0
  329. {netket-3.19.1 → netket-3.19.2}/netket/utils/seed.py +0 -0
  330. {netket-3.19.1 → netket-3.19.2}/netket/utils/static_number.py +0 -0
  331. {netket-3.19.1 → netket-3.19.2}/netket/utils/static_range.py +0 -0
  332. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/__init__.py +0 -0
  333. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/dataclass.py +0 -0
  334. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/fields.py +0 -0
  335. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/pytree_serialization_sharding.py +0 -0
  336. {netket-3.19.1 → netket-3.19.2}/netket/utils/struct/utils.py +0 -0
  337. {netket-3.19.1 → netket-3.19.2}/netket/utils/summation.py +0 -0
  338. {netket-3.19.1 → netket-3.19.2}/netket/utils/timing.py +0 -0
  339. {netket-3.19.1 → netket-3.19.2}/netket/utils/version_check.py +0 -0
  340. {netket-3.19.1 → netket-3.19.2}/netket/vqs/__init__.py +0 -0
  341. {netket-3.19.1 → netket-3.19.2}/netket/vqs/base.py +0 -0
  342. {netket-3.19.1 → netket-3.19.2}/netket/vqs/full_summ/__init__.py +0 -0
  343. {netket-3.19.1 → netket-3.19.2}/netket/vqs/full_summ/expect.py +0 -0
  344. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/__init__.py +0 -0
  345. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/common.py +0 -0
  346. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/kernels.py +0 -0
  347. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_mixed_state/__init__.py +0 -0
  348. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_mixed_state/expect.py +0 -0
  349. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_mixed_state/expect_chunked.py +0 -0
  350. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_mixed_state/state.py +0 -0
  351. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/__init__.py +0 -0
  352. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect.py +0 -0
  353. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect_chunked.py +0 -0
  354. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect_forces.py +0 -0
  355. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect_forces_chunked.py +0 -0
  356. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect_grad.py +0 -0
  357. {netket-3.19.1 → netket-3.19.2}/netket/vqs/mc/mc_state/expect_grad_chunked.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NetKet
3
- Version: 3.19.1
3
+ Version: 3.19.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/#
@@ -22,7 +22,7 @@ Requires-Dist: einops>=0.8.1
22
22
  Requires-Dist: equinox>=0.11.3
23
23
  Requires-Dist: flax>=0.10.2
24
24
  Requires-Dist: igraph>=0.10.0
25
- Requires-Dist: jax>=0.7.0
25
+ Requires-Dist: jax<0.6,>=0.4.35
26
26
  Requires-Dist: numba>=0.59
27
27
  Requires-Dist: numpy<3.0,>=1.20
28
28
  Requires-Dist: optax<0.3,>=0.2.2
@@ -3,13 +3,11 @@ from functools import partial
3
3
 
4
4
  import jax
5
5
  import jax.numpy as jnp
6
- from jax.sharding import NamedSharding, PartitionSpec as P
6
+ from jax.sharding import PositionalSharding
7
7
 
8
8
  from netket import jax as nkjax
9
9
  from netket.utils.types import Array
10
10
 
11
- from netket import config
12
-
13
11
  from netket._src.ngd.kwargs import ensure_accepts_kwargs
14
12
 
15
13
 
@@ -65,9 +63,8 @@ def _compute_sr_update(
65
63
  num_p = updates.shape[-1] // 2
66
64
  updates = updates[:num_p] + 1j * updates[num_p:]
67
65
 
68
- if config.netket_experimental_sharding:
69
- updates = jax.lax.with_sharding_constraint(
70
- updates, NamedSharding(jax.sharding.get_abstract_mesh(), P())
71
- )
66
+ updates = jax.lax.with_sharding_constraint(
67
+ updates, PositionalSharding(jax.devices()).replicate()
68
+ )
72
69
 
73
70
  return updates, old_updates, info
@@ -3,7 +3,7 @@ from functools import partial
3
3
 
4
4
  import jax
5
5
  import jax.numpy as jnp
6
- from jax.sharding import NamedSharding, PartitionSpec as P
6
+ from jax.sharding import PositionalSharding
7
7
 
8
8
  from netket import jax as nkjax
9
9
  from netket import config
@@ -40,10 +40,10 @@ def _compute_srt_update(
40
40
  nkjax.sharding.pad_axis_for_sharding(O_LT, axis=1, padding_value=0.0)
41
41
  O_LT = jax.lax.with_sharding_constraint(
42
42
  O_LT,
43
- NamedSharding(jax.sharding.get_abstract_mesh(), P("S", None)),
43
+ PositionalSharding(jax.devices()).reshape(1, -1),
44
44
  )
45
45
  dv = jax.lax.with_sharding_constraint(
46
- dv, NamedSharding(jax.sharding.get_abstract_mesh(), P())
46
+ dv, PositionalSharding(jax.devices()).replicate()
47
47
  )
48
48
 
49
49
  # This does the contraction (ns, #np) x (#np, ns) -> (ns, ns).
@@ -85,9 +85,9 @@ def _compute_srt_update(
85
85
  updates = updates[:num_p] + 1j * updates[num_p:]
86
86
 
87
87
  if config.netket_experimental_sharding:
88
- out_shardings = NamedSharding(
89
- jax.sharding.get_abstract_mesh(), P(*(None,) * updates.ndim)
90
- )
88
+ out_shardings = (
89
+ PositionalSharding(jax.devices()).replicate().reshape((1,) * updates.ndim)
90
+ ).replicate()
91
91
  updates = jax.lax.with_sharding_constraint(updates, out_shardings)
92
92
 
93
93
  return updates, old_updates, info
@@ -7,13 +7,15 @@ import jax
7
7
  import jax.numpy as jnp
8
8
  from jax.tree_util import tree_map
9
9
 
10
- from jax.sharding import NamedSharding, PartitionSpec as P
10
+ from jax.experimental.shard_map import shard_map
11
+ from jax.sharding import PartitionSpec as P, PositionalSharding
11
12
 
12
13
  from netket import jax as nkjax
13
14
  from netket import config
14
15
  from netket.jax._jacobian.default_mode import JacobianMode
15
16
  from netket.utils import timing
16
17
  from netket.utils.types import Array
18
+ from netket.utils.version_check import module_version
17
19
 
18
20
  from netket.jax import _ntk as nt
19
21
 
@@ -102,10 +104,10 @@ def srt_onthefly(
102
104
  all_samples = samples
103
105
  if config.netket_experimental_sharding:
104
106
  samples = jax.lax.with_sharding_constraint(
105
- samples, NamedSharding(jax.sharding.get_abstract_mesh(), P("S", None))
107
+ samples, PositionalSharding(jax.devices()).reshape(-1, 1)
106
108
  )
107
109
  all_samples = jax.lax.with_sharding_constraint(
108
- samples, NamedSharding(jax.sharding.get_abstract_mesh(), P())
110
+ samples, PositionalSharding(jax.devices()).replicate()
109
111
  )
110
112
 
111
113
  _jacobian_contraction = nt.empirical_ntk_by_jacobian(
@@ -115,8 +117,6 @@ def srt_onthefly(
115
117
  )
116
118
 
117
119
  def jacobian_contraction(samples, all_samples, parameters_real):
118
- if config.netket_experimental_sharding:
119
- parameters_real = jax.lax.pvary(parameters_real, "S")
120
120
  if chunk_size is None:
121
121
  # STRUCTURED_DERIVATIVES returns a complex array, but the imaginary part is zero
122
122
  # shape [N_mc/p.size, N_mc, 2, 2]
@@ -136,20 +136,27 @@ def srt_onthefly(
136
136
 
137
137
  # If we are sharding, use shard_map manually
138
138
  if config.netket_experimental_sharding:
139
- mesh = jax.sharding.get_abstract_mesh()
139
+ mesh = jax.make_mesh((jax.device_count(),), ("i",), devices=jax.devices())
140
140
  # SAMPLES, ALL_SAMPLES PARAMETERS_REAL
141
- in_specs = (P("S", None), P(), P())
142
- out_specs = P("S", None)
141
+ in_specs = (P("i", None), P(), P())
142
+ out_specs = P("i", None, None, None)
143
143
 
144
144
  # By default, I'm not sure whether the jacobian_contraction of NeuralTangents
145
145
  # Is correctly automatically sharded across devices. So we force it to be
146
146
  # sharded with shard map to be sure
147
147
 
148
- jacobian_contraction = jax.shard_map(
148
+ # check rep:
149
+ check_rep = module_version("jax") < (0, 4, 38)
150
+ # shard_map is broken between 0.4.38 and (as of 25 march 2025) 0.5.3.
151
+ # We assume any version after 0.4.38 'has a bug' that shows up as
152
+ # None is not Iterable
153
+ # it's a bug in check_rep, so we disable it in this case
154
+ jacobian_contraction = shard_map(
149
155
  jacobian_contraction,
150
156
  mesh=mesh,
151
157
  in_specs=in_specs,
152
158
  out_specs=out_specs,
159
+ check_rep=check_rep,
153
160
  )
154
161
 
155
162
  # This disables the nkjax.sharding_decorator in here, which might appear
@@ -158,12 +165,10 @@ def srt_onthefly(
158
165
  ntk_local = jacobian_contraction(samples, all_samples, parameters_real).real
159
166
 
160
167
  # shape [N_mc, N_mc, 2, 2] or [N_mc, N_mc]
161
- if config.netket_experimental_sharding:
162
- ntk = jax.lax.with_sharding_constraint(
163
- ntk_local, NamedSharding(jax.sharding.get_abstract_mesh(), P())
164
- )
165
- else:
166
- ntk = ntk_local
168
+ ntk = jax.lax.with_sharding_constraint(
169
+ ntk_local,
170
+ PositionalSharding(jax.devices()).replicate(),
171
+ )
167
172
  if mode == "complex":
168
173
  # shape [2*N_mc, 2*N_mc] checked with direct calculation of J^T J
169
174
  ntk = rearrange(ntk, "i j z w -> (i z) (j w)")
@@ -210,14 +215,12 @@ def srt_onthefly(
210
215
  if mode == "complex":
211
216
  aus_vector = aus_vector.reshape(-1, 2)
212
217
  # shape [N_mc // p.size,2]
213
- if config.netket_experimental_sharding:
214
- aus_vector = jax.lax.with_sharding_constraint(
215
- aus_vector,
216
- NamedSharding(
217
- jax.sharding.get_abstract_mesh(),
218
- P("S", *(None,) * (aus_vector.ndim - 1)),
219
- ),
220
- )
218
+ aus_vector = jax.lax.with_sharding_constraint(
219
+ aus_vector,
220
+ PositionalSharding(jax.devices()).reshape(
221
+ -1, *(1 for _ in range(aus_vector.ndim - 1))
222
+ ),
223
+ )
221
224
 
222
225
  # _, vjp_fun = jax.vjp(f, parameters_real)
223
226
  vjp_fun = nkjax.vjp_chunked(
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '3.19.1'
32
- __version_tuple__ = version_tuple = (3, 19, 1)
31
+ __version__ = version = '3.19.2'
32
+ __version_tuple__ = version_tuple = (3, 19, 2)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -22,7 +22,6 @@ from functools import partial
22
22
  from tqdm.auto import tqdm
23
23
 
24
24
  import jax
25
- from jax.sharding import NamedSharding, PartitionSpec as P
26
25
 
27
26
  from netket import config
28
27
  from netket.logging import AbstractLog, JsonLog
@@ -201,7 +200,7 @@ class AbstractVariationalDriver(abc.ABC):
201
200
  if config.netket_experimental_sharding:
202
201
  self._optimizer_state = jax.lax.with_sharding_constraint(
203
202
  self._optimizer_state,
204
- NamedSharding(jax.sharding.get_abstract_mesh(), P()),
203
+ jax.sharding.PositionalSharding(jax.devices()).replicate(),
205
204
  )
206
205
 
207
206
  @property
@@ -435,7 +434,7 @@ def apply_gradient(optimizer_fun, optimizer_state, dp, params):
435
434
  new_params = optax.apply_updates(params, updates)
436
435
 
437
436
  if config.netket_experimental_sharding:
438
- sharding = NamedSharding(jax.sharding.get_abstract_mesh(), P())
437
+ sharding = jax.sharding.PositionalSharding(jax.devices()).replicate()
439
438
  new_optimizer_state = jax.lax.with_sharding_constraint(
440
439
  new_optimizer_state, sharding
441
440
  )
@@ -1116,9 +1116,14 @@ def concrete_or_error(force, value, error_class, *args, **kwargs):
1116
1116
  *args: any additional argument and keyword argument to pass to the custom
1117
1117
  error type constructor.
1118
1118
  """
1119
+ import jax
1119
1120
  from jax.core import concrete_or_error
1120
1121
 
1121
- from jax.errors import ConcretizationTypeError
1122
+ # TODO: remove once we require jax >= 0.5.0
1123
+ if hasattr(jax.errors, "ConcretizationTypeError"):
1124
+ from jax.errors import ConcretizationTypeError
1125
+ else:
1126
+ from jax.core import ConcretizationTypeError
1122
1127
 
1123
1128
  try:
1124
1129
  return concrete_or_error(
@@ -134,8 +134,7 @@ class QSR(AbstractVariationalDriver):
134
134
  if not isinstance(training_data, RawQuantumDataset):
135
135
  training_data = RawQuantumDataset(training_data)
136
136
 
137
- seed = nkjax.PRNGKey(seed)
138
- self._rng = np.random.default_rng(np.asarray(jax.random.key_data(seed)))
137
+ self._rng = np.random.default_rng(np.asarray(nkjax.PRNGKey(seed)))
139
138
 
140
139
  # mixed states
141
140
  self.mixed_states = variational_state.__class__.__name__ in ["MCMixedState"]
@@ -161,7 +161,7 @@ class DiscreteHilbert(AbstractHilbert):
161
161
 
162
162
  # equinox.error_if is broken under shard_map.
163
163
  # If we are using shard map, we skip this check
164
- if sharding._get_SHARD_MAP_STACK_LEVEL() == 0 and jax.device_count() == 1:
164
+ if sharding.SHARD_MAP_STACK_LEVEL == 0 and jax.device_count() == 1:
165
165
  numbers = error_if(
166
166
  numbers,
167
167
  (numbers >= self.n_states).any() | (numbers < 0).any(),
@@ -264,7 +264,7 @@ class HomogeneousHilbert(DiscreteHilbert):
264
264
 
265
265
  # equinox.error_if is broken under shard_map.
266
266
  # If we are using shard map, we skip this check
267
- if sharding._get_SHARD_MAP_STACK_LEVEL() == 0 and jax.device_count() == 1:
267
+ if sharding.SHARD_MAP_STACK_LEVEL == 0 and jax.device_count() == 1:
268
268
  states = error_if(
269
269
  states,
270
270
  (states < start).any() | (states >= end).any(),
@@ -272,7 +272,7 @@ class HomogeneousHilbert(DiscreteHilbert):
272
272
  )
273
273
 
274
274
  if self.constrained:
275
- if sharding._get_SHARD_MAP_STACK_LEVEL() == 0 and jax.device_count() == 1:
275
+ if sharding.SHARD_MAP_STACK_LEVEL == 0 and jax.device_count() == 1:
276
276
  states = error_if(
277
277
  states,
278
278
  ~self.constraint(states).all(),
@@ -14,7 +14,7 @@
14
14
 
15
15
  from textwrap import dedent
16
16
  from typing import Union
17
- from functools import partial
17
+
18
18
 
19
19
  import jax
20
20
  import numpy as np
@@ -32,7 +32,7 @@ def random_state(hilb, key, *, size=None, dtype=np.float32):
32
32
 
33
33
  Args:
34
34
  hilb: The hilbert space
35
- key: The rng key generated by :func:`jax.random.key`.
35
+ key: The Jax :class:`jax.random.KeyArray` generated by :func:`jax.random.PRNGKey`.
36
36
  size: If provided, returns a batch of configurations of the form `(size, #)` if
37
37
  size is an integer or `(*size, #)` if it is a tuple and where `#` is the Hilbert
38
38
  space size. By default, a single random configuration with shape `(#,)` is
@@ -115,7 +115,6 @@ def flip_state_scalar(hilb, key, state, indx):
115
115
 
116
116
 
117
117
  @dispatch
118
- @partial(jax.jit, static_argnames=("hilb",))
119
118
  def flip_state_batch(hilb, key, states, indxs):
120
119
  keys = jax.random.split(key, states.shape[0])
121
120
  res = jax.vmap(flip_state_scalar, in_axes=(None, 0, 0, 0), out_axes=0)(
@@ -2,9 +2,7 @@ from functools import partial
2
2
 
3
3
  import jax
4
4
  import jax.numpy as jnp
5
- from netket.utils.iterators import safe_map
6
-
7
- safe_zip = partial(zip, strict=True)
5
+ from jax.util import safe_zip, safe_map
8
6
 
9
7
 
10
8
  def _tree_map_multi_out(f, tree, *rest, is_leaf=None):
@@ -19,8 +19,12 @@ import operator
19
19
 
20
20
  import jax
21
21
  import jax.numpy as jnp
22
+ from jax.util import safe_map
23
+
22
24
  from ._utils_tree import tree_leaf_iscomplex, eval_shape
23
25
 
26
+ map = safe_map
27
+
24
28
 
25
29
  def _ensure_index(x: Any) -> int | tuple[int, ...]:
26
30
  """Ensure x is either an index or a tuple of indices."""
@@ -19,6 +19,7 @@ import jax
19
19
  import jax.flatten_util
20
20
  import jax.numpy as jnp
21
21
 
22
+ import numpy as np
22
23
 
23
24
  from netket import jax as nkjax
24
25
  from netket.utils import wrap_to_support_scalar
@@ -41,7 +42,7 @@ def jacobian_real_holo(forward_fn: Callable, params: PyTree, samples: Array) ->
41
42
  y, vjp_fun = jax.vjp(
42
43
  lambda pars: wrap_to_support_scalar(forward_fn)(pars, samples), params
43
44
  )
44
- (res,) = vjp_fun(jax.lax.full_like(y, 1.0))
45
+ (res,) = vjp_fun(np.array(1.0, dtype=jnp.result_type(y)))
45
46
  return res
46
47
 
47
48
 
@@ -70,8 +71,8 @@ def _jacobian_cplx(
70
71
  if not jnp.issubdtype(jnp.result_type(y), jnp.complexfloating):
71
72
  raise TypeError("Cannot build the complex jacobian for a real-valued function.")
72
73
 
73
- (gr,) = vjp_fun(jax.lax.full_like(y, 1))
74
- (gi,) = vjp_fun(jax.lax.full_like(y, -1j))
74
+ (gr,) = vjp_fun(np.array(1.0, dtype=jnp.result_type(y)))
75
+ (gi,) = vjp_fun(np.array(-1.0j, dtype=jnp.result_type(y)))
75
76
  return _build_fn(gr, gi)
76
77
 
77
78
 
@@ -27,6 +27,7 @@ from netket.jax import (
27
27
  tree_to_real,
28
28
  vmap_chunked,
29
29
  )
30
+ from netket.jax.sharding import sharding_decorator
30
31
 
31
32
  from . import jacobian_dense
32
33
  from . import jacobian_pytree
@@ -42,7 +43,6 @@ from . import jacobian_pytree
42
43
  "center",
43
44
  "dense",
44
45
  "_sqrt_rescale",
45
- "_axis_0_is_sharded",
46
46
  ),
47
47
  )
48
48
  def jacobian(
@@ -354,6 +354,21 @@ def jacobian(
354
354
  chunk_size=chunk_size,
355
355
  axis_0_is_sharded=_axis_0_is_sharded,
356
356
  ) # see below
357
+ # vmap_chunked, as of 5/11/2024 (3.14.3) only passses the function through
358
+ # a sharding_decorator if it is chunked, and not if it's not. This creates
359
+ # a different behaviour in the two cases. To homogenize it, we do it at the
360
+ # level of nkjax.jacobian.
361
+ # This fixes computing the jacobian of logpsi with sharded functions like
362
+ # for example from get_conn_padded.
363
+
364
+ # TODO: Maybe remove this and simply always sharding_decorator inside of vmap_chunked.
365
+ # We do sharding decorator here to account for cases where the wavefunction contains
366
+ if _axis_0_is_sharded is True:
367
+ jacobian_fun = sharding_decorator(
368
+ jacobian_fun,
369
+ (False, False, True),
370
+ reduction_op_tree=False,
371
+ )
357
372
 
358
373
  jacobians = jacobian_fun(Partial(f), params, samples)
359
374
 
@@ -28,20 +28,28 @@ For details, please see "`Fast Finite Width Neural Tangent Kernel
28
28
  <https://arxiv.org/abs/2206.08720>`_".
29
29
  """
30
30
 
31
+ import operator
31
32
  from typing import Any, Protocol, TypeVar, Union
32
33
  from collections.abc import Callable, Iterable
33
34
 
34
- from functools import partial
35
- import operator
36
35
 
37
- import jax
38
- import jax.numpy as jnp
36
+ from jax import eval_shape
37
+ from jax import jacobian
38
+ from jax import lax
39
+ from jax import vmap
40
+
39
41
  from jax.core import ShapedArray
42
+
43
+
40
44
  from jax.interpreters.ad import UndefinedPrimal
41
45
 
42
- from . import utils
46
+ import jax.numpy as jnp
43
47
 
44
- safe_zip = partial(zip, strict=True)
48
+ from jax.tree_util import tree_map
49
+ from jax.tree_util import tree_reduce
50
+ from jax.util import safe_zip as zip
51
+
52
+ from . import utils
45
53
 
46
54
  PyTree = Any
47
55
  _VMapAxis = PyTree | None
@@ -223,7 +231,7 @@ def empirical_ntk_by_jacobian(
223
231
  contract_axes = _trace_axes + param_axes
224
232
  return _dot_general(x, y, contract_axes, _diagonal_axes) / size
225
233
 
226
- return jax.tree.reduce(operator.add, jax.tree.map(contract, j1, j2))
234
+ return tree_reduce(operator.add, tree_map(contract, j1, j2))
227
235
 
228
236
  def ntk_fn(
229
237
  x1: PyTree, x2: PyTree | None, params: PyTree, **apply_fn_kwargs
@@ -264,16 +272,16 @@ def empirical_ntk_by_jacobian(
264
272
  def j_fn(x, *args):
265
273
  _kwargs = {k: v for k, v in zip(keys, args)}
266
274
  fx = _get_f_params(f, x, x_axis, fx_axis, kw_axes, **_kwargs)
267
- jx = jax.jacobian(fx)(params)
275
+ jx = jacobian(fx)(params)
268
276
  return jx
269
277
 
270
278
  if not utils.all_none(x_axis) or not utils.all_none(kw_axes):
271
279
  in_axes = [x_axis] + [kw_axes[k] if k in kw_axes else None for k in keys]
272
- j_fn = jax.vmap(j_fn, in_axes=in_axes, out_axes=fx_axis)
280
+ j_fn = vmap(j_fn, in_axes=in_axes, out_axes=fx_axis)
273
281
 
274
282
  j1 = j_fn(x1, *args1)
275
283
  j2 = j_fn(x2, *args2) if not utils.all_none(x2) else j1
276
- ntk = jax.tree.map(sum_and_contract, fx1, j1, j2)
284
+ ntk = tree_map(sum_and_contract, fx1, j1, j2)
277
285
  return ntk
278
286
 
279
287
  return ntk_fn
@@ -305,13 +313,13 @@ def _get_f_params(
305
313
 
306
314
 
307
315
  def _ndim(x: PyTree) -> PyTree:
308
- return jax.tree.map(lambda x: x.ndim, x)
316
+ return tree_map(lambda x: x.ndim, x)
309
317
 
310
318
 
311
319
  def _mod(x: PyTree | None, y: PyTree) -> PyTree:
312
320
  if x is None:
313
321
  return None
314
- return jax.tree.map(operator.mod, x, y)
322
+ return tree_map(operator.mod, x, y)
315
323
 
316
324
 
317
325
  def _squeeze(x: PyTree, axis: PyTree | None) -> PyTree:
@@ -340,7 +348,7 @@ def _squeeze(x: PyTree, axis: PyTree | None) -> PyTree:
340
348
 
341
349
  return jnp.squeeze(x, non_zero_axes)
342
350
 
343
- return jax.tree.map(squeeze, x, axis)
351
+ return tree_map(squeeze, x, axis)
344
352
 
345
353
 
346
354
  def _expand_dims_array(x: _ArrayOrShape, axis: int) -> _ArrayOrShape:
@@ -348,7 +356,7 @@ def _expand_dims_array(x: _ArrayOrShape, axis: int) -> _ArrayOrShape:
348
356
  return jnp.expand_dims(x, axis)
349
357
 
350
358
  if isinstance(x, ShapedArray):
351
- return jax.eval_shape(expand, x)
359
+ return eval_shape(expand, x)
352
360
 
353
361
  if isinstance(x, jnp.ndarray):
354
362
  return expand(x)
@@ -361,7 +369,7 @@ def _expand_dims(
361
369
  ) -> PyTree | None:
362
370
  if axis is None or x is None or isinstance(x, UndefinedPrimal):
363
371
  return x
364
- return jax.tree.map(_expand_dims_array, x, axis)
372
+ return tree_map(_expand_dims_array, x, axis)
365
373
 
366
374
 
367
375
  def _get_args(
@@ -374,8 +382,8 @@ def _get_args(
374
382
  ):
375
383
  kwargs1, kwargs2 = utils.split_kwargs(apply_fn_kwargs, x1, x2)
376
384
 
377
- fx1 = jax.eval_shape(f, params, x1, **kwargs1)
378
- fx2 = fx1 if utils.all_none(x2) else jax.eval_shape(f, params, x2, **kwargs2)
385
+ fx1 = eval_shape(f, params, x1, **kwargs1)
386
+ fx2 = fx1 if utils.all_none(x2) else eval_shape(f, params, x2, **kwargs2)
379
387
 
380
388
  x_axis, fx_axis, kw_axes = _canonicalize_axes(vmap_axes, x1, fx1, **kwargs1)
381
389
 
@@ -394,13 +402,13 @@ def _canonicalize_axes(
394
402
  x_axis, fx_axis, kw_axes = vmap_axes, vmap_axes, {}
395
403
 
396
404
  if isinstance(x_axis, int):
397
- x_axis = jax.tree.map(lambda _: x_axis, x)
405
+ x_axis = tree_map(lambda _: x_axis, x)
398
406
 
399
407
  if isinstance(fx_axis, int):
400
- fx_axis = jax.tree.map(lambda _: fx_axis, fx)
408
+ fx_axis = tree_map(lambda _: fx_axis, fx)
401
409
 
402
410
  if isinstance(kw_axes, int):
403
- kw_axes = jax.tree.map(lambda _: kw_axes, kwargs)
411
+ kw_axes = tree_map(lambda _: kw_axes, kwargs)
404
412
 
405
413
  x_axis = _mod(x_axis, _ndim(x))
406
414
  fx_axis = _mod(fx_axis, _ndim(fx))
@@ -459,7 +467,7 @@ def _dot_general(
459
467
 
460
468
  dimension_numbers = ((contracting_dims, contracting_dims), (batch_dims, batch_dims))
461
469
 
462
- prod = jax.lax.dot_general(lhs, rhs, dimension_numbers, precision)
470
+ prod = lax.dot_general(lhs, rhs, dimension_numbers, precision)
463
471
  prod = utils.zip_axes(prod, n_batch_dims)
464
472
 
465
473
  res_batch_dims = _get_res_batch_dims(contracting_dims, batch_dims)
@@ -10,7 +10,9 @@ from jax.extend import linear_util as lu
10
10
  from ._utils_tree import compose
11
11
 
12
12
  _tree_add = partial(jax.tree_util.tree_map, jax.lax.add)
13
- _tree_zeros_like = partial(jax.tree_util.tree_map, jnp.zeros_like)
13
+ _tree_zeros_like = partial(
14
+ jax.tree_util.tree_map, lambda x: jnp.zeros(x.shape, dtype=x.dtype)
15
+ )
14
16
 
15
17
 
16
18
  # TODO put it somewhere
@@ -88,8 +90,7 @@ def scan_append_reduce(f, x, append_cond, op=_tree_add, zero_fun=_tree_zeros_lik
88
90
  _get_op_part = partial(_multimap, lambda c, x: x if not c else None, append_cond)
89
91
  _tree_select = partial(_multimap, lambda c, t1, t2: t1 if c else t2, append_cond)
90
92
 
91
- dummy_y = jax.eval_shape(f_flat, x0)
92
- carry_init = True, _get_op_part(zero_fun(dummy_y))
93
+ carry_init = True, _get_op_part(zero_fun(jax.eval_shape(f_flat, x0)))
93
94
 
94
95
  def f_(carry, x):
95
96
  is_first, y_carry = carry
@@ -15,7 +15,6 @@
15
15
 
16
16
  import jax
17
17
  import jax.numpy as jnp
18
- from jax.sharding import NamedSharding, PartitionSpec as P
19
18
 
20
19
  from netket.utils import random_seed, config
21
20
  from netket.utils.types import PRNGKeyT, SeedT
@@ -51,28 +50,16 @@ def PRNGKey(seed: SeedT | None = None, *, root: int = 0) -> PRNGKeyT:
51
50
  ).item()
52
51
  )
53
52
 
54
- key = jax.random.key(seed)
55
- elif isinstance(seed, jax.Array):
56
- if jnp.issubdtype(seed.dtype, jax.dtypes.prng_key):
57
- # new-style keys
58
- key = seed
59
- elif jnp.issubdtype(seed.dtype, jax.numpy.unsignedinteger):
60
- # old-style PRNGKey
61
- key = seed
62
- else:
63
- raise TypeError(
64
- f"Expected seed to be an integer or a PRNGKey, got {type(seed)}, {seed.dtype} : {seed}"
65
- )
53
+ key = jax.random.PRNGKey(seed)
66
54
  else:
67
- raise TypeError(f"unsupported type {type(seed)}")
68
-
69
- mesh = jax.sharding.get_abstract_mesh()
70
- if not mesh.empty:
71
- if len(mesh.explicit_axes) >= 0:
72
- key = jax.sharding.reshard(key, P())
73
- else:
74
- sharding = NamedSharding(mesh, P())
75
- key = jax.lax.with_sharding_constraint(key, sharding)
55
+ key = seed
56
+
57
+ if config.netket_experimental_sharding:
58
+ key = jax.lax.with_sharding_constraint(
59
+ key, jax.sharding.PositionalSharding(jax.devices()).replicate()
60
+ )
61
+ else: # type: ignore[attr-defined]
62
+ key = _bcast_key(key, root=root)
76
63
  return key
77
64
 
78
65
 
@@ -100,7 +100,7 @@ def __vjp_fun_chunked(
100
100
  if c:
101
101
  return _tree_unchunk(l, r)
102
102
  else:
103
- return jax.tree_util.tree_map(jax.lax.add, l, r)
103
+ return jax.tree_map(jax.lax.add, l, r)
104
104
 
105
105
  return jax.tree_util.tree_map(_f, append_cond, res_chunk, res_rest)
106
106
  elif n_chunks > 0:
@@ -316,12 +316,6 @@ def vjp_chunked(
316
316
  lambda c: jax.lax.psum if c else False, out_args
317
317
  )
318
318
 
319
- # jax will psum in every vjp, but we want to do one by hand at the end
320
- # so we need to set the sharded args we differentiate as varying
321
- # see https://github.com/jax-ml/jax/discussions/29608
322
- pvary_argnums = tuple(set(range(len(primals))).difference(nondiff_argnums))
323
- pvary_args = tuple(i in pvary_argnums for i in range(len(primals)))
324
-
325
319
  # check the chunk_size is not larger than the shard per device
326
320
  chunk_size = sharding_decorator(
327
321
  partial(check_chunk_size, chunk_argnums, chunk_size),
@@ -353,7 +347,6 @@ def vjp_chunked(
353
347
  _vjpc,
354
348
  sharded_args_tree=(sharded_args, True),
355
349
  reduction_op_tree=reduction_op_tree,
356
- pvary_args_tree=(pvary_args, False),
357
350
  ),
358
351
  primals,
359
352
  )
@@ -42,15 +42,7 @@ def _eval_fun_in_chunks_sharding(vmapped_fun, chunk_size, argnums, *args, **kwar
42
42
  # by computing the vmapped_fun in chunks on every shard (which sits on a separate device)
43
43
  sharded_args_tree = tuple(i in argnums for i, a in enumerate(args))
44
44
  f = HashablePartial(_eval_fun_in_chunks, vmapped_fun, chunk_size, argnums, **kwargs)
45
-
46
- # if the vmapped_fun e.g. does a vjp we need to make the params pvary here
47
- # to avoid it emitting an unwanted psum
48
- pvary_argnums = tuple(set(range(len(args))).difference(argnums))
49
- pvary_args_tree = tuple(i in pvary_argnums for i in range(len(args)))
50
-
51
- return sharding_decorator(f, sharded_args_tree, pvary_args_tree=pvary_args_tree)(
52
- *args
53
- )
45
+ return sharding_decorator(f, sharded_args_tree)(*args)
54
46
 
55
47
 
56
48
  def _chunk_vmapped_function(