The QLM set of python libraries also comes with a set of command line scripts.
These commands are used to compile AQASM code into a circuit that can be run with the QLM quantum simulators. They can also be used to convert a quantum circuit to AQASM code so that an existing circuit can be modified.
This is the main compiler of the QLM. Its converts Atos Quantum Assembly Language (AQASM) into a useable Quantum Circuit for our simulators.
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 .circ
.
Usage:
%%bash
aqasm2circ --help
For example, let us dump an AQASM circuit into a file test1.aqasm
:
%%writefile test1.aqasm
BEGIN
qubits 2
cbits 1
H q[0]
MEAS q[0] c[0]
?c[0]: X q[1]
END
And let us call the aqasm2circ
compiler on the file:
%%bash
# Write a file named input_filename.circ (test1.aqasm in our example)
aqasm2circ test1.aqasm
# Write a file name "test.circ"
aqasm2circ test1.aqasm test.circ
ls *.circ
The generated files are used as the input to one of the various simulators provided in the QLM environment.
This is the main decompiler for QLM 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
.
%%bash
circ2aqasm --help
For Example:
%%bash
circ2aqasm test.circ
cat test.circ.aqasm
%%bash
qat-jobrun --help
%%bash
qat-batchrun --help
QPUs and Plugins are referred to using the namespace:class_name
convention.
from qat.core import Circuit, Batch
circuit = Circuit.load("test.circ")
job = circuit.to_job()
job.dump("test.job")
batch = Batch(jobs=[job]*3)
batch.dump("test.batch")
%%bash
qat-jobrun --qpu qat.pylinalg:PyLinalg test.job
It is possible to dump the results in a binary file instead of having to parse the stdout:
%%bash
qat-jobrun --qpu qat.pylinalg:PyLinalg test.job -o jobres.res
The same goes for the qat-batchrun
script:
%%bash
qat-batchrun --qpu qat.pylinalg:PyLinalg test.batch
%%bash
qat-batchrun --qpu qat.pylinalg:PyLinalg test.batch -o batchres.res
Naturally, there is a command to display a dumped result in the stdout:
%%bash
qat-resprint --help
%%bash
qat-resprint jobres.res -N 2
%%bash
qat-resprint -b batchres.res -N 2
This command display some statistics about a serialized circuit. The output is pretty straightforward to interpretate:
%%bash
qat-circstat test.circ