Repository navigation
Preserve CSR backing during coordinate concatenation - #1005
MaykThewessen wants to merge 2 commits into
Conversation
Concatenate constant and coordinate metadata with xarray, remap COO rows into the output grid, and retain explicit zeros. Keep overlapping labels and unsupported operands on the existing dense fallback. Verify 18 targeted v1 cases and frozen constraints. Focused suite: 710 passed, 662 skipped. Full-suite comparison resolves 14 regression cases with no new failing test identities; 80 baseline failures/errors remain in the existing environment. Independently verify exact equality of a 168-hour BirdFlow LP and removal of its coordinate-merge densification warning. Ruff and read-only review pass.
Merging this PR will not alter performance
Comparing Footnotes
|
|
Measured BirdFlow results for a pinned fork containing this work, compared with installed Linopy 0.9.1:
The candidate was pinned to The complete 168-hour production LP matched exactly: sparse matrix plus objective, RHS, bounds, senses, variable/constraint labels and variable types (all continuous for production linearized UC). This includes 492 minimum-up/down-time rows restored by an isolated PyPSA producer repair. Shifted pre-window terms became absent under v1 semantics, which dropped nonempty UC rows. The repair makes those boundary expression terms mathematical zero. Its 46 tests passed against the fork; all 40 existing UC tests also passed with v1 globally enabled. Across all 1008 hours, dispatch, storage state, flows, nodal prices and operative loading matched exactly, with zero slack and unchanged congestion counts. All six objective values and actual cached output file hashes matched; exports and representative health checks passed. Limits: this compares the entire pinned fork plus the PyPSA repair, so it does not isolate PR #1005's gain. Timing is one sequential A/B pair. Both retain the same existing 1.24 kW rating excess and DC-angle warning. No annual or worker-scaling claim, and these results do not establish compatibility of later packaging changes.
|
Note
The following implementation summary and validation results were generated with AI assistance.
SnapshotWindow.mergeconcatenates expressions from disjoint snapshot blocks. Sparse inputs previously fell through to xarray concatenation, densifying their coefficients and mutating their backing. This change stacks eligible blocks in CSR form while preserving row order, coefficients, constants and coordinates.The sparse path accepts ordinary expressions from the same model, all backed by CSR, with matching dimensions and an existing concatenation dimension containing unique, disjoint labels. Supported joins preserve auxiliary coordinates and absence semantics. Mixed inputs, repeated labels, unsupported expression classes and extra concatenation arguments retain the existing dense fallback.
Relates to #972.
Validation includes 18 new v1 cases. Focused tests passed 710 cases with 662 skips; Ruff passed. Local mypy was unavailable, so upstream CI remains necessary.
Benchmark and full-suite evidence
Three fresh-process repetitions concatenate four disjoint blocks of 25000 cells, with term widths
[2, 2, 2, 128], using float64. Median process peak RSS falls from 0.571 to 0.438 GiB, a 23.3% reduction for this workload. Median merge time falls from 0.109 to 0.052 seconds. All output fingerprints match exactly. Timing and RSS are captured before fingerprinting.A real BirdFlow 168-hour LP has 2.583.288 rows, 1.658.758 columns and 5.035.943 nonzeros. The matrix, objective coefficients, RHS, bounds, senses and variable/row labels match exactly. The densification warning falls from one to zero in each of three builds. Overall model performance is inconclusive because repeat ranges overlap. No independent solve or annual validation was performed.
Full-suite comparison against master
f665a260finds 94 baseline failures/errors versus 80 shared candidate failures/errors. The change resolves 14 regression-test failures and introduces none. The candidate still has 52 failures and 28 errors in this environment; the full suite is not green.Implementation and this validation summary were written with GPT-6 assistance.