Skip to content

[BUG] - An experiment that compiles but can not be serialized. #39

@AGaliciaMartinez

Description

@AGaliciaMartinez

Describe the bug
We make use of the serializer in laboneq to send experiments to a queue for execution. However, some experiments do not serialize even though they can be compiled without error. This is because of how we create the oscillators for the signal calibration. We purposefully set the same uid to two oscillators that we know (because of how we generate them) are the same. However the serializer does not allow two different instances with same uid.
To Reproduce

from laboneq.simple import *
descriptor = \
"""
instruments:
  HDAWG:
  - address: DEV8755
    uid: flux
  SHFSG:
  - address: DEV12210
    uid: drive
  SHFQA:
  - address: DEV12216
    uid: readout
  PQSC:
  - address: DEV10095
    uid: device_pqsc
connections:
  flux:
    - rf_signal: q0/flux_line
      ports: [SIGOUTS/0]
  drive:
    - iq_signal: q0/drive_line
      ports: [SGCHANNELS/0/OUTPUT]
    - iq_signal: q0/drive_line_ef
      ports: [SGCHANNELS/0/OUTPUT]
  readout:
    - iq_signal: q0/measure_line
      ports: [QACHANNELS/0/OUTPUT]
    - acquire_signal: q0/acquire_line
      ports: [QACHANNELS/0/INPUT]
  device_pqsc:
    - to: flux
      port: ZSYNCS/0
    - to: drive
      port: ZSYNCS/1
    - to: readout
      port: ZSYNCS/3

"""
# device setup
device_setup = DeviceSetup.from_descriptor(yaml_text = descriptor,
                                           server_host= 0,
                                           server_port= 0)
# experiment signals
qubit = 0
signals = []
signals += [ExperimentSignal(f'drive_{qubit}'),
            ExperimentSignal(f'drive_{qubit}_ef'),]
exp_calib = Calibration()

# We set the uid of the local oscillators because we know they are the same.
lo = Oscillator(
    uid="mu_uid",
    frequency=1e9,
)
lo2 = Oscillator(
    uid="mu_uid",
    frequency=1e9,
)
osc = Oscillator(
        frequency=200e6,
        modulation_type=ModulationType.HARDWARE,
    )
exp_calib[f"drive_0"] = SignalCalibration(
    oscillator=osc,
    local_oscillator=lo,
)
exp_calib[f"drive_0_ef"] = SignalCalibration(
        oscillator=osc,
    local_oscillator=lo2,
)
    
exp.set_calibration(exp_calib)

#map signal
lsg = device_setup.logical_signal_groups[f"q{qubit}"].logical_signals
exp.map_signal(f"drive_{qubit}", lsg["drive_line"])
exp.map_signal(f"drive_{qubit}_ef", lsg["drive_line_ef"])

#--------------------------
# The generated experiment compiles without any error.
#--------------------------
session = Session(device_setup=device_setup)
session.connect(do_emulation=True)
result = session.run(exp) 

#--------------------------
# The generated experiment does not serialize.
#--------------------------
from laboneq.dsl.serialization.serializer import Serializer
Serializer.to_json(exp) # This raises error.

Expected behavior
Experiments that can be compiled should be serializable.

Versions used:

  • laboneq - latest
  • zhinst-core 23.2

Context

  • Do you know a workaround for the issue?
    We cache the generation of these oscillators so that they are the same.
  • Does the issue block your experiments?

Metadata

Metadata

Assignees

Labels

jiraSync the issue to ZI LabOneQ internal issue tracker.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions