Quantum programs

Qaptiva Framework provides tools to create quantum program. These tools are packaged under qat.lang module and are known as PyAQASM (for Python + AQASM). A Program is designed to build advanced quantum circuits which can be stored under two format:

  • the serialized .circ format - it is under this format that circuits are sent to simulation or optimization services, when command-line tools are used

  • the text .aqasm format - human readable representation of the circuit

The following picture gives an overview of the circuit generation process of the PyAQASM library:

../../../images/circuit_gen.png

Therefore, there are two ways to generate a .circ file from a Program instance by:

  • directly generating a Circuit instance and serializing it (right path in the figure)

  • exporting your program to an .aqasm text file (human readable text format), and compiling it using the command-line tool aqasm2circ (left path in the figure)

Since the core of Qaptiva is purely based on Python, serialization is NOT a mandatory step, and is here only to facilitate advanced applications

Allocating qubit and classical registers

Qubit registers are allocated by the Program using the qalloc() method.

qbits_reg = my_program.qalloc(10)

Similarly, registers that hold classical bits can be allocated using the calloc() method.

cbits_reg = my_program.calloc(10)

Applying quantum gate

Gates can be applied by using the apply() method or by calling the gate on a set of qubits. For instance:

my_program.apply(H, qbits_reg[0])
# or
H(qbits_reg[0])

A gate or the apply() method can take several arguments, to apply the gate on several qubits:

my_program.apply(CNOT, qbits_reg[1], qbits_reg[2])
# or
CNOT(qbits_reg[1], qbits_reg[2])

Advanced operations

The Program structure supports various instructions:

  • measure(): measure a qubit during the computation (not to be used for final measurements)

  • reset(): reset a qubit or classical bit: it consists in measuring the qubit, and applying a bit flip (X gate) if the outcome is 1

  • cc_apply(): apply a gate conditionally, depending on the state of a classical bit

  • cbreak(): interrupt the computation depending on a condition on a set of classical bits

Generating the circuit

Once you are satisfied with your Program, it can be exported to a circuit format that can be simulated. This is done using the to_circ() method. This method has parameters and can be fine-tuned to meet your needs

Exporting the circuit

The Program object can also be exported to a human-readable AQASM format. This is done using the export() method