-
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
include ecr native gate for pulse scaling #9397
include ecr native gate for pulse scaling #9397
Conversation
…e-ecr-gate-for-pulse-scaling
…se provided by ibm_sherbrooke
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 the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 4055132298
💛 - Coveralls |
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.
Thanks @nbronn I like the new design of CRCalType
enum. I think you also need to write a release note (as new feature).
@@ -57,15 +57,21 @@ def setUp(self): | |||
def _get_cr(time_inst, name): | |||
return isinstance(time_inst[1], Play) and time_inst[1].pulse.name.startswith(name) | |||
|
|||
cx_sched = self.inst_map.get("cx", (0, 1)) | |||
qubits = (0, 1) |
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.
Why this must be changed? This instmap is the past snapshot of Hanoi which must be the forward CX. You need to upgrade this test class with ddt
to run both on (fake) Hanoi and (fake) Sherbrooke to test CX and ECR.
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 originally changed cx_sched
to cr_sched
to treat the native entangling gates on equal footing. But I think you are correct in that I would need to make a separate test class with ddt
to test the ecr
case with (fake) Sherbrooke. Might it make more sense to run the same code for the two cases of backends (also this assumes Hanoi will always default to cx
and Sherbrooke to ecr
)?
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.
ddt with two backends sounds better, but you need overhaul of the test class because it is currently tied to Hanoi. You can remove setup and add a method to get individual play instruction, e.g. self.u0p_play
-> def get_u0p_play(self, backend):
and then pass the backend with ddt at each test function.
Hanoi and Sherbrooke might change in future, but fake backend data is locally stored as a part of terra and the object is built from there. So the gate will be always cx for Hanoi (and I guess ecr for Sherbrooke) unless someone manually update the backend data (there is a command to update the data).
…e-ecr-gate-for-pulse-scaling
fix #9308 |
…e-ecr-gate-for-pulse-scaling
issues: | ||
- | | ||
Currently the FakeSherbrooke backend does not contain `.defaults()` from which | ||
the instruction schedule map is obtained. The unit test `TestCalibrationBuilder` | ||
requires this to check `ecr` operations work similarly to the `cx` gate case. | ||
As of this PR, `ibm_sherbrooke` is the only backend with native `ecr` gates, so | ||
this requires updating. |
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 think this should be resolved. The FakeSherbrooke
backend is based on BackendV2
which doesn't have configuration()
, properties()
, or defaults()
methods. The calibrations for gates are part of the Target
object (backend.target
) and you can get an InstructionScheduleMap
from a target (backend.target.instruction_schedule_map()
). This pass was updated in #9343 to take in a target directly so when you run with FakeSherbrooke
you should just be able to do:
from qiskit.transpiler.passes import RZXCalibrationBuilder
from qiskit.providers.fake_provider import FakeSherbrooke
cal_pass = RZXCalibrationBuilder(target=FakeSherbrooke().target)
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 not that easy. We need to build reference schedule to test, but currently the builder is tied to the V1 accessors and we cannot generate the schedule with FakeV2. I wrote this issue and assigned a team member to it. We plan to update the builder in 0.24, and then we can write a test with FakeSherbrooke. The plan is (since @nbronn needs this code in a few weeks) to wait for 0.23 release and merge this PR without test. Then add the test with followup PR after above issue is resolved.
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.
@nbronn You can remove this issue note. I don't think end-users have concern about unit-test. You can leave this as a comment in the unit-test file so that developer can be aware of this.
@@ -88,6 +230,93 @@ def compute_stretch_width(self, play_gaussian_square_pulse, theta): | |||
target_area = abs(theta) / self.__angle * full_area | |||
return max(0, target_area - risefall_area) | |||
|
|||
def test_native_cr(self): |
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 must be a part of TestRZXCalibrationBuilder
because this class is a superclass of two Rzx passes of echo and non-echo. You need to write tests for
- native cr with echo
- backward cr with echo
- native cr with non-echo (backward for non echo is not supported)
with both FakeHanoi, FakeHanoiV2 and Sherbrooke.
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.
Please also update EchoRZXWeylDecomposition
to include the ECR.
While we are at it, should we add |
…c in echo_rzx_weyl_decomposition.py
…ion logic in echo_rzx_weyl_decomposition.py" This reverts commit baf069f.
…st of the RZXCalibrationBuilder (because they will need to be copied for different backends)
Modified |
It is my understanding that the |
If I understand correctly
I think DirectCX uses |
Replying to #9397 (comment) if you remove the flat-top part you have a normal Gaussian, you can still scale the amplitude but you might have some miscalibrations you need to compensate for. This is anyhow the case for Gaussian square without the drag. |
Yes. The question is how we scale the drag component in general. Since this is proportional to the derivative of amplitude, the drag coefficient must be changed with the amplitude. AFAIK there is no established method for this. |
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.
Thanks @nbronn . This almost looks good to me. This is one last feedback for unittest cleanup.
issues: | ||
- | | ||
Currently the FakeSherbrooke backend does not contain `.defaults()` from which | ||
the instruction schedule map is obtained. The unit test `TestCalibrationBuilder` | ||
requires this to check `ecr` operations work similarly to the `cx` gate case. | ||
As of this PR, `ibm_sherbrooke` is the only backend with native `ecr` gates, so | ||
this requires updating. |
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.
@nbronn You can remove this issue note. I don't think end-users have concern about unit-test. You can leave this as a comment in the unit-test file so that developer can be aware of this.
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.
Thanks @nbronn this looks good to me.
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 now has the ECR and Weyl decomposition update. LGTM. Thanks Nick.
Summary
The addition of IBM Quantum backends without native
cx
gates (i.e.,ibm_sherbrooke
where the native entangling gate isecr
, echoed cross resonance) is not compatible with the pulse scaling done byRZXCalibrationBuilder
andRZXCalibrationBuilderNoEcho
. This PR addresses this problem by treating thecx
andecr
gate on equal footing in those classes.Details and comments
The logic that handles extracting information from the entangling gates has been moved to
_check_calibration_type
and the corresponding gate is checked for inbackend.defaults().instruction_schedule_map
before assigning the correct schedule and correspondingCRCalType
(either by definition as it is only assigned in one direction forecr
or an inspection of which qubit the on-resonance compensation tones are applied to).The unit test
TestCalibrationBuilder
is also updated for compatibility with the same logic, however theFakeSherbrooke
backend fromqiskit.providers.fake_provider
currently does not have abackend.defaults()
method to obtain the instruction schedule map from.