jaqalpaq.transpilers.quil package¶
- class jaqalpaq.transpilers.quil.IonCompiler(device, names=None, native_gates=None)¶
Bases:
pyquil.api._qac.AbstractCompiler
A compiler that converts Quil programs to Jaqal circuits that can be executed on the QSCOUT device.
- Parameters
device (pyquil.device.AbstractDevice) – The quantum device the compiler should target.
names (dict or None) – A mapping from names of Quil gates to the corresponding native Jaqal gate names. If omitted, maps X, Y, RZ, and any gate produced by
qscout.quil.quil_gates()
to their QSCOUT counterparts. Any gate whose Jaqal native gate name and Quil gate name are the same up to case will automatically be mapped to each other unless an alternative mapping is specified.native_gates (dict or None) – The native gate set to target. If None, target the QSCOUT native gates.
- native_quil_to_executable(nq_program: pyquil.quil.Program) Optional[jaqalpaq.core.circuit.Circuit] ¶
Compiles a Quil program to a
qscout.core.Circuit
. Because Quil does not support any form of schedule control, the entire circuit will be put in a single unscheduled block. If theqscout.scheduler
is run on the circuit, as many as possible of those gates will be parallelized, while maintaining the order of gates that act on the same qubits. Otherwise, the circuit will be treated as a fully sequential circuit.Measurement and reset commands are supported, but only if applied to every qubit in the circuit in immediate succession. If so, they will be mapped to a prepare_all or measure_all gate. If the circuit does not end with a measurement, then a measure_all gate will be appended to it.
- Parameters
nq_program (pyquil.quil.Program) – The program to compile.
- Returns
The same quantum program, converted to JaqalPaq.
- Return type
qscout.core.Circuit
- Raises
JaqalError – If the program includes a non-gate instruction other than resets or measurements.
JaqalError – If the user tries to measure or reset only some of the qubits, rather than all of them.
JaqalError – If the program includes a gate not included in names.
- quil_to_native_quil(program: pyquil.quil.Program, *, protoquil=None) pyquil.quil.Program ¶
Currently does nothing. Eventually, will compile a Quil program down to the native gates of the QSCOUT machine.
- Parameters
program (pyquil.quil.Program) – The program to compile.
protoquil (bool) – Ignored.
- Returns
The input program.
- Return type
pyquil.quil.Program
- class jaqalpaq.transpilers.quil.QSCOUTAM¶
Bases:
pyquil.api._qam.QAM
Quantum Abstract Machine representing the QSCOUT hardware. It will refuse to load or run programs, but can be used as a compilation target. Instead of using the Quil API to load and run programs, instead compile them to Jaqal files and submit them to the QSCOUT team directly.
- load(executable)¶
Does not load a Jaqal program onto an abstraction of the QSCOUT hardware.
- Raises
JaqalError – Because the Quil API should not be used to try to execute programs on QSCOUT.
- run()¶
Does not run a previously loaded Jaqal program on an abstraction of the QSCOUT hardware.
- Raises
JaqalError – Because the Quil API should not be used to try to execute programs on QSCOUT.
- jaqalpaq.transpilers.quil.get_ion_qc(num_qubits)¶
Constructs a quantum computer object that represents the QSCOUT hardware. Unlike the builtin Quil counterparts, it can’t run quantum programs, but it can still be used as a compilation target and thus used to generate Jaqal code (which can then be submitted to be run on the actual QSCOUT device).
- Parameters
num_qubits (int) – How many qubits in the trap will be used.
- Returns
The quantum computer object for compilation.
- Return type
pyquil.api.QuantumComputer
- jaqalpaq.transpilers.quil.quil_gates(native_gates=None)¶
Generates quil versions of a gate set (the QSCOUT native gates, by default).
- Returns
A mapping of gate names to functions that take classical parameters and qubit indices and build pyquil gates.
- Return type
dict
Warning
PyQuil simulators will give an error if QSCOUT native gates are passed to them!