Skip to content
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

Correct result shape for non-multiplexed firmwares #127

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/qibosoq/programs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ def collect_shots(self) -> Tuple[list, list]:
lengths.append(self.soc.us2cycles(elem.duration, gen_ch=ro_ch))
adcs.append(adc_ch)

unique_adcs, adc_count = np.unique(adcs, return_counts=True)

len_acq = len(self.di_buf[0]) // len(unique_adcs)
stacked = (
np.stack((self.di_buf, self.dq_buf))[:, :, :len_acq]
/ np.array(lengths)[:, np.newaxis]
)
_, adc_count = np.unique(adcs, return_counts=True)
tot = []

for idx, count in enumerate(adc_count.astype(int)):
Expand All @@ -291,7 +285,12 @@ def collect_shots(self) -> Tuple[list, list]:
# (adc_channels, number_of_readouts, number_of_shots)
shape = (2, count, self.reps)

tot.append(stacked[:, idx].reshape(shape).tolist())
stacked = (
np.stack((self.di_buf[idx], self.dq_buf[idx]))[:, : np.prod(shape[1:])]
/ np.array(lengths)[:, np.newaxis]
)

tot.append(stacked.reshape(shape).tolist())

return tuple(list(x) for x in zip(*tot)) # type: ignore

Expand Down
61 changes: 36 additions & 25 deletions src/qibosoq/programs/sweepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,51 @@ def validate(self, sweeper: Sweeper):
"Sweepers on flux pulses are not implemented."
)

def add_sweep_info(self, sweeper: Sweeper):
"""Register RfsocSweep objects.
def add_sweep_info_bias(self, sweeper: Sweeper) -> List[Sweeper]:
"""Generate RfsocSweep objects for biases.

Args:
sweeper: single qibolab sweeper object to register
"""
self.validate(sweeper)
sweep_list = []
for idx, jdx in enumerate(sweeper.indexes):
gen_ch = self.qubits[jdx].dac
if gen_ch is None:
raise ValueError("Qubit dac (flux bias) not provided.")
sweep_type = "gain"
std_register = self.get_gen_reg(gen_ch, sweep_type)
swept_register = self.new_gen_reg(gen_ch, name=f"sweep_bias_{gen_ch}")
self.bias_sweep_registers[gen_ch] = (swept_register, std_register)

max_gain = int(self.soccfg["gens"][gen_ch]["maxv"])
starts = (sweeper.starts * max_gain).astype(int)
stops = (sweeper.stops * max_gain).astype(int)

if sweeper.parameters[0] is Parameter.BIAS:
for idx, jdx in enumerate(sweeper.indexes):
gen_ch = self.qubits[jdx].dac
if gen_ch is None:
raise ValueError("Qubit dac (flux bias) not provided.")
sweep_type = "gain"
std_register = self.get_gen_reg(gen_ch, sweep_type)
swept_register = self.new_gen_reg(gen_ch, name=f"sweep_bias_{gen_ch}")
self.bias_sweep_registers[gen_ch] = (swept_register, std_register)
new_sweep = QickSweep(
self,
swept_register, # sweeper_register
starts[idx], # start
stops[idx], # stop
sweeper.expts, # number of points
)
sweep_list.append(new_sweep)
return sweep_list

max_gain = int(self.soccfg["gens"][gen_ch]["maxv"])
starts = (sweeper.starts * max_gain).astype(int)
stops = (sweeper.stops * max_gain).astype(int)
def add_sweep_info(self, sweeper: Sweeper):
"""Register RfsocSweep objects.

new_sweep = QickSweep(
self,
swept_register, # sweeper_register
starts[idx], # start
stops[idx], # stop
sweeper.expts, # number of points
)
sweep_list.append(new_sweep)
Args:
sweeper: single qibolab sweeper object to register
"""
self.validate(sweeper)

self.add_sweep(merge_sweeps(sweep_list))
if sweeper.parameters[0] is Parameter.BIAS:
sweep_list = self.add_sweep_info_bias(sweeper)
merged = merge_sweeps(sweep_list)
self.add_sweep(merged)
return

sweep_list = []
for idx, jdx in enumerate(sweeper.indexes):
pulse = self.sequence[jdx]
gen_ch = pulse.dac
Expand Down Expand Up @@ -136,7 +146,8 @@ def add_sweep_info(self, sweeper: Sweeper):
)
sweep_list.append(new_sweep)

self.add_sweep(merge_sweeps(sweep_list))
merged = merge_sweeps(sweep_list)
self.add_sweep(merged)

def initialize(self):
"""Declre nyquist zones for all the DACs and all the readout frequencies.
Expand Down
Loading