-
Notifications
You must be signed in to change notification settings - Fork 39
Refactor CI #406
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
Open
penelopeysm
wants to merge
23
commits into
main
Choose a base branch
from
py/tests2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor CI #406
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
117b8e8
Remove test_ad calls from interface tests
penelopeysm d0e6a6f
remove dead code
penelopeysm fb6d71c
don't remove that
penelopeysm b020f9e
Remove macOS from CI
penelopeysm cd4e62f
fix AD
penelopeysm 78f3ef9
Refactor AD tests
penelopeysm 982d19b
add doctests, fix other things
penelopeysm 1b9964a
fix
penelopeysm 4f1004c
format
penelopeysm 481c5ca
Disable failing Enzyme rule tests
penelopeysm eb4bdfb
Re-enable Enzyme tests
penelopeysm 1400d75
format
penelopeysm c993dfb
separate mooncake rule test into its own thing
penelopeysm ef21f50
Skip broken Enzyme tests
penelopeysm e81001e
add macOS and windows test
penelopeysm d67f0c0
format
penelopeysm 28d0ca8
flows only fail on 1.11 apparently
penelopeysm a7852b6
comment
penelopeysm a86b716
Use new DI patch
penelopeysm 098ef8d
Merge branch 'main' into py/tests2
penelopeysm ce870f7
Fix Enzyme tests again
penelopeysm ba4db0e
Merge branch 'main' into py/tests2
penelopeysm 1d8e224
fix merge
penelopeysm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# We want to only run doctests on a single version of Julia, because | ||
# things like error messages / output can change between versions and | ||
# is fragile to test against. | ||
name: Doctests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
# needed to allow julia-actions/cache to delete old caches that it has created | ||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
# Cancel existing tests on the same PR if a new commit is added to a pull request | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: julia-actions/setup-julia@v2 | ||
with: | ||
version: '1' | ||
|
||
- uses: julia-actions/cache@v2 | ||
|
||
- uses: julia-actions/julia-buildpkg@v1 | ||
|
||
- uses: julia-actions/julia-runtest@v1 | ||
env: | ||
GROUP: Doctests |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
using Random: Xoshiro | ||
module BijectorsChainRulesTests | ||
|
||
using Bijectors | ||
using LinearAlgebra | ||
using ChainRulesTestUtils: ChainRulesCore | ||
using ChainRulesTestUtils: ChainRulesCore, test_frule, test_rrule, ⊢, ChainRulesTestUtils | ||
using FiniteDifferences: FiniteDifferences | ||
using Random: Xoshiro | ||
using Test | ||
|
||
# HACK: This is a workaround to test `Bijectors._inv_link_chol_lkj` which produces an | ||
# upper-triangular `Matrix`, leading to `test_rrule` comaring the _full_ `Matrix`, | ||
|
@@ -29,42 +34,6 @@ end | |
test_frule(Bijectors.find_alpha, x, y, z) | ||
test_rrule(Bijectors.find_alpha, x, y, z) | ||
|
||
if @isdefined Mooncake | ||
rng = Xoshiro(123456) | ||
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. moved to |
||
@testset "$mode" for mode in (Mooncake.ReverseMode, Mooncake.ForwardMode) | ||
Mooncake.TestUtils.test_rule( | ||
rng, | ||
Bijectors.find_alpha, | ||
x, | ||
y, | ||
z; | ||
is_primitive=true, | ||
perf_flag=:none, | ||
mode=mode, | ||
) | ||
Mooncake.TestUtils.test_rule( | ||
rng, | ||
Bijectors.find_alpha, | ||
x, | ||
y, | ||
3; | ||
is_primitive=true, | ||
perf_flag=:none, | ||
mode=mode, | ||
) | ||
Mooncake.TestUtils.test_rule( | ||
rng, | ||
Bijectors.find_alpha, | ||
x, | ||
y, | ||
UInt32(3); | ||
is_primitive=true, | ||
perf_flag=:none, | ||
mode=mode, | ||
) | ||
end | ||
end | ||
|
||
test_rrule( | ||
Bijectors.combine, | ||
Bijectors.PartitionMask(3, [1], [2]) ⊢ ChainRulesTestUtils.NoTangent(), | ||
|
@@ -182,3 +151,5 @@ end | |
end | ||
end | ||
end | ||
|
||
end # module BijectorsChainRulesTests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
@testset "AD for VecCorrBijector" begin | ||
d = 4 | ||
dist = LKJ(d, 2.0) | ||
b = bijector(dist) | ||
binv = inverse(b) | ||
using Enzyme: ForwardMode | ||
|
||
x = rand(dist) | ||
y = b(x) | ||
@testset "VecCorrBijector: $backend_name" for (backend_name, adtype) in TEST_ADTYPES | ||
@testset "d = $d" for d in (1, 2, 4) | ||
dist = LKJ(d, 2.0) | ||
b = bijector(dist) | ||
binv = inverse(b) | ||
|
||
test_ad(y) do x | ||
sum(transform(b, binv(x))) | ||
end | ||
x = rand(dist) | ||
y = b(x) | ||
|
||
test_ad(y) do y | ||
sum(transform(binv, y)) | ||
# roundtrip | ||
test_ad(y -> sum(transform(b, binv(y))), adtype, y) | ||
# inverse only | ||
test_ad(y -> sum(transform(binv, y)), adtype, y) | ||
end | ||
end | ||
|
||
@testset "AD for VecCholeskyBijector" begin | ||
d = 4 | ||
dist = LKJCholesky(d, 2.0) | ||
b = bijector(dist) | ||
binv = inverse(b) | ||
|
||
x = rand(dist) | ||
y = b(x) | ||
@testset "VecCholeskyBijector: $backend_name" for (backend_name, adtype) in TEST_ADTYPES | ||
@testset "d = $d, uplo = $uplo" for d in (1, 2, 4), uplo in ('U', 'L') | ||
dist = LKJCholesky(d, 2.0, uplo) | ||
b = bijector(dist) | ||
binv = inverse(b) | ||
|
||
test_ad(y) do y | ||
sum(transform(b, binv(y))) | ||
end | ||
x = rand(dist) | ||
y = b(x) | ||
cholesky_to_triangular = | ||
uplo == 'U' ? Bijectors.cholesky_upper : Bijectors.cholesky_lower | ||
|
||
test_ad(y) do y | ||
sum(Bijectors.cholesky_upper(transform(binv, y))) | ||
# roundtrip | ||
test_ad(y -> sum(transform(b, binv(y))), adtype, y) | ||
# inverse (we need to tack on `cholesky_upper`/`cholesky_lower`, | ||
# because directly calling `sum` on a LinearAlgebra.Cholesky doesn't | ||
# give a scalar) | ||
test_ad(y -> sum(cholesky_to_triangular(transform(binv, y))), adtype, y) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,60 @@ | ||
@testset "Enzyme: Bijectors.find_alpha" begin | ||
x = randn() | ||
y = expm1(randn()) | ||
z = randn() | ||
|
||
@testset "forward" begin | ||
# No batches | ||
@testset for RT in (Const, Duplicated, DuplicatedNoNeed), | ||
Tx in (Const, Duplicated), | ||
Ty in (Const, Duplicated), | ||
Tz in (Const, Duplicated) | ||
|
||
# Rule not picked up by Enzyme on Julia 1.11?! | ||
# Ref https://github.com/TuringLang/Bijectors.jl/pull/350#issuecomment-2470766968 | ||
if VERSION >= v"1.11" && Tx <: Const && Ty <: Const && Tz <: Const | ||
continue | ||
module BijectorsEnzymeRulesTests | ||
|
||
using Bijectors | ||
using Enzyme | ||
using EnzymeTestUtils: test_forward, test_reverse | ||
using Test | ||
|
||
# This entire test suite is broken on 1.11. | ||
# | ||
# https://github.com/EnzymeAD/Enzyme.jl/issues/2121 | ||
# https://github.com/TuringLang/Bijectors.jl/pull/350#issuecomment-2470766968 | ||
# | ||
# Ideally we'd use `@test_throws`. However, that doesn't work because | ||
# `test_forward` itself calls `@test`, and the error is captured by that | ||
# `@test`, not our `@test_throws`. Consequently `@test_throws` doesn't actually | ||
# see any error. Weird Julia behaviour. | ||
|
||
@static if VERSION < v"1.11" | ||
@testset "Enzyme: Bijectors.find_alpha" begin | ||
x = randn() | ||
y = expm1(randn()) | ||
z = randn() | ||
|
||
@testset "forward" begin | ||
# No batches | ||
@testset for RT in (Const, Duplicated, DuplicatedNoNeed), | ||
Tx in (Const, Duplicated), | ||
Ty in (Const, Duplicated), | ||
Tz in (Const, Duplicated) | ||
|
||
test_forward(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
end | ||
|
||
test_forward(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
end | ||
|
||
# Batches | ||
@testset for RT in (Const, BatchDuplicated, BatchDuplicatedNoNeed), | ||
Tx in (Const, BatchDuplicated), | ||
Ty in (Const, BatchDuplicated), | ||
Tz in (Const, BatchDuplicated) | ||
# Batches | ||
@testset for RT in (Const, BatchDuplicated, BatchDuplicatedNoNeed), | ||
Tx in (Const, BatchDuplicated), | ||
Ty in (Const, BatchDuplicated), | ||
Tz in (Const, BatchDuplicated) | ||
|
||
# Rule not picked up by Enzyme on Julia 1.11?! | ||
# Ref https://github.com/TuringLang/Bijectors.jl/pull/350#issuecomment-2470766968 | ||
if VERSION >= v"1.11" && Tx <: Const && Ty <: Const && Tz <: Const | ||
continue | ||
test_forward(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
end | ||
end | ||
@testset "reverse" begin | ||
# No batches | ||
@testset for RT in (Const, Active), | ||
Tx in (Const, Active), | ||
Ty in (Const, Active), | ||
Tz in (Const, Active) | ||
|
||
test_reverse(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
end | ||
|
||
test_forward(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
# TODO: Test batch mode | ||
# This is a bit problematic since Enzyme does not support all combinations of activities currently | ||
# https://github.com/TuringLang/Bijectors.jl/pull/350#issuecomment-2480468728 | ||
end | ||
end | ||
@testset "reverse" begin | ||
# No batches | ||
@testset for RT in (Const, Active), | ||
Tx in (Const, Active), | ||
Ty in (Const, Active), | ||
Tz in (Const, Active) | ||
|
||
test_reverse(Bijectors.find_alpha, RT, (x, Tx), (y, Ty), (z, Tz)) | ||
end | ||
end | ||
|
||
# TODO: Test batch mode | ||
# This is a bit problematic since Enzyme does not support all combinations of activities currently | ||
# https://github.com/TuringLang/Bijectors.jl/pull/350#issuecomment-2480468728 | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a replacement for
strict=false
which no longer works with Documenter.jl v1.0. It converts all docs errors into warnings. This is not good, but I didn't want fix this in this PR as well, it should be a separate PR.