qua-platform / quam

The Quantum Abstract Machine (QuAM) is a comprehensive framework designed to abstract and manage quantum programming environments, providing robust tools for configuring and running quantum operations effectively. It is built over the QUA programming language, offering an organized structure for handling complex quantum components and operations.
http://qua-platform.github.io/quam/
BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

When the `integration_weights` for a readout pulse is manually set as a list of one tuple, loading the saved configuration file throws an error #59

Closed huochenQE closed 1 month ago

huochenQE commented 1 month ago

When the integration_weights for a readout pulse is manually set as a list of one tuple, loading the saved configuration file throws an error:

Code to reproduce the error:

from quam.components import *
from quam.examples.superconducting_qubits import Transmon, QuAM
from quam.components.pulses import SquareReadoutPulse

machine = QuAM()

transmon = Transmon(id=0)
machine.qubits[transmon.name] = transmon

# Add resonator channel
transmon.resonator = InOutIQChannel(
    id=0,
    opx_output_I=("con1", 1),
    opx_output_Q=("con1", 2),
    opx_input_I=("con1", 1),
    opx_input_Q=("con1", 2,),
    frequency_converter_up=FrequencyConverter(
        mixer=Mixer(), local_oscillator=LocalOscillator(power=10, frequency=6e9)
    ),
)

# Create a Readout pulse
readout_pulse = SquareReadoutPulse(length=1000, amplitude=0.1, integration_weights=[(1.0, 1000)])

# Attach the pulse to the resonator of the first qubit
machine.qubits["q0"].resonator.operations["readout"] = readout_pulse

machine.save("test.json")
QuAM.load("test.json")

The error message is

{
    "name": "TypeError",
    "message": "Could not instantiate QuAM.qubits[\"q0\"].resonator.operations[\"readout\"].integration_weights with any of the types in typing.Union[typing.List[float], typing.List[typing.Tuple[float, int]]]",
nulinspiratie commented 1 month ago

Nice catch, this was indeed a bug. It should be fixed now, please let me know if it persists