From bd5ae9cffd526ffddbee19512a258ffd49d98f46 Mon Sep 17 00:00:00 2001 From: Sungho Shin Date: Tue, 30 Jan 2024 08:15:04 -0600 Subject: [PATCH 1/2] ExaModels ad timing added (#62) --- Project.toml | 2 +- examodels.jl | 41 ++++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Project.toml b/Project.toml index 92d83a3..8896bda 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [compat] ADNLPModels = "0.7" -ExaModels = "0.4" +ExaModels = "0.5" Ipopt = "1" JuMP = "1.15" NLPModelsIpopt = "0.10" diff --git a/examodels.jl b/examodels.jl index 42ca209..c05b4a5 100755 --- a/examodels.jl +++ b/examodels.jl @@ -190,13 +190,14 @@ function solve_opf(file_name) c13 = ExaModels.constraint!(w, c9, g.bus => -pg[g.i] for g in data.gen) c14 = ExaModels.constraint!(w, c10, g.bus => -qg[g.i] for g in data.gen) - model = ExaModels.ExaModel(w) + model = ExaModels.TimedNLPModel( + ExaModels.ExaModel(w) + ) model_build_time = time() - time_model_start time_solve_start = time() - result = NLPModelsIpopt.ipopt(model) cost = result.objective @@ -206,14 +207,14 @@ function solve_opf(file_name) solve_time = time() - time_solve_start total_time = time() - time_data_start - # TODO: once a built-in timer is implemented in ExaModels, report callback timing - - # total_callback_time = - # nlp_block.evaluator.eval_objective_timer + - # nlp_block.evaluator.eval_objective_gradient_timer + - # nlp_block.evaluator.eval_constraint_timer + - # nlp_block.evaluator.eval_constraint_jacobian_timer + - # nlp_block.evaluator.eval_hessian_lagrangian_timer + total_callback_time = + model.stats.obj_time + + model.stats.grad_time + + model.stats.cons_time + + model.stats.jac_coord_time + + model.stats.hess_coord_time + + model.stats.jac_structure_time + + model.stats.hess_structure_time println("") println("\033[1mSummary\033[0m") @@ -226,15 +227,15 @@ function solve_opf(file_name) println(" data time.: $(data_load_time)") println(" build time: $(model_build_time)") println(" solve time: $(solve_time)") - # println(" callbacks: $(total_callback_time)") + println(" callbacks: $(total_callback_time)") + println("") + println(" callbacks time:") + println(" * obj.....: $(model.stats.obj_time)") + println(" * grad....: $(model.stats.grad_time)") + println(" * cons....: $(model.stats.cons_time)") + println(" * jac.....: $(model.stats.jac_coord_time + model.stats.jac_structure_time)") + println(" * hesslag.: $(model.stats.hess_coord_time + model.stats.hess_structure_time)") println("") - # println(" callbacks time:") - # println(" * obj.....: $(nlp_block.evaluator.eval_objective_timer)") - # println(" * grad....: $(nlp_block.evaluator.eval_objective_gradient_timer)") - # println(" * cons....: $(nlp_block.evaluator.eval_constraint_timer)") - # println(" * jac.....: $(nlp_block.evaluator.eval_constraint_jacobian_timer)") - # println(" * hesslag.: $(nlp_block.evaluator.eval_hessian_lagrangian_timer)") - # println("") va_sol = ExaModels.solution(result, va) va_dict = Dict("va_$(b.j)" => va_sol[b.i] for (i,b) in enumerate(data.bus)) @@ -264,7 +265,7 @@ function solve_opf(file_name) "time_data" => data_load_time, "time_build" => model_build_time, "time_solve" => solve_time, - # "time_callbacks" => total_callback_time, + "time_callbacks" => total_callback_time, "solution" => Dict( va_dict..., vm_dict..., @@ -280,3 +281,5 @@ write_out_tuple((i,j,k)) = "$(i)_$(j)_$(k)" if isinteractive() == false solve_opf("$(@__DIR__)/data/opf_warmup.m") end + + From 785666e1e0ba929dea956270d43992b0f858f593 Mon Sep 17 00:00:00 2001 From: Carleton Coffrin Date: Tue, 30 Jan 2024 07:16:02 -0700 Subject: [PATCH 2/2] update manifest --- Manifest.toml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index b13084c..4618adf 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.10.0" manifest_format = "2.0" -project_hash = "00bfc230370ab2d06ed7ae6128542d1a85a5a113" +project_hash = "2b196f4165a07d56342f51102f8b4a3a616731b5" [[deps.ADNLPModels]] deps = ["ColPack", "ForwardDiff", "LinearAlgebra", "NLPModels", "Requires", "ReverseDiff", "SparseArrays"] @@ -444,22 +444,26 @@ uuid = "90fa49ef-747e-5e6f-a989-263ba693cf1a" version = "0.5.2" [[deps.ExaModels]] -deps = ["NLPModels", "SolverCore"] -git-tree-sha1 = "054b99d8f8d19a81a1fbbad74223af16f8012f2a" +deps = ["NLPModels", "Printf", "SolverCore"] +git-tree-sha1 = "606d0f6c1bcdda9ec7841a4892337b00814e2334" uuid = "1037b233-b668-4ce9-9b63-f9f681f55dd2" -version = "0.4.2" +version = "0.5.0" [deps.ExaModels.extensions] ExaModelsAMDGPU = "AMDGPU" ExaModelsCUDA = "CUDA" + ExaModelsJuMP = "JuMP" ExaModelsKernelAbstractions = "KernelAbstractions" + ExaModelsMOI = "MathOptInterface" ExaModelsOneAPI = "oneAPI" ExaModelsSpecialFunctions = "SpecialFunctions" [deps.ExaModels.weakdeps] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + JuMP = "4076af6c-e467-56ae-b986-b466b2749572" KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" + MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"