Skip to content

Commit

Permalink
Take optimize parameter in cascade up, to the user calls
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillermoAbadLopez committed Nov 7, 2024
1 parent 944e2f0 commit a9bbf90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/qililab/digital/circuit_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def transpile_circuits(
router (Router | type[Router] | tuple[type[Router], dict], optional): `Router` instance, or subclass `type[Router]` to
use, with optionally, its kwargs dict (other than connectivity), both in a tuple. Defaults to `Sabre`.
routing_iterations (int, optional): Number of times to repeat the routing pipeline, to get the best stochastic result. Defaults to 10.
optimize (bool, optional): whether to optimize the transpilation. Defaults to True.
optimize (bool, optional): whether to optimize the circuit and/or transpilation. Defaults to True.
Returns:
tuple[list[PulseSchedule],list[dict[str, int]]]: list of pulse schedules and list of the final layouts of the qubits, in each circuit {"qI": J}.
Expand Down
3 changes: 3 additions & 0 deletions src/qililab/execute_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def execute(
placer: Placer | type[Placer] | tuple[type[Placer], dict] | None = None,
router: Router | type[Router] | tuple[type[Router], dict] | None = None,
routing_iterations: int = 10,
optimize: bool = True,
) -> Result | list[Result]:
"""Executes a Qibo circuit (or a list of circuits) with qililab and returns the results.
Expand All @@ -47,6 +48,7 @@ def execute(
router (Router | type[Router] | tuple[type[Router], dict], optional): `Router` instance, or subclass `type[Router]` to
use,` with optionally, its kwargs dict (other than connectivity), both in a tuple. Defaults to `Sabre`.
routing_iterations (int, optional): Number of times to repeat the routing pipeline, to keep the best stochastic result. Defaults to 10.
optimize (bool, optional): whether to optimize the circuit and/or transpilation. Defaults to True.
Returns:
Result | list[Result]: :class:`Result` class (or list of :class:`Result` classes) containing the results of the
Expand Down Expand Up @@ -96,6 +98,7 @@ def execute(
placer=placer,
router=router,
routing_iterations=routing_iterations,
optimize=optimize,
)
for circuit in tqdm(program, total=len(program))
]
Expand Down
8 changes: 6 additions & 2 deletions src/qililab/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def execute(
placer: Placer | type[Placer] | tuple[type[Placer], dict] | None = None,
router: Router | type[Router] | tuple[type[Router], dict] | None = None,
routing_iterations: int = 10,
optimize: bool = True,
) -> Result | QbloxResult:
"""Compiles and executes a circuit or a pulse schedule, using the platform instruments.
Expand All @@ -924,6 +925,7 @@ def execute(
router (Router | type[Router] | tuple[type[Router], dict], optional): `Router` instance, or subclass `type[Router]` to
use, with optionally, its kwargs dict (other than connectivity), both in a tuple. Defaults to `Sabre`.
routing_iterations (int, optional): Number of times to repeat the routing pipeline, to keep the best stochastic result. Defaults to 10.
optimize (bool, optional): whether to optimize the circuit and/or transpilation. Defaults to True.
Returns:
Result: Result obtained from the execution. This corresponds to a numpy array that depending on the
Expand All @@ -936,7 +938,7 @@ def execute(
"""
# Compile pulse schedule
programs, final_layout = self.compile(
program, num_avg, repetition_duration, num_bins, placer, router, routing_iterations
program, num_avg, repetition_duration, num_bins, placer, router, routing_iterations, optimize
)

# Upload pulse schedule
Expand Down Expand Up @@ -1032,6 +1034,7 @@ def compile(
placer: Placer | type[Placer] | tuple[type[Placer], dict] | None = None,
router: Router | type[Router] | tuple[type[Router], dict] | None = None,
routing_iterations: int = 10,
optimize: bool = True,
) -> tuple[dict[str, list[QpySequence]], dict[str, int] | None]:
"""Compiles the circuit / pulse schedule into a set of assembly programs, to be uploaded into the awg buses.
Expand All @@ -1050,6 +1053,7 @@ def compile(
router (Router | type[Router] | tuple[type[Router], dict], optional): `Router` instance, or subclass `type[Router]` to
use, with optionally, its kwargs dict (other than connectivity), both in a tuple. Defaults to `Sabre`.
routing_iterations (int, optional): Number of times to repeat the routing pipeline, to keep the best stochastic result. Defaults to 10.
optimize (bool, optional): whether to optimize the circuit and/or transpilation. Defaults to True.
Returns:
tuple[dict, dict[str, int]]: Tuple containing the dictionary of compiled assembly programs (The key is the bus alias (``str``), and the value is the assembly compilation (``list``)) and the final layout of the qubits in the circuit {"qX":Y}.
Expand All @@ -1065,7 +1069,7 @@ def compile(
transpiler = CircuitTranspiler(digital_compilation_settings=self.digital_compilation_settings)

transpiled_circuits, final_layouts = transpiler.transpile_circuits(
[program], placer, router, routing_iterations
[program], placer, router, routing_iterations, optimize
)
pulse_schedule, final_layout = transpiled_circuits[0], final_layouts[0]

Expand Down

0 comments on commit a9bbf90

Please sign in to comment.