Skip to content

Commit 3bd4094

Browse files
committed
Clean up the tests
1 parent abce70c commit 3bd4094

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1465
-1533
lines changed

.JuliaFormatter.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ style = "sciml"
22
annotate_untyped_fields_with_any = false
33
format_markdown = true
44
format_docstrings = true
5-
separate_kwargs_with_semicolon = true
5+
separate_kwargs_with_semicolon = true
6+
join_lines_based_on_source = false

.buildkite/pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ steps:
1212
# Don't run Buildkite if the commit message includes the text [skip tests]
1313
if: build.message !~ /\[skip tests\]/
1414
env:
15-
GROUP: GPU
15+
RETESTITEMS_NWORKERS: 4
16+
GROUP: CUDA
1617
DATADEPS_ALWAYS_ACCEPT: 'true'
1718
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts
1819

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- Aqua
2525
version:
2626
- '1'
27-
- '~1.10.0-0'
27+
- '1.10'
2828
steps:
2929
- uses: actions/checkout@v4
3030
- uses: julia-actions/setup-julia@v2
@@ -46,6 +46,7 @@ jobs:
4646
coverage: false
4747
env:
4848
GROUP: ${{ matrix.group }}
49+
RETESTITEMS_NWORKERS: 4
4950
- uses: julia-actions/julia-processcoverage@v1
5051
- uses: codecov/codecov-action@v4
5152
with:

.github/workflows/FormatCheck.yml

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,9 @@
1-
name: format-check
1+
name: Format suggestions
22

3-
on:
4-
push:
5-
branches:
6-
- 'master'
7-
- 'release-'
8-
tags: '*'
9-
pull_request:
3+
on: [pull_request]
104

115
jobs:
12-
build:
13-
runs-on: ${{ matrix.os }}
14-
strategy:
15-
matrix:
16-
julia-version: [1]
17-
julia-arch: [x86]
18-
os: [ubuntu-latest]
6+
code-style:
7+
runs-on: ubuntu-latest
198
steps:
20-
- uses: julia-actions/setup-julia@latest
21-
with:
22-
version: ${{ matrix.julia-version }}
23-
24-
- uses: actions/checkout@v4
25-
- name: Install JuliaFormatter and format
26-
# This will use the latest version by default but you can set the version like so:
27-
#
28-
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29-
run: |
30-
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31-
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32-
- name: Format check
33-
run: |
34-
julia -e '
35-
out = Cmd(`git diff --name-only`) |> read |> String
36-
if out == ""
37-
exit(0)
38-
else
39-
@error "Some files have not been formatted !!!"
40-
write(stdout, out)
41-
exit(1)
42-
end'
9+
- uses: julia-actions/julia-format@v2

Project.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2828
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
2929

3030
[compat]
31-
ADTypes = "0.2, 1"
32-
Adapt = "3, 4"
31+
ADTypes = "1"
32+
Adapt = "4"
3333
ChainRulesCore = "1"
3434
ComponentArrays = "0.15.5"
3535
ConcreteStructs = "0.2"
@@ -38,19 +38,19 @@ Distributions = "0.25"
3838
DistributionsAD = "0.6"
3939
ForwardDiff = "0.10"
4040
Functors = "0.4"
41-
LinearAlgebra = "<0.0.1, 1"
42-
Lux = "0.5.5"
41+
LinearAlgebra = "1.10"
42+
Lux = "0.5.50"
4343
LuxCore = "0.1"
4444
PrecompileTools = "1"
45-
Random = "<0.0.1, 1"
45+
Random = "1.10"
4646
RecursiveArrayTools = "2, 3"
4747
Reexport = "0.2, 1"
4848
SciMLBase = "1, 2"
4949
SciMLSensitivity = "7"
5050
Tracker = "0.2.29"
5151
Zygote = "0.6"
5252
ZygoteRules = "0.2"
53-
julia = "1.9"
53+
julia = "1.10"
5454

5555
[extras]
5656
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
@@ -74,6 +74,7 @@ OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
7474
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
7575
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
7676
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
77+
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
7778
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
7879
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
7980
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
@@ -83,4 +84,4 @@ StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
8384
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8485

8586
[targets]
86-
test = ["Aqua", "BenchmarkTools", "CUDA", "DataInterpolations", "DelayDiffEq", "DiffEqCallbacks", "Distances", "Distributed", "Flux", "LuxCUDA", "MLDataUtils", "MLDatasets", "NLopt", "NNlib", "OneHotArrays", "Optimisers", "Optimization", "OptimizationOptimJL", "OptimizationOptimisers", "OrdinaryDiffEq", "Printf", "RecursiveArrayTools", "ReverseDiff", "SafeTestsets", "StaticArrays", "Statistics", "StochasticDiffEq", "Test"]
87+
test = ["Aqua", "BenchmarkTools", "CUDA", "DataInterpolations", "DelayDiffEq", "DiffEqCallbacks", "Distances", "Distributed", "Flux", "LuxCUDA", "MLDataUtils", "MLDatasets", "NLopt", "NNlib", "OneHotArrays", "Optimisers", "Optimization", "OptimizationOptimJL", "OptimizationOptimisers", "OrdinaryDiffEq", "Printf", "ReTestItems", "RecursiveArrayTools", "ReverseDiff", "SafeTestsets", "StaticArrays", "Statistics", "StochasticDiffEq", "Test"]

docs/make.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ include("pages.jl")
1111

1212
makedocs(; sitename = "DiffEqFlux.jl",
1313
authors = "Chris Rackauckas et al.",
14-
clean = true, doctest = false, linkcheck = true,
14+
clean = true,
15+
doctest = false,
16+
linkcheck = true,
1517
warnonly = [:docs_block, :missing_docs],
1618
modules = [DiffEqFlux],
1719
format = Documenter.HTML(; assets = ["assets/favicon.ico"],
1820
canonical = "https://docs.sciml.ai/DiffEqFlux/stable/"),
1921
pages = pages)
2022

21-
deploydocs(; repo = "github.com/SciML/DiffEqFlux.jl.git",
22-
push_preview = true)
23+
deploydocs(; repo = "github.com/SciML/DiffEqFlux.jl.git", push_preview = true)

docs/pages.jl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
pages = [
22
"DiffEqFlux.jl: High Level Scientific Machine Learning (SciML) Pre-Built Architectures" => "index.md",
3-
"Differential Equation Machine Learning Tutorials" => Any["examples/neural_ode.md",
4-
"examples/GPUs.md",
5-
"examples/mnist_neural_ode.md",
6-
"examples/mnist_conv_neural_ode.md",
7-
"examples/augmented_neural_ode.md",
8-
"examples/neural_sde.md",
9-
"examples/collocation.md",
10-
"examples/normalizing_flows.md",
11-
"examples/hamiltonian_nn.md",
12-
"examples/tensor_layer.md",
13-
"examples/multiple_shooting.md",
14-
"examples//neural_ode_weather_forecast.md"],
3+
"Differential Equation Machine Learning Tutorials" => Any[
4+
"examples/neural_ode.md", "examples/GPUs.md",
5+
"examples/mnist_neural_ode.md", "examples/mnist_conv_neural_ode.md",
6+
"examples/augmented_neural_ode.md", "examples/neural_sde.md",
7+
"examples/collocation.md", "examples/normalizing_flows.md",
8+
"examples/hamiltonian_nn.md", "examples/tensor_layer.md",
9+
"examples/multiple_shooting.md", "examples//neural_ode_weather_forecast.md"],
1510
"Layer APIs" => Any["Classical Basis Layers" => "layers/BasisLayers.md",
1611
"Tensor Product Layer" => "layers/TensorLayer.md",
1712
"Continuous Normalizing Flows Layer" => "layers/CNFLayer.md",
1813
"Spline Layer" => "layers/SplineLayer.md",
1914
"Neural Differential Equation Layers" => "layers/NeuralDELayers.md",
2015
"Hamiltonian Neural Network Layer" => "layers/HamiltonianNN.md"],
2116
"Utility Function APIs" => Any["Smoothed Collocation" => "utilities/Collocation.md",
22-
"Multiple Shooting Functionality" => "utilities/MultipleShooting.md"]
23-
]
17+
"Multiple Shooting Functionality" => "utilities/MultipleShooting.md"]]

docs/src/examples/GPUs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ For a detailed discussion on how GPUs need to be setup refer to
99

1010
```@example gpu
1111
using OrdinaryDiffEq, Lux, LuxCUDA, SciMLSensitivity, ComponentArrays, Random
12-
rng = Random.default_rng()
12+
rng = Xoshiro(0)
1313
1414
const cdev = cpu_device()
1515
const gdev = gpu_device()
@@ -72,14 +72,14 @@ Here is the full neural ODE example. Note that we use the `gpu_device` function
7272
same code works on CPUs and GPUs, dependent on `using LuxCUDA`.
7373

7474
```@example gpu
75-
using Lux, Optimization, OptimizationOptimisers, Zygote, OrdinaryDiffEq,
76-
Plots, LuxCUDA, SciMLSensitivity, Random, ComponentArrays
75+
using Lux, Optimization, OptimizationOptimisers, Zygote, OrdinaryDiffEq, Plots, LuxCUDA,
76+
SciMLSensitivity, Random, ComponentArrays
7777
import DiffEqFlux: NeuralODE
7878
7979
CUDA.allowscalar(false) # Makes sure no slow operations are occurring
8080
8181
#rng for Lux.setup
82-
rng = Random.default_rng()
82+
rng = Xoshiro(0)
8383
# Generate Data
8484
u0 = Float32[2.0; 0.0]
8585
datasize = 30

docs/src/examples/augmented_neural_ode.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ function construct_model(out_dim, input_dim, hidden_dim, augment_dim)
4242
input_dim = input_dim + augment_dim
4343
node = NeuralODE(
4444
Chain(Dense(input_dim, hidden_dim, relu),
45-
Dense(hidden_dim, hidden_dim, relu),
46-
Dense(hidden_dim, input_dim)),
45+
Dense(hidden_dim, hidden_dim, relu), Dense(hidden_dim, input_dim)),
4746
(0.0f0, 1.0f0),
4847
Tsit5();
4948
save_everystep = false,
50-
reltol = 1.0f-3, abstol = 1.0f-3, save_start = false)
49+
reltol = 1.0f-3,
50+
abstol = 1.0f-3,
51+
save_start = false)
5152
node = augment_dim == 0 ? node : AugmentedNDELayer(node, augment_dim)
5253
model = Chain(node, diffeqarray_to_array, Dense(input_dim, out_dim))
53-
ps, st = Lux.setup(Random.default_rng(), model)
54+
ps, st = Lux.setup(Xoshiro(0), model)
5455
return model, ps |> gdev, st |> gdev
5556
end
5657
@@ -70,8 +71,8 @@ end
7071
7172
loss_node(model, x, y, ps, st) = mean((first(model(x, ps, st)) .- y) .^ 2)
7273
73-
dataloader = concentric_sphere(2, (0.0f0, 2.0f0), (3.0f0, 4.0f0), 2000, 2000;
74-
batch_size = 256)
74+
dataloader = concentric_sphere(
75+
2, (0.0f0, 2.0f0), (3.0f0, 4.0f0), 2000, 2000; batch_size = 256)
7576
7677
iter = 0
7778
cb = function (ps, l)
@@ -186,15 +187,16 @@ function construct_model(out_dim, input_dim, hidden_dim, augment_dim)
186187
input_dim = input_dim + augment_dim
187188
node = NeuralODE(
188189
Chain(Dense(input_dim, hidden_dim, relu),
189-
Dense(hidden_dim, hidden_dim, relu),
190-
Dense(hidden_dim, input_dim)),
190+
Dense(hidden_dim, hidden_dim, relu), Dense(hidden_dim, input_dim)),
191191
(0.0f0, 1.0f0),
192192
Tsit5();
193193
save_everystep = false,
194-
reltol = 1.0f-3, abstol = 1.0f-3, save_start = false)
194+
reltol = 1.0f-3,
195+
abstol = 1.0f-3,
196+
save_start = false)
195197
node = augment_dim == 0 ? node : AugmentedNDELayer(node, augment_dim)
196198
model = Chain(node, diffeqarray_to_array, Dense(input_dim, out_dim))
197-
ps, st = Lux.setup(Random.default_rng(), model)
199+
ps, st = Lux.setup(Xoshiro(0), model)
198200
return model, ps |> gdev, st |> gdev
199201
end
200202
```
@@ -236,8 +238,8 @@ Next, we generate the dataset. We restrict ourselves to 2 dimensions as it is ea
236238
We sample a total of `4000` data points.
237239

238240
```@example augneuralode
239-
dataloader = concentric_sphere(2, (0.0f0, 2.0f0), (3.0f0, 4.0f0), 2000, 2000;
240-
batch_size = 256)
241+
dataloader = concentric_sphere(
242+
2, (0.0f0, 2.0f0), (3.0f0, 4.0f0), 2000, 2000; batch_size = 256)
241243
```
242244

243245
#### Callback Function

docs/src/examples/collocation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using ComponentArrays, Lux, DiffEqFlux, OrdinaryDiffEq, SciMLSensitivity, Optimi
1919
OptimizationOptimisers, Plots
2020
2121
using Random
22-
rng = Random.default_rng()
22+
rng = Xoshiro(0)
2323
2424
u0 = Float32[2.0; 0.0]
2525
datasize = 300
@@ -101,11 +101,11 @@ The smoothed collocation is a spline fit of the data points which allows
101101
us to get an estimate of the approximate noiseless dynamics:
102102

103103
```@example collocation
104-
using ComponentArrays,
105-
Lux, DiffEqFlux, Optimization, OptimizationOptimisers, OrdinaryDiffEq, Plots
104+
using ComponentArrays, Lux, DiffEqFlux, Optimization, OptimizationOptimisers,
105+
OrdinaryDiffEq, Plots
106106
107107
using Random
108-
rng = Random.default_rng()
108+
rng = Xoshiro(0)
109109
110110
u0 = Float32[2.0; 0.0]
111111
datasize = 300

docs/src/examples/hamiltonian_nn.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dataloader = ncycle(
3434
NEPOCHS)
3535
3636
hnn = HamiltonianNN(Chain(Dense(2 => 64, relu), Dense(64 => 1)); ad = AutoZygote())
37-
ps, st = Lux.setup(Random.default_rng(), hnn)
37+
ps, st = Lux.setup(Xoshiro(0), hnn)
3838
ps_c = ps |> ComponentArray
3939
4040
opt = OptimizationOptimisers.Adam(0.01f0)
@@ -57,8 +57,8 @@ res = Optimization.solve(opt_prob, opt, dataloader; callback)
5757
5858
ps_trained = res.u
5959
60-
model = NeuralHamiltonianDE(hnn, (0.0f0, 1.0f0), Tsit5(); save_everystep = false,
61-
save_start = true, saveat = t)
60+
model = NeuralHamiltonianDE(
61+
hnn, (0.0f0, 1.0f0), Tsit5(); save_everystep = false, save_start = true, saveat = t)
6262
6363
pred = Array(first(model(data[:, 1], ps_trained, st)))
6464
plot(data[1, :], data[2, :]; lw = 4, label = "Original")
@@ -101,7 +101,7 @@ We parameterize the HamiltonianNN with a small MultiLayered Perceptron. HNNs are
101101

102102
```@example hamiltonian
103103
hnn = HamiltonianNN(Chain(Dense(2 => 64, relu), Dense(64 => 1)); ad = AutoZygote())
104-
ps, st = Lux.setup(Random.default_rng(), hnn)
104+
ps, st = Lux.setup(Xoshiro(0), hnn)
105105
ps_c = ps |> ComponentArray
106106
107107
opt = OptimizationOptimisers.Adam(0.01f0)
@@ -116,8 +116,8 @@ function callback(ps, loss, pred)
116116
return false
117117
end
118118
119-
opt_func = OptimizationFunction((ps, _, data, target) -> loss_function(ps, data, target),
120-
Optimization.AutoZygote())
119+
opt_func = OptimizationFunction(
120+
(ps, _, data, target) -> loss_function(ps, data, target), Optimization.AutoZygote())
121121
opt_prob = OptimizationProblem(opt_func, ps_c)
122122
123123
res = solve(opt_prob, opt, dataloader; callback)
@@ -130,8 +130,8 @@ ps_trained = res.u
130130
In order to visualize the learned trajectories, we need to solve the ODE. We will use the `NeuralHamiltonianDE` layer, which is essentially a wrapper over `HamiltonianNN` layer, and solves the ODE.
131131

132132
```@example hamiltonian
133-
model = NeuralHamiltonianDE(hnn, (0.0f0, 1.0f0), Tsit5(); save_everystep = false,
134-
save_start = true, saveat = t)
133+
model = NeuralHamiltonianDE(
134+
hnn, (0.0f0, 1.0f0), Tsit5(); save_everystep = false, save_start = true, saveat = t)
135135
136136
pred = Array(first(model(data[:, 1], ps_trained, st)))
137137
plot(data[1, :], data[2, :]; lw = 4, label = "Original")

docs/src/examples/mnist_conv_neural_ode.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ For a step-by-step tutorial see the tutorial on the MNIST Neural ODE Classificat
77
using Fully Connected Layers.
88

99
```@example mnist_cnn
10-
using DiffEqFlux, Statistics,
11-
ComponentArrays, CUDA, Zygote, MLDatasets, OrdinaryDiffEq, Printf, Test, LuxCUDA,
12-
Random
10+
using DiffEqFlux, Statistics, ComponentArrays, CUDA, Zygote, MLDatasets, OrdinaryDiffEq,
11+
Printf, Test, LuxCUDA, Random
1312
using Optimization, OptimizationOptimisers
1413
using MLDatasets: MNIST
1514
using MLDataUtils: LabelEnc, convertlabel, stratifiedobs, batchview
@@ -45,8 +44,8 @@ const bs = 128
4544
x_train, y_train = loadmnist(bs)
4645
4746
down = Chain(Conv((3, 3), 1 => 64, relu; stride = 1), GroupNorm(64, 64),
48-
Conv((4, 4), 64 => 64, relu; stride = 2, pad = 1), GroupNorm(64, 64),
49-
Conv((4, 4), 64 => 64; stride = 2, pad = 1))
47+
Conv((4, 4), 64 => 64, relu; stride = 2, pad = 1),
48+
GroupNorm(64, 64), Conv((4, 4), 64 => 64; stride = 2, pad = 1))
5049
5150
dudt = Chain(Conv((3, 3), 64 => 64, tanh; stride = 1, pad = 1),
5251
Conv((3, 3), 64 => 64, tanh; stride = 1, pad = 1))
@@ -66,7 +65,7 @@ m = Chain(down, # (28, 28, 1, BS) -> (6, 6, 64, BS)
6665
nn_ode, # (6, 6, 64, BS) -> (6, 6, 64, BS, 1)
6766
DiffEqArray_to_Array, # (6, 6, 64, BS, 1) -> (6, 6, 64, BS)
6867
fc) # (6, 6, 64, BS) -> (10, BS)
69-
ps, st = Lux.setup(Random.default_rng(), m)
68+
ps, st = Lux.setup(Xoshiro(0), m)
7069
ps = ComponentArray(ps) |> gdev
7170
st = st |> gdev
7271
@@ -105,8 +104,8 @@ loss_function(ps, x_train[1], y_train[1])
105104
opt = OptimizationOptimisers.Adam(0.05)
106105
iter = 0
107106
108-
opt_func = OptimizationFunction((ps, _, x, y) -> loss_function(ps, x, y),
109-
Optimization.AutoZygote())
107+
opt_func = OptimizationFunction(
108+
(ps, _, x, y) -> loss_function(ps, x, y), Optimization.AutoZygote())
110109
opt_prob = OptimizationProblem(opt_func, ps)
111110
112111
function callback(ps, l, pred)

0 commit comments

Comments
 (0)