Source-linked AI summary

GridSFM: A Foundation Model for Solving AC Optimal Power Flow

Luke Bhan, Weiwei Yang, Margaret Capetz, Baosen Zhang

arXiv:2609.30173v1eess.SYcs.LGcs.SYmath.OC

TL;DR

Disconnected AC-OPF feasible sets obstruct continuous neural networks from approximating the solution map. GridSFM combines a pretrained model across grid topologies with physics-informed fine-tuning and a slacked formulation. It reports 2.45% zero-shot generation-cost error and adapts to unseen large grids from 100 solved instances.

  • Problem

    Disconnected AC-OPF feasible sets obstruct continuous neural networks from approximating the load-to-solution map.

    Source: §I · p. 1
  • Method

    GridSFM pairs a multi-topology pretrained model with physics-informed fine-tuning and a slacked AC-OPF formulation.

    Source: §I · p. 1
  • Results

    2.45% zero-shot generation-cost error, with no degradation in accuracy as system size grows.

    Source: §VII · p. 9
  • Takeaways & Limitations

    GridSFM supports solver warm starts and feasible-point projection with explicit guarantees.

    Source: §I · p. 2

Abstract

from arXiv · show

We introduce GridSFM, a framework that combines a pretrained foundation model across grid topologies with physics-informed fine-tuning for solving AC Optimal Power Flow (AC-OPF) at scale. It is a $15$ million parameter physics-inspired graph neural network pretrained across $54$ topologies of $500$ to $4{,}000$ buses. Our model attains a $2.45\%$ zero-shot generation-cost error on a $10{,}000$ bus case held-out operating conditions with no degradation as system size grows. Building on this, we pair the pretrained backbone with a physics-informed fine-tuning design based on Newton's method for power flow. With only $100$ solved instances, GridSFM adapts to unseen grids up to $10{,}000$ buses. We show it out performs single topology, dedicated neural network models that are trained more data, both in terms of cost and solver iterations when deployed as warm starting points. In designing this foundation model, we overcome the fact that the feasible set for AC-OPF can be disconnected. This is an obstruction that prevents any continuous neural network from approximating the solution map. To do so, we lift the problem and relax its constraints with logarithmically penalized slacks. We prove that the resulting elastic feasible set is contractible, that the AC-OPF minimizers remain minimizers of the elastic problem above an explicit penalty threshold, and that projecting an approximate solution back onto the AC-OPF feasible set is well posed. We release all models, data, and code so that the community can build on a shared starting point for AC-OPF.

I. INTRODUCTION

GridSFM combines multi-topology pretraining with physics-informed fine-tuning and an elastic formulation of AC-OPF. The introduction reports zero-shot and adaptation results while addressing the disconnected feasible sets that obstruct continuous neural-network solution maps.

I. INTRODUCTION

  • GridSFM pairs a 15-million-parameter model pretrained across more than 50 topologies with a graph architecture designed for stable training and millisecond batchable inference.The GNN combines linear attention with heterogeneous message passing and predicts generator and voltage setpoints.Source: §I · pp. 1–2
  • The paper states that the slacked problem recovers the AC-OPF minimizers above an explicit penalty threshold and that nearby feasibility projection is unique and Lipschitz.The projection radius is computable from network data and distance to the power-flow singularity.Source: §I · pp. 1–2
  • Fine-tuning completes predicted control setpoints through Newton power flow and trains against a slacked AC-OPF loss, with a differentiable residual term for power-flow failures.The framework combines the standard adjoint method with the residual term to remain stable from poor setpoints and adapt to far out-of-distribution inputs.Source: §I · p. 2
  • 2.45% zero-shot cost error on held-out operating conditions across all 54 pretraining grids.The pretrained backbone also shows no degradation in accuracy as system size grows.Source: §I · p. 2
  • With 100 solved instances, fine-tuning adapts GridSFM to unseen 6,470-bus and 10,000-bus systems in under 80 minutes on one GPU.The cases are case6470_rte and ACTIVSg10k, respectively.Source: §I · p. 2
  • On Texas2k, GridSFM warm starts reduce solver iterations by approximately 7.5×, while projection yields 10,000-bus feasible points at a 0.57% cost gap.The passage also reports that the projection operates at faster speeds.Source: §I · p. 2

II. PROBLEM FORMULATION

  • Disconnected AC-OPF feasible sets obstruct continuous neural networks from approximating the load-to-solution map; the proposed slacked relaxation makes the elastic feasible set contractible.The formulation introduces slack variables for equality and inequality residuals.Source: §II · p. 3
  • The logarithmic slack penalty preserves unit slope at the origin and has a bounded, decaying gradient that keeps divergent power-flow residuals from dominating training.The passage links the unit slope to retaining original AC-OPF local minimizers as minimizers of the slacked problem.Source: §II · p. 3

III. FOUNDATION MODEL DESIGN

GridSFM combines topology-agnostic pretraining, physics-informed fine-tuning, and an output interface for downstream use. Its graph encoding represents grid structure and derives positional information from topology.

III. FOUNDATION MODEL DESIGN

  • The framework maps grid topology, line parameters, and loads to generator active-power outputs and voltage magnitude, then fine-tunes for a grid and connects predictions to downstream tasks.The downstream interface includes warm-starting a conventional solver and projection.Source: §III · p. 3

A. Graph Encoding

  • The input is a heterogeneous graph with seven node types, and signed edges encode line and transformer orientation and cycle traversal.The node types are bus, generator, load, shunt, line, transformer, and cycle.Source: A. Graph Encoding · p. 3
  • Topology-derived positional encodings summarize node neighborhoods and distinguish structurally different parts of the grid.They are computed by diffusion on a topology-based Laplacian, with learned rates controlling neighbor contributions.Source: A. Graph Encoding · pp. 3–4

B. Neural Network Design

GridSFM processes encoded nodes through repeated attention, message-passing, and feed-forward layers. Its output heads produce bounded control estimates, while fine-tuning uses power-flow completion and gradients through the solver when it converges.

B. Neural Network Design

  • Eight layers combine linear self-attention, signed message passing, and position-wise feed-forward networks.Attention operates within each node type and aggregates global information across nodes of that type.Source: B. Neural Network Design · p. 4
  • Linear self-attention uses four concatenated heads in practice, with learned matrices specified per node type and head.The attention layer creates long-range dependencies by computing a shared global state from local hidden states.Source: B. Neural Network Design · p. 4

C. GridSFM Output Heads

  • Output heads fuse neighborhood and grid-wide hidden-state information, then predict generator active power and voltage magnitude within their bounds.Thresholding against generator-power and voltage bounds yields the final control output.Source: C. GridSFM Output Heads · p. 4
  • Fine-tuning runs Newton power flow for each scenario, evaluates its loss at the restored point, and updates the model using gradients through the loss and model.For converged scenarios, the method solves an adjoint system using the retained Jacobian factorization.Source: C. GridSFM Output Heads · p. 5

D. GridSFM Pretraining Loss

Pretraining regresses against solved AC-OPF instances, while physics-informed fine-tuning completes predicted controls with power flow and trains against restored operating points. The loss design also retains a residual-based route for non-convergent power-flow solves.

D. GridSFM Pretraining Loss

  • GridSFM pretraining uses supervised regression on solved AC-OPF instances, with an error function based on the top-k errors and user-set tolerances and weights.The tolerances and weights are specified by the user.Source: D. GridSFM Pretraining Loss · p. 5

IV. PHYSICS-INFORMED FINE-TUNING DESIGN

  • Because pretraining predicts generator setpoints without directly providing voltage and angle solutions, fine-tuning uses power flow to obtain physically compatible solutions for selected grids.The process is summarized in Algorithm 1.Source: §IV · p. 5

A. Power-flow design

  • Power-flow restoration solves the active and reactive residual equations with Newton’s method and a step-halving line search, stopping at 40 iterations or a residual norm of 10^-5 p.u.The resulting power-flow solutions and computed quantities form the restored operating point.Source: A. Power-flow design · p. 5

B. Fine-tuning loss

  • The fine-tuning loss accounts for inequality violations at restored points and differentiates through power flow using the implicit function theorem when the solve converges.The converged-solve gradient reuses the factorization from the final Newton step.Source: B. Fine-tuning loss · p. 5
  • When power flow fails to converge or its Jacobian is singular, fine-tuning drops the state-derivative term and uses the squared residual norm to provide a descent direction.That residual measure is computed from power-flow physics rather than proximity to a label.Source: B. Fine-tuning loss · p. 5

C. Downstream tasks: Feasible Projection and Warm Start

The paper establishes that its elastic AC-OPF formulation has a contractible feasible set, preserves local AC-OPF minimizers above a penalty threshold, and admits a well-posed local projection. GridSFM outputs can be projected to feasible points or used to warm-start conventional solvers, though they are not guaranteed to be exactly optimal or feasible before these steps.

C. Downstream tasks: Feasible Projection and Warm Start

  • Fine-tuned outputs are nearly optimal and feasible, not guaranteed exact; operators can project them to a feasible point or warm-start a conventional solve.Warm starts often outperform flat-start or DC-OPF initialization, while projection is faster and useful when no good warm start exists.Source: C. Downstream tasks: Feasible… · p. 6
  • The authors also envision using GridSFM for N −1 contingency screening, optimal transmission switching, and AC feasibility checks across candidate commitments.These uses involve enumerating topologies, loads, or operating conditions.Source: C. Downstream tasks: Feasible… · p. 6

V. WELL-POSEDNESS OF GRIDSFM TRAINING

  • The lifted elastic feasible set is contractible, hence path-connected and simply connected.Contractibility alone does not make the elastic optimization convex or its solution map continuous.Source: §V · p. 6
  • The projection guarantee assumes a nonsingular power-flow and active-constraint Jacobian near the minimizer, with the reachable radius governed by σ and network-dependent M.The paper identifies this as the standard LICQ assumption and states that the radius δ is σ/M.Source: §V · p. 7
  • When ρmin exceeds Lc/σ, the elastic problem preserves the original local minimizer with zero slacks, although σ depends on the unknown minimizer.The authors note that this makes computing the threshold potentially impractical for operators.Source: §V · p. 7
  • Within δ/2 of a local minimizer, the projection is unique, Lipschitz, and remains on the minimizer’s connected component.Its reachable radius is δ = σ/M, and the projection is well-posed when the LICQ assumption holds.Source: §V · p. 7

VI. NUMERICAL EXPERIMENTS

The experiments evaluate GridSFM as a zero-shot pretrained model across grids and test fine-tuning on out-of-distribution grids. The figure reports generation-cost percentage error against grid size, while the text says fine-tuned performance extrapolates with 100 new labels.

VI. NUMERICAL EXPERIMENTS

  • Fine-tuning extrapolates GridSFM performance to out-of-distribution grids with only 100 new labels.The experiments include zero-shot evaluation and fine-tuning; Fig. 4 plots generation-cost percentage error against bus count across 54 grids.Source: §VI · pp. 7–8, Figure 4 · p. 8

A. Dataset Generation

Across multiple grid topologies and operating conditions, GridSFM maintains zero-shot accuracy as system size grows and supports fine-tuning on unseen grids with 100 solved instances. Its warm starts reduce Ipopt iterations, while feasible projection offers a lower-cost-gap alternative to less accurate baselines.

A. Dataset Generation

  • The pretraining dataset combines base topologies from OPFData, PGLib, Texas A&M Synthetic Grids, and MSR synthetic topologies with perturbations to loads, costs, limits, and generator availability.Permuting generation costs challenges the model to adapt to changing cost rankings rather than memorize dispatch preferences.Source: A. Dataset Generation · p. 8

C. Fine-tuning performance

  • On Texas2k, GridSFM lowers iterations to solve 90% of cases from 422 to 103 (7.6× median speedup); on ACTIVSg10k, from 295 to 87 (3.3×) at 100% convergence.Per-grid MLP and GNN converge on only 3 of 100 cases; Table I reports the warm-start and projection metrics across grid sizes.Source: C. Fine-tuning performance · p. 8, Table I · p. 9
  • On case6470_rte, GridSFM projection is 3.2× faster at a 2.0% gap, while ACTIVSg10k projections finish within 45 iterations at a 0.57% gap.The MLP projection on case6470_rte is 3.6× faster but 32.9% from the optimum.Source: C. Fine-tuning performance · p. 8
  • Both control performance and AC-OPF warm-start iterations improve as more fine-tuning scenarios are used.The paper reports ablations on the power-flow residual in the fine-tuning loss and on the elastic design versus fine-tuning controls alone.Source: C. Fine-tuning performance · p. 8

B. Performance as a model across topologies

  • 2.45% zero-shot generation-cost error is achieved without accuracy degradation as system size grows.Across held-out scenarios, cost errors remain between 1% and 10% on most grids and are approximately constant with bus count.Source: B. Performance as a model across… · p. 8, §VII · p. 9

VII. CONCLUSION

  • With 100 solved instances, physics-informed fine-tuning adapts GridSFM to unseen 6,470-bus and 10,000-bus systems.For warm-starting Ipopt on Texas2k, GridSFM reduces iterations by up to 7.6×.Source: §VII · p. 9

APPENDIX A: PROOFS

The proofs establish that the lifted elastic feasible set is contractible and that feasible AC-OPF minimizers remain local minimizers of the penalized problem under a penalty condition. The argument bounds the cost decrease and penalty near a minimizer using distance to the feasible set.

A.1 Proof of Lemma 1

  • The lifted elastic feasible set is contractible because a homeomorphism maps it onto a product of convex sets.The proof concludes that the set is also simply connected.Source: §A.1 · p. 11

A.2 Proof of Lemma 2

  • Near the feasible minimizer, the cost can fall by at most L_c times the distance to feasibility, while the penalty offsets that decrease.The proof bounds the total constraint violation locally and uses it to lower-bound the logarithmic inequality penalty.Source: §A.2 · p. 11
  • A feasible local minimizer remains a local minimizer of the elastic problem when the penalty coefficient satisfies the stated strict threshold condition.The proof uses ρ_min σ > L_c, choosing σ below the constraint qualification bound σ.Source: §A.2 · pp. 11–12

A.3 Proof of Lemma 3

The proof bounds curvature of the projection problem using the structure of AC power-flow residuals. It separates branch cross terms from bus self terms and uses network-dependent bounds together with LICQ.

A.3 Proof of Lemma 3

  • The nonlinear equality residuals consist of line-flow and bus-balance terms, whose nonlinear dependence is in voltage magnitudes and angles.Generator, load, and line-flow variables enter the residuals linearly; nonlinear terms reduce to branch cross terms and bus self terms.Source: §A.3 · p. 12
  • Each branch cross term depends on four voltage and angle variables, while each bus self term depends only on its voltage magnitude.The proof bounds the Hessians of these terms using voltage limits and line-admittance magnitudes.Source: §A.3 · pp. 12–13
  • The proof assembles the residual Hessian bound by counting branch and bus contributions, then bounds multipliers using LICQ.The resulting bound depends on network quantities, including incident line-admittance magnitudes and the LICQ singular-value bound.Source: §A.3 · p. 13

B.1 Graph encoding

GridSFM represents a grid as a heterogeneous graph and combines per-type feature projections with topology-derived positional encodings. Those encodings use Laplacian diffusion and are learned jointly with the network.

B.1 Graph encoding

  • The graph has seven node types; incidence edges are unsigned for generators, loads, and shunts, and signed for lines and transformers.Lines and transformers also connect to cycles through signed edges indicating cycle traversal direction.Source: §B.1 · p. 13
  • Per-type affine maps lift raw node features to a common hidden dimension, and the architecture concatenates features where needed.For bus, branch, and cycle nodes, positional encodings capture their locations relative to other nodes through topology-based Laplacian diffusion.Source: §B.1 · p. 13
  • Each positional encoding is learned from the node’s T + 1 diffusion states, with the encoding parameters and MLP trained jointly with the network.The topology fixes the Laplacian used for diffusion; the resulting encoding is not precomputed.Source: §B.1 · p. 14

B.2 Neural Network Design

GridSFM stacks eight blocks that combine type-specific self-attention, signed message passing, and position-wise feed-forward processing in pre-normalized residual form.

B.2 Neural Network Design

  • Eight identical blocks sequence linear self-attention, signed message passing, and a position-wise feed-forward network in pre-normalized residual form.The blocks share a common hidden dimension, with parameters learned separately by node type and shared across nodes of that type.Source: §B.2 · p. 14
  • Self-attention acts within each node type, and its four-head form combines four attention-head outputs through a learnable projection.The attention feature map is specified in the design, while the node attends only to nodes of its own type.Source: §B.2 · p. 14
  • Signed message passing aggregates neighboring nodes by type, using edge signs for bus–branch and branch–cycle edges and positive signs for device edges.Learnable parameters are shared across relations with the same ordered pair of neighbor and receiving node types.Source: §B.2 · p. 14
  • The position-wise feed-forward network acts on each node alone, with weights shared among nodes of the same type within a block.Source: §B.2 · p. 14

B.3 GridSFM Output Heads

GridSFM’s output heads fuse neighborhood and grid-level information before predicting controls projected onto operational limits. Its pretraining scenarios combine demand and cost changes with probabilistic congestion, voltage-band, and outage perturbations.

B.3 GridSFM Output Heads

  • Output-head fusion gathers neighborhood information and a global grid summary before producing bus and generator readouts.The fusion also defines a single global summary across the grid.Source: §B.3 · pp. 14–15
  • Each control is predicted by a two-layer GELU network and projected onto its operational interval.The heads are evaluated at in-service generators or voltage-controlled buses, depending on the control.Source: §B.3 · p. 15
  • A fixed seven-value descriptor encodes grid scale and loading, including bus and generator counts, load fractions, voltage band, and branch ratings and admittances.The mean generator voltage setpoint at a bus is also used, with zero assigned where no generator is present.Source: §B.3 · p. 15

C.1 Hyperparameters: Dataset Generation

  • Generation-cost perturbations permute cost coefficients across selected generators, challenging the model to adapt to changing cost rankings rather than memorize dispatch preferences.The dataset also perturbs load, thermal limits, voltage bands, and generator availability.Source: §C.1 · p. 15
  • Demand and generation-cost perturbations apply to every scenario, while congestion, voltage-band, and outage modes occur with probabilities 0.20, 0.15, and 0.30.Perturbation modes are independently drawn and compose, so a scenario includes two to four modes.Source: Table II · p. 15, §C.1 · p. 15

C.2 Hyperparameters: Training and Fine-tuning

The appendix specifies training and baseline configurations, reports GPU solver comparisons, and tests fine-tuning design choices. Ablations show that inequality-penalized elastic loss and a power-flow residual matter for the evaluated warm starts and projections.

C.3 Hyperparameters: Baseline Implementations

  • Baseline configurations include per-grid MLPs trained on 1,000 instances, a shared 678,658-parameter GNN, a 20.07-million-parameter Linux Foundation model, and an unpretrained GridSFM.The MLP sizes vary from 1.07M to 10.76M parameters; the Linux Foundation model is trained on case500_goc alone, while the unpretrained GridSFM uses 1.96M parameters.Source: §C.3 · p. 16

C.4.1 Additional training metrics

  • The appendix provides additional training metrics, including fine-tuning performance and inequality violations, and specifies loss settings such as case6470_rte’s annealed control weight.For that grid, the control weight is annealed from 13.05 to 85 over the first 100 epochs to ensure convergence.Source: §C.4.1 · p. 16, Table III · p. 16

C.4.2 GPU (MadNLP) solver results

  • GPU MadNLP results show little qualitative difference from CPU solver results, and all fine-tuned model warm starts perform similarly.The comparison covers AC-OPF and feasible projection on 100 evaluation problems across grid sizes.Source: §C.4.2 · p. 16, Table VI · p. 19

C.4.3 Ablation study on fine-tuning design

  • On ACTIVSg10k and case6470_rte, fine-tuning with only the pretraining loss does not encourage inequality-satisfying points, producing failed power flows or worse warm-start and projection points than the full elastic loss.The comparison uses the pretrained loss versus the physics-informed fine-tuning loss; the figure evaluates warm starts and feasible projection over 100 cases.Source: §C.4.3 · p. 17, Figure 7 · p. 17
  • On case6470_rte, omitting the power-flow residual makes evaluation cases almost never complete power flow and worsens AC-OPF performance relative to models trained with the merit term.This grid is described as challenging for power-flow completion, with a flat start outperforming a DC start for an AC-OPF solver.Source: §C.4.3 · p. 17, Figure 8 · p. 17
Loading 2609.30173v1…