quchip.backend.containers¶
Backend-agnostic solver-result and IR-lowering containers.
These frozen/auto dataclasses are the payloads that cross the backend boundary. The
engine or the backends produce them without committing to a solver’s native storage.
A SolverResult holds native states but shows a backend-free shape. A
PreparedHamiltonian / PreparedBatch opaquely carries any RHS the
backend’s solver accepts.
References
Johansson, Nation, Nori — QuTiP 2, Comput. Phys. Commun. 183, 1760 (2012)
Guilmin et al. — dynamiqs: an open-source Python library for GPU-accelerated and differentiable simulation of quantum systems (2024)
Module Attributes
What |
Classes
|
Scattering and relative residuals from adjacent-sector response solves. |
|
Batched-solve payload whose RHS construction is deferred. |
|
Batched-solve payload with one native RHS per element. |
|
Hermitian eigensystem returned in a single diagonalization call. |
|
Backend payload for one batched passive-linear scattering solve. |
|
Backend-native Hamiltonian produced by |
|
Temporary native generator shared by one stationary operating point. |
|
Backend-agnostic container for a single time-evolution solve. |
|
Backend payload for one stationary Lindblad solve. |
|
Batched-solve payload with a single natively batched RHS. |
Exceptions
|
A numerical or configuration failure at one batch point, safe across workers. |
- exception quchip.backend.containers.BatchSolveError(index, detail, parameters=None)[source]¶
Bases:
RuntimeErrorA numerical or configuration failure at one batch point, safe across workers.
- class quchip.backend.containers.SolverResult(times, states=None, expect=None, final_state=None, stats=<factory>, solver='', native=None)[source]¶
Bases:
objectBackend-agnostic container for a single time-evolution solve.
- Variables:
times (Any) – 1D array of save times (ns) matching the solver’s
tlist.states (list[Any] | None) – Saved states, one per save time, in the backend’s native state type (
Qobj/QArray).Noneifstore_stateswas off.expect (list[list[float]] | dict[str | tuple[str, str], Any] | None) – Expectation-value traces as a
list[list[float]]indexed bye_opsand then by time. When the engine supplied labelled observables, this is adictkeyed by strings or(drive_label, op)pairs.final_state (Any | None) – Final state (
states[-1]when states are stored). Useful for multi-segment protocols that do not keep full trajectories.stats (dict[str, Any]) – Solver-specific diagnostics (integrator step count, batch index, etc.). No physics depends on them.
solver (str) – Dispatched native solver name.
native (Any) – Unchanged stochastic result, or None for a deterministic payload.
- class quchip.backend.containers.SteadyStateSolverResult(state, expect=None, stats=<factory>, residual=None, nullity=None, _condition_number=None)[source]¶
Bases:
objectBackend payload for one stationary Lindblad solve.
- Variables:
state (State) – Stationary density matrix in the native backend basis.
expect (list or None) – Expectations in the requested observable order. None when not evaluated.
stats (dict) – Backend diagnostics, including whether uniqueness was checked.
residual (scalar or None) – Norm of the stationary Liouvillian residual, or None if not calculated.
nullity (int or None) – Estimated Liouvillian null-space dimension, or None when unchecked.
- class quchip.backend.containers.LinearResponseSolverResult(responses, mode_amplitudes, residuals, _condition_numbers, _mode_covariance)[source]¶
Bases:
objectBackend payload for one batched passive-linear scattering solve.
- Variables:
responses (array_like, shape (n_freq, n_ports, n_ports)) – Complex scattering matrix indexed by frequency, output, then input.
mode_amplitudes (array_like, shape (n_freq, n_modes, n_ports)) – Internal mode response to unit incident amplitude at each input port.
residuals (array_like, shape (n_freq,)) – Linear-system residual norms at each probe frequency.
- class quchip.backend.containers.CoherenceResponseSolverResult(responses, residuals, _condition_numbers)[source]¶
Bases:
objectScattering and relative residuals from adjacent-sector response solves.
- Variables:
responses (array_like) – Scattering with shape (frequencies, outputs, inputs).
residuals (array_like) – Maximum relative block residual for each frequency.
- class quchip.backend.containers.PreparedHamiltonian(rhs, metadata=<factory>)[source]¶
Bases:
objectBackend-native Hamiltonian produced by
Backend.prepare_hamiltonian().rhsis the object the backend’s solver accepts directly: aQobj/QobjEvofor QuTiP, and a dynamiqsTimeQArrayor a sum of them for dynamiqs.metadatapasses engine-level hints through opaquely, for examplespectral_bound_ghzfor integrator step heuristics.- Variables:
- class quchip.backend.containers.PreparedStationary(backend, engine_result, liouvillian)[source]¶
Bases:
objectTemporary native generator shared by one stationary operating point.
- Variables:
backend (Backend) – Backend instance that owns this preparation.
engine_result (EngineResult) – Exact captured operating point associated with the generator.
liouvillian (object) – Native stationary generator, with rates in 1/ns.
- class quchip.backend.containers.EagerBatch(rhs_list, batch_size, metadata=<factory>, tlist=None)[source]¶
Bases:
objectBatched-solve payload with one native RHS per element.
The default
Backend.solve_batch()dispatches each element’s RHS throughBackend.batched_sesolve()/Backend.batched_mesolve().- Variables:
- class quchip.backend.containers.VmappedBatch(rhs, batch_size, metadata=<factory>, tlist=None)[source]¶
Bases:
objectBatched-solve payload with a single natively batched RHS.
rhscovers every element at once. On this dynamiqs path, the per-element signals are stacked along a leading batch axis and the solver runs one vmapped call.- Variables:
- class quchip.backend.containers.DeferredBatch(shared, batch_size, metadata=<factory>, tlist=None)[source]¶
Bases:
objectBatched-solve payload whose RHS construction is deferred.
sharedcarries backend-private state. The producing backend must overrideBackend.solve_batch()to consume it. QuTiP assembles finalQobjEvoobjects inside its workers. Dynamiqs assembles a vmapped RHS inside its cached JIT.- Variables:
- quchip.backend.containers.PreparedBatch: TypeAlias = quchip.backend.containers.EagerBatch | quchip.backend.containers.VmappedBatch | quchip.backend.containers.DeferredBatch¶
What
Backend.prepare_batch()may return — the batching strategy is explicit in the type, andBackend.solve_batch()dispatches on it.
- class quchip.backend.containers.EigensystemData(eigenvalues, eigenvector_matrix, _states_builder=None, _states_cache=None)[source]¶
Bases:
objectHermitian eigensystem returned in a single diagonalization call.
eigenvaluesis ascending.eigenvector_matrixstacks the eigenvectors as columns in the bare-product basis used for the diagonalization. Theeigenstatesproperty gives the per-column backend-native kets lazily.Backends populate
_states_builder, a callable that materializes the ket list on demand. Alternatively, backends prime_states_cachedirectly when the diagonalizer already produced the kets, for example QuTiP’sQobj.eigenstates.- Variables: