Skip to main content

LossAware-GraphCompiler: CPU-only loss-aware quantum graph compiler for photonic quantum computing simulation

Project description

Python License Platform Version

LAGC

LossAware-GraphCompiler

A CPU-only, loss-aware quantum graph compiler for photonic quantum computing simulation

FeaturesInstallationQuick StartDocsCitation


🎯 What is LAGC?

LAGC is a high-performance simulation library for photonic quantum computing that runs entirely on CPU — no GPU required.

It models realistic photon loss, automatically repairs damaged graph states through graph surgery, and performs memory-efficient tensor network contraction to simulate large-scale cluster states.

Why LAGC?

Traditional Simulators LAGC
Requires GPU CPU-only operation
Disk swap on memory overflow (100x slower) Recursive slicing within RAM
Ideal states only Realistic loss modeling + auto recovery
Low experimental accuracy Hardware-aware error mitigation

✨ Key Features

  • 🖥️ CPU-Only: No GPU required — runs on standard hardware
  • 📉 Loss-Aware: Realistic photon loss modeling with automatic graph surgery
  • 💾 Memory-Efficient: Recursive tensor slicing stays within RAM limits
  • 🔧 Hardware Models: Built-in noise profiles (ideal, realistic, near-term, experimental, future)
  • 📊 Multiple Topologies: 3D RHG, 2D Cluster, Linear, GHZ, Ring, Complete

📦 Installation

pip install lagc

From Source

git clone https://github.com/quantum-dev/lagc.git
cd lagc
pip install -e ".[dev]"

Requirements

  • Python ≥ 3.9
  • NumPy, SciPy, opt-einsum, NetworkX (auto-installed)
  • No GPU needed

🚀 Quick Start

from lagc import LAGC

# 1. Create simulator (8GB RAM limit)
sim = LAGC(ram_limit_gb=8.0, hardware='realistic')

# 2. Build 3D RHG lattice (for fault-tolerant quantum computing)
sim.create_lattice('3d_rhg', 5, 5, 5)
print(f"Created: {sim.n_qubits} qubits")

# 3. Apply 5% photon loss with automatic recovery
sim.apply_loss(p_loss=0.05)

# 4. Run simulation
result = sim.run_simulation()

# 5. Get results
print(f"Fidelity: {result.fidelity:.4f}")
print(f"Active qubits: {result.n_active}/{result.n_qubits}")
print(f"Time: {result.execution_time:.2f}s")

🗺️ Supported Topologies

Topology Use Case
'3d_rhg' Fault-tolerant MBQC (Raussendorf-Harrington-Goyal)
'2d_cluster' Standard cluster state
'linear' 1D chain (one-way quantum computing)
'ghz' GHZ state (entanglement distribution)
'ring' Cyclic protocols
'complete' Fully connected graph

🔧 Hardware Models

from lagc import LAGC

# Built-in presets
sim = LAGC(hardware='ideal')        # Perfect system (no errors)
sim = LAGC(hardware='realistic')    # Current technology
sim = LAGC(hardware='near_term')    # 5-year projection
sim = LAGC(hardware='experimental') # Cutting-edge prototypes
sim = LAGC(hardware='future')       # 10-year outlook

Custom Hardware

from lagc import HardwareModel, HardwareParams

params = HardwareParams(
    source_efficiency=0.92,
    detector_efficiency=0.88,
    gate_error_cz=0.015,
    coherence_time=5e-6
)
sim = LAGC(hardware=HardwareModel(params))

📊 Example: Loss Threshold Analysis

from lagc import LAGC

sim = LAGC(hardware='ideal', seed=42)

results = sim.scan_loss_rates(
    loss_rates=[0.0, 0.05, 0.10, 0.15, 0.20],
    topology='2d_cluster',
    dims=(10, 10),
    n_samples=5
)

for p, f in zip(results['loss_rates'], results['fidelities']):
    bar = '█' * int(f * 30)
    print(f"p={p:.2f}: {f:.4f} |{bar}")

Output:

p=0.00: 1.0000 |██████████████████████████████
p=0.05: 0.8521 |█████████████████████████
p=0.10: 0.6234 |██████████████████
p=0.15: 0.3892 |███████████
p=0.20: 0.1847 |█████

🧮 Core Algorithms

Algorithm 1: Graph Surgery (XOR-based)

For each lost photon, performs Local Complementation (τ_a) to repair the graph state:

# Invert edges between neighbors of lost node a
adj_matrix[neighbors(a), neighbors(a)] ^= 1

Algorithm 2: Recursive Tensor Slicing

Automatic memory management:

Intermediate tensor > Available RAM?
├── YES → Cut highest-centrality bond
│         ├── Branch 0: index=0
│         └── Branch 1: index=1
│         → Parallel execution via ProcessPoolExecutor
└── NO  → Direct contraction

Algorithm 3: Fidelity Estimation

$$F_{final} = \prod (1 - p_{gate})^{n_{gates}} \times \exp\left(-\sum \text{loss_paths}\right)$$


⚡ Performance

Lattice Qubits Time (8-core) Memory
4×4 Cluster 16 0.07s < 1 GB
5×5 Cluster 25 ~62s ~2 GB
3D RHG 2×2×2 18 0.21s < 1 GB

Benchmarked on Intel Core i7


💻 Command Line Interface

# Show version
lagc --version

# Show library info
lagc info

# Run simulation
lagc simulate --topology 2d_cluster --size 5 5 --loss 0.05 --hardware realistic

📚 API Reference

Main Classes

Class Description
LAGC Main simulator interface
StabilizerGraph Graph state management
TensorSlicer Memory-efficient contraction
LossRecovery Error mitigation
HardwareModel Noise modeling
TopologyGenerator Lattice creation
from lagc import (
    LAGC,
    StabilizerGraph,
    TensorSlicer,
    LossRecovery,
    HardwareModel,
    TopologyGenerator,
)

📖 Documentation

Full documentation: https://lagc.readthedocs.io


📝 Citation

If you use LAGC in your research, please cite:

@software{lagc2026,
  title = {LAGC: LossAware-GraphCompiler for Photonic Quantum Computing},
  author = {LAGC Research Team},
  year = {2026},
  url = {https://github.com/quantum-dev/lagc},
  version = {1.0.0}
}

📚 References

  1. Raussendorf, R., Harrington, J., & Goyal, K. (2007). "Topological fault-tolerance in cluster state quantum computation." New Journal of Physics.

  2. Bartolucci, S., et al. (2023). "Fusion-based quantum computation." Nature Communications.

  3. Bombin, H., et al. (2021). "Interleaving: Modular architectures for fault-tolerant photonic quantum computing." arXiv:2103.08612.


🤝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

# Development setup
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Format code
black lagc/
isort lagc/

📄 License

MIT License - see LICENSE for details.


LAGC v1.0.0
Accelerating Photonic Quantum Computing Research

⭐ Star us on GitHub if LAGC helps your research!

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

lagc_quantum_photonics-1.1.4.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

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

lagc_quantum_photonics-1.1.4-py3-none-any.whl (48.3 kB view details)

Uploaded Python 3

File details

Details for the file lagc_quantum_photonics-1.1.4.tar.gz.

File metadata

  • Download URL: lagc_quantum_photonics-1.1.4.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for lagc_quantum_photonics-1.1.4.tar.gz
Algorithm Hash digest
SHA256 703111c36c590424c0474d2d91b4553343b768e1e3edf8a01214b8aebe75a7e4
MD5 d3be9023562e5f21bf5313976dca24e8
BLAKE2b-256 cbeb9addc468d16a2cf9e8b052850ac162fb2a41e7b1727d4a34c7829adbf3a7

See more details on using hashes here.

File details

Details for the file lagc_quantum_photonics-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for lagc_quantum_photonics-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bde0a7bcf2bbf8cac27bf03fe693a7ec89b126fb685d9faffda34bbdf5236347
MD5 15de2c959760390b93bf2f1f4da93523
BLAKE2b-256 1fb0e69b02356ec35f624b35081daa26b46c35a8485e0c1b09a1d8a6e52d80e6

See more details on using hashes here.

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