jaqalpaq.transpilers.qiskit package¶
- class jaqalpaq.transpilers.qiskit.JaqalMSGate(phi, theta, label=None)¶
Bases:
qiskit.circuit.gate.Gate
The two-parameter Mølmer-Sørensen gate, as implemented on QSCOUT hardware. Note that this is not equivalent to Qiskit’s MSGate. It’s equivalent to
exp(-i theta/2 (cos(phi) XI + sin(phi) YI) (cos(phi) IX + sin(phi) IY))
or to the OpenQASM sequence
gate jaqalms(phi, theta) a,b { rz(phi) a; rz(phi+pi/2) b; CX b,a; rz(-pi/2) a; ry(theta+pi/2) b; CX a,b; ry(-pi/2) b; CX b,a; rz(-phi-pi/2) a; rz(-phi) b; }
- Parameters
phi (float) – The phase angle determining the mix of XX and YY rotation.
theta (float) – The angle by which the gate rotates the state.
label (str or None) – What to label the gate on, e.g., circuit diagrams.
- class jaqalpaq.transpilers.qiskit.JaqalRGate(axis_angle, rotation_angle, label=None)¶
Bases:
qiskit.circuit.gate.Gate
A single-qubit gate representing arbitrary rotation around an axis in the X-Y plane, as implemented on QSCOUT hardware. Note that this is essentially a different parametrization of Qiskit’s U2 gate. It’s equivalent to the OpenQASM sequence
gate jaqalr(axis_angle, rotation_angle) a { rz(-axis_angle) a; rx(rotation_angle) a; rz(axis_angle) a; }
- Parameters
axis_angle (float) – The angle that sets the planar axis to rotate around.
rotation_angle (float) – The angle by which the gate rotates the state.
label (str or None) – What to label the gate on, e.g., circuit diagrams.
- class jaqalpaq.transpilers.qiskit.SYGate(label=None)¶
Bases:
qiskit.circuit.gate.Gate
The sqrt(Y) gate, as implemented on QSCOUT hardware. It’s equivalent to a pi/2 rotation around the Y-axis on the Bloch sphere.
- Parameters
label (str or None) – What to label the gate on, e.g., circuit diagrams.
- class jaqalpaq.transpilers.qiskit.SYdgGate(label=None)¶
Bases:
qiskit.circuit.gate.Gate
The inverse sqrt(Y) gate, as implemented on QSCOUT hardware. It’s equivalent to a -pi/2 rotation around the Y-axis on the Bloch sphere.
- Parameters
label (str or None) – What to label the gate on, e.g., circuit diagrams.
- jaqalpaq.transpilers.qiskit.get_ion_instance(jaqal_backend=None)¶
Creates a qiskit.utils.QuantumInstance representing the Jaqal emulator backend. Pass it to a Qiskit Aqua algorithm or use it to transpile and emulate circuits directly with its execute method. In the latter case, it will return a result object which can be inspected with get_counts just as any other Qiskit result object.
Warning
The current implementation of this function returns a subclass of QuantumInstance. What subclass if any is returned, and any methods it may have in addition to those provided by a qiskit.utils.QuantumInstance, are internal implementation details and should not be relied on.
- Parameters
jaqal_backend (
jaqalpaq.emulator.AbstractBackend
or None) – Pass a backend instance to use. If omitted, instantiates a newjaqalpaq.emulator.UnitarySerializedEmulator
, which in practice should usually be the desired usage.- Returns
A Qiskit representation of the Jaqal emulator.
- Return type
qiskit.utils.QuantumInstance
- jaqalpaq.transpilers.qiskit.ion_pass_manager()¶
Constructs a qiskit.transpiler.PassManager that will unroll a circuit into the QSCOUT standard gate set. Pass a qiskit.circuit.Circuit object into its run method to perform the unrolling.
- Returns
The pass manager.
- Return type
qiskit.transpiler.PassManager
- jaqalpaq.transpilers.qiskit.jaqal_circuit_from_dag_circuit(dag)¶
Converts a Qiskit directed-acyclic-graph representation of a circuit to a
jaqalpaq.core.Circuit
. Seejaqal_circuit_from_qiskit_circuit()
for details.- Parameters
dag (qiskit.dagcircuit.DAGCircuit) – The directed acyclic graph circuit to convert.
- Returns
The same quantum circuit, converted to JaqalPaq.
- Return type
- jaqalpaq.transpilers.qiskit.jaqal_circuit_from_qiskit_circuit(circuit, names=None, native_gates=None, param_maps=None)¶
Converts a Qiskit circuit to a
jaqalpaq.core.Circuit
. The circuit will be structured into a sequence of unscheduled blocks. All instructions between one barrier statement and the next will be put into an unscheduled block together. If theqscout.scheduler
is run on the circuit, as many as possible of those gates will be parallelized within each block, while maintaining the order of the blocks. 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.
Circuits containing multiple quantum registers will be converted to circuits with a single quantum register, containing all the qubits from each register. The parts of that larger register that correspond to each of the original registers will be mapped with the appropriate names.
- Parameters
circuit (qiskit.circuit.QuantumCircuit) – The circuit to convert.
names (dict or None) – A mapping from names of Qiskit gates to the corresponding native Jaqal gate names. If omitted, maps jaqalr (
jaqalpaq.transpilers.qiskit.JaqalRGate
), sx (jaqalpaq.qiskit.SXGate
), sy (jaqalpaq.qiskit.SYGate
), x, y, rz, and jaqalms (jaqalpaq.qiskit.JaqalMSGate
) to their QSCOUT counterparts.native_gates (dict or None) – The native gate set to target. If None, target the QSCOUT native gates.
- Returns
The same quantum circuit, converted to JaqalPaq.
- Return type
- Raises
JaqalError – If any instruction acts on a qubit from a register other than the circuit’s qregs.
JaqalError – If the circuit includes a snapshot instruction.
JaqalError – If the user tries to measure or reset only some of the qubits, rather than all of them.
JaqalError – If the circuit includes a gate not included in names.
qiskit.circuit.QuantumCircuit extensions¶
Importing the jaqalpaq.qiskit package also patches the
qiskit.circuit.QuantumCircuit
object, adding the following four methods. This
follows the standard Qiskit API, allowing users to add trapped-ion gates to circuits using
the same syntax as gates from the Qiskit standard extension.
- qiskit.circuit.QuantumCircuit.jaqalms(theta, phi, a, b)¶
Add a two-parameter Mølmer-Sørensen gate to a circuit.
- Parameters
theta (float) – The angle by which the gate rotates the state.
phi (float) – The phase angle determining the mix of XX and YY rotation.
a (qiskit.circuit.Bit, qiskit.circuit.Register, int, slice, list, or range) – The first qubit to act on.
b (qiskit.circuit.Bit, qiskit.circuit.Register, int, slice, list, or range) – The second qubit to act on.
- qiskit.circuit.QuantumCircuit.jaqalr(theta, phi, q)¶
Add a single-qubit gate representing arbitrary rotation around an axis in the X-Y plane to a circuit. Note that this is essentially a different parametrization of Qiskit’s U2 gate.
- Parameters
theta (float) – The angle that sets the planar axis to rotate around.
phi (float) – The angle by which the gate rotates the state.
q (qiskit.circuit.Bit, qiskit.circuit.Register, int, slice, list, or range) – The qubit to act on.
- qiskit.circuit.QuantumCircuit.sy(q)¶
Add a sqrt(Y) gate to a circuit.
- Parameters
q (qiskit.circuit.Bit, qiskit.circuit.Register, int, slice, list, or range) – The qubit to act on.
- qiskit.circuit.QuantumCircuit.sydg(q)¶
Add an inverse sqrt(Y) gate to a circuit.
- Parameters
q (qiskit.circuit.Bit, qiskit.circuit.Register, int, slice, list, or range) – The qubit to act on.