Errors and Warnings

Solvers report a result they cannot vouch for instead of returning it silently. A failed solve raises; a suspicious one warns. Pass Options(strict=False) to turn a failure into a warning and keep the partial result.

Exception and warning types raised by OpenQuantumSim.

The hierarchy separates three situations a user may need to tell apart:

exception openquantumsim.errors.OpenQuantumSimError[source]

Bases: Exception

Base class for errors raised by OpenQuantumSim.

exception openquantumsim.errors.BackendError(message, *, julia_type=None)[source]

Bases: OpenQuantumSimError, RuntimeError

The Julia backend raised an error.

julia_type holds the name of the Julia exception type when it is known, for example "DimensionMismatch".

Parameters:
  • message (str)

  • julia_type (str | None)

Return type:

None

exception openquantumsim.errors.JuliaBridgeUnavailable(message, *, julia_type=None)[source]

Bases: BackendError, NotImplementedError

The Julia backend could not be loaded.

This also derives from NotImplementedError because solver entry points raised that type before a dedicated exception existed.

Parameters:
  • message (str)

  • julia_type (str | None)

Return type:

None

exception openquantumsim.errors.SolverError(message, *, solver_stats=None)[source]

Bases: OpenQuantumSimError, RuntimeError

A solver finished without a trustworthy result.

solver_stats carries the statistics reported by the backend, including the return code that triggered the error.

Parameters:
  • message (str)

  • solver_stats (Mapping[str, Any] | None)

Return type:

None

exception openquantumsim.errors.ConvergenceError(message, *, solver_stats=None)[source]

Bases: SolverError

An iterative method (Krylov exponentiation or GMRES) did not converge.

Parameters:
  • message (str)

  • solver_stats (Mapping[str, Any] | None)

Return type:

None

exception openquantumsim.errors.SolverHealthWarning[source]

Bases: UserWarning

A solver result may be inaccurate.

Emitted when conserved quantities drift beyond the expected tolerance, or in place of SolverError when Options(strict=False) is used.