Skip to content

Commit

Permalink
Merge pull request #111 from qiboteam/fixes
Browse files Browse the repository at this point in the history
Update Qick to 0.2.249
  • Loading branch information
rodolfocarobene authored Mar 27, 2024
2 parents 42172ce + 8b5484d commit 9c24db8
Show file tree
Hide file tree
Showing 13 changed files with 1,049 additions and 1,039 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ the supported QICK versions corresponding to specific Qibosoq releases.
| --------------- | ---------------------- |
| 0.1.0 | 0.2.135 |
| 0.1.1 | >=0.2.165, <=0.2.181 |
| 0.1.2 | >=0.2.211, <=0.2.230 |
| 0.1.2 | >=0.2.211, <=0.2.249 |

### TII boards

Expand Down
4 changes: 2 additions & 2 deletions doc/source/getting-started/communication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ The dictionary has to contain the following elements:
"cfg": {
"soft_avgs": int,
"reps": int,
"repetition_duration": int,
"adc_trig_offset": int,
"relaxation_time": int,
"ro_time_of_flight": int,
"average": bool,
}
"sequence": list,
Expand Down
16 changes: 8 additions & 8 deletions doc/source/getting-started/qibosoq_lab_cal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ For Qibosoq, we need to define the pulses explicitly at the beginning of each ex

sequence = [pulse]
config = Config(
repetition_duration=50, # us
adc_trig_offset=0,
relaxation_time=50, # us
ro_time_of_flight=0,
reps=1,
soft_avgs=1000,
average=True
Expand Down Expand Up @@ -389,8 +389,8 @@ For Qibosoq, the experiment needs to be defined from scratch as per the time of

sequence = [pulse]
config = Config(
repetition_duration=50,
adc_trig_offset=200,
relaxation_time=50,
ro_time_of_flight=200,
reps=1000,
average=True
)
Expand Down Expand Up @@ -557,7 +557,7 @@ As Qibosoq does not have a way of natively storing results of experiments, the n
)

config = Config(
repetition_duration = 50,
relaxation_time = 50,
reps = 1000
)
qubit = Qubit()
Expand Down Expand Up @@ -722,7 +722,7 @@ The experiment is similar to the ones before it, we just need to change a couple
)

config = Config(
repetition_duration = 50,
relaxation_time = 50,
reps = 1000
)
qubit = Qubit()
Expand Down Expand Up @@ -888,7 +888,7 @@ In this case, for example, we can see a new type of sweeper (the delay one) that
)

config = Config(
repetition_duration = 50,
relaxation_time = 50,
reps = 1000
)
qubit = Qubit()
Expand Down Expand Up @@ -1036,7 +1036,7 @@ For Qibosoq we just need to deactivate the averaging option in the Config object
sequence = [pulse_1, pulse_2]

config = Config(
repetition_duration = 50,
relaxation_time = 50,
reps = 10000,
average = False
)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting-started/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Now we can define the :class:`qibosoq.components.base.Config` object and our :cl
.. testcode:: python

config = Config(
repetition_duration = 10,
relaxation_time = 10,
reps = 2000
)
qubit = Qubit(
Expand Down
643 changes: 320 additions & 323 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages = [{ include = "qibosoq", from = "src" }]

[tool.poetry.dependencies]
python = ">=3.8, <3.12"
qick = ">=0.2.211, <=0.2.230"
qick = ">=0.2.211, <=0.2.249"

[build-system]
requires = ["poetry-core"]
Expand Down
4 changes: 2 additions & 2 deletions src/qibosoq/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class Config:
"""General RFSoC Configuration."""

repetition_duration: int = 100
relaxation_time: float = 100
"""Time to wait between shots (us)."""
adc_trig_offset: int = 200
ro_time_of_flight: int = 200
"""Time to wait between readout pulse and acquisition (ADC clock ticks)."""
reps: int = 1000
"""Number of shots."""
Expand Down
49 changes: 31 additions & 18 deletions src/qibosoq/programs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from abc import ABC, abstractmethod
from dataclasses import asdict
from typing import Dict, List, Tuple
from typing import Dict, List, Tuple, Union

import numpy as np
from qick import QickProgram, QickSoc
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(
"""In this function we define the most important settings.
In detail:
* max_gain, adc_trig_offset, max_sampling_rate, reps are imported from
* max_gain, ro_time_of_flight, max_sampling_rate, reps are imported from
qpcfg (runcard settings)
* relaxdelay (for each execution) is taken from qpcfg (runcard)
* syncdelay (for each measurement) is defined explicitly
Expand All @@ -48,15 +48,15 @@ def __init__(
self.qubits = qubits

# general settings
self.adc_trig_offset = qpcfg.adc_trig_offset
self.ro_time_of_flight = qpcfg.ro_time_of_flight

# mux settings
self.is_mux = qibosoq_cfg.IS_MULTIPLEXED
self.readouts_per_experiment = len(
[elem for elem in self.sequence if elem.type == "readout"]
)

self.relax_delay = self.us2cycles(qpcfg.repetition_duration)
self.relax_delay = self.us2cycles(qpcfg.relaxation_time)
self.syncdelay = self.us2cycles(0)
self.wait_initialize = self.us2cycles(2.0)

Expand Down Expand Up @@ -215,12 +215,12 @@ def execute_readout_pulse(
self.measure(
pulse_ch=elem.dac,
adcs=adcs,
adc_trig_offset=self.adc_trig_offset,
adc_trig_offset=self.ro_time_of_flight,
wait=False,
syncdelay=self.syncdelay,
)
elif isinstance(elem, Measurement):
self.trigger(adcs, adc_trig_offset=self.adc_trig_offset)
self.trigger(adcs, adc_trig_offset=self.ro_time_of_flight)
if self.syncdelay is not None:
self.sync_all(self.syncdelay)

Expand Down Expand Up @@ -255,9 +255,6 @@ def perform_experiment(

def collect_shots(self) -> Tuple[list, list]:
"""Read the internal buffers and returns single shots (i,q)."""
tot_i = []
tot_q = []

adcs = [] # list of adcs per readouts (not unique values)
lengths = [] # length of readouts (only one per adcs)
for elem in (elem for elem in self.sequence if elem.type == "readout"):
Expand All @@ -269,15 +266,31 @@ def collect_shots(self) -> Tuple[list, list]:

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

for idx, adc_ch in enumerate(unique_adcs):
count = adc_count[idx]
shape = (count, self.expts, self.reps) if self.expts else (count, self.reps)
i_val = self.di_buf[idx].reshape(shape) / lengths[idx]
q_val = self.dq_buf[idx].reshape(shape) / lengths[idx]

tot_i.append(i_val.tolist())
tot_q.append(q_val.tolist())
return tot_i, tot_q
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]
)
tot = []

for idx, count in enumerate(adc_count.astype(int)):
try:
# if we are doing sweepers
# (adc_channels, number_of_readouts, number_of_points, number_of_shots)
shape = (
2,
count,
int(np.prod(self.sweep_axes)),
self.reps,
) # type: Union[Tuple[int, int, int], Tuple[int, int, int, int]]
except AttributeError:
# if we are not doing sweepers
# (adc_channels, number_of_readouts, number_of_shots)
shape = (2, count, self.reps)

tot.append(stacked[:, idx].reshape(shape).tolist())

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

def declare_gen_mux_ro(self):
"""Declare nqz zone for multiplexed readout."""
Expand Down
Loading

0 comments on commit 9c24db8

Please sign in to comment.