-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
102 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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,3 +1,28 @@ | ||
using ReTestItems | ||
using ReTestItems, Pkg, InteractiveUtils, Hwloc | ||
|
||
ReTestItems.runtests(@__DIR__) | ||
@info sprint(versioninfo) | ||
|
||
const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", "all")) | ||
const EXTRA_PKGS = String[] | ||
|
||
(BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda") && push!(EXTRA_PKGS, "LuxCUDA") | ||
(BACKEND_GROUP == "all" || BACKEND_GROUP == "amdgpu") && push!(EXTRA_PKGS, "AMDGPU") | ||
|
||
if !isempty(EXTRA_PKGS) | ||
@info "Installing Extra Packages for testing" EXTRA_PKGS=EXTRA_PKGS | ||
Pkg.add(EXTRA_PKGS) | ||
Pkg.update() | ||
Base.retry_load_extensions() | ||
Pkg.instantiate() | ||
end | ||
|
||
using DeepEquilibriumNetworks | ||
|
||
const RETESTITEMS_NWORKERS = parse( | ||
Int, get(ENV, "RETESTITEMS_NWORKERS", string(min(Hwloc.num_physical_cores(), 16)))) | ||
const RETESTITEMS_NWORKER_THREADS = parse(Int, | ||
get(ENV, "RETESTITEMS_NWORKER_THREADS", | ||
string(max(Hwloc.num_virtual_cores() ÷ RETESTITEMS_NWORKERS, 1)))) | ||
|
||
ReTestItems.runtests(DeepEquilibriumNetworks; nworkers=RETESTITEMS_NWORKERS, | ||
nworker_threads=RETESTITEMS_NWORKER_THREADS, testitem_timeout=12000) |
This file contains 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,55 +1,56 @@ | ||
@testsetup module SharedTestSetup | ||
|
||
using DeepEquilibriumNetworks, Functors, Lux, Random, StableRNGs, Zygote, ForwardDiff | ||
import LuxTestUtils: @jet | ||
using LuxCUDA | ||
using LuxTestUtils | ||
using MLDataDevices, GPUArraysCore | ||
|
||
CUDA.allowscalar(false) | ||
LuxTestUtils.jet_target_modules!(["Boltz", "Lux", "LuxLib"]) | ||
|
||
__nameof(::X) where {X} = nameof(X) | ||
const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", "all")) | ||
|
||
__get_prng(seed::Int) = StableRNG(seed) | ||
if BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda" | ||
using LuxCUDA | ||
end | ||
|
||
if BACKEND_GROUP == "all" || BACKEND_GROUP == "amdgpu" | ||
using AMDGPU | ||
end | ||
|
||
__is_finite_gradient(x::AbstractArray) = all(isfinite, x) | ||
GPUArraysCore.allowscalar(false) | ||
|
||
cpu_testing() = BACKEND_GROUP == "all" || BACKEND_GROUP == "cpu" | ||
function cuda_testing() | ||
return (BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda") && | ||
MLDataDevices.functional(CUDADevice) | ||
end | ||
function amdgpu_testing() | ||
return (BACKEND_GROUP == "all" || BACKEND_GROUP == "amdgpu") && | ||
MLDataDevices.functional(AMDGPUDevice) | ||
end | ||
|
||
function __is_finite_gradient(gs::NamedTuple) | ||
gradient_is_finite = Ref(true) | ||
function __is_gradient_finite(x) | ||
!isnothing(x) && !all(isfinite, x) && (gradient_is_finite[] = false) | ||
return x | ||
end | ||
fmap(__is_gradient_finite, gs) | ||
return gradient_is_finite[] | ||
const MODES = begin | ||
modes = [] | ||
cpu_testing() && push!(modes, ("cpu", Array, CPUDevice(), false)) | ||
cuda_testing() && push!(modes, ("cuda", CuArray, CUDADevice(), true)) | ||
amdgpu_testing() && push!(modes, ("amdgpu", ROCArray, AMDGPUDevice(), true)) | ||
modes | ||
end | ||
|
||
function __get_dense_layer(args...; kwargs...) | ||
is_finite_gradient(x::AbstractArray) = all(isfinite, x) | ||
is_finite_gradient(::Nothing) = true | ||
is_finite_gradient(gs) = all(is_finite_gradient, fleaves(gs)) | ||
|
||
function dense_layer(args...; kwargs...) | ||
init_weight(rng::AbstractRNG, dims...) = randn(rng, Float32, dims) .* 0.001f0 | ||
return Dense(args...; init_weight, use_bias=false, kwargs...) | ||
end | ||
|
||
function __get_conv_layer(args...; kwargs...) | ||
function conv_layer(args...; kwargs...) | ||
init_weight(rng::AbstractRNG, dims...) = randn(rng, Float32, dims) .* 0.001f0 | ||
return Conv(args...; init_weight, use_bias=false, kwargs...) | ||
end | ||
|
||
const GROUP = get(ENV, "GROUP", "All") | ||
|
||
cpu_testing() = GROUP == "All" || GROUP == "CPU" | ||
cuda_testing() = LuxCUDA.functional() && (GROUP == "All" || GROUP == "CUDA") | ||
|
||
const MODES = begin | ||
cpu_mode = ("CPU", Array, LuxCPUDevice(), false) | ||
cuda_mode = ("CUDA", CuArray, LuxCUDADevice(), true) | ||
|
||
modes = [] | ||
cpu_testing() && push!(modes, cpu_mode) | ||
cuda_testing() && push!(modes, cuda_mode) | ||
|
||
modes | ||
end | ||
|
||
export Lux, LuxCore, LuxLib | ||
export MODES, __get_dense_layer, __get_conv_layer, __is_finite_gradient, __get_prng, | ||
__nameof, @jet | ||
export MODES, dense_layer, conv_layer, is_finite_gradient, StableRNG, @jet, test_gradients | ||
|
||
end |