-
Notifications
You must be signed in to change notification settings - Fork 162
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
Add plugin pass to support non-calibrated rzz angles #2043
Add plugin pass to support non-calibrated rzz angles #2043
Conversation
Thanks @nkanazawa1989. As much as users will certainly be happy to have all angle values covered, it will also be confusing for them to see that values that are supposed to be invalid pass all the checks and run successfully. Therefore:
|
What I wrote here is not accurate. An ISA circuit is still a circuit where all rzz angles are in the range [0, pi/2]. How can we let the users know that, if they transpile with a backend that enables fractional gates, then they enjoy the service of the transpiler taking care of the angle values for them? |
Co-authored-by: Yael Ben-Haim <[email protected]>
Co-authored-by: Yael Ben-Haim <[email protected]>
Co-authored-by: Yael Ben-Haim <[email protected]>
The documentation that you added is very good. I think the general documentation of fractional gates should be updated somehow. Right now it says that theta must be between 0 and pi/2, and does not mention that you don't have to worry about it if you only transpile your circuit. |
+1. @kaelynj can you update the doc? |
Just not yet... Thanks 😄. |
Be aware of Qiskit/qiskit#13320. It's planned for Qiskit 2.0. #2043 should be merged first. |
Thanks for linking the issue. Probably it's safer to merge this first as you mention. Qiskit core doesn't need to consider angle restriction because this is very IBM Quantum specific. |
@kt474 I'm reviewing the transpiler pass, but can you please review the design of the entry point |
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.
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.
@yaelbh I think we can take over this PR. I didn't understand the bug you mentioned and I would rather defer to someone else on the consistency of the transpiler plugins. I think otherwise this looks good. I will apply the wording suggestions you made.
Co-authored-by: Yael Ben-Haim <[email protected]>
I'll take care of this PR today. Main work items:
|
@kt474 Can you please explain how the transpiler plugins mechanism works? I tried: def test_fractional_pluging(self):
""" Verify that a pass manager created for a fractional backend applies the rzz folding
pass"""
circ = QuantumCircuit(2)
circ.rzz(7, 0, 1)
# this commented section is not working either
#pm = generate_preset_pass_manager(optimization_level=0, target=FakeFractionalBackend().target)
#isa_circ = pm.run(circ)
from qiskit import transpile
isa_circ = transpile(circ, FakeFractionalBackend())
print(isa_circ) But the pass manager is not applied, what am I doing wrong? |
Note a comment in another issue, that's related to this PR: #2032 (comment). |
@yaelbh Regarding the transpiler plugin, I think the problem is that qiskit-ibm-runtime/qiskit_ibm_runtime/ibm_backend.py Lines 912 to 914 in 639f307
Edit: I see the PR does modify the |
The hook is not working for me also with an from qiskit.circuit import QuantumCircuit, Parameter
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService
service = QiskitRuntimeService()
backend = service.backend("ibm_fez", use_fractional_gates=True)
p = Parameter("p")
circ = QuantumCircuit(2)
circ.rzz(7, 0, 1)
pm = generate_preset_pass_manager(optimization_level=0, target=backend.target)
isa_circ = pm.run(circ)
print(isa_circ) This results with |
If you're using the hook points for a backend alternate default stage those only work if you specify the backend to the pass manager constructor. They don't exist on the target. |
Thanks @mtreinish, it works for fez. |
Thanks to an advice from @alexanderivrii, I was able to write a test that I'm OK with, in bae9209. |
This would work too: qiskit-ibm-runtime/qiskit_ibm_runtime/transpiler/passes/scheduling/__init__.py Lines 156 to 157 in 681aeb9
|
…le_fractional_constraint
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.
Here are some minor formatting suggestions for the release note. Otherwise, I think this is ready to merge. If merging the release note suggestions dismisses my approval, I think you can still approve and merge @yaelbh since you did not open the PR.
Following #2043 (comment): |
Also I guess that the doc update should take place at the time of the next release of qiskit-ibm-runtime, and it should be stated that this feature is available only starting from that release. |
Summary
IBM Quantum recently released new basis set including rzz gate. The Rzz gate supports continuous angle but it is calibrated only within [0, pi/2]. We have implemented the validation mechanism to detect non-calibrated angles, but user always need to manually tweak circuits to avoid angles outside this range, which is a bit cumbersome.
This PR adds a plugin pass to automatically modifies the input circuit so that end users don't need to consider our hardware constraints. However, a user still needs to consider the constraints when they send parameterized PUB with Rzz gates. The latter case is outside the scope of this PR.
Details and comments
This PR adds new translation plugin. Alternatively we can add new pass to existing
ibm_dynamic_circuits
entry point, but name is very specific to the dynamic circuits feature and adding fractional feature under this plugin name seems confusing. For now I decided to create new entry pointibm_fractional
but eventually these must be merged when our hardware supports both features with a single execution path.