-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Optimize consecutive RZZ gates into a single RZZ gate #13428
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
Comments
Is this issue limited to the rzz gates and not other gates like ryy rzx etc.? |
Not limited to RZZ. But I don't mind RYY and RZX because RZZ becomes a basis gate of devices that supports fractional gates. RYY and RZX are not basis gates of any device. |
There is a synthesis algorithm Here is an example of the output of this algorithm on the circuit suggested below:
outputs:
This algorithm should be added to the unitary synthesis tranpiler pass (#13320). |
@melechlapson - |
Thank you for your information, @ShellyGarion. I would like to use the algorithm as a transpiler pass. So I wait for #13320. |
Thank you, @ShellyGarion. It looks great. from qiskit import QuantumCircuit, __version__, generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService
print(__version__, "\n")
service = QiskitRuntimeService(name="primitives")
backend = service.backend("ibm_torino", use_fractional_gates=True)
target = backend.target
qc = QuantumCircuit(2)
qc.rzz(0.1, 0, 1)
qc.rzz(0.2, 0, 1)
pm = generate_preset_pass_manager(optimization_level=2, target=target)
tqc = pm.run(qc)
print(backend.configuration().basis_gates)
print(tqc.draw(idle_wires=False), "\n")
I found that the existence of 'cz' in the basis gates prevents the merge as follows. from qiskit import QuantumCircuit, __version__, generate_preset_pass_manager
print(__version__, "\n")
qc = QuantumCircuit(2)
qc.rzz(0.1, 0, 1)
qc.rzz(0.2, 0, 1)
for basis_gates in [["rz", "rzz", "rx"], ["rz", "rzz", "rx", "cz"]]:
pm = generate_preset_pass_manager(optimization_level=2, basis_gates=basis_gates)
tqc = pm.run(qc)
print(basis_gates)
print(tqc.draw(idle_wires=False), "\n")
|
Thanks @t-imamichi for checking this! This PR should fix it #13958 (and it will hopefully be merged in time for 2.0). |
@ShellyGarion I see #12850 might make a regression. Could you check it?
script from qiskit import QuantumCircuit, __version__, generate_preset_pass_manager
print(__version__, "\n")
qc = QuantumCircuit(2)
qc.rzz(0.1, 0, 1)
qc.rzz(0.2, 0, 1)
for basis_gates in [["rz", "rzz", "rx"], ["rz", "rzz", "rx", "cz"]]:
pm = generate_preset_pass_manager(optimization_level=2, basis_gates=basis_gates)
tqc = pm.run(qc)
print(basis_gates)
print(tqc.draw(idle_wires=False), "\n") |
One case that has not been solved yet is the following:
In this case, the circuit would not get consolidated and re-synthesized into a single RZZ gate.
outputs:
|
Thank you for your information. I wait for #13419. |
What should we add?
Since the fractional gates are available, RZZ can be used as a basis gate.
But, optimization of consecutive RZZ gates does not seem to be enough as follows.
It would be nice to merge them into a single RZZ.
output (both 1.2.4 and main branch)
The text was updated successfully, but these errors were encountered: