Skip to content

mahabubul-alam/QAOA-Compiler

Repository files navigation

QAOA Compiler with Qiskit Backend

This repository holds implementations of QAOA-specific compilation policies described in the following articles for superconducting quantum processors (on top of the Qiskit compiler backend):

Dependencies

  • python>=3.6.13
  • qiskit==0.23.1
  • networkx==2.5
  • commentjson==0.9.0

Environment Setup

git clone https://github.com/mahabubul-alam/QAOA-Compiler.git
cd QAOA-Compiler
conda create -n XX python=3.6.13
conda activate XX
pip install -r requirements.txt

Structure

  • compile_qaoa: Python Class implementation of the compilation policies.
  • examples: Sample input files and outputs.
  • utils: Helper scripts to generate input json files.

How to Run

python run.py -arg arg_val
  • -device_json string (mandatory): Target device configuration file location. This file holds the information on basis gates, reliability, and allowed two-qubit operations. It has to be written in json format. An example can be found here.

  • -circuit_json string (mandatory): Problem QAOA-circuit file location. This file holds the required ZZ interactions between various qubit-pairs to encode the cost hamiltonian. It has to be written in json format. An example can be found here.

  • -config_json string (mandatory): Compiler configuration file location. This file holds target p-level, and chosen packing limit, qiskit transpiler seed, optimization level, and routing method. It has to be written in json format. An example can be found here.

  • -policy_compilation string: Chosen compilation policy. The current version supports the following policies: Instruction Parallelization-only ('IP'), Iterative Compilation ('IterC'), Incremental Compilation ('IC'), Variation-aware Incremental Compilation ('VIC'). The default value is 'IC'.

  • -target_IterC string: Minimization objective of Iterative Compilation. The current version supports the following minimization objectives: Circuit Depth ('D'), Native two-qubit gate-count ('GC_2Q'), Estimated Success Probability ('ESP'). The default value is 'GC_2Q'.

  • -initial_layout_method string: The chosen initial layout method. Currently supported methods: 'vqp', 'qaim', 'random'. The default method is 'qaim'.

  • -output_qasm_file_name string: File name to write the compiled parametric QAOA circuit. The output is written in qasm format. The default value is 'QAOA.qasm'. The output qasm files are written following this naming style: {Method(IP/IC/VIC/IterC)}_{output_qasm_file_name}.

Running the Example

python run.py -device_json examples/QC.json -circuit_json examples/QAOA_circ.json -config_json examples/Config.json  -policy_compilation VIC -initial_layout_method vqp
python run.py -d examples/QC.json -ci examples/QAOA_circ.json -co examples/Config.json  -p VIC -i vqp

Printed in the Terminal

############################################################################
Variation-aware Incremental Compilation (VIC) completed (initial layout: vqp)!
QASM File Written: VIC_QAOA.qasm
##################### Notes on the Output File #############################
(naive) Depth: 128, gate-count(2Q): 227, ESP: 0.0019301743858659978
(VIC) Depth: 69, gate-count(2Q): 151, ESP: 0.015510689327353987
The circuit is written with beta/gamma parameters at different p-lavels (https://arxiv.org/pdf/1411.4028.pdf)
bX --> beta parameter at p=X
gX --> gamma parameter at p=X (https://arxiv.org/pdf/1411.4028.pdf)
############################################################################

Notes on the Output File

Docker Image

A docker image can be downloaded from: https://hub.docker.com/repository/docker/mahabubul92/qaoa-compiler

Citation

@inproceedings{alam2020circuit,
  title={Circuit Compilation Methodologies for Quantum Approximate Optimization Algorithm},
  author={Alam, Mahabubul and Ash-Saki, Abdullah and Ghosh, Swaroop},
  booktitle={2020 53rd Annual IEEE/ACM International Symposium on Microarchitecture (MICRO)},
  pages={215--228},
  year={2020},
  organization={IEEE}
}

@inproceedings{alam2020efficient,
  title={An efficient circuit compilation flow for quantum approximate optimization algorithm},
  author={Alam, Mahabubul and Ash-Saki, Abdullah and Ghosh, Swaroop},
  booktitle={2020 57th ACM/IEEE Design Automation Conference (DAC)},
  pages={1--6},
  year={2020},
  organization={IEEE}
}

@inproceedings{alam2020noise,
  title={Noise resilient compilation policies for quantum approximate optimization algorithm},
  author={Alam, Mahabubul and Ash-Saki, Abdullah and Li, Junde and Chattopadhyay, Anupam and Ghosh, Swaroop},
  booktitle={Proceedings of the 39th International Conference on Computer-Aided Design},
  pages={1--7},
  year={2020}
}