Skip to content

fix(neutral-atoms): fix channel serialization using QUAM reference strings#89

Open
sebastianorbell-qm wants to merge 1 commit intofeat/neutral_atomsfrom
fix/neutral-atoms-ghz-channel-references
Open

fix(neutral-atoms): fix channel serialization using QUAM reference strings#89
sebastianorbell-qm wants to merge 1 commit intofeat/neutral_atomsfrom
fix/neutral-atoms-ghz-channel-references

Conversation

@sebastianorbell-qm
Copy link
Copy Markdown
Contributor

Summary

  • qpu.save() was failing with TypeError: Object of type SingleChannel is not JSON serializable because channels were being stored in two places in the QUAM hierarchy simultaneously (BaseQuamNA._channels and AOD.channels/Sensor.channel). QUAM enforces exclusive parent ownership, so the duplicate reference could not be serialized.
  • Fixed by storing all channels exclusively in a root channels: Dict[str, Channel] dict and having drivers/sensors hold QUAM reference strings (channel.get_reference()) instead of direct object references. These strings are transparently resolved on attribute access via QUAM's built-in reference mechanism.
  • Additional fixes: corrected AOD field annotations and method bodies, fixed Sensor channel type, cleaned up ghz.py (save path, position arithmetic, stale import, typo).

Test plan

  • python tests/neutral_atoms/GHZ/ghz.py completes without error and writes quam_state/state.json
  • aod.channel_x / aod.channel_y resolve correctly to SingleChannel objects at runtime
  • qpu.save() / BaseQuamNA.load() round-trip preserves all channel references
  • Existing test suite passes with no regressions

…rings

Channels were being registered in two places simultaneously — in
BaseQuamNA._channels and inside AOD/Sensor as direct object references.
QUAM enforces exclusive parent ownership, so json.dump failed with
"Object of type SingleChannel is not JSON serializable".

Fix by storing all channels exclusively in a root channels dict and
having drivers/sensors reference them via QUAM path strings
(channel.get_reference()), which are transparently resolved on access.

Changes:
- base_quam_na: _channels list → channels Dict[str, Channel]; add
  get_serialiser(); update register_channel()/get_channel()
- aod: replace tuple annotation with channel_x/channel_y fields typed
  as SingleChannel (hold reference strings); fix enable/disable/move
- sensor: fix channel type annotation DigitalOutputChannel → SingleChannel
- ghz.py: register all channels before constructing drivers; use
  channel.get_reference() at call sites; fix save path; fix tuple
  arithmetic for position offset; fix typo initial_postion; remove
  stray nv_center import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant