Quantum ML System

Overview

We focus on the intersection of quantum computer systems and machine learning. We build better ML systems to optimize quantum computing problems and also use quantum computers to run ML tasks. We open-source the TorchQuantum library to facilitate research in this area.

Quantum computing is at a historic time in its development and there is a profound desire for research in quantum computer systems. With quantum systems of tens or hundreds of qubits available, plenty of system-level problems emerge such as compilation, qubit mapping, instruction scheduling, etc. Meanwhile, the large quantum noise on real devices severely jeopardizes reliability. Our goal is to leverage algorithm-system co-design methodology, especially with the help of Machine Learning to improve noise-robust, efficiency, and accuracy of quantum circuits on real quantum devices. Meanwhile, we also expedite leveraging quantum computers to solve ML tasks in order to achieve quantum advantage on machine learning, i.e., better speed, efficiency, and accuracy than classical algorithms.

We envision a future in which machine learning is extensively used in all levels of quantum computer design and quantum computers are also employed in various machine learning tasks. The virtuous cycle is achieved with our fundamental philosophy: cross-stack software-hardware co-design.

Publications

Pipeline for parameterized quantum circuit (quantum neural networks) architecture search:

QuantumNAS: Noise-Adaptive Search for Robust Quantum Circuits

Hanrui Wang, Yongshan Ding, Jiaqi Gu, Zirui Li, Yujun Lin, David Z. Pan, Frederic T. Chong, Song Han
HPCA 2022 paper / code / poster

Quantum noise is the key challenge in Noisy Intermediate-Scale Quantum (NISQ) computers. Previous work for mitigating noise has primarily focused on gate-level or pulse-level noise-adaptive compilation. However, limited research efforts have explored a higher level of optimization by making the quantum circuits themselves resilient to noise. We propose QuantumNAS, a comprehensive framework for noise-adaptive co-search of the variational circuit and qubit mapping. Variational quantum circuits are a promising approach for constructing QML and quantum simulation. However, finding the best variational circuit and its optimal parameters is challenging due to the large design space and parameter training cost. We propose to decouple the circuit search and parameter training by introducing a novel SuperCircuit. The SuperCircuit is constructed with multiple layers of pre-defined parameterized gates and trained by iteratively sampling and updating the parameter subsets (SubCircuits) of it. It provides an accurate estimation of SubCircuits performance trained from scratch. Then we perform an evolutionary co-search of SubCircuit and its qubit mapping. The SubCircuit performance is estimated with parameters inherited from SuperCircuit and simulated with real device noise models. Finally, we perform iterative gate pruning and finetuning to remove redundant gates. Extensively evaluated with 12 QML and VQE benchmarks on 10 quantum computers, QuantumNAS significantly outperforms baselines. For QML, QuantumNAS is the first to demonstrate over 95% 2-class, 85% 4-class, and 32% 10-class classification accuracy on real QC. It also achieves the lowest eigenvalue for VQE tasks on H2, H2O, LiH, CH4, BeH2 compared with UCCSD.

QuantumNAS motivation and framework overview:

  • The quantum noise severely degrades the accuracy of parameterized quantum circuits on real machine.
  • Given the huge design space of parameterized quantum circuits, how to efficiently design robust circuit architecture is a challenge.

Basic idea of QuantumNAS: decoupling the training and search. We only pay the training cost of SuperCircuit for once but can use it to evaluate many candidates.

QuantumNAS models achieve higher robustness and accuracy than human baseline and noise-unaware search models:

QuantumNAT: Quantum Noise-Aware Training with Noise Injection, Quantization and Normalization

Hanrui Wang, Jiaqi Gu, Yongshan Ding, Zirui Li, Frederic T. Chong, David Z. Pan and Song Han

DAC 2022 paper / code

Parameterized Quantum Circuits (PQC) are promising towards quantum advantage on near-term quantum hardware. However, due to the large quantum noises (errors), the performance of PQC models has a severe degradation on real quantum devices. Take Quantum Neural Network (QNN) as an example, the accuracy gap between noise-free simulation and noisy results on IBMQ-Yorktown for MNIST-4 classification is over 60%. Existing noise mitigation methods are general ones without leveraging unique characteristics of PQC; on the other hand, existing PQC work does not consider noise effect. To this end, we present QuantumNAT, a PQC-specific framework to perform noise-aware optimizations in both training and inference stages to improve robustness. We experimentally observe that the effect of quantum noise to PQC measurement outcome is a linear map from noise-free outcome with a scaling and a shift factor. Motivated by that, we propose post-measurement normalization to mitigate the feature distribution differences between noise-free and noisy scenarios. Furthermore, to improve the robustness against noise, we propose noise injection to the training process by inserting quantum error gates to PQC according to realistic noise models of quantum hardware. Finally, post-measurement quantization is introduced to quantize the measurement outcomes to discrete values, achieving the denoising effect. Extensive experiments on 8 classification tasks using 6 quantum devices demonstrate that QuantumNAT improves accuracy by up to 43%, and achieves over 94% 2-class, 80% 4-class, and 34% 10-class classification accuracy measured on real quantum computers. The code for construction and noise-aware training of PQC is available in the TorchQuantum library.

QuantumNAT framework overview:

QuantumNAT improves QNN accuracy on real quantum machines:

QOC: Quantum On-Chip Training with Parameter Shift and Gradient Pruning

Hanrui Wang*, Zirui Li*, Jiaqi Gu, Yongshan Ding, David Z. Pan and Song Han
DAC 2022 paper / code

Parameterized Quantum Circuits (PQC) are drawing increasing research interest thanks to its potential to achieve quantum advantages on near-term Noisy Intermediate Scale Quantum (NISQ) hardware. In order to achieve scalable PQC learning, the training process needs to be offloaded to real quantum machines instead of using exponential-cost classical simulators. One common approach to obtain PQC gradients is parameter shift whose cost scales linearly with the number of qubits. We present QOC, the first experimental demonstration of practical on-chip PQC training with parameter shift. Nevertheless, we find that due to the significant quantum errors (noises) on real machines, gradients obtained from naive parameter shift have low fidelity and thus degrading the training accuracy. 

To this end, we further propose probabilistic gradient pruning to firstly identify gradients with potentially large errors and then remove them. Specifically, small gradients have larger relative errors than large ones, thus having a higher probability to be pruned. We perform extensive experiments with the Quantum Neural Network (QNN) benchmarks on 5 classification tasks using 5 real quantum machines. The results demonstrate that our on-chip training achieves over 90% and 60% accuracy for 2-class and 4-class image classification tasks. The probabilistic gradient pruning brings up to 7% PQC accuracy improvements over no pruning. Overall, we successfully obtain similar on-chip training accuracy compared with noise-free simulation but have much better training scalability. The QOC code is available in the TorchQuantum library.

QOC framework overview:

 

QOC achieves higher scalability for than training on classical machines:

TorchQuantum Library

TorchQuantum is the library for quantum machine learning and machine learning for quantum. It has several main features:

  • Easy construction of parameterized quantum circuits such as Quantum Neural Networks in PyTorch
  • Support batch mode inference and training on GPU/CPU, supports highly-parallelized training
  • Support easy deployment on real quantum devices such as IBMQ
  • Provide tutorials, videos and example projects of QML and using ML to optimize quantum computer system problems
Installation

To install TorchQuantum, run the following commands in the terminal:

git clone https://github.com/mit-han-lab/torchquantum.git
cd torchquantum
pip install --editable .
python fix_qiskit_parameterization.py
Documentation
GitHub
Support

If you have any questions or comments for TorchQuantum, please feel free to post to our forum or contact the TorchQuantum team. Contributions are highly welcomed!

Tutorials

We introduce several projecs of quantum machine learning and explain how to use TorchQuantum to implement them.

Simple MNIST Example 

Link

Construction and training of simple QNN to perform MNIST image classification task and deploy on real QC.

Quantum Convolutional (Quanvolution)

Link / Video

Construction and training of Quantum Convolution (Quanvolution) Neural Networks to perform MNIST image classification task and deploy on real QC.

Quantum Kernel Method

Link / Video

Construction and training of Quantum Convolution (Quanvolution) Neural Networks to perform MNIST image classification task and deploy on real QC.

On-chip QNN Training

Link

Training QNN with real quantum machine, using the parameter shift rules to get gradients.

Clifford QNN

Link

Construct and train QNN with only Clifford gates in order to reduce classical simulation cost.