--- license: apache-2.0 --- # HamiltonZero HamiltonZero is Simulacra Research's research release for compiled neural wavefunctions of quantum spin Hamiltonians. It exposes three workflows: - learned-router multisystem training; - compiled single-system fine-tuning; - compiled single-system evaluation, with optional router contest or large-N execution. ## Installation HamiltonZero requires Python 3.12 or newer and JAX-compatible accelerator drivers. ```bash python -m pip install hamiltonzero ``` To install from a source checkout instead, run `python -m pip install .` in the repository root. Example configurations and research datasets are repository assets rather than wheel data. Clone the matching [`v0.1.1` source tree](https://github.com/simulacra-research/HamiltonZero/tree/v0.1.1) to run the documented commands unchanged. The package pins `jax==0.11.0` and `jaxlib==0.11.0`. Install the accelerator plugin appropriate for the host using the standard JAX instructions. Learned-router training uses eight visible accelerators and requires an MCMC batch size divisible by eight. Fine-tuning uses all visible accelerators and requires its MCMC batch size to be divisible by their count. Evaluation chooses a visible-device subset compatible with its walker batch. ## Foundation checkpoint This Hugging Face repository stores the directly loadable HamiltonZero v1 foundation checkpoint at `weights/hamiltonzero_v1.eqx`, with its manifest in `config.json`. To download both files without cloning the repository: ```bash hf download simulacra-research/HamiltonZero \ config.json \ weights/hamiltonzero_v1.eqx \ --local-dir . ``` The checkpoint contains the complete foundation wavefunction and its learned router. `router` is the checkpoint kind, not a router-only parameter file. To load the model directly, construct an architecture template and deserialize its array leaves: ```python import jax from hamiltonzero.checkpoint import load_model from hamiltonzero.config import ModelConfig from hamiltonzero.model import build_model template = build_model( ModelConfig(), jax.random.PRNGKey(0), n_max=64, ) model = load_model("weights/hamiltonzero_v1.eqx", template) ``` The template key initializes placeholder values only; deserialization replaces all serialized array leaves. Set `n_max` to the padded width of the system when constructing a template for direct model use. The command-line evaluation path does this from the input system automatically. ## Hamiltonians and NetworkX The public API follows the textbook convention ```text H = sum_(i.eqx` files. For a one-system training panel it may be a single file. Training runs `mcmc.burn_in` iterations after either fresh initialization or loading reused states. Each iteration uses `mcmc.burn_in_replica_steps` MCMC moves. ## Fine-tune Fine-tuning selects and freezes a route from a router checkpoint, compiles the single-system wavefunction, and optimizes that compiled model: ```bash hamiltonzero finetune examples/finetune.json ``` The example fine-tunes on the 256-spin PPP-Ohno system and writes `outputs/ppp_ohno_n256.eqx`. A neighboring `.eqx.json` sidecar records the compiled-fine-tune kind, frozen model width, and configured ranks. A compatible single post-burn-in state can also be supplied: ```bash hamiltonzero finetune examples/finetune.json --reuse-mcmc path/to/state.eqx ``` ## Evaluate Compiled evaluation uses the route selected by a router checkpoint, or the embedded frozen route in a compiled fine-tune checkpoint: ```bash hamiltonzero eval examples/eval.json ``` Use router contest to compare candidate routes before evaluating the winner: ```bash hamiltonzero eval examples/eval.json --contest ``` Use the sequence-sharded large-N implementation for the large systems: ```bash hamiltonzero eval examples/eval_large_n.json --large-n ``` Each evaluation writes `eval.json` and `eval.metrics.jsonl` inside its configured output directory. Training and fine-tuning metrics are written beside the final checkpoint as `.metrics.jsonl`. Evaluation writes the same per-measurement fields to `eval.metrics.jsonl`. These JSONL rows contain step, energy, energy standard deviation, step wall time, and total wall time. Final `eval.json` additionally reports exchange/field channels and lag-one autocorrelation when available. ## Configuration Every command accepts one JSON configuration. The files in `examples/` are minimal runnable configurations; omitted parameters use the defaults in `hamiltonzero.config`. The KFAC-JAX fork is vendored under `src/kfac_jax`. ## License HamiltonZero first-party source, datasets, and released model weights are licensed under Apache-2.0, copyright Simulacra Research Inc. The vendored KFAC-JAX fork and JAX-derived large-N attention kernel remain under Apache-2.0. The Microsoft-Folx-derived attention forward and reverse-mode kernels remain under MIT. See [`THIRD_PARTY_NOTICES.md`](https://github.com/simulacra-research/HamiltonZero/blob/v0.1.1/THIRD_PARTY_NOTICES.md).