This repository was archived by the owner on May 15, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: update to new DI.jl #160
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,77 @@ | ||
@testitem "Solving on GPUs" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) begin | ||
@testitem "Solving on GPUs" tags=[:cuda] begin | ||
using StaticArrays, CUDA | ||
|
||
CUDA.allowscalar(false) | ||
if CUDA.functional() | ||
CUDA.allowscalar(false) | ||
|
||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
|
||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
# Static Arrays | ||
u0 = @SVector[1.0f0, 1.0f0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
# Static Arrays | ||
u0 = @SVector[1.0f0, 1.0f0] | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays Inplace | ||
if !(alg isa SimpleHalley) | ||
# Regular Arrays | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{true}(f!, u0) | ||
probN = NonlinearProblem{false}(f, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
|
||
# Regular Arrays Inplace | ||
if !(alg isa SimpleHalley) | ||
u0 = [1.0, 1.0] | ||
probN = NonlinearProblem{true}(f!, u0) | ||
sol = solve(probN, alg; abstol = 1.0f-6) | ||
@test SciMLBase.successful_retcode(sol) | ||
@test maximum(abs, sol.resid) ≤ 1.0f-6 | ||
end | ||
end | ||
end | ||
end | ||
|
||
@testitem "CUDA Kernel Launch Test" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) timeout=3600 begin | ||
@testitem "CUDA Kernel Launch Test" tags=[:cuda] begin | ||
using StaticArrays, CUDA | ||
|
||
CUDA.allowscalar(false) | ||
if CUDA.functional() | ||
CUDA.allowscalar(false) | ||
|
||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
f(u, p) = u .* u .- 2 | ||
f!(du, u, p) = du .= u .* u .- 2 | ||
|
||
function kernel_function(prob, alg) | ||
solve(prob, alg) | ||
return nothing | ||
end | ||
function kernel_function(prob, alg) | ||
solve(prob, alg) | ||
return nothing | ||
end | ||
|
||
prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) | ||
prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) | ||
prob = NonlinearProblem{false}(f, @SVector[1.0f0, 1.0f0]) | ||
prob = convert(SimpleNonlinearSolve.ImmutableNonlinearProblem, prob) | ||
|
||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
@test begin | ||
try | ||
@cuda kernel_function(prob, alg) | ||
@info "Successfully launched kernel for $(alg)." | ||
true | ||
catch err | ||
@error "Kernel Launch failed for $(alg)." | ||
false | ||
end | ||
end broken=(alg isa SimpleHalley) | ||
@testset "$(nameof(typeof(alg)))" for alg in ( | ||
SimpleNewtonRaphson(), SimpleDFSane(), SimpleTrustRegion(), | ||
SimpleTrustRegion(; nlsolve_update_rule = Val(true)), | ||
SimpleBroyden(), SimpleLimitedMemoryBroyden(), SimpleKlement(), | ||
SimpleHalley(), SimpleBroyden(; linesearch = Val(true)), | ||
SimpleLimitedMemoryBroyden(; linesearch = Val(true))) | ||
@test begin | ||
try | ||
@cuda kernel_function(prob, alg) | ||
@info "Successfully launched kernel for $(alg)." | ||
true | ||
catch err | ||
@error "Kernel Launch failed for $(alg)." | ||
false | ||
end | ||
end broken=(alg isa SimpleHalley) | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
using ReTestItems, CUDA | ||
using ReTestItems, SimpleNonlinearSolve, Hwloc, InteractiveUtils | ||
using Pkg | ||
|
||
const GROUP = get(ENV, "GROUP", CUDA.functional() ? "All" : "Core") | ||
@info sprint(InteractiveUtils.versioninfo) | ||
|
||
if GROUP == "All" | ||
ReTestItems.runtests(@__DIR__) | ||
else | ||
tags = [Symbol(lowercase(GROUP))] | ||
ReTestItems.runtests(@__DIR__; tags) | ||
const GROUP = lowercase(get(ENV, "GROUP", "All")) | ||
|
||
if GROUP == "adjoint" || GROUP == "all" | ||
Pkg.add(["SciMLSensitivity"]) | ||
end | ||
|
||
if GROUP == "cuda" || GROUP == "all" | ||
Pkg.add(["CUDA"]) | ||
end | ||
|
||
const RETESTITEMS_NWORKERS = parse( | ||
Int, get(ENV, "RETESTITEMS_NWORKERS", string(min(Hwloc.num_physical_cores(), 4)))) | ||
const RETESTITEMS_NWORKER_THREADS = parse(Int, | ||
get(ENV, "RETESTITEMS_NWORKER_THREADS", | ||
string(max(Hwloc.num_virtual_cores() ÷ RETESTITEMS_NWORKERS, 1)))) | ||
|
||
@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers" | ||
|
||
ReTestItems.runtests( | ||
SimpleNonlinearSolve; tags = (GROUP == "all" ? nothing : [Symbol(GROUP)]), | ||
nworkers = RETESTITEMS_NWORKERS, nworker_threads = RETESTITEMS_NWORKER_THREADS, | ||
testitem_timeout = 3600, retries = 4) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that DI is completely untested on GPUs at the moment, so issues may (will) arise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for that? Do you not have the buildkite access setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't gotten around to it yet, CPU AD kept me busy enough ^^ but now that the API has stabilized I can look into it