Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion qiskit/transpiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,10 @@
towards the ISA.

For a Clifford+T basis set, the single-qubit rotation gates are approximated using the
:class:`.SolovayKitaevDecomposition` algorithm.
:class:`.UnitarySynthesis` pass. By default (when ``unitary_synthesis_method='default'``),
this invokes the :class:`.SolovayKitaevDecomposition` algorithm. A custom synthesis
method may be also speficied, but it must be capable of performing approximations using the
Clifford+T basis set.

This is the default translation method.

Expand Down
16 changes: 12 additions & 4 deletions qiskit/transpiler/preset_passmanagers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@ def generate_translation_passmanager(
# We set target=None to make sure extended_basis_gates is not overwritten by the target.
extended_basis_gates = list(basis_gates) + ["u"]

# The default value of unitary_synthesis_method in transpile/generate_preset_pass_manager
# is "default". In this case we want to use the Solovay-Kitaev decomposition (called "sk").
# However, we also allow specifyig a non-default Clifford+T unitary synthesis plugin.
if unitary_synthesis_method == "default":
unitary_synthesis_method = "sk"
Comment on lines +504 to +505
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this done here and not in the default synthesis method? For this to work correctly I would expect the default unitary synthesis plugin to understand it needs to use solovay kitaev when in the presence of a clifford+t basis set.
Doing the plugin selection out of band in the translation stage plugin like this will result in an infinite loop (until we reach the pass manager iteration limit) if there is an synthesis method selected for clifford+t basis provided to the preset pass manager. Since the translation stage is used in the optimization loop to correct for the cases when there is a non-target aware optimization or synthesis.

Additionally, baking this into the default plugin will operate solely in the rust domain and be much faster to execute.


unroll = [
# Use the UnitarySynthesis pass to unroll 1-qubit and 2-qubit gates named "unitary" into
# extended_basis_gates.
Expand Down Expand Up @@ -542,18 +548,20 @@ def generate_translation_passmanager(
# We use the "clifford" unitary synthesis plugin to replace single-qubit
# unitary gates that can be represented as Cliffords by Clifford gates.
UnitarySynthesis(method="clifford", plugin_config={"max_qubits": 1}),
# We use the Solovay-Kitaev decomposition via the plugin mechanism for "sk"
# UnitarySynthesisPlugin.
# We decompose single-qubit unitary gates using the UnitarySynthesisPlugin interface
# By default it's the Solovay-Kitaev decomposition. If a custom ``unitary_synthesis_method``
# method is specified, it must be capable of performing approximations using the
# Clifford+T basis set.
UnitarySynthesis(
basis_gates=["h", "t", "tdg"],
approximation_degree=approximation_degree,
coupling_map=coupling_map,
plugin_config=unitary_synthesis_plugin_config,
method="sk",
method=unitary_synthesis_method,
min_qubits=1,
target=None,
),
# Finally, we use BasisTranslator to translate ["h", "t", "tdg"] to the actually
# Finally, we use BasisTranslator to translate Clifford+T/Tdg to the actually
# specified set of basis gates.
BasisTranslator(sel, basis_gates, target),
]
Expand Down