You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My current intention was to start from the Pulses, and propagate Pydantic to the other classes involved in serialize.py, to eventually drop the custom functions, manipulating the various objects.
While inspecting serializing.py, I'm finding a few limitations that makes it impractical to just follow this plan, without taking care at the same time of other aspects involved.
_load_pulse is almost fully converted, but for couplers
Extra arguments are ignored, in order to standardize the qubit handling, since the
:cls:`Delay` object has no `qubit` field.
This will be removed once there won't be any need for dedicated couplers handling.
"""
def_load_pulse(pulse_kwargs: dict, qubit: Qubit):
coupler="coupler"inpulse_kwargs
pulse_kwargs["qubit"] =pulse_kwargs.pop(
"coupler"ifcouplerelse"qubit", qubit.name
)
return_PulseLike.validate_python(pulse_kwargs)
_load_single_qubit_natives should not present any further complication (beyond full _load_pulse conversion)
_load_two_qubit_natives is also dealing with couplers explicitly, and converting one-element's sequences
register_gates is also dealing with couplers explicitly, and with qubit names (it requires json.loads to deserialize integers and strings at the same time), and similar shenanigans are involved for the qubit pair names, and extra handling for symmetric gates
_dump_pulse is taking the burden of deleting a bunch of things
and it is also explicitly converting the enum variants to the values (that I suspect being wrong, since already done by Pydantic, so most likely it's not properly tested)
_dump_single_qubit_natives is deleting the .qubit attribute
_dump_two_qubit_natives is dealing with couplers explicitly, and it's also filtering 0-length sequences
dump_native_gates is dealing with couplers explicitly, filtering 0-length sequences, and constructing the pair name
they are essentially everywhere, and you always have to check manually if you want to target a qubit or a coupler, and then do the exact same thing
we should treat couplers as regular qubits, or inherit both from the same object
standardize qubit names
I still would like to restrict to integers, and keep a mapping somewhere else (if in Qibolab as well, fully external)
Pydantic could handle the Union for us (but I'd suggest avoiding)
same for pairs identifiers
symmetric gates should not be duplicated on load, but the lookup process should realize it is symmetric, and check for the sorted one (or check for a random one, and fallback on the other)
0-length sequences should be left where they are (if you don't want to serialize, do not add to the platform at all) and 1-length sequences should be treated as sequences, and not converted to elements
pulse attributes should be serialized as they are, without manual deletions
if there are fields that should not be there when serializing, maybe they shouldn't be there at all
My current intention was to start from the
Pulse
s, and propagate Pydantic to the other classes involved inserialize.py
, to eventually drop the custom functions, manipulating the various objects.While inspecting
serializing.py
, I'm finding a few limitations that makes it impractical to just follow this plan, without taking care at the same time of other aspects involved._load_pulse
is almost fully converted, but for couplersqibolab/src/qibolab/serialize.py
Lines 90 to 107 in b6335dc
_load_single_qubit_natives
should not present any further complication (beyond full_load_pulse
conversion)_load_two_qubit_natives
is also dealing with couplers explicitly, and converting one-element's sequencesregister_gates
is also dealing with couplers explicitly, and with qubit names (it requiresjson.loads
to deserialize integers and strings at the same time), and similar shenanigans are involved for the qubit pair names, and extra handling for symmetric gates_dump_pulse
is taking the burden of deleting a bunch of thingsqibolab/src/qibolab/serialize.py
Lines 185 to 191 in b6335dc
and it is also explicitly converting the enum variants to the values (that I suspect being wrong, since already done by Pydantic, so most likely it's not properly tested)
_dump_single_qubit_natives
is deleting the.qubit
attribute_dump_two_qubit_natives
is dealing with couplers explicitly, and it's also filtering 0-length sequencesdump_native_gates
is dealing with couplers explicitly, filtering 0-length sequences, and constructing the pair nameThus, to advance this PR, it would be nice to:
Union
for us (but I'd suggest avoiding)Originally posted by @alecandido in #870 (comment)
A discussion about couplers is in the following comments #870 (comment), with a proposal on how to deal with them #870 (comment).
The text was updated successfully, but these errors were encountered: