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.
pip install quantumgridos
For development:
git clone https://github.com/saralsystems/quantumgridos.git
cd quantumgridos
pip install -e .[dev]
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())
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())
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)
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
| 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 |
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[]
}
}
Full documentation available at saralsystems.github.io/quantumgridos
# Run all tests
pytest tests/
# Run with coverage
pytest --cov=quantumgridos tests/
# Run benchmarks
python -m quantumgridos.benchmark
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.
Apache License 2.0 - see LICENSE file.
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}
}
Based on research from NREL ARIES and quantum-in-loop (QIL) architecture.