Table of Contents
Fetching ...

QUT: A Unit Testing Framework for Quantum Subroutines

Mykhailo V. Klymenko, Thong Hoang, Hoa Nguyen, Samuel A. Wilkinson, Bahar Goldozian, Xing Zhenchang, Qinghua Lu, Muhammad Usman, Liming Zhu

Abstract

We present the architectural design and prototype implementation of QUT (Quantum Unit Testing), a framework for unit testing of quantum subroutines. The framework is developed with a focus on usability and simplicity, making the complex theoretical concepts behind quantum unit testing accessible to a wide range of users with diverse backgrounds. This is achieved through the implementation of polymorphic probabilistic assertions, whose evaluation methods adapt to the data types of the arguments used in assertion statements, which may vary according to the context-dependent semantics of quantum subroutines. These arguments can be represented as qubit measurement outcomes, density matrices, or Choi matrices. For each type, the architecture integrates a specific testing protocol - such as quantum process tomography, quantum state tomography, or Pearson's chi-squared test - while remaining flexible enough to incorporate additional protocols in the future. The framework is built on the Qiskit software stack, providing compatibility with a broad range of quantum hardware backends and simulation platforms. Drawing on the reasoning provided by the denotational semantics of quantum subroutines, this work also highlights the key distinctions between quantum unit testing and its classical counterpart.

QUT: A Unit Testing Framework for Quantum Subroutines

Abstract

We present the architectural design and prototype implementation of QUT (Quantum Unit Testing), a framework for unit testing of quantum subroutines. The framework is developed with a focus on usability and simplicity, making the complex theoretical concepts behind quantum unit testing accessible to a wide range of users with diverse backgrounds. This is achieved through the implementation of polymorphic probabilistic assertions, whose evaluation methods adapt to the data types of the arguments used in assertion statements, which may vary according to the context-dependent semantics of quantum subroutines. These arguments can be represented as qubit measurement outcomes, density matrices, or Choi matrices. For each type, the architecture integrates a specific testing protocol - such as quantum process tomography, quantum state tomography, or Pearson's chi-squared test - while remaining flexible enough to incorporate additional protocols in the future. The framework is built on the Qiskit software stack, providing compatibility with a broad range of quantum hardware backends and simulation platforms. Drawing on the reasoning provided by the denotational semantics of quantum subroutines, this work also highlights the key distinctions between quantum unit testing and its classical counterpart.

Paper Structure

This paper contains 24 sections, 4 equations, 9 figures, 2 tables.

Figures (9)

  • Figure 1: Denotational semantics of a quantum subroutine is defined as a quantum process. The syntax of the subroutine is represented by a circuit diagram. The denotational semantics is expressed using the language of the graphic calculus of monoidal categories for quantum processes coecke2017picturing.
  • Figure 2: Context-dependent denotational semantics for quantum subroutines for three different contexts: (A) no context information provided (subroutine is used to modify an input quantum state), (B) inputs qubits are initialized to fixed states (subroutine is used as a part of the state preparation process), and (C) same as (B) plus the remaining output qubits subjected to measurement (subroutine is used for sampling probabilistic classical data or evaluating an expectation value). Depending on the environment in which the subroutine is going to be used, the unit test for a quantum subroutine can be significantly simplified imposing modification in the denotational semantics prior to the testing procedure.
  • Figure 3: Denotational semantics of a unit test for a quantum subroutine. The explicit forms of the processes $\Phi_n^{pre}$ and $\Phi_m^{meas}$ and the range of the parameters $n$, $\theta$ and $m$ determines the testing protocol. The output of the unit test is a probability of passing the test evaluated by the oracle and expressed as a real number in the closed interval $[0, 1]$.
  • Figure 4: a) Functional model of a classical unit test; and b) functional model of a quantum unit test with context-aware polymorphic assertions.
  • Figure 5: UML diagram of the class library implementing the QUT framework
  • ...and 4 more figures