Repository navigation
Conversation
Every case is parsed by PowerIO instead of ExaPowerIO, so any single-phase network PowerIO reads (MATPOWER, PSS/E, PowerModels JSON, pandapower, CGMES, ...) becomes an OPF case, and a network already parsed with PowerIO can be passed wherever a file name was. ExaPowerIO is no longer a dependency; the PGLib-OPF artifact it provided is declared here, with the same tree hash. `parse_ac_power_data` reads `PowerIO.to_powerdata(net, T)` and keeps what is in service, in file order, as named isbits row types with ExaPowerIO's field names, so no model body changes. It matches ExaPowerIO 0.3.4 field for field on every PGLib-OPF case, except that `va` is in radians, storage is remapped to model bus positions, and a lost reference bus moves to the largest-Pmax generator (ExaPowerIO compared PMIN). A load curve no longer scales bus shunts (#52). The MATPOWER writer refuses a solution whose row counts do not match the case file. The compiled library parses with `parse(BalancedNetwork, path)` and the positional `to_powerdata(net, T)`, which pass `juliac --trim=safe` from eigenergy/PowerIO.jl#184; PowerIO is pinned to that branch until 0.11.7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parser_tests.jl covers inference of the arguments a compiled library builds, in-service selection and renumbering on an edited case14, each refusal, the implied thermal limit against PowerModels, pre-parsed and updated networks, PowerModels JSON and PSS/E round trips, case lookup, and the multi-period load contract. PGLib cases by name are solved against PowerModels, and DC OPF against DCPPowerModel through the unused `test_dcopf_case`. An `aot` slice runs `test_aot`, now compiling into a temporary directory, with a case loaded by path, so a regression in the trimmed case reader fails CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PowerIO.jl #184 now returns the value from parse(BalancedNetwork, path), as
parse(T, str) does in Base, and the module from parse(PioModule{V}, path). The
case reader drops its `.value`; the tests that emit or apply updates ask for
the module.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s VA in radians The parse now gives va0 in radians, so case_start must not convert it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KernelAbstractions 0.10.7 runs the CPU backend through ThreadTeams 1.4, whose new_job_closure holds an edge that fails verification when its package image loads. Every stored POCL kernel launch is rejected and compiles again at run time, including cons! and opf_violations. With KernelAbstractions 0.10.5 the same workload loads without compiling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| k == 0 && throw(ArgumentError("storage at unknown bus " * string(s.storage_bus))) | ||
| push!(storage, _row(StorageRow{T}, merge(s, (; | ||
| i = length(storage) + 1, storage_bus = _at(k, "storage unit"), | ||
| p_loss = s.p_loss / raw.baseMVA, q_loss = s.q_loss / raw.baseMVA)))) |
There was a problem hiding this comment.
nit (non-blocking): p_loss/q_loss are now put on per unit here, but Pexts/Qexts stay in MW/MVAr: PowerIO's to_powerdata emits st.active_power_mw undivided (exa.jl lines 249-250 in 0.11.7), and this row copies it as is. The model subtracts s.Pexts from per-unit powers in c_storage_balance (pst + pstd - pstc - s.Pexts - s.Zr*I2), so a case with a nonzero ps/qs column is off by baseMVA there. ExaPowerIO 0.3.4 had the same inconsistency (its parser only divided columns 4-7, 10-12, 15-16), so this is not a regression and every fixture has ps = qs = 0, but since this is the one place the storage row is rescaled, Pexts = s.Pexts / raw.baseMVA, Qexts = s.Qexts / raw.baseMVA would make the whole row per unit, as PowerModels' make_per_unit! does for ps/qs.
| pos[k] = length(bus) + 1 | ||
| push!(bus, _row(BusRow{T}, merge(b, (; i = pos[k])))) | ||
| end | ||
| _at(k, what) = pos[k] == 0 ? |
There was a problem hiding this comment.
nit (non-blocking): an in-service generator, branch or storage unit at a type-4 bus is refused here, where MATPOWER's ext2int and PowerModels' propagate_topology_status! deactivate it (with a warning) and go on. The refusal is documented and tested, so this is a design choice, but PSS/E RAW is now an advertised input, and RAW files routinely leave the branches and machines of an IDE=4 bus with STAT=1 (PSS/E treats them as out of service by virtue of the bus type). Unless PowerIO's RAW reader already clears those statuses, such a file will fail to load with this error rather than build the connected part of the network. Dropping the element with @warn, or at least saying so in the opf_model docstring, would make the RAW path match what users of those files expect.
| name = "ExaModelsPower" | ||
| uuid = "2fff4b78-0b6c-428d-bac8-85ccea8c4bdf" | ||
| version = "0.4.8" | ||
| version = "0.5.0" |
There was a problem hiding this comment.
nit (non-blocking): the 0.4.8 → 0.5.0 bump lands in 8641e95 together with the parser rewrite, and the compat widening to PowerIO = "0.11.7, 0.12" in 65881d2 together with the case_start radians change. The repo convention is that version and compat changes go in their own commits. The minor bump itself is right for the behavior changes listed in the description (radians va0, storage_bus as a position, dropped ExaPowerIO dependency). If the PR is squash-merged this is moot.
There was a problem hiding this comment.
VERDICT: APPROVE (head d10276f)
What I checked
- Parser against PowerIO 0.11.7's
to_powerdata(read from the PowerIO source):vaarrives in radians, generator and branch bus references are positions inbus,storage_busis a source id,p_loss/q_lossare MW, costs are already scaled to per unit (c2*base^2, c1*base, c0),rate_a = 0andInfpass through, and isolated buses keep type 4._in_servicehandles each of these correctly: dense renumbering in file order,f_idx/t_idxand the arc table rebuilt from the kept branches, storage resolved id → raw position → model position,p_loss/q_lossdivided bybaseMVA. The reference-bus rule (largest Pmax when the file's reference has no in-service generator) is PowerIO's and matches the description. The typedparse(BalancedNetwork, path), positionalto_powerdata(net, T; zero_impedance)andlibrary_available()all exist in 0.11.7, so the compat lower bound is right. - Thermal limit for
rateA = 0: same formula as PowerModels'calc_thermal_limits!(the extra cap of the angle at π only matters for |angmax| > π and is documented in the comment); the arcrate_ais taken from the adjusted branch row. - Model bodies: unchanged. Rows are concrete isbits
NamedTupletypes with ExaPowerIO's field names and order, so the generators still compile into the same blocks andconvert_arraymoves them to the GPU once; all per-element logic stays in the parser.storage_busis now a model position, which is whatc_active_power_balanceandc_ohmsindex with; the old raw bus number was wrong for non-1..n numbering. - Load curve (#52):
pd/qdscaled,gs/bskept. case3 (the only multi-period fixture solved against a hard-coded objective) has no shunts, so those references are legitimately unchanged. case_start:va0in radians, used as is.write_matpower_solution: the row-count and non-MATPOWER refusals are correct (the table regex matches onlybus|gen|branch, sotables == 3is the right check).- Artifacts.toml: same PGLib tree hash and sha256 as ExaPowerIO's, so existing depots reuse the download. No Manifest.toml. Exported API docstrings updated for the
caseargument. No leftoverExaPowerIOreferences. - Tests:
test/parser_tests.jlis wired intoruntests.jlin thenothingslice and covers inference, renumbered/isolated/out-of-service rows with every index checked, each refusal,rateA = 0against PowerModels, pre-parsed and updated networks, JSON/RAW round trips, PGLib case5/14/30/57 against PowerModels/Ipopt atrtol = 1e-6, DC OPF case3/5/14 againstDCPPowerModel, the writer refusals and the multi-period shape errors. Theaotslice is new;test_aotnow also compiles a case by path inRect. The only weakened check is the POCL zero-compile test, markedbrokenfor KernelAbstractions ≥ 0.10.7 with the reason stated in the comment and the description; it also fails on main. - PR description vs diff: matches. CI (
gh pr checks 76): all seven checks still pending at review time; the description states theaotslice only passes on Julia 1.13, which the owner should keep in mind if the1channel resolves to 1.12.
Blocking findings: none.
Non-blocking nits (inline):
src/parser.jl:155:Pexts/Qextsstay in MW while the rest of the storage row is per unit; the model subtractsPextsfrom per-unit powers. Pre-existing (ExaPowerIO did the same), fixtures have 0.src/parser.jl:117: refusing an in-service element at an isolated bus is stricter than MATPOWER/PowerModels, and PSS/E RAW files commonly have that pattern.Project.toml:3: version bump and compat change share commits with code changes.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #76 +/- ##
==========================================
+ Coverage 90.27% 92.91% +2.64%
==========================================
Files 12 12
Lines 1326 1440 +114
==========================================
+ Hits 1197 1338 +141
+ Misses 129 102 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ExaPowerIO parses MATPOWER 1.7x to 11x faster than PowerIO 0.12.1 (66 PGLib-OPF cases and an 82k-bus case), so .m files go through ExaPowerIO's filtered parse with no copy of its rows, as on main. A case that parse cannot represent (an element at an isolated bus, a piecewise-linear cost, storage) is read unfiltered and compacted in place. PowerIO reads every other format and pre-parsed networks into the same ExaPowerIO row types. Bus rows keep VA in degrees; va0 is in radians. Storage Pexts/Qexts are per unit on both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y PMAX Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| # the download or reports a path the caller did not write. | ||
| function _case_path(case::AbstractString) | ||
| path = String(case) | ||
| ispath(path) && return path |
There was a problem hiding this comment.
nit (non-blocking): ispath accepts a directory, so ac_opf_model("some/dir") is handed to PowerIO.parse and fails there with a parse error rather than the ArgumentError this function exists to give. isfile(path) && return path keeps the message for the one case that cannot be a case file.
There was a problem hiding this comment.
Kept ispath: PowerIO reads some formats from a directory (PowerIO.parse takes "a path to a file or directory", e.g. a CGMES folder), so a directory can be a case. A directory that is not one still fails in PowerIO.parse with its own error. The other nits are addressed in 107634a.
| raw = try | ||
| ExaPowerIO.parse_matpower(T, path) | ||
| catch err | ||
| err isa BoundsError || rethrow() |
There was a problem hiding this comment.
nit (non-blocking): the fallback for a generator at an isolated bus whose id is the file's lowest or highest relies on ExaPowerIO throwing a BoundsError from bus_map[...] / has_gen[gen.bus]. That holds today only because ExaPowerIO's function-level @inbounds does not reach the method body; an @inbounds added inside parse_matpower_inner later would turn this path into an out-of-bounds read or write that never reaches the catch. Worth a comment here stating the assumption, or an upstream check in ExaPowerIO that raises a typed error for an unknown bus id so the catch can be narrowed to it. No test covers this branch (the isolated bus in parser_tests.jl is an interior id), so a case with the lowest or highest bus id isolated would be the one to add.
| end | ||
| println(io, "\t", join(out, '\t'), ";", isempty(comment) ? "" : "\t" * comment) | ||
| end | ||
| tables == 3 || throw(ArgumentError(case_file * " is not a MATPOWER case: the solution " * |
There was a problem hiding this comment.
nit (non-blocking): this check runs after the loop has already copied every line of the input into io, so with the path form (write_matpower_solution(out, case_file, ...)) a non-MATPOWER case leaves a file at out holding a copy of the JSON/RAW input before the ArgumentError. Counting the mpc.bus|gen|branch = [ headers in lines before the first println would refuse without writing anything.
| the compiler needs, not its values, so the resulting library instantiates any | ||
| case at run time from a path. The multi-period models additionally bake `N` and the | ||
| case at run time from a path, in any format PowerIO reads. The library reads | ||
| cases through PowerIO's native library, which it finds the way PowerIO does (the |
There was a problem hiding this comment.
nit (non-blocking): since 609b1d5 a .m file is read by ExaPowerIO and only other formats go through PowerIO's native library, so this sentence now overstates when the powerio_capi artifact is needed. Suggest: "A MATPOWER .m file is read with ExaPowerIO; any other format is read through PowerIO's native library, which the compiled library finds the way PowerIO does (...)".
| name = "ExaModelsPower" | ||
| uuid = "2fff4b78-0b6c-428d-bac8-85ccea8c4bdf" | ||
| version = "0.4.8" | ||
| version = "0.5.0" |
There was a problem hiding this comment.
nit (non-blocking): 0.5.0 is the right bump for the behavior changes listed in the description (the va0 unit, storage indexing, the new refusals). The repository's practice so far has been to land the version bump as its own commit on main after the feature PR (Bump version to 0.4.7, 0.4.6, ...), and here it sits in the first feature commit. Either keep it and note the departure, or drop it from the PR and bump after merging.
There was a problem hiding this comment.
VERDICT: APPROVE (head 2296dd4)
Full review of the PR at head 2296dd4 (7 commits, 19 files).
What was checked
- Parser correctness (
src/parser.jl): the fast path keeps ExaPowerIO's filtered MATPOWER parse untouched, so the row structs, per-unit scaling, cost normalisation bybaseMVA^(n-i), tap/shift/angle limits in radians and therateA = 0thermal limit are the same as on main. The fallback (_exapowerio_rows+_in_service!) and the PowerIO path (_powerio_rows) were traced against ExaPowerIO 0.3.5 and PowerIO 0.12.1 sources: isolated buses dropped and the rest renumbered densely in file order; generator/branch bus references remapped throughpos;f_idx = l,t_idx = l + mwithmthe in-service branch count and arcs rebuilt to match; storage looked up by source bus id and mapped to model position;Pexts/Qexts/p_loss/q_lossbrought to per unit on both paths (ExaPowerIO 0.3.5 already dividesp_loss/q_loss, PowerIO reports all four in MW); PowerIO'sva(radians) converted back to degrees in the bus row andva0 = deg2rad(va)in the tables, soCASE_STARTdropping itspi/180is consistent. Bus-type reconciliation and reference-bus replacement match between the two readers for a single reference bus. PWL costs refused on both paths; the fast path falls back when it sees storage, a bus index 0 or a PWL row. - Multi-period loads:
update_load_datanow scalespd/qdonly, fixing #52; shunts keep their value, which the new test asserts on case14's bus 9. Shape errors replaceBoundsError/@assert. - Model bodies: unchanged; constraints remain generators over the same row structs, so the block structure and GPU behaviour are as before. CUDA slice green.
- Writer: row-count and non-MATPOWER refusals are correct and tested.
- Tests:
test/parser_tests.jlis wired in throughruntests.jlunder thenothingslice; it covers inference, the edited case14 (reversed/offset bus numbers, isolated bus, out-of-service rows, storage in and out of service), each refusal,rateA = 0against PowerModels, pre-parsed/updated networks, PowerModels JSON and PSS/E round trips, and PGLib case5/14/30/57 against PowerModels/Ipopt. DC OPF now checked againstDCPPowerModelon case3/5/14. The POCL zero-compile test is markedbrokenwith the KernelAbstractions 0.10.7 reason stated, and reports an unexpected pass if it starts working. No test weakened or deleted otherwise. NewaotCI slice runstest_aot. - Conventions: no Manifest.toml; every renamed public entry point keeps its docstring; compat
ExaPowerIO = "0.3.5"is its own commit;PowerIO = "0.11.7, 0.12",LazyArtifacts = "1"; version 0.5.0 is the right semver bump for the listed behaviour changes. - CI: all checks pass (
nothing,cpu,cuda,goc3,aot, build, docs, codecov). The description's verification claims match.
Blocking findings: none.
Non-blocking nits (inline): _case_path uses ispath and so accepts a directory; the MATPOWER fast path's fallback depends on a BoundsError from ExaPowerIO for an isolated bus at the lowest/highest id and that branch is untested; the writer copies the whole input before refusing a non-MATPOWER case; the compile_all docstring still says all cases go through PowerIO's native library; the version bump sits in the feature commit rather than its own.
…id isolated buses, drop the version bump - write_matpower_solution checks that the case is MATPOWER before opening out, so a refused case leaves no file. - A test isolates the lowest and highest bus ids of case14, the case where the fast MATPOWER read fails on its bus lookup and the case is read again. - The compile_all docstring says .m files are read with ExaPowerIO. - The version stays 0.4.8; it is bumped after merging, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Continues #68 (by @samtalki) from a branch in this repository, so the Claude review workflow can run; the commits from #68 are kept with their author.
MATPOWER files are still read with ExaPowerIO; every other format is read through PowerIO.jl, so any single-phase network PowerIO reads becomes an OPF case: PSS/E RAW/RAWX, PowerModels JSON, pandapower, PowerWorld, CGMES, XIIDM, and more, as well as networks already parsed with PowerIO. Issue #52 is fixed here.
How a case is read
Lookup: a path, or a bare PGLib-OPF name (
pglib_opf_*.m, alsoapi/…andsad/…). Names resolve in the same lazy PGLib-OPF v23.07 artifact ExaPowerIO used, now declared in this package'sArtifacts.toml. It has the same tree hash, so existing depots reuse the download. A missing path that isn't a PGLib name is anArgumentErrorand no longer triggers the download.Pre-parsed networks: anywhere a file name was accepted, a network already parsed with PowerIO works too:
PowerIO.parse(BalancedNetwork, path; format), or its modulePowerIO.parse(PioModule{BalancedNetwork}, path), possibly edited withPowerIO.apply_updates!.Parsing:
parse_ac_power_datacallsPowerIO.to_powerdata(net, T), then keeps what is in service, in file order:rateA = 0(or a non-finite rating) becomes the limit implied by the voltage and angle bounds, as ExaPowerIO 0.3.2 does.Both paths give ExaPowerIO's row structs, so no model body changed. A MATPOWER file goes through ExaPowerIO's own filtered parse with no copy of its rows, as on main; a file that parse cannot represent (an element at an isolated bus, a piecewise-linear cost, storage) is read unfiltered and compacted in place. Empty tables stay concrete for GPU
convert_array.Parity: the ExaPowerIO and PowerIO paths give the same tables, every field to 1e-12, on all 66 top-level PGLib-OPF v23.07 cases and the 5 fixtures in
data/.Ahead-of-time compilation
compile_allruns the case reader inside ajuliac --trim=safelibrary. PowerIO 0.11.6 fails trim verification (90 errors: a value type picked at run time, untyped handle locks, a keyword element type). eigenergy/PowerIO.jl#184 adds:parse(BalancedNetwork, path), which returns the network asparse(T, str)does in Base;to_powerdata(net, T);With it, the
:acplibrary verifies and links, and itsobj/consmatch the in-Julia model exactly on case14 (by path) and on case30 andapi/case14(by PGLib name). This PR adds anaotCI slice so a regression shows up. A compiled library can't download the PGLib artifact; that was already true with ExaPowerIO, andtest_aotnow resolves the name in Julia first.PowerIO 0.11.7 and later are registered, so the branch pin is gone; compat is
PowerIO = "0.11.7, 0.12". With PowerIO 0.12.1, theaotslice passes on Julia 1.13.2 (31/31); on Julia 1.12.7 trim verification fails (also with PowerIO 0.11.12), mostly on PkgREPLExtcode reached throughLazyArtifacts.Behavior changes (0.5.0)
storage_busis the model position of the bus; it was the raw MATPOWER bus number, which indexed the wrong bus whenever numbering wasn't 1..n. Storagep_loss/q_lossare per unit, as in ExaPowerIO 0.3.4.pd/qdonly; bus shunts (gs,bs) keep their value. The Pd/Qd matrix path already did this. Nothing in the test fixtures has a shunt, so the hard-coded objectives are unchanged.ArgumentError; before, it silently got bus index 0;ArgumentError; before, its breakpoints were read as polynomial coefficients.N, Pd/Qd with the wrong number of rows, mismatched Pd/Qd, or too few periods raiseDimensionMismatchinstead of aBoundsErroror an@assert.va0is in radians. It was degrees, so a warm startstart = (va = d -> d.va0,)was off by 180/π. The default starts don't use it. Bus rows keepvain degrees, as the file gives it.DimensionMismatch), and a non-MATPOWER case file (ArgumentError). Before, it could write values into the wrong rows.Tests
test/parser_tests.jl(thenothingslice):opf_args(path and pre-parsed),mpopf_args_defaultand positionalmpopf_args; isbits rows, empty tables included;rateA = 0against PowerModels'calc_thermal_limits!;rtol = 1e-6). DC OPF case3/5/14 against PowerModels'DCPPowerModel, through the previously unusedtest_dcopf_case.aotCI slice:test_aot(theEMP_TEST_AOTopt-in still works), plus a case loaded by path in the rectangular form.Verification (local, Julia 1.13.1, macOS)
EMP_TEST_SELECTION=nothing: 808 passed.cpu: 450 passed.aot: 19 passed, with all six models compiled under--trim=safe.cudaslice needs the self-hosted runners.goc3slice is untouched here. The GOC3 path moves to PowerIO in a separate PR.Rebased onto main (0.4.8)
Conflicts resolved in
Project.toml,src/opf.jl,src/ExaModelsPower.jl,test/runtests.jl; the parser tests run next to the violations, case-start and zero-compile tests.case_start(from Start from the case's operating point: start = :case, case_start, compiled start writer #72) convertedva0from degrees; withva0now in radians it is used as is.Local results with PowerIO 0.12.1:
nothing868/868 (Julia 1.12.7);cpu458 passed, 1 broken (below);aot31/31 (Julia 1.13.2).cuda,goc3and docs were not run locally.POCL zero-compile check marked broken on KernelAbstractions ≥ 0.10.7. That release runs the CPU backend through ThreadTeams 1.4, whose
new_job_closureholds an edge that fails verification when its package image loads, so every stored POCL kernel launch (KernelAbstractions' own, andcons!/opf_violationshere) is rejected and compiles again at run time. With KernelAbstractions 0.10.5 the same workload loads without compiling. This check also fails on main since that release.Parse speed
ExaPowerIO 0.3.4 parses MATPOWER faster than PowerIO 0.12.1 on all 66 PGLib-OPF cases and an 82k-bus case (median 5.7x, 1.7x to 10.6x; Julia 1.13.4, median of 5 after a warm-up), which is why
.mfiles stay on ExaPowerIO. End to end,parse_ac_power_dataagainst main (Julia 1.13.4, 3 alternating processes of 15 repetitions each, median): case14 0.82x, case1354_pegase 0.98x, case9241_pegase 0.99x, case13659_pegase 1.00x, case30000_goc 1.01x, case78484_epigrids 1.01x, an 82k-bus case 1.00x.🤖 Generated with Claude Code