Skip to content

Commit

Permalink
Merge branch 'main' into compathelper/new_version/2024-09-19-01-00-46…
Browse files Browse the repository at this point in the history
…-351-01475325828
  • Loading branch information
alexandrebouchard authored Nov 8, 2024
2 parents ec31341 + aa92864 commit e0041d9
Show file tree
Hide file tree
Showing 30 changed files with 292 additions and 89 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
30 changes: 16 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@latest
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails
file: lcov.info


# test OpenMPI by requesting it with MPIPreferences
Expand All @@ -71,7 +73,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
- uses: julia-actions/cache@v2
Expand All @@ -85,7 +87,7 @@ jobs:
MPIPreferences.use_jll_binary("OpenMPI_jll")
rm("test/Manifest.toml")
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-runtest@v1


# # CI is getting too slow!
Expand All @@ -98,7 +100,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1'
- '1.10'
os:
- macos-13
mpi:
Expand All @@ -119,7 +121,7 @@ jobs:
distribution: 'temurin'
java-version: '11'

- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}

Expand All @@ -137,7 +139,7 @@ jobs:
run(`sed -i.bu 's/unknown/MPICH/' test/LocalPreferences.toml`) # fix wrong abi detection for mpich
rm("test/Manifest.toml")
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-runtest@v1


docs:
Expand All @@ -151,11 +153,11 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v2
with:
version: '1.9'
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-docdeploy@latest
version: '1.10'
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: ${{ runner.arch }}
Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributing Guide

Thank you for your interest in contributing to Pigeons.jl! There are multiple ways to contribute, and we appreciate all contributions.

## Ways to Contribute

### Bug Reports and Feature Requests

If you are working with Pigeons, and run into a bug, or require additional features, we definitely want to know about it. Please let us know by creating a [GitHub Issue](https://github.com/PigeonsAD/Pigeons.jl/issues).

### How to Submit a Pull Request

If you would like to contribute, please feel free to open a pull request. The pull request should:

- Include a small unit test
- Not contain any unrelated changes
- Be an isolated change. Independent changes should be submitted as separate pull requests as this makes reviewing easier.

## Code of Conduct

As a Julia Project we expect all participants to abide by the [Julia Community Standards](https://julialang.org/community/standards/).

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Pigeons"
uuid = "0eb8d820-af6a-4919-95ae-11206f830c31"
authors = ["Alexandre Bouchard-Côté <[email protected]>, Nikola Surjanovic <[email protected]>, Paul Tiede <[email protected]>, Trevor Campbell, Miguel Biron-Lattes, Saifuddin Syed"]
version = "0.4.5"
version = "0.4.7"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down Expand Up @@ -59,7 +59,7 @@ BridgeStan = "2"
DataFrames = "1"
Distributions = "0.25"
DocStringExtensions = "0.9"
DynamicPPL = "0.23, 0.24, 0.25, 0.26, 0.27, 0.28"
DynamicPPL = "0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.30"
Enzyme = "0.12, 0.13"
Expect = "0.3"
FillArrays = "1"
Expand Down
Binary file added docs/img/alex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/lucas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/miguel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/nikola.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/paul.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/saif.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/son.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/trevor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/william.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/yujia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ InferenceReport.headless() do
"More on distributed PT" => "distributed.md",
"Interfaces" => Pigeons.informal_doc(@__DIR__, Pigeons),
"Reference" => "reference.md",
"About Us" => "about-us.md",
"Google Summer of Code" => "gsoc.md"
],
)
Expand Down
103 changes: 103 additions & 0 deletions docs/src/about-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
```@meta
CurrentModule = Pigeons
```
# [The Pigeons Team - About Us](@id about)

Planning for the Pigeons project started taking place in the summer of 2022.
Since then, we have grown as a team and have added various features to the software.
We still have great ambitions and a swath of features to add; if you would like
to become a part of our team feel free to reach out!

## Team Members (chronological order)

```@raw html
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/alex.png" alt="Alexandre Bouchard-Côté" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Alexandre Bouchard-Côté</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/nikola.jpg" alt="Nikola Surjanovic" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Nikola Surjanovic</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/paul.jpg" alt="Paul Tiede" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Paul Tiede</b>
</br>
Harvard University, Event Horizon Telescope
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/saif.jpg" alt="Saifuddin Syed" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Saifuddin Syed</b>
</br>
University of Oxford
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/trevor.jpg" alt="Trevor Campbell" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Trevor Campbell</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/miguel.jpg" alt="Miguel Biron-Lattes" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Miguel Biron-Lattes</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/william.png" alt="William Thompson" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>William Thompson</b>
</br>
Herzberg Astronomy and Astrophysics Research Centre
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/yujia.jpg" alt="Yujia Ma" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Yujia Ma</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/lucas.jpg" alt="Lucas Wong" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Lucas Wong</b>
</br>
University of British Columbia
</div>
</div>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="https://raw.githubusercontent.com/Julia-Tempering/Pigeons.jl/27ee86b8e0827ba9e7eead6374960ba8673e1006/docs/img/son.jpg" alt="Son Luu" style="width: 100px; height: 100px; border-radius: 50%; margin-right: 20px;">
<div>
<b>Son Luu</b>
</br>
University of British Columbia
</div>
</div>
```
28 changes: 17 additions & 11 deletions ext/PigeonsEnzymeExt/PigeonsEnzymeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,32 @@ else
using ..LogDensityProblemsAD
end

# TODO: currently, the concrete versions of ADGradientWrapper are defined only
# in the extensions of LogDensityProblemsAD. Therefore, it is impossible to
# dispatch on them; see
# https://github.com/tpapp/LogDensityProblemsAD.jl/issues/32
# This is a HACK to extract that type
const EnzymeGradientLogDensity = if isdefined(Base, :get_extension)
Base.get_extension(LogDensityProblemsAD, :LogDensityProblemsADEnzymeExt).EnzymeGradientLogDensity
else
LogDensityProblemsAD.LogDensityProblemsADEnzymeExt.EnzymeGradientLogDensity
# A simpler version of the wrapper defined in LogDensityProblemsAD's extension
struct EnzymeWrapper{TLP} <: Pigeons.ADWrapper
log_potential::TLP
end

# special ADgradient constructor for Enzyme
function LogDensityProblemsAD.ADgradient(
kind::Val{:Enzyme},
log_potential,
buffers::Pigeons.Augmentation
)
d = LogDensityProblems.dimension(log_potential)
buffer = Pigeons.get_buffer(buffers, :gradient_buffer, d)
enclosed = EnzymeWrapper(log_potential)
Pigeons.BufferedAD(enclosed, buffer, nothing, nothing)
end

# adapted from LogDensityProblemsAD to use the Replica's buffer
function LogDensityProblems.logdensity_and_gradient(
b::Pigeons.BufferedAD{<:EnzymeGradientLogDensity},
b::Pigeons.BufferedAD{<:EnzymeWrapper},
x::AbstractVector
)
∂ℓ_∂x = fill!(b.buffer, zero(eltype(b.buffer))) # NB: Enzyme gives erroneous answer if buffer is not zeroed first
_, y = Enzyme.autodiff(
Enzyme.ReverseWithPrimal, LogDensityProblems.logdensity, Enzyme.Active,
Enzyme.Const(b.enclosed.), Enzyme.Duplicated(x, ∂ℓ_∂x)
Enzyme.Const(b.enclosed.log_potential), Enzyme.Duplicated(x, ∂ℓ_∂x)
)
y, ∂ℓ_∂x
end
Expand Down
26 changes: 11 additions & 15 deletions ext/PigeonsForwardDiffExt/PigeonsForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ else
import ..ForwardDiff: DiffResults
end

# TODO: currently, the concrete versions of ADGradientWrapper are defined only
# in the extensions of LogDensityProblemsAD. Therefore, it is impossible to
# dispatch on them; see
# https://github.com/tpapp/LogDensityProblemsAD.jl/issues/32
# This is a HACK to extract that type
const ForwardDiffLogDensity = if isdefined(Base, :get_extension)
Base.get_extension(LogDensityProblemsAD, :LogDensityProblemsADForwardDiffExt).ForwardDiffLogDensity
else
LogDensityProblemsAD.LogDensityProblemsADForwardDiffExt.ForwardDiffLogDensity
# A simpler version of the wrapper defined in LogDensityProblemsAD's extension
struct ForwardDiffWrapper{TLP, TGC <: ForwardDiff.GradientConfig} <: Pigeons.ADWrapper
log_potential::TLP
gradient_config::TGC
end

# special ADgradient constructor for ForwardDiff
Expand All @@ -33,21 +28,22 @@ function LogDensityProblemsAD.ADgradient(
buffers::Pigeons.Augmentation
)
d = LogDensityProblems.dimension(log_potential)
buffer = Pigeons.get_buffer(buffers, :gradient_buffer, d)
enclosed = ADgradient(kind, log_potential; x = buffer)
buffer = Pigeons.get_buffer(buffers, :gradient_buffer, d)
lp_fix = Base.Fix1(LogDensityProblems.logdensity, log_potential)
gradient_config = ForwardDiff.GradientConfig(lp_fix, buffer, ForwardDiff.Chunk(d))
enclosed = ForwardDiffWrapper(log_potential, gradient_config)
diff_result = DiffResults.MutableDiffResult(zero(eltype(buffer)), (buffer, ))
Pigeons.BufferedAD(enclosed, diff_result, nothing, nothing)
end

# adapted from LogDensityProblemsAD to use the Replica's buffer
function LogDensityProblems.logdensity_and_gradient(
b::Pigeons.BufferedAD{<:ForwardDiffLogDensity},
b::Pigeons.BufferedAD{<:ForwardDiffWrapper},
x::AbstractVector
)
diff_result = b.buffer
ℓ_fix = Base.Fix1(LogDensityProblems.logdensity, b.enclosed.ℓ)
ForwardDiff.gradient!(diff_result, ℓ_fix, x, b.enclosed.gradient_config)

lp_fix = Base.Fix1(LogDensityProblems.logdensity, b.enclosed.log_potential)
ForwardDiff.gradient!(diff_result, lp_fix, x, b.enclosed.gradient_config)
return (DiffResults.value(diff_result), DiffResults.gradient(diff_result))
end

Expand Down
Loading

0 comments on commit e0041d9

Please sign in to comment.