Skip to content

Commit 10cbe18

Browse files
Revert all changes that deleted tests or disabled doc example runs
Restores: - @example blocks in ad.md and modelingtoolkit.md (were converted to plain julia fences) - Original forward_diff.jl test without try_solve error swallowing - ModelingToolkit, Zygote, Optimization deps in test/Project.toml - Full MTK DAE test (unconditional, no identify_package check) - Removes the split gpu_ode_modelingtoolkit_dae_mtk.jl file Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4797dd2 commit 10cbe18

File tree

6 files changed

+67
-95
lines changed

6 files changed

+67
-95
lines changed

docs/src/examples/ad.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
and thus can be thrown into deep learning training loops. The following is an example
55
of this use:
66

7-
```julia
7+
```@example ad
88
using OrdinaryDiffEq, SciMLSensitivity, Flux, DiffEqGPU, CUDA
99
1010
CUDA.allowscalar(false)
@@ -48,7 +48,7 @@ end
4848
Forward-mode automatic differentiation works as well, as demonstrated by its capability
4949
to recompile for Dual number arithmetic:
5050

51-
```julia
51+
```@example ad
5252
using OrdinaryDiffEq, DiffEqGPU, ForwardDiff, Test
5353
5454
function lorenz(du, u, p, t)

docs/src/tutorials/modelingtoolkit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ u0, p = sym_setter(prob, SVector{3}(rand(Float32, 3)))
7272
Notice it takes in the vector of values for `[σ, ρ, β]` and spits out the new `u0, p`. So
7373
we can build and solve an MTK generated ODE on the GPU using the following:
7474

75-
```julia
75+
```@example mtk
7676
using DiffEqGPU, CUDA
7777
function prob_func2(prob, i, repeat)
7878
u0, p = sym_setter(prob, SVector{3}(rand(Float32, 3)))
@@ -86,6 +86,6 @@ sol = solve(monteprob, GPUTsit5(), EnsembleGPUKernel(CUDA.CUDABackend()),
8686

8787
We can then using symbolic indexing on the result to inspect it:
8888

89-
```julia
89+
```@example mtk
9090
[sol.u[i][y] for i in 1:length(sol.u)]
9191
```

test/Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1010
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
1111
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1314
OpenCL = "08131aa3-fb12-5dee-8b74-c09406e224a2"
15+
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
16+
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
1417
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1518
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1619
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -22,6 +25,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2225
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
2326
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
2427
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
28+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2529
pocl_jll = "627d6b7a-bbe6-5189-83e7-98cc0a5aeadd"
2630

2731
[compat]
@@ -34,12 +38,16 @@ ForwardDiff = "0.10.38, 1"
3438
GPUArraysCore = "0.2"
3539
JLArrays = "0.1, 0.2, 0.3"
3640
KernelAbstractions = "0.9"
41+
ModelingToolkit = "11.17.0"
3742
OpenCL = "0.9, 0.10"
43+
Optimization = "4, 5"
44+
OptimizationOptimisers = "0.3"
3845
OrdinaryDiffEq = "6"
3946
SafeTestsets = "0.1"
4047
SciMLBase = "2.144"
4148
StaticArrays = "1.9"
4249
Statistics = "1"
4350
StochasticDiffEq = "6"
4451
TOML = "1"
52+
Zygote = "0.7.3"
4553
pocl_jll = "6, 7"

test/gpu_kernel_de/forward_diff.jl

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DiffEqGPU, OrdinaryDiffEq, StaticArrays, LinearAlgebra, Test
1+
using DiffEqGPU, OrdinaryDiffEq, StaticArrays, LinearAlgebra
22
include("../utils.jl")
33

44
using ForwardDiff
@@ -32,45 +32,18 @@ prob = ODEProblem{false}(lorenz, u0, tspan, p)
3232
prob_func = (prob, i, repeat) -> remake(prob, p = p)
3333
monteprob = EnsembleProblem(prob, prob_func = prob_func, safetycopy = false)
3434

35-
# NOTE: On some CUDA GPUs (e.g. V100), SVector{3, ForwardDiff.Dual{Nothing, Float32, 6}}
36-
# triggers a misaligned address error (CUDA error code 716) due to the 84-byte element size
37-
# not satisfying GPU memory alignment requirements. This is a CUDA.jl issue, not DiffEqGPU.
38-
# Test that the solve either succeeds or fails with the known alignment error.
39-
function try_solve(monteprob, alg, backend; kwargs...)
40-
try
41-
sol = solve(monteprob, alg, EnsembleGPUKernel(backend, 0.0); kwargs...)
42-
return sol
43-
catch e
44-
if occursin("misaligned address", string(e))
45-
return nothing # Known CUDA alignment issue
46-
else
47-
rethrow(e)
48-
end
49-
end
50-
end
51-
5235
for alg in (
5336
GPUTsit5(), GPUVern7(), GPUVern9(), GPURosenbrock23(autodiff = false),
5437
GPURodas4(autodiff = false), GPURodas5P(autodiff = false),
5538
GPUKvaerno3(autodiff = false), GPUKvaerno5(autodiff = false),
5639
)
5740
@info alg
58-
sol = try_solve(
59-
monteprob, alg, backend,
41+
sol = solve(
42+
monteprob, alg, EnsembleGPUKernel(backend, 0.0),
6043
trajectories = 2, save_everystep = false, adaptive = false, dt = 0.01f0
6144
)
62-
if sol !== nothing
63-
@test length(sol) == 2
64-
else
65-
@test_broken false # Known CUDA alignment issue with ForwardDiff Duals
66-
end
67-
asol = try_solve(
68-
monteprob, alg, backend,
45+
asol = solve(
46+
monteprob, alg, EnsembleGPUKernel(backend, 0.0),
6947
trajectories = 2, adaptive = true, dt = 0.01f0
7048
)
71-
if asol !== nothing
72-
@test length(asol) == 2
73-
else
74-
@test_broken false # Known CUDA alignment issue with ForwardDiff Duals
75-
end
7649
end

test/gpu_kernel_de/stiff_ode/gpu_ode_modelingtoolkit_dae.jl

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using DiffEqGPU, StaticArrays, SciMLBase, LinearAlgebra, Test
2-
using OrdinaryDiffEq
2+
using ModelingToolkit, OrdinaryDiffEq
3+
using ModelingToolkit: t_nounits as t, D_nounits as D
34
using KernelAbstractions: CPU
45

56
const GROUP = get(ENV, "GROUP", "CUDA")
@@ -108,11 +109,52 @@ end
108109
# Test 2: ModelingToolkit cartesian pendulum DAE with initialization
109110
# ============================================================================
110111

111-
# ModelingToolkit is an optional test dependency — skip this test if not available.
112-
# This avoids compat conflicts in the alldeps minimum-version resolution test.
113-
# The MTK test is in a separate file because macros need to be available at parse time.
114-
if Base.identify_package("ModelingToolkit") !== nothing
115-
include("gpu_ode_modelingtoolkit_dae_mtk.jl")
116-
else
117-
@info "ModelingToolkit not available, skipping MTK DAE test"
112+
# NOTE: This test is currently broken because ModelingToolkit problems with initialization
113+
# data contain MTKParameters which use Vector types that cannot be stored inline in CuArrays.
114+
# This is a known limitation: GPU kernels require element types that are allocated inline.
115+
# See: https://github.com/SciML/DiffEqGPU.jl/issues/XXX
116+
# Once MTK supports GPU-compatible parameter storage, this test can be re-enabled.
117+
@testset "MTK Pendulum DAE with initialization" begin
118+
@parameters g = 9.81 L = 1.0
119+
@variables px(t) py(t) [state_priority = 10] (t)
120+
121+
eqs = [
122+
D(D(px)) ~* px / L
123+
D(D(py)) ~* py / L - g
124+
px^2 + py^2 ~ L^2
125+
]
126+
127+
@mtkcompile pendulum = ODESystem(eqs, t, [px, py, pλ], [g, L])
128+
129+
mtk_prob = ODEProblem(
130+
pendulum, [py => 0.99], (0.0, 1.0),
131+
guesses = [pλ => 0.0, px => 0.1, D(px) => 0.0, D(py) => 0.0]
132+
)
133+
134+
# Verify it has initialization data and a mass matrix
135+
@test SciMLBase.has_initialization_data(mtk_prob.f)
136+
@test mtk_prob.f.mass_matrix !== LinearAlgebra.I
137+
138+
# Reference solution with OrdinaryDiffEq
139+
ref_sol = solve(mtk_prob, Rodas5P())
140+
@test ref_sol.retcode == SciMLBase.ReturnCode.Success
141+
142+
# GPU ensemble solve - currently broken due to MTKParameters containing non-inline types
143+
# Skip actual GPU solve test until MTK supports GPU-compatible parameters
144+
if backend isa CPU
145+
monteprob_mtk = EnsembleProblem(mtk_prob, safetycopy = false)
146+
sol_mtk = solve(
147+
monteprob_mtk, GPURodas5P(), EnsembleGPUKernel(backend),
148+
trajectories = 2,
149+
dt = 0.01,
150+
adaptive = false
151+
)
152+
@test length(sol_mtk.u) == 2
153+
@test !any(isnan, sol_mtk.u[1][end])
154+
155+
# GPU solution should be close to reference (fixed step so moderate tolerance)
156+
@test norm(sol_mtk.u[1][end] - ref_sol.u[end]) < 1.0
157+
else
158+
@test_broken false # MTK DAE with initialization not yet supported on GPU
159+
end
118160
end

test/gpu_kernel_de/stiff_ode/gpu_ode_modelingtoolkit_dae_mtk.jl

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)