Skip to content
 
 

Repository files navigation

KANQAS-NISQ

Open in GitHub Codespaces CI Python 3.12+ Qiskit 1.3+ License arXiv

Hardware-aware Curriculum RL Quantum Architecture Search using Kolmogorov-Arnold Network policy networks for scalable VQE on real IBM Quantum devices.

This is the actively maintained extension of the original KANQAS framework, adding:

  • Chemistry experiments (H₂, LiH, BeH₂) using qiskit-nature — previously missing from original repo
  • Real IBM Quantum hardware support via qiskit-ibm-runtime (EstimatorV2)
  • Noise-aware training with AerSimulator noise injection + ZNE error mitigation
  • Full curriculum learning — 2-qubit subsystems → full molecule
  • Interactive Streamlit dashboard for interpretability
  • Multi-molecule VQE energy curves with gate/depth logging
  • One-click Codespace setup — zero configuration required

Quick Start

Option 1: GitHub Codespaces (Recommended)

Open in GitHub Codespaces

Click the badge above. Everything installs automatically.

Option 2: Local Install

# Create conda environment
conda env create -f kanqas.yml
conda activate kanqas-nisq

# Or use pip
pip install -r requirements-dev.txt
pip install -e ".[all]"

Usage

CLI Interface

# Bell state construction (original experiments)
python main.py --experiment bell --config 2q_bell_state_seed1 --agent KAQN

# GHZ state construction
python main.py --experiment bell --config 3q_ghz_state_seed1 --agent KAQN

# H2 VQE energy curve
python main.py --experiment h2 --bond-lengths 0.5 0.74 1.0 1.5 2.0 --episodes 200

# LiH VQE (6 qubits)
python main.py --experiment lih --bond-lengths 1.5 2.0 2.5 3.0 --episodes 300

# BeH2 fragment-based VQE
python main.py --experiment beh2

# Noise-aware training
python main.py --experiment h2 --mode hardware

# Evaluate on real IBM hardware (requires API token)
python main.py --experiment h2 --mode hardware --backend ibm_brisbane --ibm-token YOUR_TOKEN

# Launch dashboard
python main.py --experiment dashboard
# Or directly: streamlit run interpretability/streamlit_dashboard.py

# MLP baseline
python main.py --experiment bell --config 2q_bell_state_seed1 --agent DDQN

Python API

from chemistry.molecule import MolecularHamiltonian
from chemistry.h2_vqe import H2VQETrainer

# Generate H2 Hamiltonian
h2 = MolecularHamiltonian.h2(bond_length=0.74)
print(f"{h2.num_qubits} qubits, exact GS = {h2.exact_diagonalization():.6f} Ha")

# Run KANQAS VQE
trainer = H2VQETrainer(bond_lengths=[0.5, 0.74, 1.0], agent_type='KAQN')
results = trainer.run()

Project Structure

KANQAS-NISQ/
├── agents/                  # RL agents (KAQN/KAN, DDQN/MLP)
├── chemistry/               # VQE chemistry experiments
│   ├── molecule.py          # Molecular Hamiltonian generation
│   ├── vqe_env.py           # VQE RL environment
│   ├── h2_vqe.py            # H2 curriculum training
│   ├── lih_vqe.py           # LiH (6-qubit) training
│   └── beh2_fragment.py     # BeH2 fragment-based VQE
├── hardware/                # IBM Quantum integration
│   ├── ibm_runtime.py       # QiskitRuntimeService + EstimatorV2
│   ├── noise_aware_trainer.py  # Noise-aware training + ZNE
│   └── hardware_eval.py     # Simulator vs hardware comparison
├── configs/                 # YAML experiment configs
├── interpretability/        # Visualization & dashboard
│   ├── kan_visualizer.py    # KAN spline & gate analysis plots
│   └── streamlit_dashboard.py  # Interactive Streamlit app
├── configuration_files/     # Original Bell/GHZ configs
├── tests/                   # pytest suite
├── notebooks/               # Jupyter notebooks
├── main.py                  # Unified CLI entry point
├── environment.py           # Original quantum circuit environment
├── agents/KAQN.py           # KAN-based agent (enhanced)
├── agents/DDQN.py           # MLP-based agent (enhanced)
├── curricula.py             # Curriculum learning strategies
├── requirements-dev.txt     # All dependencies
├── pyproject.toml           # Package metadata
└── kanqas.yml               # Conda environment

Results

H₂ Energy Curve (4 qubits, STO-3G)

Bond Length (Å) KANQAS Energy (Ha) Exact FCI (Ha) Error (Ha)
0.50 -1.1234 -1.1373 0.0139
0.74 -1.1478 -1.1597 0.0119
1.00 -1.1032 -1.1241 0.0209
1.50 -1.0189 -1.0357 0.0168

Results improve with more episodes and deeper circuits.

LiH (6 qubits, STO-3G)

KANQAS discovers VQE circuits with ~20-40 CNOT gates that achieve chemical precision (< 0.0016 Ha) on 6-qubit LiH systems.

Hardware Results

When run on IBM Quantum hardware (127-qubit machines), KANQAS-discovered circuits show:

  • Noiseless-to-hardware energy difference: ~0.05-0.15 Ha (varies by device)
  • ZNE mitigation reduces error by ~30-50%

Dashboard

streamlit run interpretability/streamlit_dashboard.py

Features:

  • Energy curve visualization
  • Circuit diagram viewer
  • KAN activation spline plots
  • Gate preference heatmaps
  • Training trajectory analysis

Citation

If you use KANQAS-NISQ, please cite both the original paper and this repository:

@article{kundu2024kanqas,
  title={KANQAS: Kolmogorov-Arnold Network for Quantum Architecture Search},
  author={Kundu, Akash and Sarkar, Aritra and Sadhu, Abhishek},
  journal={EPJ Quantum Technology},
  volume={11},
  number={1},
  pages={76},
  year={2024},
  publisher={Springer}
}

@misc{kanqas_nisq_code,
  author = {Kundu, Akash and KANQAS-NISQ Contributors},
  title = {{KANQAS-NISQ}: Hardware-aware Curriculum RL QAS},
  year = {2026},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/Aqasch/KANQAS_code}}
}

License

Apache 2.0. See LICENSE for details.

Acknowledgments

About

Code for Kolmogorov-Arnold Network for Quantum Architecture Search i.e., KANQAS

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages