quchip.interop¶
Third-party model interoperability: ModelMapping authoring surface and registry.
This package is the library-agnostic foundation for converting circuit-QED models to and from quchip devices. Concrete mappings for specific libraries (e.g. scqubits) live in sibling modules and import both sides; this module never does.
- class quchip.interop.EigenbasisDevice(energies, *, charge_operator=None, phase_operator=None, levels=None, label=None, source_type=None, collapse_model='fermi_golden', coupling_channel=None, collapse_rate_threshold=1e-08, **noise)[source]¶
Bases:
BaseDeviceDevice backed by frozen energies and optional energy-basis operators.
This is the narrow import path for a third-party model that quchip cannot reconstruct from symbolic circuit parameters. Its authored local space is already the source model’s energy basis, so normal engine materialization applies without a device-owned diagonalization or projection path.
- Parameters:
- tunable_param_names = ()¶
Bare parameters this device exposes as differentiable / tunable scalars.
fit_a_dresswalks this tuple to discover what it is allowed to optimize on each device, decoupling the inverse-design surface from any specific device model. Three states, keyed on whether the value is explicitly declared:No explicit declaration anywhere in the
DeviceModellineage — the default is derived: every declaredparameter()field, in declaration order (seeDeviceModel.__init_subclass__).Explicit tuple on the class or an ancestor — exact curation, validated at class-definition time; authoritative and inherited until a subclass explicitly replaces it.
Explicit empty tuple — deliberately freezes the device (and its subclasses, until one replaces it) out of inverse design.
On a plain (non-
DeviceModel)BaseDevicesubclass there is no derivation; the default stays empty unless the subclass declares its own tuple — e.g.Fluxoniumuses("E_C", "E_J", "E_L", "phi_ext").
- dissipation(op, p)[source]¶
Return the common T1, T2, and thermal device channels.
- Parameters:
- Return type:
tuple[CollapseChannel, …]
- unresolved_hamiltonian()[source]¶
Return the frozen source spectrum as the authored Hamiltonian.
- Return type:
- eigenvectors()[source]¶
Return the identity map because the authored basis is energy ordered.
- Return type:
- charge_coupling_operator()[source]¶
Return the supplied charge-like operator in the authored basis.
- Return type:
- phase_coupling_operator()[source]¶
Return the supplied phase-like operator in the authored basis.
- Return type:
- physics_notes()[source]¶
Return human-readable declarations of this device’s approximations.
Each entry names a non-obvious assumption, approximation, or truncation that a user of this device should be aware of — e.g. “Hilbert truncation: 3 levels”, a model regime (Duffing), or a noise-channel selection (charge- vs flux-coupled T1).
The baseline entry is
_truncation_note(), since everyBaseDevicehas some form of Hilbert-space truncation. A pure-dephasing note is added whenT2is set, since the number-operator dephasing model carries non-obvious assumptions. Subclassessuper().physics_notes()and append their own model-specific notes; no registry / engine-side dispatch is needed.
- classmethod from_dict(data)[source]¶
Reconstruct from
to_dict()output.On the registry root, dispatch to the concrete subclass named by
data["type"](forwarding*args/**kwargs). On a concrete subclass, defer to_from_dict_payload(). Concrete subclasses that carry payload override this method directly.- Parameters:
- Return type:
- class quchip.interop.ModelMapping[source]¶
Bases:
objectBase class for a single third-party <-> quchip device conversion.
- source¶
Registry key (see
source_key()) of the third-party type this mapping imports from.Nonemeans the mapping supports export only.- Type:
str or None
- target¶
The quchip device type this mapping exports to. Required whenever
export_model()is overridden;Nonemeans import-only.- Type:
type or None
- library¶
Name of the third-party library this mapping exports for. Defaults to
source.split(".")[0]whensourceis set; export-only mappings must set it explicitly.- Type:
str or None
- Subclassing registers the mapping automatically
- \* setting ``source`` registers it for :func:`import_object` under that
key; a second subclass reusing the same
sourceraisesTypeErrorat class-definition time.
- \* overriding :meth:`export_model` registers it for :func:`export_object`
under
(library, target); overriding without settingtargetraisesTypeError, overriding without a resolvablelibrary(nosourceto default it from) raisesTypeError, and a second subclass reusing the same(library, target)pair raisesTypeErrornaming both classes.
- The abstract base itself (``source is None`` and no ``export_model``
- override) registers nothing.
- import_model(obj, **opts)[source]¶
Convert third-party object obj into a quchip device.
Override to support import. The base implementation raises
NotImplementedError.
- quchip.interop.export_object(device, library, **opts)[source]¶
Export quchip device to a third-party object of library.
Walks
type(device).__mro__and dispatches to the firstModelMappingregistered under(library, that class).- Raises:
LookupError – No mapping is registered for
(library, type(device))or any base class. The message lists the device types library can export.- Parameters:
- Return type:
- quchip.interop.import_object(obj, **opts)[source]¶
Import third-party obj into a quchip device via a registered mapping.
Walks
type(obj).__mro__and dispatches to the firstModelMappingregistered under that class’ssource_key().- Raises:
LookupError – No mapping is registered for
type(obj)or any of its base classes. The message names the missing source key and shows the skeleton for authoring a newModelMapping.- Parameters:
- Return type:
- quchip.interop.source_key(tp)[source]¶
Return the registry key for third-party type tp.
The key is the type’s top-level module name joined with its qualified name, e.g.
"scqubits.Transmon". Only the top-level module is used so that a mapping registered against a package root matches classes re-exported from submodules.
Modules
Library-agnostic registry and dispatch for third-party model mappings. |
|
A frozen energy-basis device for third-party models without a native quchip model. |
|
scqubits interoperability — |