Skip to content

Commit 4d94f03

Browse files
authored
test: test SimpleChains and Flux as separate projects (#1474)
* test: test SimpleChains and Flux as separate projects * test: fixes * test: move distributed testing deps into a project * chore: run fmt * test: missing test * ci: separate out Flux/SimpleChains and Distributed test group * test: fix tests
1 parent 32b325b commit 4d94f03

19 files changed

+854
-681
lines changed

.buildkite/testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ steps:
3737
- "autodiff"
3838
- "misc"
3939
- "reactant"
40+
- "extras"
4041

4142
# - group: ":julia: (Lux) AMD GPU"
4243
# steps:

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- "autodiff"
4141
- "misc"
4242
- "reactant"
43+
- "extras"
4344
uses: ./.github/workflows/CommonCI.yml
4445
with:
4546
julia_version: ${{ matrix.version }}
@@ -60,6 +61,7 @@ jobs:
6061
- "autodiff"
6162
- "misc"
6263
- "reactant"
64+
- "extras"
6365
uses: ./.github/workflows/CommonCI.yml
6466
with:
6567
julia_version: "1.11"

src/transform/simplechains.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ performed using SimpleChains.
2525
2626
## Example
2727
28-
```jldoctest
28+
```julia
2929
julia> import SimpleChains
3030
3131
julia> using Adapt, Lux, Random

test/Project.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623"
1919
LuxLib = "82251201-b29d-42c6-8e01-566dec8acb11"
2020
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
2121
MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
22-
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
2322
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
2423
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
2524
Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4"
@@ -34,7 +33,6 @@ Reactant = "3c362404-f566-11ee-1572-e11a4b42c853"
3433
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
3534
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
3635
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
37-
SimpleChains = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5"
3836
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
3937
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
4038
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -70,7 +68,6 @@ LuxCore = "1.2"
7068
LuxLib = "1.3.4"
7169
LuxTestUtils = "2"
7270
MLDataDevices = "1.6.10"
73-
MLUtils = "0.4.3"
7471
Mooncake = "0.4.138"
7572
NNlib = "0.9.26"
7673
Octavian = "0.3.28"
@@ -85,7 +82,6 @@ Reactant = "0.2.160"
8582
Reexport = "1.2.2"
8683
ReverseDiff = "1.15.3"
8784
Setfield = "1.1.1"
88-
SimpleChains = "0.4.7"
8985
StableRNGs = "1.0.2"
9086
Static = "1"
9187
StaticArrays = "1.9"

test/distributed/Project.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[deps]
2+
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
3+
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
4+
LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda"
5+
MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
6+
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
7+
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
8+
NCCL = "3fe64909-d7a1-4096-9b7d-7a0f12cf0f6b"
9+
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
10+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
11+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
12+
13+
[sources]
14+
Lux = {path = "../.."}
15+
LuxCUDA = {path = "../../lib/LuxCUDA"}
16+
MLDataDevices = {path = "../../lib/MLDataDevices"}
17+
18+
[compat]
19+
ComponentArrays = "0.15.29"
20+
Lux = "1.21"
21+
LuxCUDA = "0.3.3"
22+
MLDataDevices = "1.12"
23+
MLUtils = "0.4.8"
24+
MPI = "0.20.23"
25+
NCCL = "0.1.1"
26+
Optimisers = "0.4.6"
27+
Pkg = "1.10"
28+
Test = "1.10"
29+

test/distributed/common_distributedtest.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
using Lux, MPI, Test
22

33
const input_args = length(ARGS) == 2 ? ARGS : ("cpu", "mpi")
4+
45
if input_args[1] == "cuda"
5-
using LuxCUDA, NCCL
6+
using LuxCUDA
67
end
78
if input_args[1] == "amdgpu"
89
using AMDGPU
910
end
1011

1112
const backend_type = input_args[2] == "nccl" ? NCCLBackend : MPIBackend
13+
14+
if input_args[1] == "nccl"
15+
using NCCL
16+
end
17+
1218
const dev = if input_args[1] == "cpu"
1319
CPUDevice()
1420
else

test/distributed/data_distributedtest.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ using Lux, MPI, Random, Test
77
using MLUtils
88

99
const input_args = length(ARGS) == 2 ? ARGS : ("cpu", "mpi")
10+
1011
if input_args[1] == "cuda"
11-
using LuxCUDA, NCCL
12+
using LuxCUDA
1213
end
1314
if input_args[1] == "amdgpu"
1415
using AMDGPU
1516
end
1617

1718
const backend_type = input_args[2] == "nccl" ? NCCLBackend : MPIBackend
19+
20+
if input_args[1] == "nccl"
21+
using NCCL
22+
end
23+
1824
const dev = if input_args[1] == "cpu"
1925
CPUDevice()
2026
else
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using MPI, Pkg, Test
2+
3+
nprocs_str = get(ENV, "JULIA_MPI_TEST_NPROCS", "")
4+
nprocs = nprocs_str == "" ? clamp(Sys.CPU_THREADS, 2, 4) : parse(Int, nprocs_str)
5+
6+
testdir = @__DIR__
7+
isdistributedtest(f) = endswith(f, "_distributedtest.jl")
8+
9+
distributedtestfiles = String[]
10+
for (root, dirs, files) in walkdir(testdir)
11+
for file in files
12+
if isdistributedtest(file)
13+
push!(distributedtestfiles, joinpath(root, file))
14+
end
15+
end
16+
end
17+
18+
cur_proj = dirname(Pkg.project().path)
19+
20+
@info "Running Distributed Tests with $nprocs processes"
21+
22+
include("../setup_modes.jl")
23+
24+
@testset "distributed tests: $(mode)" for (mode, aType, dev, ongpu) in MODES
25+
backends = mode == "cuda" ? ("mpi", "nccl") : ("mpi",)
26+
@testset "Backend: $(backend_type)" for backend_type in backends
27+
np = backend_type == "nccl" ? min(nprocs, length(CUDA.devices())) : nprocs
28+
@testset "$(basename(file))" for file in distributedtestfiles
29+
@info "Running $file with $backend_type backend on $mode device"
30+
try
31+
run(`$(MPI.mpiexec()) -n $(np) $(Base.julia_cmd()) --color=yes \
32+
--code-coverage=user --project=$(cur_proj) --startup-file=no \
33+
$(file) $(mode) $(backend_type)`)
34+
@test true
35+
catch
36+
@test false
37+
end
38+
end
39+
end
40+
end

test/distributed/optimizer_distributedtest.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
using Lux, MPI, Optimisers, Random, Test
22

33
const input_args = length(ARGS) == 2 ? ARGS : ("cpu", "mpi")
4+
45
if input_args[1] == "cuda"
5-
using LuxCUDA, NCCL
6+
using LuxCUDA
67
end
78
if input_args[1] == "amdgpu"
89
using AMDGPU
910
end
1011

1112
const backend_type = input_args[2] == "nccl" ? NCCLBackend : MPIBackend
13+
14+
if input_args[1] == "nccl"
15+
using NCCL
16+
end
17+
1218
const dev = if input_args[1] == "cpu"
1319
CPUDevice()
1420
else

test/distributed/synchronize_distributedtest.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
using ComponentArrays, Lux, MPI, Optimisers, Random, Test
22

33
const input_args = length(ARGS) == 2 ? ARGS : ("cpu", "mpi")
4+
45
if input_args[1] == "cuda"
5-
using LuxCUDA, NCCL
6+
using LuxCUDA
67
end
78
if input_args[1] == "amdgpu"
89
using AMDGPU
910
end
1011

1112
const backend_type = input_args[2] == "nccl" ? NCCLBackend : MPIBackend
13+
14+
if input_args[1] == "nccl"
15+
using NCCL
16+
end
17+
1218
const dev = if input_args[1] == "cpu"
1319
CPUDevice()
1420
else

0 commit comments

Comments
 (0)