Skip to content

Commit bb2f848

Browse files
authored
Merge pull request #91 from control-toolbox/90-doc-graph-gpu-vs-cpu
90 doc graph gpu vs cpu
2 parents 96b5322 + 115acee commit bb2f848

6 files changed

Lines changed: 1974 additions & 748 deletions

File tree

docs/src/assets/benchmarks/core-ubuntu-latest/Manifest.toml

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.11.7"
44
manifest_format = "2.0"
5-
project_hash = "504321ce5e41e219898888ab0c5197c8a0da3a8b"
5+
project_hash = "bad3358bf5ff5a00b4825524d0fafd1b96b4e6d1"
66

77
[[deps.ADNLPModels]]
88
deps = ["ADTypes", "ForwardDiff", "LinearAlgebra", "NLPModels", "Requires", "ReverseDiff", "SparseArrays", "SparseConnectivityTracer", "SparseMatrixColorings"]
@@ -120,16 +120,9 @@ version = "0.5.0"
120120

121121
[[deps.CTBase]]
122122
deps = ["DocStringExtensions"]
123-
git-tree-sha1 = "62017f38515aea94b44eaa4892e3552f5ef5dcbf"
123+
git-tree-sha1 = "ebc7d07d0bf4db7a841c5e7d51b4271bcf1e921c"
124124
uuid = "54762871-cc72-4466-b8e8-f6c8b58076cd"
125-
version = "0.16.4"
126-
127-
[deps.CTBase.extensions]
128-
CTBaseDocstrings = ["HTTP", "JSON"]
129-
130-
[deps.CTBase.weakdeps]
131-
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
132-
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
125+
version = "0.16.2"
133126

134127
[[deps.CTDirect]]
135128
deps = ["CTBase", "CTModels", "DocStringExtensions", "HSL", "MKL", "NLPModels", "SolverCore", "SparseArrays"]
@@ -321,9 +314,9 @@ version = "1.8.1"
321314

322315
[[deps.DataStructures]]
323316
deps = ["OrderedCollections"]
324-
git-tree-sha1 = "6c72198e6a101cccdd4c9731d3985e904ba26037"
317+
git-tree-sha1 = "e357641bb3e0638d353c4b29ea0e40ea644066a6"
325318
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
326-
version = "0.19.1"
319+
version = "0.19.3"
327320

328321
[[deps.DataValueInterfaces]]
329322
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
@@ -409,9 +402,9 @@ version = "1.11.0"
409402

410403
[[deps.FillArrays]]
411404
deps = ["LinearAlgebra"]
412-
git-tree-sha1 = "173e4d8f14230a7523ae11b9a3fa9edb3e0efd78"
405+
git-tree-sha1 = "5bfcd42851cf2f1b303f51525a54dc5e98d408a3"
413406
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
414-
version = "1.14.0"
407+
version = "1.15.0"
415408

416409
[deps.FillArrays.extensions]
417410
FillArraysPDMatsExt = "PDMats"
@@ -578,10 +571,16 @@ uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
578571
version = "1.7.1"
579572

580573
[[deps.JSON]]
581-
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
582-
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
574+
deps = ["Dates", "Logging", "Parsers", "PrecompileTools", "StructUtils", "UUIDs", "Unicode"]
575+
git-tree-sha1 = "eb04df293213df64ddd720c86de3c431f5f8ccf1"
583576
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
584-
version = "0.21.4"
577+
version = "1.2.1"
578+
579+
[deps.JSON.extensions]
580+
JSONArrowExt = ["ArrowTypes"]
581+
582+
[deps.JSON.weakdeps]
583+
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
585584

586585
[[deps.JSON3]]
587586
deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"]
@@ -615,9 +614,9 @@ version = "0.2.1+0"
615614

616615
[[deps.KernelAbstractions]]
617616
deps = ["Adapt", "Atomix", "InteractiveUtils", "MacroTools", "PrecompileTools", "Requires", "StaticArrays", "UUIDs"]
618-
git-tree-sha1 = "83c617e9e9b02306a7acab79e05ec10253db7c87"
617+
git-tree-sha1 = "b5a371fcd1d989d844a4354127365611ae1e305f"
619618
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
620-
version = "0.9.38"
619+
version = "0.9.39"
621620

622621
[deps.KernelAbstractions.extensions]
623622
EnzymeExt = "EnzymeCore"
@@ -941,15 +940,15 @@ version = "0.5.6+0"
941940

942941
[[deps.OptimalControl]]
943942
deps = ["ADNLPModels", "CTBase", "CTDirect", "CTFlows", "CTModels", "CTParser", "CommonSolve", "DocStringExtensions", "ExaModels", "RecipesBase"]
944-
git-tree-sha1 = "b692710be9b1fba3bd14a0cb949297ba75505e79"
943+
git-tree-sha1 = "bd4205fab4ea6c5ad5504efcf9e5868ef253227c"
945944
uuid = "5f98b655-cc9a-415a-b60e-744165666948"
946-
version = "1.1.5"
945+
version = "1.1.6"
947946

948947
[[deps.OptimalControlProblems]]
949948
deps = ["ADNLPModels", "CTBase", "CTDirect", "CTModels", "DocStringExtensions", "ExaModels", "OrderedCollections", "SolverCore"]
950-
git-tree-sha1 = "6b09a457e4a160d385d834ee90f7d2a38e8578b5"
949+
git-tree-sha1 = "767f6292fdb312e7151bc30a652227c8d5c5dd8d"
951950
uuid = "59046045-fb9c-4c23-964f-ff0a25704f96"
952-
version = "0.3.1"
951+
version = "0.3.2"
953952
weakdeps = ["JuMP", "OptimalControl"]
954953

955954
[deps.OptimalControlProblems.extensions]
@@ -1136,9 +1135,9 @@ version = "1.11.0"
11361135

11371136
[[deps.SparseConnectivityTracer]]
11381137
deps = ["ADTypes", "DocStringExtensions", "FillArrays", "LinearAlgebra", "Random", "SparseArrays"]
1139-
git-tree-sha1 = "62f3dbfa8e0bb01ce41076ee31686f0514a9e339"
1138+
git-tree-sha1 = "ba6dc9b87304964647bd1c750b903cb360003a36"
11401139
uuid = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
1141-
version = "1.1.1"
1140+
version = "1.1.2"
11421141

11431142
[deps.SparseConnectivityTracer.extensions]
11441143
SparseConnectivityTracerChainRulesCoreExt = "ChainRulesCore"
@@ -1156,19 +1155,22 @@ version = "1.1.1"
11561155

11571156
[[deps.SparseMatrixColorings]]
11581157
deps = ["ADTypes", "DocStringExtensions", "LinearAlgebra", "PrecompileTools", "Random", "SparseArrays"]
1159-
git-tree-sha1 = "d3f3b7bb8a561b5ff20ee7cf9574841ee4e4e137"
1158+
git-tree-sha1 = "6ed48d9a3b22417c765dc273ae3e1e4de035e7c8"
11601159
uuid = "0a514795-09f3-496d-8182-132a7b665d35"
1161-
version = "0.4.22"
1160+
version = "0.4.23"
11621161

11631162
[deps.SparseMatrixColorings.extensions]
11641163
SparseMatrixColoringsCUDAExt = "CUDA"
11651164
SparseMatrixColoringsCliqueTreesExt = "CliqueTrees"
11661165
SparseMatrixColoringsColorsExt = "Colors"
1166+
SparseMatrixColoringsJuMPExt = ["JuMP", "MathOptInterface"]
11671167

11681168
[deps.SparseMatrixColorings.weakdeps]
11691169
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
11701170
CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8"
11711171
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
1172+
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
1173+
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
11721174

11731175
[[deps.SpecialFunctions]]
11741176
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
@@ -1218,6 +1220,20 @@ git-tree-sha1 = "159331b30e94d7b11379037feeb9b690950cace8"
12181220
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
12191221
version = "1.11.0"
12201222

1223+
[[deps.StructUtils]]
1224+
deps = ["Dates", "UUIDs"]
1225+
git-tree-sha1 = "79529b493a44927dd5b13dde1c7ce957c2d049e4"
1226+
uuid = "ec057cc2-7a8d-4b58-b3b3-92acb9f63b42"
1227+
version = "2.6.0"
1228+
1229+
[deps.StructUtils.extensions]
1230+
StructUtilsMeasurementsExt = ["Measurements"]
1231+
StructUtilsTablesExt = ["Tables"]
1232+
1233+
[deps.StructUtils.weakdeps]
1234+
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
1235+
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1236+
12211237
[[deps.StyledStrings]]
12221238
uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
12231239
version = "1.11.0"

docs/src/assets/benchmarks/core-ubuntu-latest/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "CTBenchmarks"
22
uuid = "db1dffaa-5ed3-4583-9a66-b5881c82ef11"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
authors = ["Olivier Cots <olivier.cots@toulouse-inp.fr>"]
55

66
[deps]
@@ -29,7 +29,7 @@ DataFrames = "1"
2929
Dates = "1"
3030
InteractiveUtils = "1"
3131
Ipopt = "1"
32-
JSON = "0.21"
32+
JSON = "1"
3333
JuMP = "1"
3434
MadNLPGPU = "0.7"
3535
MadNLPMumps = "0.5"

docs/src/assets/benchmarks/core-ubuntu-latest/core-ubuntu-latest.jl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
using Pkg
2-
const project_dir = normpath(@__DIR__, "..")
3-
ENV["PROJECT"] = project_dir
1+
# Benchmark script for core-ubuntu-latest
2+
# Setup (Pkg.activate, instantiate, update, using CTBenchmarks) is handled by the workflow
43

5-
println("📦 Activating project environment...")
6-
Pkg.activate(project_dir)
7-
8-
println("📥 Installing dependencies...")
9-
Pkg.instantiate()
10-
11-
println("🔄 Updating dependencies...")
12-
Pkg.update()
13-
14-
println("🔄 Loading CTBenchmarks package...")
15-
using CTBenchmarks
16-
17-
println("⏱️ Ready to run core benchmark...")
184
function main()
5+
project_dir = normpath(@__DIR__, "..")
196
outpath=joinpath(
207
project_dir, "docs", "src", "assets", "benchmarks", "core-ubuntu-latest"
218
)
@@ -25,7 +12,7 @@ function main()
2512
:beam,
2613
:chain,
2714
:double_oscillator,
28-
:ducted_fan,
15+
# :ducted_fan,
2916
:electric_vehicle,
3017
:glider,
3118
:insurance,
@@ -38,7 +25,7 @@ function main()
3825
:vanderpol,
3926
],
4027
solver_models=[:ipopt => [:JuMP, :adnlp, :exa], :madnlp => [:JuMP, :adnlp, :exa]],
41-
grid_sizes=[200, 500, 1000],
28+
grid_sizes=[200, 500, 1000, 2000],
4229
disc_methods=[:trapeze],
4330
tol=1e-6,
4431
ipopt_mu_strategy="adaptive",

docs/src/assets/benchmarks/core-ubuntu-latest/data.json

Lines changed: 1879 additions & 624 deletions
Large diffs are not rendered by default.

docs/src/assets/utils.jl

Lines changed: 40 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -186,104 +186,68 @@ function _print_results(bench_id)
186186
end
187187
end
188188

189-
function _plot_results(bench_id)
190-
191-
function pratios(df_sub)
192-
wide = unstack(df_sub, [:problem, :grid_size], :solver, :time)
193-
if !("ipopt" in names(wide)) || !("madnlp" in names(wide))
194-
return nothing
195-
end
196-
min_times = min.(wide.ipopt, wide.madnlp)
197-
wide.r_ipopt = wide.ipopt ./ min_times
198-
wide.r_madnlp = wide.madnlp ./ min_times
199-
return wide
200-
end
201-
202-
# write in english
189+
# write in english
203190
# use log base 2 instead of log base 1
204191
# group the graphs by solver–model pairs
205192
# on Moonshot, plot two curves: one for GPU and one for CPU
206193
# plot with respect to the number of iterations
207194
# set time to infinity if it does not converge
208-
function plot_performance_profile(wide, model)
209-
r_ipopt = sort(collect(skipmissing(wide.r_ipopt)))
210-
r_madnlp = sort(collect(skipmissing(wide.r_madnlp)))
211-
n = length(r_ipopt)
212-
y = (1:n) ./ n
213-
plt = plot(
214-
r_ipopt, y,
215-
label = "Ipopt", lw = 2,
216-
xlabel = "τ (Performance ratio)",
217-
ylabel = "Proportion of solved instances ≤ τ",
218-
title = "Performance profile — $(model)",
219-
legend = :bottomright,
220-
xscale = :log2,
221-
grid = true
222-
)
223-
plot!(
224-
r_madnlp, y,
225-
label = "MadNLP", lw = 2
226-
)
227-
return plt
228-
end
229-
230-
brut = _get_bench_data(bench_id)
231-
if brut === nothing
232-
println("⚠️ No result (missing or invalid file) for bench_id: $bench_id")
233-
return plot()
195+
function _plot_results(bench_id)
196+
raw = _get_bench_data(bench_id)
197+
if raw === nothing
198+
println("⚠️ No result (missing or invalid file) for bench_id: $bench_id")
199+
return plot()
234200
end
235201

236-
rows = get(brut, "results", Any[])
202+
rows = get(raw, "results", Any[])
237203
if isempty(rows)
238-
println("⚠️ No ('results') recorded in the benchmark file.")
204+
println("⚠️ No ('results') recorded in the benchmark file.")
239205
return plot()
240206
end
241207

242208
df = DataFrame(rows)
243-
244209
df_successful = filter(row -> row.success == true && row.benchmark !== nothing, df)
245210
if isempty(df_successful)
246-
println("⚠️ No successful benchmark entry to analyze.")
247-
return plot()
211+
println("⚠️ No successful benchmark entry to analyze.")
212+
return plot()
248213
end
249214

250215
df_successful.time = [row.benchmark["time"] for row in eachrow(df_successful)]
251216
select!(df_successful, [:problem, :model, :solver, :grid_size, :time])
252-
sort!(df_successful, [:model, :problem, :grid_size, :solver])
253-
models = unique(df_successful.model)
254-
model_plots = Plots.Plot[]
255-
256-
println("\nGenerating performance profiles by model :\n")
217+
df_successful = dropmissing(df_successful, :time)
218+
sort!(df_successful, [:problem, :grid_size, :model, :solver])
257219

258-
for m in models
259-
df_sub = filter(row -> row.model == m, df_successful)
220+
df_min = combine(groupby(df_successful, [:problem, :grid_size]), :time => minimum => :min_time)
221+
df_successful = leftjoin(df_successful, df_min, on = [:problem, :grid_size])
222+
df_successful.ratio = df_successful.time ./ df_successful.min_time
260223

261-
wide = pratios(df_sub)
262-
263-
if wide === nothing
264-
println("Skipped model $(m) (one of the solvers missing)")
265-
continue
266-
end
267-
268-
plt = plot_performance_profile(wide, m)
224+
df_successful.combo = string.("(", df_successful.model, ", ", df_successful.solver, ")")
269225

270-
push!(model_plots, plt)
271-
println("✅ Plot created for the model $(m)")
272-
end
226+
function performance_profile(df)
227+
combos = unique(df.combo)
228+
plt = plot(
229+
xlabel = "τ (Performance ratio)",
230+
ylabel = "Proportion of solved instances ≤ τ",
231+
title = "Performance profile — Global models × solvers",
232+
legend = :bottomright,
233+
xscale = :log2,
234+
grid = true,
235+
lw = 2,
236+
size = (900, 600)
237+
)
273238

239+
for c in combos
240+
sub = filter(row -> row.combo == c, df)
241+
ratios = sort(collect(skipmissing(sub.ratio)))
242+
n = length(ratios)
243+
y = (1:n) ./ n
244+
plot!(ratios, y, label = c)
245+
end
274246

275-
n_plots = length(model_plots)
276-
if n_plots == 0
277-
println("⚠️ No model plot could be generated.")
278-
return plot()
247+
return plt
279248
end
280249

281-
println("\nDone: Combining $n_plots plots...")
282-
283-
return plot(model_plots...;
284-
layout = (n_plots, 1),
285-
size = (800, 500 * n_plots),
286-
left_margin = 10Plots.mm,
287-
bottom_margin = 10Plots.mm
288-
)
289-
end
250+
plt = performance_profile(df_successful)
251+
println("✅ Global performance profile generated.")
252+
return plt
253+
end

docs/src/benchmark-core.md.template

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(joinpath(@__DIR__, "assets", "utils.jl"))
55

66
# Define benchmark IDs
77
const BENCH_CORE_UBUNTU = "core-ubuntu-latest"
8-
const BENCH_CORE_MOONSHOT = "core-moonshot"
8+
const BENCH_CORE_MOONSHOT = "core-moonshot-gpu"
99
```
1010

1111
## Ubuntu Latest
@@ -72,6 +72,10 @@ ENV_NAME = BENCH
7272

7373
### ⚡ Results
7474

75+
```@example BENCH
76+
_plot_results(BENCH_CORE_MOONSHOT) # hide
77+
```
78+
7579
```@example BENCH
7680
_print_results(BENCH_CORE_MOONSHOT) # hide
7781
nothing # hide

0 commit comments

Comments
 (0)