$ show pymc-devs/pymc
PyMC is a production-grade Bayesian modeling and probabilistic programming library built on PyTensor. It exposes a model-building API (pm.Model, pm.Normal, pm.sample), automatic log-probability derivation through graph rewriting, MCMC samplers (NUTS, HMC, Metropolis, Slice, DEMetropolis), Sequential Monte Carlo, variational inference (ADVI, FullRankADVI, SVGD), Gaussian processes, ODE support, and data containers (pm.Data, Minibatch). Users construct symbolic random-variable graphs using PyTensor; PyMC rewrites those graphs into measurable IR, computes log-probabilities and transforms, compiles sampling or variational objective functions, and returns posterior traces as xarray/ArviZ DataTree objects. Although the library primarily serves research and statistical workflows, the repository itself is an application/library, not a data-research pipeline. Architecturally, this is a library, not a service: there are no daemons or network endpoints. The entry points are Python APIs in pymc/model/core.py, pymc/sampling/mcmc.py, pymc/distributions/, pymc/step_methods/, and pymc/variational/. The core data flow is model specification -> PyTensor graph -> fgraph_from_model -> logprob rewrites -> compiled sampling functions -> trace backends (ndarray, zarr) -> to_inference_data for posterior analysis. External dependencies include NumPy, SciPy, PyTensor, ArviZ, and optional JAX/BlackJAX/NumPyro, Numba, Zarr, Rich, and Marimo. The codebase has an extensive test suite and CI, with some experimental areas such as pymc.dims and ongoing deprecations. Maintenance is active, with recent commits and rigorous CI. Technical drift is medium: most of the stack tracks current Python, but the Zarr backend is not yet ported to Zarr 3 and several optional integrations carry compatibility shims. Overall craftsmanship is strong but not exceptional: the code is deeply engineered, though its size and internal coupling make individual components less trivially extractable, and some deprecated APIs and experimental modules add friction.
The LLM identified 4 files worth highlighting for reuse:
Collection of numerically stable mathematical helpers for probability computations. Includes logpow for underflow-safe powers, log1mexp-style corrections, bounded parameter checks, and log-space distribution math used across all PyMC distributions. These functions are self-contained PyTensor/NumPy operations that can be lifted into any probabilistic modeling codebase to avoid common precision failures.
A reusable distribution-validation framework built around Domain objects and check_logp, check_logcdf, check_icdf routines. It systematically enumerates parameter domains, compares PyMC results against SciPy or analytical references across float32/float64, and provides RNG and random-draw validation. This is a strong blueprint for validating any new probability distribution or custom logp implementation.
Implements adaptive HMC mass-matrix estimation with online covariance tracking (WeightedCovariance and exponential weighted variance) and multiple potential types (diagonal, full, sparse). The online covariance classes are compact, self-contained streaming-statistics algorithms that can be reused in any adaptive MCMC or online learning system.
Hilbert Space Gaussian Process approximation for stationary kernels, with configurable boundary conditions, power spectral density computation, and linearized prior basis vectors. It turns expensive full-covariance GP inference into a finite basis expansion, a non-obvious numerical technique that can be adapted to other kernel-based models needing scalability.