Skip to main content

Real-time quantum computing interface for power systems optimization

Project description

QuantumGridOS

Python License Documentation

QuantumGridOS is a Python library for connecting power systems data to quantum computers.

[!IMPORTANT] This library currently supports Python 3.8 to 3.11. Python 3.12+ is not yet supported.

It enables solving power system optimization problems using quantum algorithms (QAOA, VQE) with minimal latency TCP/IP data exchange.

๐Ÿš€ Features

  • Real-time TCP/IP streaming for power systems data exchange
  • Quantum algorithm support: QAOA, VQE, Grover's
  • Power system optimizations: Unit commitment, MaxCut, OPF, State estimation
  • Low-latency architecture with async I/O and buffer management
  • Hardware agnostic: Works with IBM Quantum, IonQ, Rigetti, simulators
  • Extensive examples and documentation

๐Ÿ“ฆ Installation

pip install quantumgridos

For development:

git clone https://github.com/saralsystems/quantumgridos.git
cd quantumgridos
pip install -e .[dev]

๐ŸŽฏ Quick Start

Basic MaxCut for Power Network Partitioning

import quantumgridos as qgo

# Initialize quantum-power interface
interface = qgo.QuantumPowerInterface(
    quantum_backend='qiskit_aer',
    tcp_host='localhost',
    tcp_port=5000
)

# Define power network
network = qgo.PowerNetwork.from_ieee_case(14)  # IEEE 14-bus

# Create MaxCut optimizer for network partitioning
optimizer = qgo.MaxCutOptimizer(
    network=network,
    algorithm='qaoa',
    layers=3
)

# Start real-time processing
async def process_stream():
    async for data in interface.tcp_stream():
        # Solve partitioning problem
        result = await optimizer.solve_async(data)
        
        # Send result back to power system
        await interface.send_result(result)

# Run
import asyncio
asyncio.run(process_stream())

Unit Commitment Example

import quantumgridos as qgo

# Configure unit commitment problem
uc_problem = qgo.UnitCommitment(
    generators=[
        {'name': 'G1', 'pmin': 50, 'pmax': 200, 'cost': 1000},
        {'name': 'G2', 'pmin': 20, 'pmax': 100, 'cost': 1500}
    ],
    demand_forecast=[150, 180, 200, 170],
    time_periods=4
)

# Setup quantum solver
solver = qgo.QuantumSolver(
    problem=uc_problem,
    backend='ibmq_qasm_simulator',
    algorithm='vqe',
    optimizer='cobyla'
)

# Solve with TCP streaming
with qgo.TCPInterface(port=5000) as tcp:
    for demand_update in tcp.stream():
        uc_problem.update_demand(demand_update)
        solution = solver.solve()
        tcp.send(solution.to_scada_format())
        solution = solver.solve()
        tcp.send(solution.to_scada_format())

Low-Inertia Counterfactual Search

import quantumgridos as qgo

# Built-in Braket-scale demo case inspired by the GB 9 Aug 2019 disturbance.
study = qgo.create_low_inertia_study()

# QuantumGridOS builds a QUBO candidate-search layer, then validates every
# candidate with reduced frequency-security physics.
result = qgo.solve_low_inertia_counterfactual(
    study,
    solvers=("exact", "annealing", "qaoa"),
    top_k=24,
    qaoa_layers=1,
)

print(result.best.portfolio.selected_labels)
print(result.best.metrics["nadir_hz"])
print(result.best.metrics["max_abs_rocof_hz_s"])

Use this API for low-inertia studies where quantum or quantum-inspired solvers search over approved binary grid/DER settings such as synchronous commitment, BESS fast-frequency response, grid-forming mode, DER ride-through package, and pre-event export reduction. Classical physics validation remains authoritative.

For publication screening, enable the native two-area dynamic-label surrogate:

result = qgo.solve_low_inertia_counterfactual(
    study,
    solvers=("exact", "annealing"),
    dynamic_labels=True,
)

label = qgo.label_low_inertia_dynamics(study, bits=result.best.portfolio.bitstring)
print(label.metrics["max_relative_angle_rad"])
print(label.metrics["min_electromechanical_damping_ratio"])

The dynamic labeler adds inter-area angle, area-frequency split, and small-signal damping checks. It is a reproducible reduced electromechanical screen, not a replacement for RMS/EMT validation.

Public handoff links and CUDA execution requirements are available directly from the package:

import quantumgridos as qgo

catalog = qgo.get_low_inertia_public_data_catalog()
print(catalog["s3_public_handoff_bundle"]["s3_uri"])
print(catalog["public_sources"]["neso_august_2019_frequency"])

The July 2026 handoff bundle is stored at:

  • S3 URI: s3://qgo-low-inertia-public-data-20260706-654777652612/public/low_inertia_quantum_public_handoff_20260706.zip
  • SHA256: 534e4c6b01845f3ac9e48d4fb3f4b0104db025b2f4f6db833eef26ed65bc3fc2
  • Approximate size: 91 MB

The object currently requires a presigned HTTPS URL. Do not commit expiring S3 signed URLs to source control; share them out-of-band or generate a fresh one from the owning AWS account. CUDA/cuOpt comparisons should use the same package-variable schema as the CPU and Qiskit solvers and report end-to-end wall-clock time.

Quantum Power Flow

import quantumgridos as qgo

# Load network from CSV
net = qgo.create_network("examples/test_case_4bus", type='csv')

# Run Quantum Newton-Raphson (HHL Fast Mode)
success, x, history, circuit = qgo.run_quantum_nr(net, method='hhl_fast')

if success:
    print("Converged! Voltage Angles:", net.buses['v_ang'].values)
    # Optional: Visualize the circuit
    # from quantumgridos.utils.visualizer import draw_circuit
    # draw_circuit(circuit)

๐Ÿ—๏ธ Architecture

QuantumGridOS/
โ”œโ”€โ”€ Core Modules
โ”‚   โ”œโ”€โ”€ quantum_interface.py     # Quantum backend abstraction
โ”‚   โ”œโ”€โ”€ tcp_handler.py          # High-performance TCP/IP
โ”‚   โ”œโ”€โ”€ data_encoder.py         # Power data โ†’ Qubits
โ”‚   โ””โ”€โ”€ time_sync.py            # Clock synchronization
โ”œโ”€โ”€ Algorithms
โ”‚   โ”œโ”€โ”€ qaoa.py                 # QAOA implementation
โ”‚   โ”œโ”€โ”€ vqe.py                  # VQE implementation
โ”‚   โ””โ”€โ”€ grover.py               # Grover's algorithm
โ”œโ”€โ”€ Power Systems
โ”‚   โ”œโ”€โ”€ network.py              # Power network modeling
โ”‚   โ”œโ”€โ”€ optimizations/
โ”‚   โ”‚   โ”œโ”€โ”€ unit_commitment.py
โ”‚   โ”‚   โ”œโ”€โ”€ opf.py             # Optimal Power Flow
โ”‚   โ”‚   โ”œโ”€โ”€ state_estimation.py
โ”‚   โ”‚   โ””โ”€โ”€ maxcut.py
โ”‚   โ””โ”€โ”€ converters.py           # IEEE/MATPOWER formats
โ””โ”€โ”€ Utils
    โ”œโ”€โ”€ benchmarks.py
    โ””โ”€โ”€ visualization.py

๐Ÿ“Š Benchmarks

Problem Type Network Size Classical (ms) Quantum (ms) Speedup
MaxCut IEEE 14-bus 120 45 2.67x
Unit Commitment 10 units 340 180 1.89x
State Estimation 30-bus 250 110 2.27x

๐Ÿ”Œ TCP/IP Protocol

QuantumGridOS uses optimized binary protocol for minimal latency:

# Message format
{
    'timestamp': int64,          # Unix timestamp in microseconds
    'msg_type': uint8,          # 0: data, 1: control, 2: result
    'data': {
        'bus_voltages': float32[],
        'line_flows': float32[],
        'generator_status': bool[]
    }
}

๐Ÿ“š Documentation

Full documentation available at saralsystems.github.io/quantumgridos

๐Ÿงช Testing

# Run all tests
pytest tests/

# Run with coverage
pytest --cov=quantumgridos tests/

# Run benchmarks
python -m quantumgridos.benchmark

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

All contributors must sign a Contributor License Agreement (CLA) before their contributions can be merged. See CLA.md for individual contributors and CLA-CORPORATE.md for corporate contributors.

๐Ÿ“„ License

Apache License 2.0 - see LICENSE file.

๐Ÿ“– Citation

If you use QuantumGridOS in research, please cite:

@software{quantumgridos,
  title = {QuantumGridOS: Real-time Quantum-Power Systems Interface},
  author = {Saral Systems},
  year = {2025},
  url = {https://github.com/saralsystems/quantumgridos},
  license = {Apache-2.0}
}

๐Ÿ™ Acknowledgments

Based on research from NREL ARIES and quantum-in-loop (QIL) architecture.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantumgridos-0.1.9.tar.gz (97.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantumgridos-0.1.9-py3-none-any.whl (73.5 kB view details)

Uploaded Python 3

File details

Details for the file quantumgridos-0.1.9.tar.gz.

File metadata

  • Download URL: quantumgridos-0.1.9.tar.gz
  • Upload date:
  • Size: 97.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantumgridos-0.1.9.tar.gz
Algorithm Hash digest
SHA256 3bf5f14da4f255655d1f9205f77ca54c6c0abdbb9c8501414425b50a5bed72df
MD5 f3205961f6c9e0e57f577814332e2684
BLAKE2b-256 a26a1609e6590af5118781430ee71a08e181fc168a7e00e0f6c9c925f4da9cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantumgridos-0.1.9.tar.gz:

Publisher: python-publish.yml on saralsystems/quantumgridos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quantumgridos-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: quantumgridos-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 73.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantumgridos-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f5d465e46ca706c88d251a439c09d10823e1d8efc1e19dac9d43e76f138c4d04
MD5 4cc57d83ffde89f81afd79f5f9df7fed
BLAKE2b-256 c9b8db039fb3848678c91d966cd6f46f676bc3395ad633cbedf946b7ee6ee36f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantumgridos-0.1.9-py3-none-any.whl:

Publisher: python-publish.yml on saralsystems/quantumgridos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page