Skip to content

ichbingautam/QMitigate

Repository files navigation

QMitigate

High-Performance Quantum Error Mitigation Engine

A C++ quantum state-vector simulator with Zero-Noise Extrapolation for NISQ processors

C++20 OpenMP Python License: MIT


🎯 Research Statement

I am a Quantum Research Engineer focused on error mitigation and compiler optimization for superconducting qubits. My work aims to squeeze maximum utility out of current NISQ devices.

This project demonstrates the intersection of High-Performance Computing, Quantum Physics, and Research Engineering by implementing a production-grade quantum simulator with state-of-the-art error mitigation.


📚 Table of Contents


🔬 The Problem

Quantum computers today operate in the Noisy Intermediate-Scale Quantum (NISQ) era:

  • Gate errors: ~0.1-1% per operation
  • Decoherence: Qubits lose information over time (T1, T2 decay)
  • Exponential noise accumulation: Deep circuits become useless
Circuit Depth →
  ▲
  │  ■ Ideal Result (perfect)
  │   ╲
  │    ╲  ● Noisy Result (exponential decay)
  │     ╲●
  │      ╲●
  │       ●╲●
  │         ╲●●●●
  ╰─────────────────→ Fidelity

💡 The Solution: Zero-Noise Extrapolation

ZNE recovers accurate results by:

  1. Noise Scaling: Run circuits at multiple noise levels (1×, 3×, 5×)
  2. Digital Folding: Replace $U \rightarrow U U^\dagger U$ to amplify noise
  3. Extrapolation: Fit noisy data and extrapolate to zero noise
from qmitigate import Circuit, Simulator, ZeroNoiseExtrapolator

# Create noisy simulator
noise = create_depolarizing_noise_model(0.02)
sim = Simulator(noise)

# Build circuit
circuit = Circuit(2)
circuit.h(0)
circuit.cnot(0, 1)

# Apply ZNE
zne = ZeroNoiseExtrapolator(sim, scale_factors=[1, 3, 5])
mitigated_value = zne.mitigate_expectation_Z(circuit, qubit=0)

📐 Mathematical Theory

Depolarizing Channel

The depolarizing channel is the primary noise model:

$$\mathcal{E}(\rho) = (1-p)\rho + \frac{p}{3}(X\rho X + Y\rho Y + Z\rho Z)$$

where $p$ is the error probability per gate.

Richardson Extrapolation

Given noisy expectation values at scale factors $\lambda_1, \lambda_2, \lambda_3$:

$$E(\lambda) = E(0) + a_1\lambda + a_2\lambda^2 + \ldots$$

We solve for $E(0)$ using polynomial fitting or the Richardson formula:

$$E_{mitigated} = \frac{\lambda_2 E(\lambda_1) - \lambda_1 E(\lambda_2)}{\lambda_2 - \lambda_1}$$

Digital Folding

To scale noise without modifying hardware:

$$U \xrightarrow{\text{3× folding}} U U^\dagger U \xrightarrow{\text{5× folding}} U U^\dagger U U^\dagger U$$

This maintains logical equivalence ($U^\dagger U = I$) while physically tripling circuit depth.


✨ Key Features

High-Performance Computing

Feature Implementation Benefit
C++ Core State-vector simulator 50-100× faster than Python
OpenMP Parallel gate application Multi-core utilization
Sparse Gates O(2ⁿ) vs O(4ⁿ) Memory efficient
PyBind11 Python interface Research flexibility

Quantum Simulation

  • Single-qubit gates: X, Y, Z, H, S, T, RX, RY, RZ, U3
  • Two-qubit gates: CNOT, CZ, CY, SWAP, CRZ
  • Three-qubit gates: Toffoli, Fredkin
  • Multi-controlled: MCX with arbitrary controls

Error Mitigation

  • Noise channels: Depolarizing, bit-flip, phase-flip
  • ZNE methods: Richardson, linear, exponential extrapolation
  • Bias-variance: Statistical analysis tools

🛠 Build Instructions

Prerequisites

  • CMake 3.16+
  • C++20 compiler (GCC 10+, Clang 12+)
  • OpenMP
  • Python 3.8+ with NumPy, SciPy

Build Steps

# Clone repository
git clone https://github.com/yourusername/QMitigate.git
cd QMitigate

# Create build directory
mkdir build && cd build

# Configure with CMake
cmake .. -DCMAKE_BUILD_TYPE=Release

# Build
make -j$(nproc)

# Run tests
ctest --verbose

# Run benchmarks
./benchmark_engine

Python Setup

# Install Python dependencies
pip install numpy scipy matplotlib

# Add to Python path
export PYTHONPATH=$PYTHONPATH:/path/to/QMitigate/python

🚀 Quick Start

C++ Usage

#include "qmitigate/simulator.hpp"

using namespace qmitigate;

int main() {
    // Create Bell state circuit
    Circuit circuit(2);
    circuit.h(0);
    circuit.cnot(0, 1);

    // Run simulation
    Simulator sim;
    QuantumState result = sim.run(circuit);

    // Measure
    std::cout << "⟨Z₀⟩ = " << result.expectation_Z(0) << std::endl;
    return 0;
}

Python Usage

from qmitigate import (
    Circuit, Simulator, create_depolarizing_noise_model,
    ZeroNoiseExtrapolator, richardson_extrapolate
)

# Build circuit
circuit = Circuit(3)
for q in range(3):
    circuit.h(q)
circuit.cnot(0, 1)
circuit.cnot(1, 2)

# Ideal simulation
ideal_sim = Simulator()
ideal_result = ideal_sim.run(circuit)
ideal_value = ideal_result.expectation_Z(0)

# Noisy simulation with ZNE
noise = create_depolarizing_noise_model(0.02)
noisy_sim = Simulator(noise)

zne = ZeroNoiseExtrapolator(noisy_sim, scale_factors=[1, 3, 5])
mitigated, data = zne.mitigate_expectation_Z(circuit, qubit=0, return_raw=True)

print(f"Ideal: {ideal_value:.4f}")
print(f"Noisy: {data['unmitigated']:.4f}")
print(f"Mitigated: {mitigated:.4f}")

📊 Results

The "Money Plot": ZNE Recovery

ZNE Recovery

Measurement Value Error
Ideal 0.9500
Noisy (raw) 0.7200 0.2300
ZNE Mitigated 0.9350 0.0150
Improvement 15.3×

Performance Benchmark

╔══════════════════════════════════════════════════════════════╗
║         QMitigate High-Performance Benchmark                  ║
╚══════════════════════════════════════════════════════════════╝

Qubits    Depth    State (MB)    Time (ms)    Gates/sec
-------------------------------------------------------
     5       50          0.00        0.012    4,166,667
    10       50          0.02        0.089      561,798
    15       50          0.52        2.341       21,358
    20       50         16.78       78.234          639
    25       50        537.00     2,891.00           17

🏗 Architecture

QMitigate/
├── include/qmitigate/
│   ├── types.hpp          # Core types (Complex, GateType, etc.)
│   ├── quantum_state.hpp  # QuantumState class
│   ├── gates.hpp          # Gate operations
│   ├── noise_model.hpp    # Noise channels
│   └── simulator.hpp      # Circuit simulator
├── src/
│   ├── quantum_state.cpp
│   ├── gates.cpp
│   ├── noise_model.cpp
│   ├── simulator.cpp
│   └── python_bindings.cpp
├── python/qmitigate/
│   ├── __init__.py
│   ├── zne.py             # ZNE implementation
│   └── benchmarks.py
├── tests/unit/
├── benchmarks/
└── notebooks/
    └── Demo_ZNE_Correction.ipynb

📖 Research References

Foundational Papers

  1. Temme, K., Bravyi, S., & Gambetta, J. M. (2017) "Error mitigation for short-depth quantum circuits." Physical Review Letters.

    Origin of ZNE theory. Proved that noisy expectation values can be expressed as a power series in the noise parameter.

  2. Giurgica-Tiron, T., et al. (2020) "Digital zero noise extrapolation for quantum error mitigation." IEEE ICQC.

    Introduced digital folding ($U \to UU^\dagger U$) as a hardware-agnostic noise scaling method.

  3. LaRose, R., et al. (2022) "Mitiq: A software package for error mitigation on noisy quantum computers." Quantum.

    Discusses bias-variance tradeoff in ZNE and provides practical implementation guidelines.

Related Work

  • VQE: Peruzzo, A., et al. (2014). "A variational eigenvalue solver on a photonic quantum processor."
  • QAOA: Farhi, E., et al. (2014). "A Quantum Approximate Optimization Algorithm."
  • Quantum Chemistry: McArdle, S., et al. (2020). "Quantum computational chemistry."

🔧 Technical Differentiators

For Research Engineer Roles

  1. OpenMP Parallelization

    #pragma omp parallel for
    for (std::size_t i = 0; i < N; i += 2 * step) {
        // Gate application with cache-efficient access
    }
  2. Hypothesis Testing (Python)

    from hypothesis import given, strategies as st
    
    @given(st.integers(min_value=1, max_value=10))
    def test_circuit_matches_qiskit(num_qubits):
        # Property-based testing against Qiskit
  3. Memory Limit Handling

    if (num_qubits > MAX_QUBITS) {
        throw std::runtime_error("Memory limit exceeded");
    }

📈 Potential Applications

Domain Application QMitigate Contribution
Quantum Chemistry Molecular ground state energy VQE with ZNE for H₂ simulation
Finance Portfolio optimization QAOA with noise mitigation
Machine Learning Quantum kernels Improved classification accuracy

🤝 Contributing

Contributions are welcome! Areas of interest:

  • Probabilistic Error Cancellation (PEC)
  • Clifford Data Regression (CDR)
  • GPU acceleration (CUDA/ROCm)
  • Qiskit/Cirq backend integration

📄 License

MIT License - See LICENSE for details.


Built with ❤️ for the Quantum Computing Research Community

Demonstrating the intersection of HPC Systems, Quantum Physics, and Research Engineering

About

Characterization and Error Mitigation of NISQ Processors using Zero-Noise Extrapolation (ZNE).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published