-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix missing inverse definitions in generate_basis_approximations
#13517
base: main
Are you sure you want to change the base?
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 12233529353Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Nice catch! Did you notice this because you saw decompositions with |
Not really. I was trying to set up a transpilation pipeline for compiling arbitrary circuits to the Clifford+T gate-set. I wanted to throw all possible single-qubit Clifford gates into the basis approximations method, including the |
Ah so the test you added fails without |
Yeah, exactly. |
Hi @burgholzer, a question not directly related to the PR: what is the best way to transpile into Clifford+T (i.e. how did you set up the transpilation pipeline for that)? Thx! |
Hi 👋🏼 from qiskit import transpile
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.transpiler.passes.synthesis import SolovayKitaev
# The quantum circuit to transpile
qc = ...
# Clifford+T gateset
gateset = [
"i",
"x",
"y",
"z",
"h",
"s",
"sdg",
"t",
"tdg",
"sx",
"sxdg",
"cx",
"cy",
"cz",
"swap",
"iswap",
"dcx",
"ecr",
"measure",
"barrier",
]
# Transpile the circuit to single- and two-qubit gates including rotations
compiled_for_sk = transpile(
qc,
basis_gates=[*gateset, "rx", "ry", "rz"],
)
# Synthesize the rotations to Clifford+T gates
# Measurements are removed and added back after the synthesis to avoid errors in the Solovay-Kitaev pass
pass_ = SolovayKitaev()
new_qc = dag_to_circuit(pass_.run(circuit_to_dag(compiled_for_sk.remove_final_measurements(inplace=False))))
new_qc.measure_all()
# Transpile once more to remove unnecessary gates and optimize the circuit
compiled_qc = transpile(
new_qc,
basis_gates=gateset,
) While one could use the from qiskit import QuantumCircuit, transpile
import numpy as np
qc = QuantumCircuit(2)
qc.cp(np.pi/4, 0, 1)
gateset = [
"i",
"x",
"y",
"z",
"h",
"s",
"sdg",
"t",
"tdg",
"sx",
"sxdg",
"cx",
"cy",
"cz",
"swap",
"iswap",
"dcx",
"ecr",
"measure",
"barrier",
]
compiled_qc = transpile(
qc,
basis_gates=gateset,
unitary_synthesis_method = "sk",
) would not work an error out because the synthesis does nothing, and then the basis gate decomposer cannot find a decomposition into the discrete basis. However, I haven't had the time to fully work this out and report it as an issue. |
Summary
This tiny PR fixes an oversight in the generation routine for basis approximations that is used in the SolovayKitaev synthesis pass.
Details and comments
While the dictionary of single-qubit gates listed the
sx
andsxdg
gates, the dictionary of inverses was missing those definitions.This PR simply adds the respective definitions.
Should this receive a release note?