Skip to content

Conversation

@eggerdj
Copy link
Contributor

@eggerdj eggerdj commented Mar 17, 2022

Summary

This is a fix for issue #558. The PR fixes several small bugs/inconsistencies in the Calibrations class.

Details and comments

The following issues/bugs/inconsistencies are fixed:

  • A check is added to the __init__ of calibrations that forces users to specify a coupling map if the control_channel_map is given. The check requires that qubits in the keys of control_channel_map are also contained as qubits in the coupling map. This is because the coupling map is used to determine the number of qubits of gate instructions (see _get_operated_qubits).
  • update_inst_map has the following if qubits is not None changed to if qubits. This change means that _robust_inst_map_add will not run using default designated parameters (i.e., qubits == tuple()) but will instead run over all schedules concerned by the change of the default parameter value. This is checked by the new test test_inst_map_stays_consistent.
  • The _get_channel_index method has a small change so that a potential KeyError will not be raised until later in the code where the more meaningful CalibrationError is raised.
  • ParameterValue now makes sure that all date times have time-zone information.

  - check consistency between coupling map and control channel map
  - made date times as time zone
  - added qubits arg to update inst map
  - fixed issue with qubits in update_inst_map
@eggerdj eggerdj requested a review from wshanks March 17, 2022 14:52
Copy link
Collaborator

@wshanks wshanks left a comment

Choose a reason for hiding this comment

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

I marked a few things to think about. Mainly it is the consistency test that we should think about before merging this because it points to a larger bug.


self.assertEqual(self.cals.get_schedule("tcp", (3, 2)), expected)

def test_inst_map_stays_consistent(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is a bug that this test is passing currently. The only reason it is passing is that the sigma parameters between the cr and xp schedules are tied, which is not realistic. If you uncouple the sigma parameters or switch to updating amp instead of sigma, the test fails.

When a parameter in a schedule nested inside a call instruction of an outer schedule is updated, the outer schedule also needs to be updated in the instruction schedule map. Should we address that case in this PR as well?

It also feels a bit weird that updating a parameter for a one qubit schedule also updates the parameter for two qubits. I thought we had scoped parameters to a number of qubits but perhaps not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this. We should fix this in this PR. Here is how the test should look like: eace06e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok this was non-trivial to fix. See here: f3b76b9

The complications were:

  1. figuring out which schedules call a schedule that we want to update and then add the caller to the update list.
  2. figuring out the qubits of the caller schedules. This happens in e.g. with an ECR gate that calls an X gate. Suppose we want to update xp on qubit (3, ). Now suppose that cr on (3, 2) calls xp then under step 1. we find that we need to also update cr but we only know that we have qubits (3, ) we therefore need to figure out that cr applies, e.g., on (2, 3) and (3, 2). Out of safety both are updated here.

@eggerdj eggerdj requested a review from wshanks March 22, 2022 11:54
Copy link
Collaborator

@wshanks wshanks left a comment

Choose a reason for hiding this comment

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

Looks good! I had some minor comments.

Copy link
Collaborator

@wshanks wshanks left a comment

Choose a reason for hiding this comment

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

Looks good!

@eggerdj eggerdj merged commit 2efe5bb into qiskit-community:main Mar 29, 2022
@eggerdj eggerdj deleted the issue-558 branch March 29, 2022 09:29
@chriseclectic chriseclectic added Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog labels Apr 25, 2022
paco-ri pushed a commit to paco-ri/qiskit-experiments that referenced this pull request Jul 11, 2022
* This PR adds the following consistency fixes for Calibrations:
  - check consistency between coupling map and control channel map
  - made date times as time zone
  - added qubits arg to update inst map
  - fixed issue with qubits in update_inst_map
  - Adds a methodology to deal with parameter updating in Calls for inst map.

Co-authored-by: Will Shanks <wshaos@posteo.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants