Skip to content

AARC-lab/L4DC26_VQA

Repository files navigation

The PID Controller Strikes Back: Classical Controller Helps Mitigate Barren Plateaus in Noisy Variational Quantum Circuits

This repository provides the reference implementation of NPID (Neural Enhanced PID Controller), a neural enhanced PID controller quantum circuit architecture designed to mitigate barren plateau effects in variational quantum algorithms by introducing a PID controller in the backward part.

NPID improves both trainability and convergence efficiency.

The repository includes:

  • NPID: A hybrid approach that integrates a classical proportional-integral-derivative (PID) controller with a neural network to update the parameters of variational quantum circuits.
  • NEQP: Neural Enhanced Quantum Parametric Model that only use neural network to update quantum circuit parameters.
  • Vanilla: variational quantum circuit as a baseline (no PID controller).

The flowchart is as follows:

image The construction of the Neural Proportional–Integral–Derivative Model.

Code Architecture

# These are the main functions we used in this project
├── model
│   ├── __init__.py
│   ├── cost_function.py 
│   └── model.py
├── plot
│   ├── __init__.py
│   ├── plot_loss_vs_iteration.py
│   ├── plot_noise_rate_vs_iteration.py
│   └── plot_qubits_vs_iteration.py
├── preparation
│   ├── __init__.py
│   ├── circuit.py
│   ├── config.py
│   ├── create_folder.py
│   └── gpu_info.py
├── __init__.py
└── py.typed


# These are the main python and shell scripts in scripts/
.
├── main.py
└── run_main.sh

Simulation Setup

All simulations are performed using stochastic gradient descent (SGD) with a learning rate of 0.01.

  • Number of qubits: 7–12
  • Circuit depth: $n^2\log (n)$
  • Input states: random quantum states
  • Number of repetitions: 5 for each model
  • Convergence criterion: loss value < 0.001
  • Maximum iteration: 1500

Metrics collected:

  • Average stopping iteration
  • Average convergence efficiency
  • Fluctuation Rate under different noise rate

Running the Code

Step 0

Please install uv

# mac and linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# more information see uv website
https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1

Step 1

# first to clone this repo and synchronize all the necessary package
git clone https://github.com/AARC-lab/DCAS_2026_QLINK.git
cd QLINK
uv venv --python 3.12
source .venv/bin/activate
uv sync
uv build

Step 2

# Make the script executable
chmod +x scripts/run_main.sh

This is how the shell file looks like

# The main shell part
{
    echo "================================================================================"
    echo "START TIME: $(date)"
    echo "DEVICE:     $DEVICE"
    echo "SEED:       $SEED"
    echo "QUBITS:     $N_QUBITS"
    echo "LOG FILE:   $LOG_FILE"
    echo "================================================================================"
    echo ""

    uv run python -u scripts/main.py \
        --device "$DEVICE" \
        --dtype "float32" \
        --seed "$SEED" \
        --n_qubits_list $N_QUBITS \
        --runs_per_model 5 \
        --noise_modes "$NOISE_MODES" \
        --model_list "NPID" "NEQP_S" "NEQP_L" "Vanilla" \
        --noise_type "$NOISE_TYPE" \
        --noise_sigma_fixed 0.01 \
        --noise_sigma_list 0.03 0.05 0.07 0.09 \
        --base_lr 0.01 \
        --mlp_lr 0.01 \
        --gain_lr 0.01 \
        --vanilla_lr 0.01 \
        --max_steps 1500 \
        --loss_eps 0.001 \
        --record_dir "data_record"

    echo ""
    echo "================================================================================"
    echo "FINISH TIME: $(date)"
    echo "================================================================================"
} 2>&1 | tee "$LOG_FILE"
  • You can change settings here as you want.
  • We have two different noise_type, one is fixed_noise, another is list_noise. fixed_noise will give you the outcome shown in Figure 4. list_noise will give you the outcome shown in Figure 6.

Step 3

# To run in the background
bash scripts/run_main.sh 

This will:

  • train all models for different numbers of qubits
  • generate loss curves
  • save figures and data under data_record/
  • all the training output will also be recorded in logs/training_L4DC.log
  • all the paper results are shown in paper_results/

Authors

Zhehao Yi - Algorithm Design, Implementation & Writing
Rahul Bhadani - Project Guidance & Supervision
If you have any questions, please reach out to Zhehao Yi at zhehao.yi@uah.edu

Citation

If you want to cite our work, we recommand in this way:

@inproceedings{yi2026npid,
  author    = {Yi, Z. and Bhadani, R.},
  title     = {The PID Controller Strikes Back: Classical Controller Helps Mitigate Barren Plateaus in Noisy Variational Quantum Circuits},
  booktitle = {2026 8th Annual Conference on Learning for Dynamics and Control},
  year      = {2026},
  month     = {June},
  publisher = {Proceedings of Machine Learning Research},
  note      = {To appear}
}

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors