Skip to content

SimulationOptions

from cascaqit import SimulationOptions

SimulationOptions

SimulationOptions(
    method: SimulationMethod = "auto",
    integrator: SimulationIntegrator = "auto",
    device: SimulationDevice = "auto",
    dtype: SimulationDType = "complex128",
    max_memory_bytes: int | None = None,
    memory_fraction: float = 0.8,
    max_wall_time_seconds: float | None = None,
    workers: WorkerRequest = "auto",
    trajectories: int = 256,
    target_statistical_error: float | None = None,
    rtol: float = 1e-09,
    atol: float = 1e-11,
    max_steps: int = 10000,
    blockade_mode: BlockadeMode = "auto",
    seed: int = 0,
    metadata: dict[str, Any] = dict(),
    schema_version: str = SIMULATION_PLANNING_SCHEMA_VERSION,
)

Supply method, precision and resource-planning options to the unified local backend. With auto, the planner considers the program, noise and available resources. An explicitly requested method can be rejected when inapplicable; not every option combination is executable.

Parameter Meaning and range
method auto, state_vector, subspace, density_matrix or trajectory
integrator auto, adaptive_dop853 or fixed_step_krylov; purely Digital circuits need no time integration
device auto, cpu or gpu can be declared; execution currently supports only CPU, so requesting gpu fails planning
dtype complex64 or complex128; assess numerical error separately when reducing precision
max_memory_bytes / memory_fraction Positive integer memory ceiling and fraction in (0, 1] used for estimates; these do not enforce OS memory isolation
workers auto or a positive integer for scan/trajectory planning, not kernel threads
trajectories At least 2, default 256; trajectory samples are distinct from measurement shots
rtol / atol / max_steps Positive relative/absolute tolerances and a positive integer step limit, interpreted by the selected solver
blockade_mode auto, full or subspace, subject to whether the program supports the required subspace
seed Integer random seed; explicit run/config/backend seeds take precedence

max_wall_time_seconds and target_statistical_error accept positive values but are currently retained only in plan metadata. They do not enforce a deadline or automatically increase trajectories until an error target is met. metadata and schema_version retain additional information and the format identifier.

from cascaqit import Circuit, LocalBackend, SimulationOptions

options = SimulationOptions(method="state_vector", device="cpu", workers=1, seed=7)
result = LocalBackend().run(Circuit(1).x(0).measure_all(),
                            options=options, shots=32).result()
assert result.counts == {"1": 32}
assert SimulationOptions.from_dict(options.to_dict()) == options

from_dict

from_dict(data: dict[str, Any]) -> SimulationOptions

Return SimulationOptions from a dictionary, using constructor defaults for omitted fields and validating enums, positivity and types again. There is no from_json(); decode JSON to a dictionary with json.loads() first.

to_dict

to_dict() -> dict[str, Any]

Return a JSON-compatible dictionary, serializing nested objects and converting tuples to arrays. This stores the declaration, not an execution result.

to_json

to_json(*, indent: int | None = None) -> str

Return a JSON string without writing a file. indent=None uses compact formatting; supply an indentation width for readable output.

stable_hash

stable_hash() -> str

Return the SHA-256 hex digest of canonical JSON. Fields, identifiers and metadata can affect it. Use it to compare saved content, not to decide physical equivalence.