neuralqx.hilbert.utils package¶
- check_one_state_jax(state, constraints, q_min, q_max, q_step)¶
Check all gauge-fixing constraints for a single configuration.
Given a state
stateof shape(N,)and a preprocessed list of constraint specifications, this function verifies that every constraint is satisfied. Each constraint is represented as a pair(inc_data, out_data), where both entries are lists of(idx, sgn)pairs. The valuestate[idx]is multiplied by its signsgnand then combined using a modular sum.For a single constraint, define the signed incoming and outgoing aggregates
\[S_{\mathrm{in}} = \bigoplus_{(i, s) \in \mathrm{inc}} (s\,\sigma_i), \qquad S_{\mathrm{out}} = \bigoplus_{(j, s) \in \mathrm{out}} (s\,\sigma_j),\]where \(\sigma_i = \texttt{state}[i]\) and \(\oplus\) denotes the modular addition implemented by
neuralqx.utils.jit.mod_sum_jax()on the discrete domain[q_min, q_max]with stepq_step. The constraint is satisfied iff\[S_{\mathrm{in}} = S_{\mathrm{out}}.\]All constraints must pass for the state to be accepted.
- Parameters:
state – One configuration array of shape
(N,).constraints – Preprocessed constraints as produced by the corresponding preprocessing helper. Each item is
(inc_data, out_data)withinc_dataandout_datalists of(idx, sgn)pairs.q_min – Minimum allowed local quantum number for the modular domain.
q_max – Maximum allowed local quantum number for the modular domain.
q_step – Step size between allowed local quantum numbers.
- Returns:
A boolean JAX scalar indicating whether all constraints are satisfied.
- make_hashable(obj)¶
Recursively convert an object into a hashable representation.
This helper is intended for building stable cache keys from nested container structures commonly encountered in constraint specifications and preprocessed data.
Conversion rules:
list/tupleare converted into tuples of recursively converted items;dictis converted into a sorted tuple of(key, value)pairs, with values converted recursively;array-like objects exposing
.tolist()(for example JAX or NumPy arrays) are converted via their Python list representation and then processed recursively;all other objects are returned unchanged.