Skip to content

PIPS on HPC: block decomposition, diagnostics, launch config and SLURM jobs#863

Draft
FabianHofmann wants to merge 8 commits into
revive-to-block-filesfrom
pips-hpc-integration
Draft

PIPS on HPC: block decomposition, diagnostics, launch config and SLURM jobs#863
FabianHofmann wants to merge 8 commits into
revive-to-block-filesfrom
pips-hpc-integration

Conversation

@FabianHofmann

Copy link
Copy Markdown
Collaborator

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) (also m.assign_blocks(...)) splits a dimension into contiguous blocks and sets m.blocks.
  • diagnose(m, target_cores=None) -> BlockReport reports the arrowhead structure from m.matrices alone (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)

  • PipsConfig groups the run knobs: launcher (mpirun/srun), rank count, threads-per-rank, linear-solver backend, launcher args and extra driver options.
  • The pips solver derives these from environment defaults overridden by solver_options, defaults the rank count to the block count (capped so PIPS never over-subscribes), sets OMP_NUM_THREADS/MKL_NUM_THREADS, and now also supports srun.

Detached cluster runs (write_job)

  • write_job(export_dir, config, ...) emits a ready-to-sbatch SLURM script: --ntasks from the block count, --cpus-per-task from threads, thread env exports, and the driver launched under srun with the chosen backend. The flow is export → sbatchread_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.
  • A "diagnosing block quality" and a "detached / SLURM" section in the PIPS guide, plus API-reference entries.

Checklist

  • AI-generated content is marked (see AGENTS.md).
  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

FabianHofmann and others added 8 commits July 23, 2026 10:22
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.
…, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant