Skip to content
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

Attach calibrations for gates used in calibration experiments #1160

Merged
merged 2 commits into from
May 2, 2023

Conversation

wshanks
Copy link
Collaborator

@wshanks wshanks commented Apr 28, 2023

Summary

Previously EFRoughXSXAmplitudeCal and FineXDragCal only attached the
calibrations for the gates being calibrated by the experiments, not the
calibrations for the other gates used by the experiments.

Previously EFRoughXSXAmplitudeCal and FineXDragCal only attached the
calibrations for the gates being calibrated by the experiments, not the
calibrations for the other gates used by the experiments.
@wshanks
Copy link
Collaborator Author

wshanks commented Apr 28, 2023

This is the quick fix for #1158. The tests to really check these changes are in #1157.

@wshanks wshanks added backport stable potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: Bugfix Include in the "Fixed" section of the changelog labels Apr 28, 2023
Copy link
Contributor

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks like this fixes and omission of when we started attaching schedules. It makes sense to attach for all the gates. Can you answer the one question before I approve?

@@ -108,6 +108,10 @@ def _attach_calibrations(self, circuit: QuantumCircuit):
"""Attach the calibrations to the circuit."""
schedule = self._cals.get_schedule(self._sched_name, self.physical_qubits)
circuit.add_calibration(self._sched_name, self.physical_qubits, schedule)
# FineDrag always uses sx so attach it if it is not sched_name
if self._sched_name != "sx":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use has_template here as below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the purpose of this conditional is to avoid getting and attaching sx twice when running the sx cal (since then the self._sched_name call of add_calibration just above would do it). I was thinking that otherwise you would always want sx attached. We could make it provisional though but it would be

Suggested change
if self._sched_name != "sx":
if self._sched_name != "sx" and self.has_template("sx", self.physical_qubits):

and not just

        if self.has_template("sx", self.physical_qubits):

What do you think?

This kind of nuance was what was making me think that maybe we should try to use transpile() with routing="none" and translation="none" rather than a custom pass manager and attaching the calibrations directly because then we could defer to the pulse gate pass whether or not to attach calibrations for other gates in the circuit besides the one being tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. We are essentially requiring that self._cals contains the sx gate. I think this is an okay assumption in a calibration context. My question would have perhaps been better placed on the rough_amplitude_cal.py file below. I can rephrase and ask: "Why use has_template at all"? The code in rough_amplitude_cal.py seems more permissive by allowing that self._cals to not contain an X gate. Do we need the has_template check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a workflow we make easy, so maybe we should not make an allowance for it here, but I have heard from other users who are interested in working with qutrits and my thought was that users might want to calibrate sx12 and x12 but still just rely on the defaults for sx and x. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes perfect sense. Is that worth a comment in the code?

Copy link
Contributor

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Perhaps add a comment on the has check?

@wshanks wshanks enabled auto-merge May 2, 2023 22:23
@wshanks wshanks added this pull request to the merge queue May 2, 2023
Merged via the queue into qiskit-community:main with commit 2a77748 May 2, 2023
mergify bot pushed a commit that referenced this pull request May 2, 2023
### Summary

Previously `EFRoughXSXAmplitudeCal` and `FineXDragCal` only attached the
calibrations for the gates being calibrated by the experiments, not the
calibrations for the other gates used by the experiments.

(cherry picked from commit 2a77748)
coruscating pushed a commit that referenced this pull request May 3, 2023
#1160) (#1161)

This is an automatic backport of pull request #1160 done by
[Mergify](https://mergify.com).

Co-authored-by: Will Shanks <willshanks@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport stable potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants