Skip to content

Commit

Permalink
test: reduce lux groups
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Nov 4, 2024
1 parent 2bff3e4 commit 2ffa2f7
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
style = "blue"
style = "sciml"
whitespace_in_kwargs = false
margin = 92
indent = 4
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ jobs:
- windows-latest
test_group:
- "core_layers"
- "contrib"
- "helpers"
- "distributed"
- "normalize_layers"
- "others"
- "autodiff"
- "recurrent_layers"
- "eltype_match"
- "fluxcompat"
- "autodiff"
- "misc"
- "reactant"
steps:
- uses: actions/checkout@v4
Expand Down
35 changes: 26 additions & 9 deletions .github/workflows/CIPreRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ jobs:
- ubuntu-latest
test_group:
- "core_layers"
- "contrib"
- "helpers"
- "distributed"
- "normalize_layers"
- "others"
- "autodiff"
- "recurrent_layers"
- "eltype_match"
- "fluxcompat"
- "autodiff"
- "misc"
- "reactant"
steps:
- uses: actions/checkout@v4
Expand All @@ -62,8 +57,30 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- name: "Install Dependencies"
run: |
import Pkg
dev_pkgs = Pkg.PackageSpec[]
for pkg in ("lib/LuxCore", "lib/MLDataDevices", "lib/WeightInitializers", "lib/LuxLib",)
push!(dev_pkgs, Pkg.PackageSpec(path=pkg))
end
Pkg.develop(dev_pkgs)
Pkg.Registry.update()
Pkg.instantiate()
Pkg.activate("test")
dev_pkgs = Pkg.PackageSpec[]
for pkg in ("lib/LuxTestUtils", "lib/LuxLib", "lib/MLDataDevices", "lib/LuxCore", ".")
push!(dev_pkgs, Pkg.PackageSpec(path=pkg))
end
Pkg.develop(dev_pkgs)
Pkg.instantiate()
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=. {0}
- name: "Run Tests"
run: |
import Pkg, Lux
dir = dirname(pathof(Lux))
include(joinpath(dir, "../test/runtests.jl"))
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=test {0}
env:
LUX_TEST_GROUP: ${{ matrix.test_group }}
BACKEND_GROUP: "CPU"
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/CI_LuxLib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_group:
- "conv"
- "dense"
- "normalization"
- "misc"
blas_backend:
- "default"
loopvec:
- "true"
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
Expand Down Expand Up @@ -174,9 +164,9 @@ jobs:
include(joinpath(dir, "../test/runtests.jl"))
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=lib/LuxLib/test {0}
env:
LUXLIB_TEST_GROUP: ${{ matrix.test_group }}
LUXLIB_BLAS_BACKEND: ${{ matrix.blas_backend }}
LUXLIB_LOAD_LOOPVEC: ${{ matrix.loopvec }}
LUXLIB_TEST_GROUP: "all"
LUXLIB_BLAS_BACKEND: "default"
LUXLIB_LOAD_LOOPVEC: "true"
- uses: julia-actions/julia-processcoverage@v1
with:
directories: lib/LuxLib/src,lib/LuxLib/ext,lib/LuxCore/src,lib/LuxCore/ext,lib/MLDataDevices/src,lib/MLDataDevices/ext,lib/LuxTestUtils/src
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ DispatchDoctor = "0.4.12"
Enzyme = "0.13.1"
EnzymeCore = "0.8.1"
FastClosures = "0.3.2"
Flux = "0.14.20"
Flux = "0.14.25"
ForwardDiff = "0.10.36"
FunctionWrappers = "1.1.3"
Functors = "0.4.12"
Expand Down
4 changes: 2 additions & 2 deletions test/contrib/debug_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Debugging Tools: DimensionMismatch" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "Debugging Tools: DimensionMismatch" setup=[SharedTestSetup] tags=[:misc] begin
using Logging

rng = StableRNG(12345)
Expand Down Expand Up @@ -43,7 +43,7 @@
end
end

@testitem "Debugging Tools: NaN" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "Debugging Tools: NaN" setup=[SharedTestSetup] tags=[:misc] begin
using Logging, ChainRulesCore
import ChainRulesCore as CRC

Expand Down
4 changes: 2 additions & 2 deletions test/contrib/freeze_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "All Parameter Freezing" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "All Parameter Freezing" setup=[SharedTestSetup] tags=[:misc] begin
rng = StableRNG(12345)

@testset "$mode" for (mode, aType, dev, ongpu) in MODES
Expand Down Expand Up @@ -63,7 +63,7 @@
end
end

@testitem "Partial Freezing" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "Partial Freezing" setup=[SharedTestSetup] tags=[:misc] begin
using Lux.Experimental: FrozenLayer

rng = StableRNG(12345)
Expand Down
2 changes: 1 addition & 1 deletion test/contrib/map_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Layer Map" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "Layer Map" setup=[SharedTestSetup] tags=[:misc] begin
using Setfield, Functors

function occurs_in(kp::KeyPath, x::KeyPath)
Expand Down
2 changes: 1 addition & 1 deletion test/contrib/share_parameters_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Parameter Sharing" setup=[SharedTestSetup] tags=[:contrib] begin
@testitem "Parameter Sharing" setup=[SharedTestSetup] tags=[:misc] begin
rng = StableRNG(12345)

@testset "$mode" for (mode, aType, dev, ongpu) in MODES
Expand Down
6 changes: 4 additions & 2 deletions test/enzyme_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const MODELS_LIST = [
(Chain(Conv((4, 4), 2 => 2; pad=SamePad()), MeanPool((5, 5); pad=SamePad())), rand(Float32, 5, 5, 2, 2)),
(Chain(Conv((3, 3), 2 => 3, relu; pad=SamePad()), MaxPool((2, 2))), rand(Float32, 5, 5, 2, 2)),
(Maxout(() -> Dense(5 => 4, tanh), 3), randn(Float32, 5, 2)),
(Bilinear((2, 2) => 3), randn(Float32, 2, 3)),
# XXX: https://github.com/LuxDL/Lux.jl/issues/1024
# (Bilinear((2, 2) => 3), randn(Float32, 2, 3)),
(SkipConnection(Dense(2 => 2), vcat), randn(Float32, 2, 3)),
(ConvTranspose((3, 3), 3 => 2; stride=2), rand(Float32, 5, 5, 3, 1)),
(StatefulRecurrentCell(RNNCell(3 => 5)), rand(Float32, 3, 2)),
Expand All @@ -61,7 +62,8 @@ const MODELS_LIST = [
(Chain(Dense(2, 4), GroupNorm(4, 2)), randn(Float32, 2, 3)),
(Chain(Conv((3, 3), 2 => 6), GroupNorm(6, 3)), randn(Float32, 6, 6, 2, 2)),
(Chain(Conv((3, 3), 2 => 6, tanh), GroupNorm(6, 3)), randn(Float32, 6, 6, 2, 2)),
(Chain(Conv((3, 3), 2 => 3, gelu), LayerNorm((1, 1, 3))), randn(Float32, 4, 4, 2, 2)),
# XXX: Recent Enzyme release breaks this
# (Chain(Conv((3, 3), 2 => 3, gelu), LayerNorm((1, 1, 3))), randn(Float32, 4, 4, 2, 2)),
(Chain(Conv((3, 3), 2 => 6), InstanceNorm(6)), randn(Float32, 6, 6, 2, 2)),
(Chain(Conv((3, 3), 2 => 6, tanh), InstanceNorm(6)), randn(Float32, 6, 6, 2, 2)),
]
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/compact_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "@compact" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "@compact" setup=[SharedTestSetup] tags=[:misc] begin
using ComponentArrays, Zygote

rng = StableRNG(12345)
Expand Down Expand Up @@ -439,7 +439,7 @@
end
end

@testitem "@compact error checks" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "@compact error checks" setup=[SharedTestSetup] tags=[:misc] begin
showerror(stdout, Lux.LuxCompactModelParsingException(""))
println()

Expand Down
10 changes: 5 additions & 5 deletions test/helpers/loss_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "LuxOps.xlogx & LuxOps.xlogy" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "LuxOps.xlogx & LuxOps.xlogy" setup=[SharedTestSetup] tags=[:misc] begin
using ForwardDiff, Zygote, Enzyme

@test iszero(LuxOps.xlogx(0))
Expand Down Expand Up @@ -55,7 +55,7 @@
end
end

@testitem "Regression Loss" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Regression Loss" setup=[SharedTestSetup] tags=[:misc] begin
using Zygote

@testset "$mode" for (mode, aType, dev, ongpu) in MODES
Expand Down Expand Up @@ -99,7 +99,7 @@ end
end
end

@testitem "Classification Loss" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Classification Loss" setup=[SharedTestSetup] tags=[:misc] begin
using OneHotArrays, Zygote

@testset "$mode" for (mode, aType, dev, ongpu) in MODES
Expand Down Expand Up @@ -283,7 +283,7 @@ end
end
end

@testitem "Other Losses" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Other Losses" setup=[SharedTestSetup] tags=[:misc] begin
using Zygote

@testset "$mode" for (mode, aType, dev, ongpu) in MODES
Expand Down Expand Up @@ -404,7 +404,7 @@ end
end
end

@testitem "Losses: Error Checks and Misc" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Losses: Error Checks and Misc" setup=[SharedTestSetup] tags=[:misc] begin
@testset "Size Checks" begin
@test_throws DimensionMismatch MSELoss()([1, 2], [1, 2, 3])
end
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/size_propagator_test.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Size Propagator" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Size Propagator" setup=[SharedTestSetup] tags=[:misc] begin
rng = StableRNG(12345)

@testset "Simple Chain (LeNet)" begin
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/size_propagator_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Size Propagator" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Size Propagator" setup=[SharedTestSetup] tags=[:misc] begin
rng = StableRNG(12345)

@testset "Simple Chain (LeNet)" begin
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/stateful_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Simple Stateful Tests" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Simple Stateful Tests" setup=[SharedTestSetup] tags=[:misc] begin
using Setfield, Zygote

rng = StableRNG(12345)
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/training_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "TrainState" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "TrainState" setup=[SharedTestSetup] tags=[:misc] begin
using Optimisers

rng = StableRNG(12345)
Expand All @@ -19,7 +19,7 @@
end
end

@testitem "AbstractADTypes" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "AbstractADTypes" setup=[SharedTestSetup] tags=[:misc] begin
using ADTypes, Optimisers

function _loss_function(model, ps, st, data)
Expand Down Expand Up @@ -50,7 +50,7 @@ end
end
end

@testitem "Training API" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Training API" setup=[SharedTestSetup] tags=[:misc] begin
using ADTypes, Optimisers

mse = MSELoss()
Expand Down Expand Up @@ -125,7 +125,7 @@ end
end
end

@testitem "Enzyme: Invalidate Cache on State Update" setup=[SharedTestSetup] tags=[:helpers] skip=:(using LuxTestUtils; !LuxTestUtils.ENZYME_TESTING_ENABLED) begin
@testitem "Enzyme: Invalidate Cache on State Update" setup=[SharedTestSetup] tags=[:misc] skip=:(using LuxTestUtils; !LuxTestUtils.ENZYME_TESTING_ENABLED) begin
using ADTypes, Optimisers

mse = MSELoss()
Expand Down Expand Up @@ -196,7 +196,7 @@ end
@test hasfield(typeof(tstate_new2.cache.extras), :reverse)
end

@testitem "Compiled ReverseDiff" setup=[SharedTestSetup] tags=[:helpers] begin
@testitem "Compiled ReverseDiff" setup=[SharedTestSetup] tags=[:misc] begin
using ADTypes, Optimisers, ReverseDiff

mse1 = MSELoss()
Expand Down
18 changes: 12 additions & 6 deletions test/layers/basic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ end
@jet layer(x, ps, st)

__f = (x, ps) -> sum(first(layer(x, ps, st)))
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])

d = Dense(2 => 2)
display(d)
Expand All @@ -291,7 +292,8 @@ end
@jet layer(x, ps, st)

__f = (x, ps) -> sum(first(layer(x, ps, st)))
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])

d = Dense(2 => 3)
display(d)
Expand All @@ -307,7 +309,8 @@ end
@jet layer(x, ps, st)

__f = (x, ps) -> sum(first(layer(x, ps, st)))
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])
end

@testset "Two-streams zero sum" begin
Expand All @@ -325,7 +328,8 @@ end
@jet layer((x, y), ps, st)

__f = (x, y, ps) -> sum(first(layer((x, y), ps, st)))
@test_gradients(__f, x, y, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, y, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])
end

@testset "Inner interactions" begin
Expand All @@ -339,7 +343,8 @@ end
@jet layer(x, ps, st)

__f = (x, ps) -> sum(first(layer(x, ps, st)))
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])

x = randn(Float32, 2, 1) |> aType
layer = Bilinear(2 => 3)
Expand All @@ -351,7 +356,8 @@ end
@jet layer(x, ps, st)

__f = (x, ps) -> sum(first(layer(x, ps, st)))
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3)
@test_gradients(__f, x, ps; atol=1.0f-3, rtol=1.0f-3,
skip_backends=[AutoEnzyme()])
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/qa_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Aqua: Quality Assurance" tags=[:others] begin
@testitem "Aqua: Quality Assurance" tags=[:misc] begin
using Aqua, ChainRulesCore, ForwardDiff

Aqua.test_all(Lux; ambiguities=false, piracies=false)
Expand All @@ -10,7 +10,7 @@
Aqua.test_piracies(Lux; treat_as_own=[Lux.outputsize])
end

@testitem "Explicit Imports: Quality Assurance" tags=[:others] begin
@testitem "Explicit Imports: Quality Assurance" tags=[:misc] begin
# Load all trigger packages
import Lux, ComponentArrays, ReverseDiff, SimpleChains, Tracker, Zygote, Enzyme
using ExplicitImports
Expand All @@ -30,7 +30,7 @@ end
end

# Some of the tests are flaky on prereleases
@testitem "doctests: Quality Assurance" tags=[:others] begin
@testitem "doctests: Quality Assurance" tags=[:misc] begin
using Documenter

doctestexpr = quote
Expand Down
Loading

0 comments on commit 2ffa2f7

Please sign in to comment.