quchip.chip.serialization

Chip serialization, deserialization, and structural cloning.

These helpers turn a Chip into a JSON-safe dict and back (via the device / coupling registries), and produce isolated structural clones suitable for sweep evaluation.

Cloning is structural, not numerical: devices are copied fresh, couplings are rebound to the cloned device instances, and control equipment — when attached — is cloned and reconnected. Clones keep the chip-specific backend selection so sweeps run on the same backend as the original.

Functions

clone_chip(chip)

Isolated structural clone suitable for sweep evaluation.

deserialize_chip(data)

Reconstruct a chip from serialize_chip() output.

serialize_chip(chip)

Serialize chip topology into a JSON-safe dictionary.

quchip.chip.serialization.serialize_chip(chip)[source]

Serialize chip topology into a JSON-safe dictionary.

Captures devices, couplings, baths, frame, RWA policy, and — if present — the control equipment wiring. The chip label (if any) is included verbatim. Backend identity is not serialized; deserialization uses the process default backend unless changed afterwards.

Parameters:

chip (Chip)

Return type:

dict[str, Any]

quchip.chip.serialization.deserialize_chip(data)[source]

Reconstruct a chip from serialize_chip() output.

Device and coupling classes are resolved through their shared Registrable registries (via BaseDevice.from_dict() / BaseCoupling.from_dict()), which are populated at subclass-definition time, so any extension module must be imported before deserialization.

Parameters:

data (dict[str, Any])

Return type:

Chip

quchip.chip.serialization.clone_chip(chip)[source]

Isolated structural clone suitable for sweep evaluation.

Devices are copied and decoupled from their original drive wiring; couplings are rebound to the cloned device instances. Control equipment, when present, is cloned and reconnected so the clone’s drives target the clone’s devices — not the originals.

Parameters:

chip (Chip)

Return type:

Chip