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

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

Open
2 tasks
AGaliciaMartinez opened this issue Jun 7, 2023 · 2 comments
Open
2 tasks
Assignees
Labels
jira Sync the issue to ZI LabOneQ internal issue tracker.

Comments

@AGaliciaMartinez
Copy link

AGaliciaMartinez commented Jun 7, 2023

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?
@kshirer
Copy link
Collaborator

kshirer commented Jun 8, 2023

Hi @AGaliciaMartinez, we're looking into a solution for this. In the meantime, as a workaround, is it possible to just use the lo = Oscillator(uid="mu_uid", frequency=1e9) for both the drive and drive_ef LOs in your experiment?

@AGaliciaMartinez
Copy link
Author

This is indeed the current workaround we have. It is a little inconvenient though as we would rather not keep track of the already created oscillators.

@mforoozandeh mforoozandeh added the jira Sync the issue to ZI LabOneQ internal issue tracker. label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira Sync the issue to ZI LabOneQ internal issue tracker.
Projects
None yet
Development

No branches or pull requests

4 participants