-
Notifications
You must be signed in to change notification settings - Fork 48
Parallel MCMC via DEER algorithm #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
af1b5a6
d26b5ed
c1d422b
656fd8a
4593dbc
5036586
c041fe9
f19ac33
cce5e53
9a3457c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||||||||||||||||||
| # CLAUDE.md | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| AdvancedHMC.jl is a Julia implementation of advanced Hamiltonian Monte Carlo (HMC) algorithms. It serves as a backend for Turing.jl and can be used directly for flexible MCMC sampling. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Common Commands | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Testing | ||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # Run all core tests | ||||||||||||||||||||||||||||||||||
| julia --project -e 'using Pkg; Pkg.test()' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run specific test group | ||||||||||||||||||||||||||||||||||
| AHMC_TEST_GROUP=AdvancedHMC julia --project test/runtests.jl | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run experimental/research tests | ||||||||||||||||||||||||||||||||||
| AHMC_TEST_GROUP=Experimental julia --project test/runtests.jl | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run downstream Turing.jl integration tests | ||||||||||||||||||||||||||||||||||
| AHMC_TEST_GROUP=Downstream julia --project test/runtests.jl | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Tests use ReTest.jl. Test files are in `test/` and cover: metric, hamiltonian, integrator, trajectory, adaptation, sampler, abstractmcmc, mcmcchains, constructors. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Code Formatting | ||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
| julia -e 'using JuliaFormatter; format(".")' | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
| Uses Blue style (see `.JuliaFormatter.toml`). | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Architecture | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| The library uses a modular, composable design where sampling is built from independent components: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
| Sampler (NUTS/HMC/HMCDA) | ||||||||||||||||||||||||||||||||||
| ↓ | ||||||||||||||||||||||||||||||||||
| Hamiltonian (metric + kinetic energy + log density) | ||||||||||||||||||||||||||||||||||
| ↓ | ||||||||||||||||||||||||||||||||||
| Integrator (Leapfrog variants) | ||||||||||||||||||||||||||||||||||
| ↓ | ||||||||||||||||||||||||||||||||||
| Trajectory (termination criteria + sampling method) | ||||||||||||||||||||||||||||||||||
| ↓ | ||||||||||||||||||||||||||||||||||
| Adaptation (step size + mass matrix) | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Key Source Files | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - `src/metric.jl` - Metric types: `UnitEuclideanMetric`, `DiagEuclideanMetric`, `DenseEuclideanMetric` | ||||||||||||||||||||||||||||||||||
| - `src/hamiltonian.jl` - `Hamiltonian`, `PhasePoint`, `DualValue` (caches value+gradient) | ||||||||||||||||||||||||||||||||||
| - `src/integrator.jl` - `Leapfrog`, `JitteredLeapfrog`, `TemperedLeapfrog` | ||||||||||||||||||||||||||||||||||
| - `src/trajectory.jl` - Termination criteria (`ClassicNoUTurn`, `GeneralisedNoUTurn`, `FixedNSteps`) and trajectory samplers (`EndPointTS`, `SliceTS`, `MultinomialTS`) | ||||||||||||||||||||||||||||||||||
| - `src/adaptation/` - Step size (`NesterovDualAveraging`), mass matrix (`WelfordVar`, `WelfordCov`, `NutpieVar`), composite (`StanHMCAdaptor`, `NaiveHMCAdaptor`) | ||||||||||||||||||||||||||||||||||
| - `src/constructors.jl` - Convenience constructors: `NUTS`, `HMC`, `HMCDA` | ||||||||||||||||||||||||||||||||||
| - `src/abstractmcmc.jl` - AbstractMCMC.jl interface implementation | ||||||||||||||||||||||||||||||||||
| - `src/riemannian/` - Riemannian manifold support with `GeneralizedLeapfrog` | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Extensions (ext/) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Optional features loaded when dependencies are available: | ||||||||||||||||||||||||||||||||||
| - `AdvancedHMCOrdinaryDiffEqExt` - DiffEqIntegrator support | ||||||||||||||||||||||||||||||||||
| - `AdvancedHMCMCMCChainsExt` - MCMCChains.jl integration | ||||||||||||||||||||||||||||||||||
| - `AdvancedHMCCUDAExt` - CUDA array support | ||||||||||||||||||||||||||||||||||
| - `AdvancedHMCComponentArraysExt` - ComponentArrays support | ||||||||||||||||||||||||||||||||||
| - `AdvancedHMCADTypesExt` - ADTypes.jl integration | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+64
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Key Interfaces | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Works with: | ||||||||||||||||||||||||||||||||||
| - `LogDensityProblems.jl` - Define target distributions | ||||||||||||||||||||||||||||||||||
| - `LogDensityProblemsAD.jl` - Automatic differentiation | ||||||||||||||||||||||||||||||||||
| - `AbstractMCMC.jl` - MCMC sampling interface | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+73
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Code Conventions | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Mathematical notation in comments: | ||||||||||||||||||||||||||||||||||
| - `ℓπ` - log density of target distribution | ||||||||||||||||||||||||||||||||||
| - `θ` - position/parameters | ||||||||||||||||||||||||||||||||||
| - `r` - momentum | ||||||||||||||||||||||||||||||||||
| - `z` - phase point (θ, r) | ||||||||||||||||||||||||||||||||||
| - `∂ℓπ∂θ` - gradient of log density | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+80
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶