cirq.optimize_for_target_gateset
Transforms the given circuit into an equivalent circuit using gates accepted by gateset
.
cirq.optimize_for_target_gateset(
circuit: 'cirq.AbstractCircuit',
*,
context: Optional['cirq.TransformerContext'] = None,
gateset: Optional['cirq.CompilationTargetGateset'] = None,
ignore_failures: bool = True,
max_num_passes: Union[int, None] = 1
) -> 'cirq.Circuit'
Used in the notebooks
Repeat max_num_passes times or when max_num_passes=None
until no further changes can be done
- Run all
gateset.preprocess_transformers
- Convert operations using built-in cirq decompose +
gateset.decompose_to_target_gateset
.
- Run all
gateset.postprocess_transformers
Note |
The optimizer is a heuristic and may not produce optimal results even with
max_num_passes=None. The preprocessors and postprocessors of the gate set
as well as their order yield different results.
|
Args |
circuit
|
Input circuit to transform. It will not be modified.
|
context
|
cirq.TransformerContext storing common configurable options for transformers.
|
gateset
|
Target gateset, which should be an instance of cirq.CompilationTargetGateset .
|
ignore_failures
|
If set, operations that fail to convert are left unchanged. If not set,
conversion failures raise a ValueError.
|
max_num_passes
|
The maximum number of passes to do. A value of None means to keep
iterating until no more changes happen to the number of moments or operations.
|
Returns |
An equivalent circuit containing gates accepted by gateset .
|
Raises |
ValueError
|
If any input operation fails to convert and ignore_failures is False.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]