Context: validating that an instruction list does not have mid-circuit measurements is currently very expensive. It checks that there are no mid circuit measurements by iterating through the entire instruction set, and checking if a qubit has an acquire instruction appear before a pulse. To do so, it has to resolve the qubit for each pulse. However, this only needs to practically be done once per pulse channel, so we can cache the result and reuse that.
Changes:
Cached the result of resolving_qb_pulse_channel for each quantum target so that it can be reused.
Fixed an error in the validation that compared acquire and measure channels (maybe this needs to be more robust to consider both acquires and measures)
Added a test to ensure mid-circuit measurements are caught.
Results in an order of magnitude improvement for validate for deep circuits (likely to be less impactful for shallow circuits)
Context: validating that an instruction list does not have mid-circuit measurements is currently very expensive. It checks that there are no mid circuit measurements by iterating through the entire instruction set, and checking if a qubit has an acquire instruction appear before a pulse. To do so, it has to resolve the qubit for each pulse. However, this only needs to practically be done once per pulse channel, so we can cache the result and reuse that.
Changes:
Results in an order of magnitude improvement for validate for deep circuits (likely to be less impactful for shallow circuits)