|
1 | | -# ISAX |
| 1 | +# Getting Started |
2 | 2 |
|
3 | | -Block-parallel sampling for Ising models on arbitrary graphs using JAX. |
4 | | - |
5 | | -ISAX is a [JAX](https://github.com/google/jax)-based library for sampling from Ising models using block-parallel Gibbs sampling. It supports hypergraphs, custom sampling schedules, and JAX transformations. |
6 | | - |
7 | | -## Quick Example |
8 | | - |
9 | | -```python |
10 | | -import jax |
11 | | -import jax.numpy as jnp |
12 | | -from isax import IsingModel, IsingSampler, BlockGraph, sample_chain, SamplingArgs |
13 | | - |
14 | | -# Create a 2D lattice Ising model |
15 | | -n_nodes = 100 |
16 | | -edges = [(i, j) for i in range(n_nodes) for j in range(i+1, n_nodes) |
17 | | - if abs(i-j) == 1 or abs(i-j) == 10] # 2D grid connectivity |
18 | | - |
19 | | -# Initialize model with random weights |
20 | | -key = jax.random.PRNGKey(0) |
21 | | -weight_key, sample_key = jax.random.split(key) |
22 | | -weights = jax.random.normal(weight_key, (len(edges),)) |
23 | | -biases = jnp.zeros(n_nodes) |
24 | | - |
25 | | -model = IsingModel(weights=weights, biases=biases) |
26 | | - |
27 | | -# Create block structure for parallel sampling |
28 | | -graph = BlockGraph(n_nodes, edges, n_blocks=4) |
29 | | - |
30 | | -# Sample using Gibbs sampler |
31 | | -sampler = IsingSampler() |
32 | | -initial_state = jax.random.choice(sample_key, jnp.array([-1, 1]), (n_nodes,)) |
33 | | - |
34 | | -# Run sampling |
35 | | -samples = sample_chain( |
36 | | - initial_state, |
37 | | - [sampler] * graph.n_blocks, |
38 | | - model, |
39 | | - SamplingArgs(gibbs_steps=1000, blocks_to_sample=list(range(4)), data=graph.get_sampling_params()), |
40 | | - sample_key |
41 | | -) |
42 | | -``` |
| 3 | +isax is a [JAX](https://github.com/google/jax)-based library for sampling from Ising models using blocked Gibbs sampling. It supports hypergraphs, flexible sampling/modeling, and all the usual JAX transformations. isax is heavily inspired by [thrml](https://docs.thrml.ai/en/latest/). |
43 | 4 |
|
44 | 5 | ## Installation |
45 | 6 |
|
46 | | -```bash |
47 | | -pip install isax |
48 | | -``` |
49 | | - |
50 | | -Or install from source: |
51 | | - |
52 | 7 | ```bash |
53 | 8 | git clone https://github.com/lockwo/isax |
54 | 9 | cd isax |
55 | 10 | pip install -e . |
56 | 11 | ``` |
57 | 12 |
|
58 | | -## Features |
59 | | - |
60 | | -Traditional MCMC sampling for Ising models can be slow for large graphs. ISAX accelerates this through: |
61 | | - |
62 | | -1. **Block decomposition**: Divide the graph into blocks that can be updated in parallel |
63 | | -2. **JAX compilation**: JIT-compile the sampling loops for maximum performance |
64 | | -3. **Vectorization**: Process multiple chains simultaneously with `vmap` |
65 | | -4. **Hardware acceleration**: Automatic GPU/TPU support through JAX |
66 | | - |
67 | | -## Navigation |
68 | | - |
69 | | -- [API Reference](api/block.md) - Complete API documentation |
70 | | -- [Examples](examples/01_ising_model_physics.ipynb) - Jupyter notebooks with practical examples |
71 | 13 |
|
72 | 14 | ## Citation |
73 | 15 |
|
74 | 16 | If you use ISAX in your research, please cite: |
75 | | - |
76 | | -```bibtex |
77 | | -@software{isax2025, |
78 | | - title = {ISAX: Block-parallel sampling for Ising models}, |
79 | | - year = {2025}, |
80 | | - url = {https://github.com/lockwo/isax} |
81 | | -} |
82 | | -``` |
0 commit comments