Skip to content

Mark tests broken based on nightly #87

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

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.7' # Lowest claimed support in Project.toml
Copy link
Member Author

@mcabbott mcabbott Aug 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failures on 1.8 look like this, so perhaps it should run on 1.7 too:

┌ Warning: ir verification broken. Either use 1.9 or 1.7
└ @ Diffractor ~/work/Diffractor.jl/Diffractor.jl/src/stage1/recurse.jl:889
┌ Warning: ir verification broken. Either use 1.9 or 1.7
└ @ Diffractor ~/work/Diffractor.jl/Diffractor.jl/src/stage1/recurse.jl:889
Error During Test at /home/runner/work/Diffractor.jl/Diffractor.jl/test/runtests.jl:23
  Test threw exception
  Expression: tup2(my_tuple) == (ZeroTangent(), 4)
  task switch not allowed from inside staged nor pure functions
  Stacktrace:
    [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
      @ Base ./task.jl:861
    [2] wait()
      @ Base ./task.jl:931
    [3] uv_write(s::Base.PipeEndpoint, p::Ptr{UInt8}, n::UInt64)
      @ Base ./stream.jl:1043

- '1' # Latest Release
- 'nightly'
os:
Expand Down
6 changes: 3 additions & 3 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ChainRules = "1.5"
ChainRulesCore = "1.2"
ChainRules = "1.44.5"
ChainRulesCore = "1.15.3"
Combinatorics = "1"
StaticArrays = "1"
StatsBase = "0.33"
StructArrays = "0.6"
StructArrays = "0.6.12"
julia = "1.7"
33 changes: 22 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ using ChainRulesCore
using ChainRulesCore: ZeroTangent, NoTangent, frule_via_ad, rrule_via_ad
using Symbolics
using LinearAlgebra

using Test

const fwd = Diffractor.PrimeDerivativeFwd
const bwd = Diffractor.PrimeDerivativeBack

@testset verbose=true "Diffractor.jl" begin # overall testset, ensures all tests run

# Unit tests
function tup2(f)
a, b = ∂⃖{2}()(f, 1)
Expand Down Expand Up @@ -88,9 +92,9 @@ let var"'" = Diffractor.PrimeDerivativeBack
@test @inferred(sin'(1.0)) == cos(1.0)
@test @inferred(sin''(1.0)) == -sin(1.0)
@test sin'''(1.0) == -cos(1.0)
@test sin''''(1.0) == sin(1.0)
@test sin'''''(1.0) == cos(1.0)
@test sin''''''(1.0) == -sin(1.0)
@test sin''''(1.0) == sin(1.0) broken = VERSION >= v"1.8"
@test sin'''''(1.0) == cos(1.0) broken = VERSION >= v"1.8"
@test sin''''''(1.0) == -sin(1.0) broken = VERSION >= v"1.8"

f_getfield(x) = getfield((x,), 1)
@test f_getfield'(1) == 1
Expand All @@ -101,9 +105,9 @@ let var"'" = Diffractor.PrimeDerivativeBack

complicated_2sin(x) = (x = map(sin, Diffractor.xfill(x, 2)); x[1] + x[2])
@test @inferred(complicated_2sin'(1.0)) == 2sin'(1.0)
@test @inferred(complicated_2sin''(1.0)) == 2sin''(1.0)
@test @inferred(complicated_2sin'''(1.0)) == 2sin'''(1.0)
@test @inferred(complicated_2sin''''(1.0)) == 2sin''''(1.0)
@test @inferred(complicated_2sin''(1.0)) == 2sin''(1.0) broken=true
@test @inferred(complicated_2sin'''(1.0)) == 2sin'''(1.0) broken=true
@test @inferred(complicated_2sin''''(1.0)) == 2sin''''(1.0) broken=true

# Control flow cases
@test @inferred((x->simple_control_flow(true, x))'(1.0)) == sin'(1.0)
Expand Down Expand Up @@ -149,9 +153,6 @@ end
# Regression tests
@test gradient(x -> sum(abs2, x .+ 1.0), zeros(3))[1] == [2.0, 2.0, 2.0]

const fwd = Diffractor.PrimeDerivativeFwd
const bwd = Diffractor.PrimeDerivativeBack

function f_broadcast(a)
l = a / 2.0 * [[0. 1. 1.]; [1. 0. 1.]; [1. 1. 0.]]
return sum(l)
Expand All @@ -161,7 +162,15 @@ end
# Make sure that there's no infinite recursion in kwarg calls
g_kw(;x=1.0) = sin(x)
f_kw(x) = g_kw(;x)
@test bwd(f_kw)(1.0) == bwd(sin)(1.0)
@test bwd(f_kw)(1.0) == bwd(sin)(1.0) broken=true
#=
MethodError: no method matching +(::Tangent{var"#g_kw#47"{var"#g_kw#11#48"}, NamedTuple{(Symbol("#g_kw#11"),), Tuple{ZeroTangent}}}, ::Tangent{Diffractor.KwFunc{var"#g_kw#47"{var"#g_kw#11#48"}, var"#g_kw#47##kw"}, NamedTuple{(:kwf,), Tuple{ZeroTangent}}})
...
[2] elementwise_add(a::NamedTuple{(:contents,), Tuple{Tangent{var"#g_kw#47"{var"#g_kw#11#48"}, NamedTuple{(Symbol("#g_kw#11"),), Tuple{ZeroTangent}}}}}, b::NamedTuple{(:contents,), Tuple{Tangent{Diffractor.KwFunc{var"#g_kw#47"{var"#g_kw#11#48"}, var"#g_kw#47##kw"}, NamedTuple{(:kwf,), Tuple{ZeroTangent}}}}})
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:287
[3] +(a::Tangent{Core.Box, NamedTuple{(:contents,), Tuple{Tangent{var"#g_kw#47"{var"#g_kw#11#48"}, NamedTuple{(Symbol("#g_kw#11"),), Tuple{ZeroTangent}}}}}}, b::Tangent{Core.Box, NamedTuple{(:contents,), Tuple{Tangent{Diffractor.KwFunc{var"#g_kw#47"{var"#g_kw#11#48"}, var"#g_kw#47##kw"}, NamedTuple{(:kwf,), Tuple{ZeroTangent}}}}}})
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/ctmSK/src/tangent_arithmetic.jl:130
=#

function f_crit_edge(a, b, c, x)
# A function with two critical edges. This used to trigger an issue where
Expand Down Expand Up @@ -220,3 +229,5 @@ z45, delta45 = frule_via_ad(DiffractorRuleConfig(), (0,1), x -> log(exp(x)), 2)

# Higher order control flow not yet supported (https://github.com/JuliaDiff/Diffractor.jl/issues/24)
#include("pinn.jl")

end # overall testset