Skip to content

Commit

Permalink
swap sweepers carefully - not all frequency sweepers are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-k committed Mar 22, 2024
1 parent 07d4df1 commit c1d6129
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/qibolab/instruments/zhinst/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from qibolab.couplers import Coupler
from qibolab.instruments.abstract import Controller
from qibolab.instruments.port import Port
from qibolab.pulses import FluxPulse, PulseSequence, PulseType
from qibolab.pulses import DrivePulse, FluxPulse, PulseSequence, PulseType
from qibolab.qubits import Qubit
from qibolab.sweeper import Parameter, Sweeper
from qibolab.unrolling import Bounds
Expand Down Expand Up @@ -701,11 +701,10 @@ def play_sweep(exp, channel_name, pulse):
def rearrange_rt_sweepers(
sweepers: list[Sweeper],
) -> tuple[Optional[tuple[int, int]], list[Sweeper]]:
"""Rearranges list of real-time sweepers based on hardware limitations.
"""Rearranges list of real-time sweepers based on heuristic
discoveries.
The only known limitation currently is that frequency sweepers must be applied before (on the outer loop) other
(e.g. amplitude) sweepers. Consequently, the only thing done here is to swap the frequency sweeper with the
first sweeper in the list.
The only thing this function currently does is either swap two sweeper or do nothing.
Args:
sweepers: Sweepers to rearrange.
Expand All @@ -718,12 +717,17 @@ def rearrange_rt_sweepers(
iter(s for s in sweepers if s.parameter is Parameter.frequency), None
)
if freq_sweeper:
# If readout frequency sweep, swap it with the outermost loop
# If drive, swap it with the innermost sweep
swap_idx = 0
if any(isinstance(pulse.type, DrivePulse) for pulse in freq_sweeper.pulses):
swap_idx = len(sweepers) - 1
sweepers_copy = sweepers.copy()
freq_sweeper_idx = sweepers_copy.index(freq_sweeper)
sweepers_copy[freq_sweeper_idx] = sweepers_copy[0]
sweepers_copy[0] = freq_sweeper
sweepers_copy[freq_sweeper_idx] = sweepers_copy[swap_idx]
sweepers_copy[swap_idx] = freq_sweeper
log.warning("Sweepers were reordered")
return (0, freq_sweeper_idx), sweepers_copy
return (swap_idx, freq_sweeper_idx), sweepers_copy
return None, sweepers

def sweep(self, qubits, couplers, sequence: PulseSequence, options, *sweepers):
Expand Down

0 comments on commit c1d6129

Please sign in to comment.