Alchemize v0.1.0
First public release of Alchemize — an AI agent that transpiles between probabilistic programming languages and compiles models to optimized native code.
pip install alchemize-ai
What it does
Alchemize uses Claude Code as a compiler. You give it a model in one framework, it autonomously writes, validates, and iterates on code in another framework — driven by gradient-distance feedback against a reference implementation. No human writes the output code.
Features
PyMC → Rust compiler
Compile any PyMC model to an optimized Rust binary, validated against PyMC's exact numerical output. 3-7x faster than the already-fast Numba backend in benchmarks across Normal, Linear Regression, Hierarchical, GP (ExpQuad), and ZeroSumNormal models.
import pymc as pm
from alchemize import compile_model
with pm.Model() as model:
mu = pm.Normal("mu", 0, 10)
sigma = pm.HalfNormal("sigma", 5)
y = pm.Normal("y", mu=mu, sigma=sigma, observed=data)
result = compile_model(model)Stan → PyMC transpiler
Translate Stan models to idiomatic PyMC, validated against BridgeStan gradients. Produced 108 out of 120 posteriordb models in a single run.
Stan → Rust compiler
Same Rust target, Stan source.
JAX ↔ PyTorch translator
Bidirectional translation between JAX and PyTorch models.
PyTorch → Rust
PyTorch models to standalone Rust binaries (includes minGPT example).
Architecture
- Agent-based: Claude Agent SDK with tools for write / build / validate / iterate
- Skills: Markdown files teach the agent specialized knowledge (GP CPU/CUDA/Accelerate, ZeroSumNormal, Stan→PyMC, etc.)
- Validation loop: Every output is numerically verified against the reference implementation
- Composable: Add a new model type or hardware backend by writing a markdown skill
CLI
alchemize convert model.py --target rustRequirements
- Python ≥ 3.11
- Anthropic API key
- Rust toolchain (for Rust targets)
- BridgeStan + Stan toolchain (for Stan sources)
Links
- Docs & examples: https://github.com/pymc-labs/alchemize
- PyPI: https://pypi.org/project/alchemize-ai/
- Blog posts coming soon