-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow dynamical decoupling pass to work on circuits with pulse gates #10834
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
Conversation
One or more of the the following people are requested to review this:
|
Closes #10833 |
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.
In principle this looks fine to me, though I'd wait for one of the pulse maintainers to review properly.
gate_length = dag.calibrations[gate.name][(physical_index, gate.params)] | ||
gate_length = dag.calibrations[gate.name][ | ||
((physical_index,), tuple(gate.params)) | ||
].duration |
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.
In QuantumCircuit.has_calibration_for
, the params
tuple is built by coercing bound ParameterExpression
objects to float
as well:
qiskit/qiskit/circuit/quantumcircuit.py
Lines 451 to 456 in e599713
params = [] | |
for p in operation.params: | |
if isinstance(p, ParameterExpression) and not p.parameters: | |
params.append(float(p)) | |
else: | |
params.append(p) |
Does that need to be done here too?
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 you are right. I think it would probably be best to have a QuantumCircuit.get_calibration(gate, qubits, params)
method to abstract this operation, but I won't add that here.
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.
Yeah, agreed on both parts.
You need to put the "closes #10833" in the top PR comment for it to have an effect, but you can edit it in and it'll work. |
Ah, okay. I put it separately because I don't like it ending up in the commit message, but I guess it's fine. |
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 Will. This looks good to me. I'll approve and add this to queue once linter error is fixed.
@@ -17,6 +17,7 @@ | |||
from numpy import pi | |||
from ddt import ddt, data | |||
|
|||
from qiskit import pulse |
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.
Imported twice
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.
Fixed!
@@ -339,6 +340,69 @@ def test_insert_dd_ghz_everywhere(self): | |||
|
|||
self.assertEqual(ghz4_dd, expected) | |||
|
|||
def test_insert_dd_with_pulse_gate_calibrations(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.
Do you also want a test for parametric echo gate? I don't think this is realistic and it's up to you.
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.
Since the code handles parameters, we might as well test them. I added an extra test.
The PR body isn't used for the commit message in a squash-merge - GitHub just catenates all the commit messages together, so if you've got stuff that's added to the PR comment but not the head commit message, it doesn't get included. (I think the rules are different if the PR is merged by merge, though.) |
Ah, okay, I have not looked closely at the commit messages since this repo switched to using the merge queue (EDIT: actually, I see now that mergify was also configured for this commit message format, but back then one could also do a direct "Squash and merge" though one was not supposed to because it require extra CI churn). In qiskit-experiments, when we started using the merge queue, we changed the default commit message to "Pull request title and body" so that we could have more control over the commit message. I forgot that wasn't the default behavior. I hope some day the "Merge when ready" button will open a text box for editing the commit message like "Squash and merge" does. Now I want to squash and force push before merging 🤔 |
Pull Request Test Coverage Report for Build 6180555583
💛 - Coveralls |
41d98fe
to
da6b511
Compare
The pass was accessing the circuit calibrations incorrectly, resulting in an error when one of the gates in the dynamical decoupling sequence had a pulse gate calibration.
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. This looks good to me.
Summary
Allow dynamical decoupling pass to work on circuits with pulse gates
Details and comments
The pass was accessing the circuit calibrations incorrectly, resulting in
an error when one of the gates in the dynamical decoupling sequence had
a pulse gate calibration.
Closes #10833