-
Notifications
You must be signed in to change notification settings - Fork 67
Add dynamical decoupling pass #367
Add dynamical decoupling pass #367
Conversation
Pull Request Test Coverage Report for Build 2837041673
💛 - Coveralls |
dd_sequence: Sequence of gates to apply in idle spots. | ||
qubits: Physical qubits on which to apply DD. | ||
If None, all qubits will undergo DD (when possible). | ||
spacing: A list of spacings between the DD gates. |
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 do we need spacing between DD gates? I'm wondering if the DD gates still adds to identity if there are delays between them?
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 sort of the definition of DD where you take a long delay and break it up into some different chunks. those chunks are the spacing
here. They are identity for circuit transformation purposes.
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, Ali! :)
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.
# (3) Construct DD sequence with delays | ||
num_elements = max(len(self._dd_sequence), len(taus)) | ||
idle_after = t_start | ||
for dd_ind in range(num_elements): |
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, we insert DD gates interleaved with delays (i.e., taus), right? Is there a scenario where len(self._dd_sequence)>len(taus)
, and we insert two DD gates with no delay in between? Do we need to check for that scenario and raise an error?
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 see the condition below if dd_ind < len(taus)
and if dd_ind < len(self._dd_sequence):
which effectively perform this error handling.
# Check if DD sequence is identity | ||
if num_pulses != 1: | ||
if num_pulses % 2 != 0: | ||
raise TranspilerError( | ||
"DD sequence must contain an even number of gates (or 1)." | ||
) | ||
noop = np.eye(2) | ||
for gate in self._dd_sequence: | ||
noop = noop.dot(gate.to_matrix()) | ||
if not matrix_equal(noop, IGate().to_matrix(), ignore_phase=True): | ||
raise TranspilerError( | ||
"The DD sequence does not make an identity operation." | ||
) | ||
self._sequence_phase = np.angle(noop[0][0]) |
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, we multiply the DD gates to see if they add to identity. How about the delays we add in between the DD gates? Don't we need to multiply them as well?
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.
The delay operation is the identity if we're in the frame of the qubits.
…s DD support. Tests are executing but failing currently.
f53474a
to
065b71d
Compare
Just a heads up related to this we're adding a backend interface for backend's to specify custom compilation stages: Qiskit/qiskit#8648 this is probably a good fit for this pass. Once that is released we should update dynamic circuits backends to add the hook point so that by default |
Summary
This PR adds a dynamical decoupling pass for IBM dynamical circuit backends. It is based on the contents of #365 and should only be merged after.
Details and comments