Skip to content

Commit

Permalink
Adding transpilation docsrtings to all execute methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillermoAbadLopez committed Nov 11, 2024
1 parent dea01bb commit f5e300d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/qililab/digital/circuit_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
# 3) Layout stage, where the initial_layout will be created.

def route(self, circuit: Circuit, iterations: int = 10) -> tuple[Circuit, dict[str, int]]:
"""Routes the virtual/logical qubits of a circuit, to the chip's physical qubits.
"""Routes the virtual/logical qubits of a circuit, to the chip's physical qubits. And returns/logs the final layout of the qubits.
**Examples:**
Expand Down Expand Up @@ -139,7 +139,7 @@ def route(self, circuit: Circuit, iterations: int = 10) -> tuple[Circuit, dict[s
def _iterate_routing(
routing_pipeline: Passes, circuit: Circuit, iterations: int = 10
) -> tuple[Circuit, dict[str, int], int | None]:
"""Iterates the routing pipeline, to keep the best stochastic result.
"""Iterates the routing pipeline, to keep the best stochastic result. And returns/logs the final layout of the qubits.
Args:
routing_pipeline (Passes): Transpilation pipeline passes.
Expand Down
13 changes: 9 additions & 4 deletions src/qililab/digital/circuit_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ def transpile_circuits(
"""Transpiles a list of ``qibo.models.Circuit`` to a list of pulse schedules.
First makes a routing and placement of the circuit to the chip's physical qubits. And returns/logs the final layout of the qubits.
If passed, this is done, with the `placer`, `router` and `routing_iterations` params (if not, default ones are applied).
Then translates the circuit to a native gate circuit and applies virtual Z gates and phase corrections for CZ gates.
Then translates the circuit to the native gate circuit, of the chip (CZ, RZ, Drag, Wait and M (Measurement).
And finally, it converts the native gate circuit to a pulse schedule using calibrated settings from the runcard.
If ``optimize=True`` (default behaviour), then it also does some circuit optimization:
- cancelling adjacent pairs of Hermitian gates (H, X, Y, Z, CNOT, CZ and SWAPs).
- applying virtual Z gates and phase corrections (adding up several pulses into a single one, commuting them with virtual Zs).
**Examples:**
If we instantiate some ``Circuit``, ``Platform`` and ``CircuitTranspiler`` objects like:
Expand Down Expand Up @@ -138,9 +143,9 @@ def route_circuit(
coupling_map: list[tuple[int, int]] | None = None,
iterations: int = 10,
) -> tuple[Circuit, dict[str, int]]:
"""Routes the virtual/logical qubits of a circuit, to the chip's physical qubits.
"""Routes the virtual/logical qubits of a circuit, to the chip's physical qubits. And returns/logs the final layout of the qubits.
If passed, this is done, with the passed `placer`, `router` and `routing_iterations` params (if not, default ones are applied).
**Examples:**
Expand Down Expand Up @@ -217,7 +222,7 @@ def optimize_circuit(self, circuit: Circuit) -> Circuit:
return CircuitOptimizer.run_gate_cancellations(circuit)

def circuit_to_native(self, circuit: Circuit) -> Circuit:
"""Converts circuit with qibo gates to circuit with native gates
"""Converts circuit with qibo gates to circuit with native gates (CZ, RZ, Drag, Wait and M (Measurement).
Args:
circuit (Circuit): circuit with qibo gate.
Expand Down
10 changes: 10 additions & 0 deletions src/qililab/execute_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def execute(
The ``program`` argument is first translated into pulses using the transpilation settings of the runcard and the
passed placer and router. Then the pulse will be compiled into the runcard machines assembly programs, and executed.
The transpilation is done with the :class:`CircuitTranspiler`, ``transpile_circuits()`` method, refer to it for more detailed information,
but the main stages of this process are:
- Making the routing and placement of the circuit into the chip physical connectivity.
- Translates the gates into the system native's gates (CZ, RZ, Drag, Wait and M (Measurement).
- Converts the native gates to a pulse schedule using calibrated settings from the runcard.
If ``optimize=True`` (default behaviour), then the transpilation also does some circuit optimization:
- cancelling adjacent pairs of Hermitian gates (H, X, Y, Z, CNOT, CZ and SWAPs).
- applying virtual Z gates and phase corrections (adding up several pulses into a single one, commuting them with virtual Zs).
Args:
circuit (Circuit | list[Circuit]): Qibo Circuit.
runcard (str | dict): If a string, path to the YAML file containing the serialization of the Platform to be
Expand Down
20 changes: 20 additions & 0 deletions src/qililab/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,16 @@ def execute(
To compile to assembly programs, the ``platform.compile()`` method is called; check its documentation for more information.
The transpilation is done with the :class:`CircuitTranspiler`, ``transpile_circuits()`` method, refer to it for more detailed information,
but the main stages of this process are:
- Making the routing and placement of the circuit into the chip physical connectivity.
- Translates the gates into the system native's gates (CZ, RZ, Drag, Wait and M (Measurement).
- Converts the native gates to a pulse schedule using calibrated settings from the runcard.
If ``optimize=True`` (default behaviour), then the transpilation also does some circuit optimization:
- cancelling adjacent pairs of Hermitian gates (H, X, Y, Z, CNOT, CZ and SWAPs).
- applying virtual Z gates and phase corrections (adding up several pulses into a single one, commuting them with virtual Zs).
Args:
program (:class:`PulseSchedule` | :class:`Circuit`): Circuit or pulse schedule to execute.
num_avg (int): Number of hardware averages used.
Expand Down Expand Up @@ -1041,6 +1051,16 @@ def compile(
If the ``program`` argument is a :class:`Circuit`, it will first be translated into a :class:`PulseSchedule` using the transpilation
settings of the platform and passed placer and router. Then the pulse schedules will be compiled into the assembly programs.
The transpilation is done with the :class:`CircuitTranspiler`, ``transpile_circuits()`` method, refer to it for more detailed information,
but the main stages of this process are:
- Making the routing and placement of the circuit into the chip physical connectivity.
- Translates the gates into the system native's gates (CZ, RZ, Drag, Wait and M (Measurement).
- Converts the native gates to a pulse schedule using calibrated settings from the runcard.
If ``optimize=True`` (default behaviour), then the transpilation also does some circuit optimization:
- cancelling adjacent pairs of Hermitian gates (H, X, Y, Z, CNOT, CZ and SWAPs).
- applying virtual Z gates and phase corrections (adding up several pulses into a single one, commuting them with virtual Zs).
This methods gets called during the ``platform.execute()`` method, check its documentation for more information.
Args:
Expand Down

0 comments on commit f5e300d

Please sign in to comment.