Skip to content

Debug a CI crash? #79

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 23 commits into from
Apr 27, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- '1'
- '6' # t>2 might be ignored on Julia <= 1.5
version:
- '1.4'
- '1.5'
- '1' # automatically expands to the latest stable 1.x release of Julia
steps:
- uses: actions/checkout@v2
Expand Down
20 changes: 11 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
name = "Tullio"
uuid = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
authors = ["Michael Abbott"]
version = "0.2.14"
version = "0.3.0"

[deps]
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
CUDA = "1, 2"
CUDA = "2"
CUDAKernels = "0.1"
DiffRules = "1"
FillArrays = "0.10"
FillArrays = "0.10, 0.11"
ForwardDiff = "0.10"
KernelAbstractions = "0.5.2"
LoopVectorization = "0.8.26, 0.9.20"
KernelAbstractions = "0.6"
LoopVectorization = "0.12.12"
NamedDims = "0.2"
OffsetArrays = "1"
Requires = "1"
TensorOperations = "3"
Tracker = "0.2"
VectorizationBase = "0.12.33, 0.15.7"
Zygote = "0.6"
julia = "1.3"
VectorizationBase = "0.19.30"
Zygote = "0.6.9"
julia = "1.5"

[extras]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CUDAKernels = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Expand All @@ -42,4 +44,4 @@ VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Test", "CUDA", "FillArrays", "ForwardDiff", "KernelAbstractions", "LinearAlgebra", "LoopVectorization", "NamedDims", "OffsetArrays", "Printf", "Random", "TensorOperations", "Tracker", "VectorizationBase", "Zygote"]
test = ["Test", "CUDA", "CUDAKernels", "FillArrays", "ForwardDiff", "KernelAbstractions", "LinearAlgebra", "LoopVectorization", "NamedDims", "OffsetArrays", "Printf", "Random", "TensorOperations", "Tracker", "VectorizationBase", "Zygote"]
19 changes: 7 additions & 12 deletions src/eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,13 @@ using Requires

@inline anyone(cond::Bool) = cond

#=

@init @require LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890" begin
using .LoopVectorization
if isdefined(LoopVectorization, :SVec) # version 0.8, for Julia ⩽1.5
using .LoopVectorization.VectorizationBase: SVec, Mask, prevpow2
@require ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" begin
# Dual numbers + svec, not needed on version 0.9
include("grad/avxdual.jl")
end
else # version 0.9, supports Julia 1.6
using .LoopVectorization.VectorizationBase: Vec, Mask, prevpow2
SVec{N,T} = Vec{N,T}
using .LoopVectorization # version 0.9+ only now
using .LoopVectorization.VectorizationBase: Vec, Mask, prevpow2
SVec{N,T} = Vec{N,T}
end
#=
# Functions needed for safe vectorised max gradient
@inline Tullio.onlyone(cond::Bool, seen::SVec) = cond && allzero(seen)

Expand All @@ -75,9 +69,10 @@ using Requires
@inline allzero(seen::SVec) = iszero((!iszero(seen)).u)

@inline Tullio.anyone(cond::Mask) = !iszero(cond.u)
=#
end

=#

#========== CuArrays ==========#

using Requires
Expand Down
2 changes: 1 addition & 1 deletion test/cuda.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using Tullio, Test
using CUDA, KernelAbstractions
using CUDA, CUDAKernels, KernelAbstractions
CUDA.allowscalar(false)
using Tracker, ForwardDiff
@tullio grad=Base
Expand Down
37 changes: 29 additions & 8 deletions test/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file is run several times
=#

using Tullio, Test, ForwardDiff, Random
# using Tracker; _gradient(x...) = Tracker.gradient(x...); GRAD = :Tracker
# using Tracker; _gradient(x...) = Tracker.gradient(x...); GRAD = :Tracker; macro printline() end

function gradtest(f, dims)
x = randn(dims...)
Expand All @@ -16,8 +16,6 @@ end

@testset "simple" begin

if Tullio._GRAD[] != :Dual || VERSION >= v"1.5" # These 3 give errors on Julia 1.4, LV 0.8, I have no idea why.

@test _gradient(x -> sum(@tullio y[i] := 2*x[i]), rand(3))[1] == [2,2,2]
@test _gradient(x -> sum(@tullio y[i] := 2*x[i] + i), rand(3))[1] == [2,2,2]

Expand All @@ -32,7 +30,6 @@ if Tullio._GRAD[] != :Dual || VERSION >= v"1.5" # These 3 give errors on Julia 1
g_fd = ForwardDiff.gradient(x -> sum(sin, g2(x)), r100)
@test g_fd ≈ _gradient(x -> sum(sin, g2(x)), r100)[1]

end
r100 = randn(100)

# scalar output
Expand Down Expand Up @@ -68,6 +65,9 @@ end
@test abs2_grad ≈ _gradient(v -> (@tullio s := abs2(1 + v[i]^2)), va)[1]

end

@printline

@testset "zero-arrays" begin

# Using zero-dim arrays fails on ReverseDiff & Tracker
Expand Down Expand Up @@ -106,6 +106,9 @@ end
# [1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 0.0, 64.0, 81.0, 100.0, 121.0] ≈ [1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0, 81.0, 100.0, 121.0]

end

@printline

@testset "shifts, etc" begin

c1(N,K) = @tullio M[x,y,c] := N[x+i-1, y+j-1,c] * K[i,j]
Expand Down Expand Up @@ -158,6 +161,9 @@ end
end

end

@printline

@testset "from TensorTrace" begin
# These can all be handled using TensorOperations

Expand Down Expand Up @@ -196,6 +202,8 @@ end
con7(x) = @tullio C[m,n,j,i] := 44 * x[i,j,k] * r392[k,m,n]
@test gradtest(con7, (9,2,3))

@printline

## contract! B
con8b(x) = @tullio K[i,j] := 5 * r32[i,k] * x[k,j]
@test gradtest(con8b, (2,3))
Expand All @@ -215,15 +223,19 @@ end
con14(x) = @tullio K[i,j] := r3399[a,b,j,k] * x[b,c,k,i] * r33[a,c]
@test gradtest(con14, (3,3,9,9))

@printline

## scalar -- one with :=, one without
sc1(x) = @tullio s = r22[b,β] * x[a,b,c] * r312[c,a,β]
@test gradtest(sc1, (1,2,3))
sc1(x) = @tullio s = r22[b,β] * x[a,b,c] * r312[c,a,β] avx=false
@test gradtest(sc1, (1,2,3)) # UndefVarError: ####op#798_0 not defined

sc2(x) = @tullio s := x[γ,c] * r3399[c,γ,i,i]
sc2(x) = @tullio s := x[γ,c] * r3399[c,γ,i,i] avx=false
@test gradtest(sc2, (3,3))

end

@printline

if Tullio._GRAD[] != :Dual
#=
@testset "products" begin
Expand Down Expand Up @@ -319,6 +331,9 @@ if Tullio._GRAD[] != :Dual
# I suspect that @avx is re-ordering loops, which makes onlyone() incorrect.

end

@printline

@testset "finalisers" begin

norm2(m) = @tullio n[i] := m[i,j]^2 |> sqrt
Expand All @@ -328,9 +343,11 @@ if Tullio._GRAD[] != :Dual
@test _gradient(sum∘norm2, mat)[1] ≈ ForwardDiff.gradient(sum∘norm2, mat)
@test gradtest(norm2, (3,4))

layer(x) = @tullio y[i,k] := mat[i,j] * x[j,k] |> tanh
layer(x) = @tullio y[i,k] := mat[i,j] * x[j,k] |> tanh avx=false # this takes 15 mins +?
@test gradtest(layer, (3,4))

@printline

lse1(mat) = @tullio lse[j] := log <| exp(mat[i,j])
@test gradtest(lse1, (3,4))

Expand All @@ -344,6 +361,8 @@ if Tullio._GRAD[] != :Dual
end
end

@printline

if GRAD == :Zygote
@testset "nograd keyword" begin

Expand All @@ -358,3 +377,5 @@ if GRAD == :Zygote

end
end

@printline
19 changes: 7 additions & 12 deletions test/group-3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,15 @@ end

@testset "parsing + LoopVectorization" begin include("parsing.jl") end

if test_group != "3" # Github CI fails, on some runs, "ERROR: Package Tullio errored during testing (received signal: KILL)"
# https://github.com/mcabbott/Tullio.jl/pull/57/checks?check_run_id=1753332805

using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Base
@testset "gradients: Tracker + DiffRules + LoopVectorization" begin include("gradients.jl") end
using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Dual
@testset "gradients: Tracker + ForwardDiff + LoopVectorization" begin include("gradients.jl") end
@tullio grad=Base
@testset "gradients: Tracker + DiffRules + LoopVectorization" begin include("gradients.jl") end

end
@tullio grad=Dual
@testset "gradients: Tracker + ForwardDiff + LoopVectorization" begin include("gradients.jl") end

@info @sprintf("LoopVectorization tests took %.1f seconds", time()-t8)

Expand Down
Loading