-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
c814d58
to
70ae09d
Compare
There was an error handling pipeline event d1c778eb-96d1-4148-a0a6-acf71695e171. |
Pull Request Test Coverage Report for Build 2620326171
💛 - Coveralls |
Pull Request Test Coverage Report for Build 2836986822
💛 - Coveralls |
def _visit_reset(self, node: DAGNode) -> None: | ||
"""Visit a reset node. | ||
|
||
Reset currently triggers the end of a pulse block in IBM dynamic circuits hardware | ||
as conditional reset is performed internally using a c_if. | ||
This means that it is possible to schedule *up to* a reset (and during its measurement pulses) | ||
but the reset will be followed by a period of conditional indeterminism. | ||
All resets on disjoint qubits will be collected on the same qubits to be run simultaneously. | ||
This means that from the perspective of scheduling resets have the same behaviour and duration | ||
as a measurement. | ||
""" | ||
self._visit_measure(node) |
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.
What if the measurement result is |1>? Shouldn't reset operation always replace the data stored in qubit to |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.
Yes, the reset maps |0> -> |0>
and |1> -> |0>
. From the perspective of scheduling, measurement ends the scheduling - therefore what happens after (such as c_if) has no impact on the scheduling
# In this case, you can insert readout access before tq0 | ||
# | ||
# |t0q | ||
# Q ▒▒▒▒▒▒▒▒▒▒▒ | ||
# C ▒▒▒░░░▒▒░░░ | ||
# |t0q | ||
# |
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 this case, you can insert readout access before tq0
Is this true even if t0q-t0c
is very small? It seems like we will not have enough time to do the readout access then, right?
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.
Also is the label below (i.e., |t0q ) correct?
# C ▒▒▒░░░▒▒░░░
# |t0q
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 code is just trying not to overly occupy classical bits on the timeline. it won't have an impact on QASM3 as the model of classical bits used for scheduling here does not apply.
I skimmed this briefly. So what is the main thing that makes this IBM specific and not general purpose? Is it that measurements terminate a block? I'm just trying to figure out what exactly it is that prevents us from having this in terra (because right now i think terra is unable to produce any schedule for dynamic circuits) |
I think this is reasonable approach. It is of course possible to upgrade Terra's scheduling pass, however, this means we must guarantee the backward compatibility, and this prevents IBM hardwares from upgrading their behavior. Provider specific passes can be much flexible because we assume the output program will be executed on a particular hardware, and backward compatibility doesn't matter since there is no hardware that can execute old program. (edit) I think it's also good idea to support dynamic circuit scheduling in terra. We need more investigation for controller of other vendors to design some generic model of control flow, since terra is backend agnostic. |
I'm running the teleportation example in the documentation here:
I think q0 and q1 should be measured simultaneously, since there's no dependency. Putting barrier between them will cause a long decay. |
This is a problem with Qiskit's topological sort being used as the basis for the pass. I will look into fixes to reorder this, however, I think in general this requires a "measurement grouping" pass. Does such a pass already exist in Qiskit? |
All limitations are explained in the code. Basically indeterminism in control-flow, and measurement/reset grouping behavior currently. With future hardware updates, this may get even more complicated as we add additional scheduling constraints. |
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 @taalexander, the code looks good to me. Some minor comments before approving.
t0 = max(t0q, t1c) # pylint: disable=invalid-name | ||
|
||
t1 = t0 + op_duration # pylint: disable=invalid-name | ||
self._update_idles(node, t0, t1) |
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.
Just to confirm; in the current backend classical registers are also blocked until qubit operation completes? I think this code should be fine anyways because there is no instruction that can be conditional and takes both quantum and classical registers.
|
||
# now update all measure qarg times. | ||
|
||
self._current_block_measures.add(node) |
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 line appears twice?
t0 = t0q # pylint: disable=invalid-name | ||
bit_indices = {bit: index for index, bit in enumerate(self._dag.qubits)} | ||
measure_duration = self.durations.get( | ||
Measure(), [bit_indices[qarg] for qarg in node.qargs], unit="dt" |
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.
Ah likely I misunderstood the behavior of the code. Since this iterates over all measurements in the block individually, it doesn't change duration depending on the combination of qubits (and node.qargs
here is a single qubit in our device configuration). This is another question, why you cannot use _get_duration
method? This also takes pulse gate into account, and we can in principle override measurement with the pulse gate.
Agree this is tricky to do if using topological sort. There is a pass which performs a similar but different grouping for barriers |
Summary
This PR Is based on #366 and should only be merged after.
This PR adds two components
This PR will be followed with additional PRs rounding out dynamical decoupling and dynamic circuit utility functionality. We should also encourage IBM specific infrastructure to be productized and added to these modules going forward.
Details and comments