-
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
Optimal Synthesis into RXX(theta) #6551
Conversation
The |
@ajavadia : At present, this is hard-coded in the internal package, exactly because I didn't want to make a decision about how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm checking the code functionality. When I run this:
from qiskit import transpile, QuantumRegister, QuantumCircuit
from qiskit.quantum_info import random_unitary
import numpy as np
# generate a random unitary
u = random_unitary(4, seed=9)
q = QuantumRegister(2)
circuit = QuantumCircuit(q)
circuit.append(u, q)
output_circuit = transpile(circuit, basis_gates=['rzx', 'rz', 'sx'], translation_method='synthesis')
output_circuit.draw('mpl')
I get two uses of RZX(pi/4) and one use of CX:
However when I change translation_method='translator'
I get something that can be simplified to just two uses of RZX(pi/4) (not sure why it emits RZX(-pi/4) at all, but it does). this
And finally when I use translation_method='unroller'
it errors (I guess that's separate from this PR but it would be good to get to the bottom of it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking mostly good, and thanks for the recent updates. I left some comments which shouldn't be too much work, mostly around documenting user interfaces.
I think the main thing that I will work on after this is for a way to automatically convert transpiler basis_gates to embodiments
in this decomposer. I like that the option exists to request certain XX embodiments, but using it is a bit involved at the moment. e.g. if I want XX everywhere and CX instead of XX(pi/2), I need to do:
xx_circuit = QuantumCircuit(2)
theta = Parameter('theta')
xx_circuit.rxx(theta, 0, 1)
cx_circuit = QuantumCircuit(2)
cx_circuit.h(0)
cx_circuit.cx(0, 1)
cx_circuit.h(1)
cx_circuit.s(0)
cx_circuit.s(1)
cx_circuit.h(0)
cx_circuit.h(1)
cx_circuit.global_phase += np.pi / 4
embodiments = {t: xx_circuit.bind_parameters({theta: t}) for t in [np.pi/4, np.pi/6]}
embodiments.update({np.pi/2: cx_circuit})
decomposer = XXDecomposer(euler_basis='U3', embodiments=embodiments)
output_circuit = decomposer(u, basis_fidelity=.99)
releasenotes/notes/feature-rzx-decomposition-c3b5a36b88303c1f.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/feature-rzx-decomposition-c3b5a36b88303c1f.yaml
Outdated
Show resolved
Hide resolved
I agree that the "embodiments" stuff is not super slick, mainly since it hasn't been flexed much. I'm sure you'll be able to find ergonomic improvements as you poke around. |
Co-authored-by: Ali Javadi-Abhari <[email protected]>
Pull Request Test Coverage Report for Build 1418807430
💛 - Coveralls |
In Qiskit#6551 a few debug prints slipped into the unittests which are dumping arrays to stdout during unit test runs. This commit just cleans those up and removes the stray prints.
In #6551 a few debug prints slipped into the unittests which are dumping arrays to stdout during unit test runs. This commit just cleans those up and removes the stray prints. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This PR installs moves a few
TwoQubitBasisDecomposer
constructors into a helper, then constructs anXXDecomposer
if the target gateset includesrzx
. This implements some internal, nearly-published theory work.Details and comments
Here's a brief usage demonstration: