tpt-augur

Rust

A hardware-accelerated probabilistic programming language — write variables as distributions, not values, and run built-in Bayesian inference (HMC, VI, particle filter, MH) at native speed.

0 stars0 forks0 watchersApache License 2.0
bayesian-inferencecompilerhamiltonian-monte-carlomachine-learningmcmcprobabilistic-programmingprogramming-languageruststatistical-computingvariational-inference

Languages

Rust96.9%Python1.3%JavaScript1.0%TypeScript0.8%
README

TPT Augur

A hardware-accelerated probabilistic programming language.

Augur lets you write variables as probability distributions instead of static values and runs massive parallel posterior sampling at native speed. It compiles a small, distribution-native language down to a typed model and executes it with several built-in Bayesian inference engines.

let mu ~ Normal(0, 1)
observe Normal(mu, 1) = 0.5

The posterior of mu is Normal(0.25, 0.5) — Augur recovers it automatically.

Status

This repository is the compiler, runtime, standard-library, package manifest, and CLI for Augur. It is self-contained and builds with a plain Rust toolchain — no external tpt-gpu checkout is required to use the language or run inference on CPU. Hardware offload, LSP tooling, and TPT-ecosystem integrations (Keystone DB, Locus) are tracked in TODO.md and the design spec.

Features

  • Distribution-native syntaxlet x ~ Normal(0, 1); uncertainty propagates automatically through +, -, *, / and nested calls.
  • Built-in inference engines, selected automatically from model topology or forced with an explicit override:
    • Hamiltonian Monte Carlo (hmc)
    • Mean-field variational inference (vi)
    • Bootstrap particle filter / SMC (pf)
    • Random-walk Metropolis–Hastings (mh)
  • Error-tolerant parser — partially-broken programs still yield a usable parse tree with diagnostics, which powers the formatter and future editor tooling.
  • Type-checker & static analysis — undeclared variables, arity mismatches, and degenerate distribution parameters are caught up front.
  • Mixed deterministic / probabilistic control flow — standard if/else gates observations and priors safely alongside stochastic logic.

Quickstart

# Build the workspace
cargo build --workspace

# Type-check a model
cargo run -p tpt-tpt-augur-cli -- check examples/beta_binomial.augur

# Run inference (engine auto-selected)
cargo run -p tpt-tpt-augur-cli -- run examples/beta_binomial.augur

# Pretty-print / canonicalise a model
cargo run -p tpt-tpt-augur-cli -- fmt examples/beta_binomial.augur

# Read a model from stdin and infer
cargo run -p tpt-tpt-augur-cli -- repl < examples/normal_mean.augur

Language

ConstructMeaning
let name ~ Dist(a, b)A latent random variable with a prior.
let name = exprA deterministic binding (carries the uncertainty of its inputs).
observe Dist(...) = valueA likelihood / conditioning statement.
if cond { ... } else { ... }Deterministic control flow gating enclosed items.

Supported distributions: Normal, HalfNormal, Beta, Gamma, Uniform, Exponential, Binomial, Poisson, Bernoulli.

CLI

CommandDescription
augur run <file>Parse, type-check, and run inference. Flags: -e/--engine, -n/--samples, -c/--chains, --warmup, --seed.
augur check <file>Type-check and report diagnostics without sampling.
augur fmt <file>Emit canonical formatting.
augur replRead a model from stdin and infer with the auto-selected engine.

Workspace layout

CrateRole
compiler/tpt-tpt-augur-frontendLexer, AST, error-tolerant parser, formatter.
compiler/tpt-tpt-augur-irTyped IR: lowering, type-checking, uncertainty propagation.
runtime/tpt-tpt-augur-runtimeInference engines (HMC, VI, PF, MH) and posterior summaries.
stdlib/tpt-tpt-augur-stdConcrete distributions with log-densities and samplers.
pkg/tpt-tpt-augur-pkgAugur package manifest format (Augur.toml).
tools/tpt-tpt-augur-cliThe augur command-line interface.

Examples

See examples/:

  • beta_binomial.augur — Beta–Binomial conjugacy (posterior mean ≈ 0.667).
  • normal_mean.augur — Normal–Normal conjugacy.
  • bayesian_regression.augur — Bayesian linear regression.
  • ar1_timeseries.augur — AR(1) time-series filtering.

Run any of them with cargo run -p tpt-tpt-augur-cli -- run examples/<file>.

Testing

cargo test --workspace

The runtime test suite validates each engine against known closed-form posteriors (Normal–Normal, Beta–Binomial).

License

Dual-licensed under MIT or Apache License 2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.