PIPS on HPC: block decomposition, diagnostics, launch config and SLURM jobs#863
Draft
FabianHofmann wants to merge 8 commits into
Draft
PIPS on HPC: block decomposition, diagnostics, launch config and SLURM jobs#863FabianHofmann wants to merge 8 commits into
FabianHofmann wants to merge 8 commits into
Conversation
New linopy.pips module for HPC Phase A: assign_blocks splits a dimension into N contiguous blocks (also m.assign_blocks), and diagnose reports the arrowhead structure - border fraction, block balance, adjacent-vs-border linking rows, and a rank/thread recommendation - as pure computation over m.matrices, needing no PIPS build. Adds tests and docs.
Phase B: PipsConfig + build_pips_command (pure, unit-tested) control the launcher (mpirun/srun), rank count, threads-per-rank (OMP/MKL env), linear solver and extra driver options. The pips solver derives them from env defaults overridden by solver_options, defaults ranks to the block count, and supports srun. Adds unit tests for the command builder and config.
write_job emits a SLURM batch script from an export dir + PipsConfig: sets ntasks to the block count (capped), cpus-per-task to threads_per_rank, exports OMP/MKL threads and runs the driver under srun with the chosen linear solver and options. Detached flow is export -> sbatch -> read_pips_ solution. Adds tests, a cluster docs section, and API entries.
for more information, see https://pre-commit.ci
…, doctor preflight (Phase D) Add pips.run.json provenance (write_run_manifest) written by write_job and the inline solver; harden the generated SLURM script (set -euo pipefail with the module/env_setup block wrapped in set +u/-u, --output, module preamble, new output/modules/env_setup kwargs); add doctor() login-node preflight.
Relocate the top-level linopy/pips.py into a new linopy/backends/ subpackage so backend-specific code no longer sits at the package root (the PIPS solver class stays in solvers.py alongside the others). Public API is now linopy.backends.pips.*; update the two internal imports, tests and docs.
for more information, see https://pre-commit.ci
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the HPC-facing half of the PIPS-IPM++ integration: decompose a model into blocks, check whether that split will actually scale, control the parallel run, and generate a batch job for a cluster. Driving case: splitting the pypsa-eur time dimension of one year into ~50 blocks.
Note
The following content was generated by AI.
Important
Stacked on top of #862 (base branch
revive-to-block-files). Review/merge that PR first; the diff here is only the three HPC commits.Changes proposed in this Pull Request
Block decomposition + diagnostics (
linopy/pips.py)assign_blocks(m, dim, n_blocks)(alsom.assign_blocks(...)) splits a dimension into contiguous blocks and setsm.blocks.diagnose(m, target_cores=None) -> BlockReportreports the arrowhead structure fromm.matricesalone (no PIPS build): border fraction, block-nnz balance, linking rows split into adjacent (span two neighbouring blocks, e.g. storage continuity) vs border (span many blocks, e.g. global budgets), and a rank/thread recommendation with warnings. This answers "will a K-way split scale?" before spending an allocation.Launch control (
PipsConfig,linopy/solvers.py)PipsConfiggroups the run knobs: launcher (mpirun/srun), rank count, threads-per-rank, linear-solver backend, launcher args and extra driver options.pipssolver derives these from environment defaults overridden bysolver_options, defaults the rank count to the block count (capped so PIPS never over-subscribes), setsOMP_NUM_THREADS/MKL_NUM_THREADS, and now also supportssrun.Detached cluster runs (
write_job)write_job(export_dir, config, ...)emits a ready-to-sbatchSLURM script:--ntasksfrom the block count,--cpus-per-taskfrom threads, thread env exports, and the driver launched undersrunwith the chosen backend. The flow is export →sbatch→read_pips_solution(no new ingest code needed).Tests + docs
test/test_pips.py: the split, the diagnostics (hand-computed against a synthetic storage/budget model), the command builder, the config resolution, and the generated SLURM script — all pure-Python, no PIPS or HPC needed.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.