From 0ed9328c39fef3e439632fb3f5254aa7a26dfb34 Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Mon, 1 Jul 2024 23:56:11 +0530 Subject: [PATCH 1/8] build: bump compats --- Project.toml | 10 +++++----- docs/Project.toml | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 345acd1..03b00ed 100644 --- a/Project.toml +++ b/Project.toml @@ -23,11 +23,11 @@ cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [compat] Aqua = "0.8" -CUDA = "4.4, 5" +CUDA = "5" DiffEqBase = "6.137" Distributions = "v0.25.107" DocStringExtensions = "0.9" -Flux = "0.13.12, 0.14" +Flux = "≥ 0.14.6" Functors = "0.4" LinearAlgebra = "1.10" Random = "1.10" @@ -38,9 +38,9 @@ SparseArrays = "1.10" Statistics = "1.10" StochasticDiffEq = "6.63" Test = "1.10" -Tracker = "0.2.18" -Zygote = "0.6.61" -cuDNN = "1.1" +Tracker = "0.2.34" +Zygote = "0.6.70" +cuDNN = "1.2" julia = "1.10" [extras] diff --git a/docs/Project.toml b/docs/Project.toml index c6d1296..45b25ee 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,9 +1,10 @@ [deps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" HighDimPDE = "57c578d5-59d4-4db8-a490-a9fc372d19d2" [compat] +CUDA = "5" Documenter = "1" Flux = "0.13, 0.14" -HighDimPDE = "2" From 546730232d5fc383961595842888d4a6ba592e40 Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 14:39:31 +0530 Subject: [PATCH 2/8] fix(DeepBSDE): replace with Ensemble --- src/DeepBSDE.jl | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/DeepBSDE.jl b/src/DeepBSDE.jl index c421b21..3bf25c7 100644 --- a/src/DeepBSDE.jl +++ b/src/DeepBSDE.jl @@ -137,32 +137,32 @@ function DiffEqBase.solve(prob::ParabolicPDEProblem, u = h[end] X = h[1:(end - 1)].data t_ = eltype(X)(t) - _σᵀ∇u = σᵀ∇u([X; t_])' |> collect - _f = -f(X, u.data, _σᵀ∇u, p, t_) - + _σᵀ∇u = re2(p)([X; t_])' |> collect + _f = -f(X, u.data, _σᵀ∇u, re3(p), t_) Tracker.TrackedArray(vcat(μ(X, p, t), [_f])) end function G(h::Tracker.TrackedArray, p, t) X = h[1:(end - 1)].data t_ = eltype(X)(t) - _σᵀ∇u = σᵀ∇u([X; t_])' |> collect - Tracker.TrackedArray(vcat(σ(X, p, t), _σᵀ∇u)) + _σᵀ∇u = re2(p)([X; t_])' |> collect + Tracker.TrackedArray(vcat(σ(X, re3(p), t), _σᵀ∇u)) end noise = zeros(Float32, d + 1, d) - prob = SDEProblem{false}(F, G, [x0; 0.0f0], tspan, p3, noise_rate_prototype = noise) + sde_prob = SDEProblem{false}(F, G, [x0; 0.0f0], tspan, p3, noise_rate_prototype = noise) function neural_sde(init_cond) - map(1:trajectories) do j #TODO add Ensemble Simulation - predict_ans = Array(solve(prob, sdealg; - dt = dt, - u0 = init_cond, - p = p3, - save_everystep = false, - sensealg = SciMLSensitivity.TrackerAdjoint(), - kwargs...))[:, end] - (X, u) = (predict_ans[1:(end - 1)], predict_ans[end]) + sde_prob = remake(sde_prob, u0 = init_cond) + ensemble_prob = EnsembleProblem(sde_prob) + sol = solve(ensemble_prob, sdealg, EnsembleSerial(); + u0 = init_cond, trajectories = trajectories, dt = dt, p = p3, + sensealg = SciMLSensitivity.TrackerAdjoint(), + save_everystep = false, + kwargs...) + map(sol) do _sol + predict_ans = Array(_sol) + (predict_ans[1:(end - 1), end], predict_ans[end, end]) end end @@ -185,7 +185,6 @@ function DiffEqBase.solve(prob::ParabolicPDEProblem, verbose && println("Current loss is: $l") l < pabstol && Flux.stop() end - verbose && println("DeepBSDE") Flux.train!(loss_n_sde, ps, data, opt; cb = cb) From 5d1b969bc9952a1f1525958ae63f19059a42d907 Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 14:39:46 +0530 Subject: [PATCH 3/8] test(DeepBSDE): update tests --- test/DeepBSDE.jl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/DeepBSDE.jl b/test/DeepBSDE.jl index 5684153..c1cd31c 100644 --- a/test/DeepBSDE.jl +++ b/test/DeepBSDE.jl @@ -21,16 +21,16 @@ end tspan = (0.0f0, 5.0f0) dt = 0.5f0 # time step d = 1 # number of dimensions - m = 10 # number of trajectories (batch size) + m = 100 # number of trajectories (batch size) g(X) = sum(X .^ 2) # terminal condition - f(X, u, σᵀ∇u, p, t) = Float32(0.0) - μ_f(X, p, t) = zero(X) #Vector d x 1 - σ_f(X, p, t) = Diagonal(ones(Float32, d)) |> Matrix #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + f(X, u, σᵀ∇u, p, t) = eltype(X)(0.0) + μ_f(X, p, t) = X*0.0f0 #Vector d x 1 + σ_f(X, p, t) = Diagonal(ones(eltype(X), d)) |> Matrix #Matrix d x d + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) hls = 10 + d #hidden layer size - opt = Flux.Optimise.Adam(0.005) #optimizer + opt = Flux.Optimise.Adam(0.05) #optimizer #sub-neural network approximating solutions at the desired point u0 = Flux.Chain(Dense(d, hls, relu), Dense(hls, hls, relu), @@ -69,7 +69,7 @@ end f(X, u, σᵀ∇u, p, t) = Float32(0.0) μ_f(X, p, t) = zero(X) #Vector d x 1 σ_f(X, p, t) = Diagonal(ones(Float32, d)) |> Matrix #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) hls = 10 + d #hidden layer size opt = Flux.Optimise.Adam(0.005) #optimizer @@ -113,7 +113,7 @@ end g(X) = sum(X .^ 2) μ_f(X, p, t) = zero(X) #Vector d x 1 σ_f(X, p, t) = Diagonal(sigma * X) |> Matrix #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) hls = 10 + d #hide layer size opt = Flux.Optimise.Adam(0.001) @@ -153,7 +153,7 @@ end f(X, u, σᵀ∇u, p, t) = u .- u .^ 3 μ_f(X, p, t) = zero(X) #Vector d x 1 σ_f(X, p, t) = Diagonal(ones(Float32, d)) |> Matrix #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) hls = 20 + d #hidden layer size opt = Flux.Optimise.Adam(5^-3) #optimizer @@ -195,7 +195,7 @@ end f(X, u, σᵀ∇u, p, t) = -λ * sum(σᵀ∇u .^ 2) μ_f(X, p, t) = zero(X) #Vector d x 1 λ σ_f(X, p, t) = Diagonal(sqrt(2.0f0) * ones(Float32, d)) #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) # TODO: This is a very large neural networks which size must be reduced. hls = 256 #hidden layer size @@ -266,7 +266,7 @@ end μ_f(X, p, t) = µc * X #Vector d x 1 σ_f(X, p, t) = σc * Diagonal(X) #Matrix d x d - prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan, g, f) + prob = ParabolicPDEProblem(μ_f, σ_f, x0, tspan; g, f) hls = 256 #hidden layer size opt = Flux.Optimise.Adam(0.008) #optimizer From e12ae0973d5d54020f42f39383cb94fede1f638f Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 14:40:28 +0530 Subject: [PATCH 4/8] test: enable DeepBSDE tests --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index e8f7c0d..f9e1c9a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,7 @@ using SafeTestsets, Test @time @safetestset "reflect" include("reflect.jl") @time @safetestset "MLP" include("MLP.jl") @time @safetestset "Deep Splitting" include("DeepSplitting.jl") + @time @safetestset "Deep Splitting" include("DeepBSDE.jl") @time @safetestset "MC Sample" include("MCSample.jl") @time @safetestset "NNStopping" include("NNStopping.jl") @time @safetestset "NNKolmogorov" include("NNKolmogorov.jl") From 32b4812a3e10fe9295249632fe236800c10253f2 Mon Sep 17 00:00:00 2001 From: Ashutosh Bharambe <43771652+ashutosh-b-b@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:44:49 +0530 Subject: [PATCH 5/8] =?UTF-8?q?build:=20remove=20=E2=89=A5=20from=20Flux?= =?UTF-8?q?=20compat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christopher Rackauckas --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 03b00ed..0559892 100644 --- a/Project.toml +++ b/Project.toml @@ -27,7 +27,7 @@ CUDA = "5" DiffEqBase = "6.137" Distributions = "v0.25.107" DocStringExtensions = "0.9" -Flux = "≥ 0.14.6" +Flux = "0.14.6" Functors = "0.4" LinearAlgebra = "1.10" Random = "1.10" From 880a663444e7f803c5f7b6405c258794ce0a08b2 Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 16:44:37 +0530 Subject: [PATCH 6/8] build: bump compat for SciMLSensitivity --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0559892..fd66e8f 100644 --- a/Project.toml +++ b/Project.toml @@ -33,7 +33,7 @@ LinearAlgebra = "1.10" Random = "1.10" Reexport = "1" SafeTestsets = "0.1" -SciMLSensitivity = "7.49" +SciMLSensitivity = "7.62" SparseArrays = "1.10" Statistics = "1.10" StochasticDiffEq = "6.63" From 357c4aa4f367bb8d1fbd0087054ce2fa6f2c5aff Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 16:46:12 +0530 Subject: [PATCH 7/8] .github: make depwarn yes --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ae64375..088406d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,7 +37,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 with: - depwarn: error + depwarn: yes - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v4 with: From e46ffa775dc46657d610e1a96c1ac25c11aa2cad Mon Sep 17 00:00:00 2001 From: ashutosh-b-b Date: Tue, 2 Jul 2024 16:49:17 +0530 Subject: [PATCH 8/8] build: bump compats --- Project.toml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index fd66e8f..2ccbfa4 100644 --- a/Project.toml +++ b/Project.toml @@ -23,24 +23,24 @@ cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [compat] Aqua = "0.8" -CUDA = "5" -DiffEqBase = "6.137" +CUDA = "5.4.2" +DiffEqBase = "6.151" Distributions = "v0.25.107" -DocStringExtensions = "0.9" -Flux = "0.14.6" -Functors = "0.4" +DocStringExtensions = "0.9.3" +Flux = "0.14.16" +Functors = "0.4.11" LinearAlgebra = "1.10" Random = "1.10" -Reexport = "1" +Reexport = "1.2.2" SafeTestsets = "0.1" SciMLSensitivity = "7.62" SparseArrays = "1.10" Statistics = "1.10" -StochasticDiffEq = "6.63" +StochasticDiffEq = "6.66" Test = "1.10" Tracker = "0.2.34" Zygote = "0.6.70" -cuDNN = "1.2" +cuDNN = "1.3.2" julia = "1.10" [extras]