Command-line tools
The myQLM set of Python libraries also comes with a set of command-line scripts to generate, execute and optimize circuits
Compiler
myQLM comes with a compiler and a decompiler to convert Atos Quantum Assembly Language (AQASM) files into useable Quantum Circuit for our QPUs and vice-versa. Please refer to The AQASM format to learn more about the AQASM format.
aqasm2circ
This command takes one or two arguments, an input file (i.e. AQASM file) and
optionally an output file. If no output file is supplied, the output will be
the input file appended with .circ
.
For example, assuming the file my_prog.aqasm
contains the
following code:
BEGIN
qubits 2
cbits 1
H q[0]
MEAS q[0] c[0]
?c[0]: X q[1]
END
The command aqasm2circ
can be used to compile this program into
a useable Quantum Circuit:
aqasm2circ my_prog.aqasm compiled.circ
The file compiled.circ
is a binary file describing a quantum circuit.
This circuit could be load using Python:
from qat.core import Circuit
# Load compiled circuit
compiled = Circuit.load("compiled.circ")
circ2aqasm
This is the main decompiler which will take a Quantum Circuit file and
return the resulting Atos Quantum Assembly Language (AQASM) file used to
generate the circuit. The command takes one or two arguments, an input file
and optionally an output file. If no output file is supplied the output will
be the input file appended with .aqasm
.
For example, considering the file compiled.circ
of the previous
section, the following command can be used to generate an AQASM file
equivalent to my_prog.aqasm
circ2aqasm compiled.circ my_prog_2.aqasm
Simulation / Execution commands
myQLM provides qat-jobrun
and qat-batchrun
to execute any
Job or Batch using any QPU. Moreover, plugins coulb be linked to this QPU
direclty from the command line. Moreover, the QLM provides tools to
display results of a simulation / execution.
qat-jobrun and qat-batchrun
This command will deserialize a job (or a batch) and run it via some execution stack.
QPUs and Plugins are referred to using the namespace:class_name
convention.
For instance, the following Python code generate a Batch and a Job using
the circuit compiled with aqasm2circ
. This batch and job will be then
simulated using qat-batchrun
and qat-jobrun
.
from qat.core import Circuit, Batch
# Generate a job
circuit = Circuit.load("compiled.circ")
job = circuit.to_job()
job.dump("compiled.job")
# Generate a batch
batch = Batch(jobs=[job, job, job])
batch.dump("compiled.batch")
The qat-batchrun
or qat-jobrun
commands can be used to
simulate this circuit.
The following command call PyLinalg to simulate the batch and display
the output of the simulation in the stdout.
qat-batchrun --qpu qat.pylinalg:PyLinalg compiled.batch
qat-jobrun --qpu qat.pylinalg:PyLinalg compiled.job
It is possible to dump the results in a binary file instead of having to parse the stdout
qat-batchrun --qpu qat.pylinalg:PyLinalg compiled.batch -o batchout.res
qat-jobrun --qpu qat.pylinalg:PyLinalg compiled.batch -o jobout.res
qat-resprint
Naturally, there is a command to display a dumped result in the stdout. This
command can be used to display the result of qat-jobrun
or
qat-batchrun
.
For instance, to display the result of the previous simulation:
qat-resprint jobout.res -N 2
qat-resprint -b batchres.res -N 2
qat-circstat
This command displays some statistics about a serialized circuit. The output is straightforward to interpretate:
qat-circstat compiled.circ