-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into fp/madnlp
- Loading branch information
Showing
20 changed files
with
354 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[compat] | ||
CUDA = "4.1, 5" | ||
FiniteDiff = "2.7" | ||
Ipopt = "1" | ||
MadNLP = "0.7" | ||
|
||
[deps] | ||
Argos = "ef244971-cf80-42b0-9762-2c2c832df5d5" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
CUSOLVERRF = "a8cc9031-bad2-4722-94f5-40deabb4245c" | ||
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
ExaPF = "0cf0e50c-a82e-488f-ac7e-41ffdff1b8aa" | ||
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" | ||
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" | ||
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" | ||
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
MadNLP = "2621e9c9-9eb4-46b1-8089-e8c72242dfb6" | ||
MadNLPGPU = "d72a61cc-809d-412f-99be-fd81f4b8a598" | ||
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[extras] | ||
CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
using Pkg | ||
Pkg.instantiate() | ||
|
||
using CUDA | ||
|
||
argos_path = joinpath(@__DIR__, "..") | ||
Pkg.develop(path=argos_path) | ||
|
||
CUDA.set_runtime_version!(v"11.8") |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
informational: true | ||
patch: | ||
default: | ||
informational: true |
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,7 +1,7 @@ | ||
name = "Argos" | ||
uuid = "ef244971-cf80-42b0-9762-2c2c832df5d5" | ||
authors = ["fpacaud <[email protected]>"] | ||
version = "0.3.3" | ||
version = "0.3.4" | ||
|
||
[deps] | ||
ExaPF = "0cf0e50c-a82e-488f-ac7e-41ffdff1b8aa" | ||
|
@@ -13,27 +13,17 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6" | |
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
|
||
[weakdeps] | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
CUSOLVERRF = "a8cc9031-bad2-4722-94f5-40deabb4245c" | ||
|
||
[extensions] | ||
ArgosCUDAExt = ["CUDA", "CUSOLVERRF"] | ||
|
||
[compat] | ||
CUDA = "4.1, 5" | ||
ExaPF = "~0.9.3" | ||
FiniteDiff = "2.7" | ||
Ipopt = "1" | ||
KernelAbstractions = "0.9" | ||
MadNLP = "0.7" | ||
MathOptInterface = "1" | ||
NLPModels = "0.19, 0.20" | ||
julia = "1.6" | ||
|
||
[extras] | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" | ||
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" | ||
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" | ||
MadNLPGPU = "d72a61cc-809d-412f-99be-fd81f4b8a598" | ||
MadNLPTests = "b52a2a03-04ab-4a5f-9698-6a2deff93217" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test", "CUDA", "DelimitedFiles", "FiniteDiff", "Ipopt", "LazyArtifacts", "MadNLPGPU", "MadNLPTests", "Random"] | ||
julia = "1.9" |
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
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
include("common.jl") | ||
|
||
#= | ||
CONFIG | ||
=# | ||
|
||
# Number of trial runs to estimate running time. | ||
ntrials = 3 | ||
# Save results on disk? | ||
save_results = true | ||
# Should we use the GPU to evaluate the derivatives? | ||
use_gpu = true | ||
# Verbose level | ||
verbose = true | ||
print_level = if verbose | ||
MadNLP.DEBUG | ||
else | ||
MadNLP.ERROR | ||
end | ||
|
||
# OPF instances | ||
cases = [ | ||
"case118.m", | ||
"case1354pegase.m", | ||
"case2869pegase.m", | ||
"case9241pegase.m", | ||
] | ||
|
||
|
||
function benchmark_kkt(model, kkt; use_gpu=false, ntrials=3, options...) | ||
use_gpu && refresh_memory() | ||
blk = build_opf_model(model; use_gpu=use_gpu) | ||
|
||
## Warm-up | ||
solver = build_madnlp(blk, kkt; max_iter=1, options...) | ||
MadNLP.solve!(solver) | ||
|
||
## Benchmark | ||
t_build, t_factorization, t_backsolve = (0.0, 0.0, 0.0) | ||
delta_err = 0.0 | ||
for _ in 1:ntrials | ||
t_build += CUDA.@elapsed begin | ||
MadNLP.build_kkt!(solver.kkt) | ||
end | ||
t_factorization += CUDA.@elapsed begin | ||
MadNLP.factorize!(solver.linear_solver) | ||
end | ||
t_backsolve += CUDA.@elapsed begin | ||
MadNLP.solve_refine_wrapper!(solver, solver.d, solver.p) | ||
end | ||
|
||
dsol = MadNLP.primal_dual(solver.d) | ||
n = length(dsol) | ||
psol = zeros(n) | ||
|
||
mul!(psol, solver.kkt, dsol) | ||
|
||
delta_err += norm(psol .- MadNLP.primal_dual(solver.p), Inf) | ||
end | ||
|
||
return ( | ||
build=t_build / ntrials, | ||
factorization=t_factorization / ntrials, | ||
backsolve=t_backsolve / ntrials, | ||
accuracy=delta_err / ntrials, | ||
) | ||
end | ||
|
||
function benchmark_kkt(cases, kkt, ntrials, save_results; use_gpu=false, options...) | ||
# Setup | ||
dev = use_gpu ? :cuda : :cpu | ||
form = isa(kkt, Argos.BieglerReduction) ? :biegler : :full | ||
|
||
nexp = length(cases) | ||
results = zeros(nexp, 5) | ||
|
||
i = 0 | ||
for case in cases | ||
i += 1 | ||
datafile = joinpath(DATA, case) | ||
model = ExaPF.PolarForm(datafile) | ||
nbus = PS.get(model, PS.NumberOfBuses()) | ||
|
||
r = benchmark_kkt(model, kkt; ntrials=ntrials, use_gpu=use_gpu, options...) | ||
results[i, :] .= (nbus, r.build, r.factorization, r.backsolve, r.accuracy) | ||
end | ||
|
||
if save_results | ||
output_dir = joinpath(dirname(@__FILE__), RESULTS_DIR) | ||
if !isdir(output_dir) | ||
mkdir(output_dir) | ||
end | ||
output_file = joinpath(output_dir, "benchmark_kkt_$(form)_$(dev).txt") | ||
writedlm(output_file, results) | ||
end | ||
return results | ||
end | ||
|
||
#= | ||
Benchmark using ma27 as a reference. | ||
=# | ||
benchmark_kkt( | ||
cases, | ||
Argos.FullSpace(), | ||
ntrials, | ||
save_results; | ||
print_level=print_level, | ||
linear_solver=Ma27Solver, | ||
use_gpu=use_gpu, | ||
) | ||
|
||
|
||
#= | ||
Benchmark Biegler's reduction. | ||
=# | ||
benchmark_kkt( | ||
cases, | ||
Argos.BieglerReduction(), | ||
ntrials, | ||
save_results; | ||
print_level=print_level, | ||
linear_solver=LapackGPUSolver, | ||
use_gpu=use_gpu, | ||
) | ||
|
Oops, something went wrong.