Thermodynamic Hypergraphical Model Library in JAX
翻譯準備中
開發工具Python · HTMLGitHub @extropic-ai自行安裝營運者未確認
試用過了嗎? 點一下就好,不需要登入。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
安裝型專案無需部署網域也可驗證。個人儲存庫可透過 GitHub 登入驗證,組織儲存庫可使用上方的儲存庫驗證檔案。
製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗THRML is a JAX library for building and sampling probabilistic graphical models, with a focus on efficient block Gibbs sampling and energy-based models. Extropic is developing hardware to make sampling from certain classes of discrete PGMs massively more energy efficient; THRML provides GPU‑accelerated tools for block sampling on sparse, heterogeneous graphs, making it a natural place to prototype today and experiment with future Extropic hardware.
Features include:
From a technical point of view, the internal structure compiles factor-based interactions to a compact "global" state representation, minimizing Python loops and maximizing array-level parallelism in JAX.
Requires Python 3.10+.
pip install thrml
or
uv pip install thrml
Available at docs.thrml.ai.
If you use THRML in your research, please cite us!
@misc{jelinčič2025efficientprobabilistichardwarearchitecture,
title={An efficient probabilistic hardware architecture for diffusion-like models},
author={Andraž Jelinčič and Owen Lockwood and Akhil Garlapati and Guillaume Verdon and Trevor McCourt},
year={2025},
eprint={2510.23972},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2510.23972},
}
Sampling a small Ising chain with two-color block Gibbs:
import jax
import jax.numpy as jnp
from thrml import SpinNode, Block, SamplingSchedule, sample_states
from thrml.models import IsingEBM, IsingSamplingProgram, hinton_init
nodes = [SpinNode() for _ in range(5)]
edges = [(nodes[i], nodes[i+1]) for i in range(4)]
biases = jnp.zeros((5,))
weights = jnp.ones((4,)) * 0.5
beta = jnp.array(1.0)
model = IsingEBM(nodes, edges, biases, weights, beta)
free_blocks = [Block(nodes[::2]), Block(nodes[1::2])]
program = IsingSamplingProgram(model, free_blocks, clamped_blocks=[])
key = jax.random.key(0)
k_init, k_samp = jax.random.split(key, 2)
init_state = hinton_init(k_init, model, free_blocks, ())
schedule = SamplingSchedule(n_warmup=100, n_samples=1000, steps_per_sample=2)
samples = sample_states(k_samp, program, schedule, init_state, [], [Block(nodes)])
Sampling uses JaxBackend by default. IsingSamplingProgram holds the logical model
in .model and its block layout in .gibbs_spec. Pass backend=your_backend to
sample_states, sample_with_observation, estimate_moments, or estimate_kl_grad
to use a backend supplied by an external package. Physical execution and calibration
belong to that package.
An initial state of None requests continuation of the backend's retained chain;
actual JAX sampling requires an explicit state. Use [] for an explicitly empty
state when there are no free blocks. Explicit physical initialization is optional
and backend-owned, and may require additional device operations.
For low-level JAX updates or access to .samplers and .per_block_*, convert an
Ising program with JaxBackend().compile(program). It uses a private JIT helper to
reuse the graph and layout work while applying the current model parameters on
every call. The first conversion compiles this helper; an enclosing JIT inlines it.
The result is the existing executable representation. Compile again after changing
the model parameters. Existing BlockSamplingProgram and FactorSamplingProgram
objects are returned unchanged.
See the concepts guide for portable observers,
backend batching, and training.
Sampling schedules are immutable because JAX uses them as compilation-cache keys.
Mutating a cached schedule can reuse a computation with the old record count.
Use dataclasses.replace(schedule, n_samples=100) to create an updated schedule.
For a more extensive example, see the dtm-replication repository which runs on THRML.