Skip to content

Local Simulator Algorithms

中文版本

CASCAQit's current local simulator is a family of CPU numerical engines behind LocalBackend. A resource planner selects the state representation and time integrator before a Job is created or a large array is allocated. The normal entrypoint is:

from cascaqit import LocalBackend, SimulationOptions

result = LocalBackend(seed=7).run(
    program,
    shots=256,
    options=SimulationOptions(method="auto", integrator="auto"),
).result()

print(result.counts)
print(result.execution_config())
print(result.solver_evidence())
print(result.resource_usage())

program may be a bound Digital circuit, Analog AHS program, or typed HybridProgram. Execution is offline and does not contact hardware or cloud services.

Planning And Automatic Selection

SimulationPlanner evaluates program semantics, requested accuracy, dtype, CPU count, available memory, memory_fraction, max_memory_bytes, worker count, and trajectory count. Explicit requests that are semantically invalid or over budget fail before numerical execution.

Workload Default method Default integrator
Ideal Digital state_vector not_applicable
Eligible ideal Analog with a blockade basis subspace adaptive_dop853
Other ideal Analog or Hybrid state_vector adaptive_dop853
Noisy Digital within density budget density_matrix not_applicable
Noisy Analog or Hybrid within density budget density_matrix adaptive_dop853
Noisy execution after density rejection trajectory fixed_step_krylov
Noise with atom-loss occupation semantics trajectory fixed_step_krylov

blockade_mode="full" disables subspace selection. An explicit adaptive_dop853 request for trajectory execution is rejected because the current trajectory engine uses fixed time slices.

State Representations

Method Stored state Leading state storage Intended use
state_vector One complex amplitude vector O(2N)\mathcal{O}(2^N) Ideal Digital, Analog, and Hybrid
subspace Amplitudes for an explicit blockade basis O(Db)\mathcal{O}(D_b) Eligible ideal Analog workloads
density_matrix Full density operator O(4N)\mathcal{O}(4^N) Small exact noisy references
trajectory T independently seeded pure states O(T2N)\mathcal{O}(T2^N) Larger noisy workloads and atom loss

Here N is the number of logical sites, D_b is the blockade-basis dimension, and T is the number of trajectories. Solver workspaces and worker copies add to these leading state sizes; the planner includes them in its peak-memory estimate.

Digital Evolution

The scalable Digital kernel reshapes the state vector into one axis per qubit, moves the target axes to the front, applies the local gate matrix, and restores the original axis order. It supports gates acting on at most three qubits and never constructs a full 2N×2N2^N\times2^N unitary.

Digital gates currently have no duration semantics. They do not advance logical time and do not use an ODE or exponential integrator. In Hybrid execution, they act directly on the state produced by the preceding block.

Analog Hamiltonian

The ideal Analog and Hybrid engines evolve a two-level Rydberg model:

H(t)=∑iΩi(t)2(eiϕi(t)∣ri⟩⟨gi∣+h.c.)−∑iΔi(t)ni+∑i<jVijninj. H(t) = \sum_i \frac{\Omega_i(t)}{2} \left(e^{\mathrm{i}\phi_i(t)}\lvert r_i\rangle\langle g_i\rvert + \mathrm{h.c.}\right) - \sum_i \Delta_i(t)n_i + \sum_{i<j} V_{ij}n_i n_j.

The controls include global and site-addressed Rabi amplitude, detuning, and phase. Local fields are added coherently before the Hamiltonian acts. Piecewise site-addressing frames and waveform knots are part of the time-domain model.

The Hamiltonian is exposed as a SciPy LinearOperator. Matrix-vector and matrix-matrix actions are computed directly from basis occupations and single-site flips, so the engine does not materialize a dense Hamiltonian.

When an AHSProgram declares VanDerWaalsInteraction, the engine constructs each active pair from the register's Euclidean coordinates and applies

Vij=C6rij6 V_{ij} = \frac{C_6}{r_{ij}^{6}}

to the pair occupation term. C6 uses rad*um^6/us; distances and the inclusive cutoff use um. Disabled interactions and pairs with distance > cutoff_radius contribute zero. The geometry planner accepts arbitrary two-dimensional layouts, so line registers use exactly the same code path.

This deterministic Hamiltonian contribution is classified as coherent + crosstalk + number_number. It is separate from the executable noise model's coherent XX crosstalk channel, and both may coexist. The executed interaction report contains distinct interaction and geometry hashes rather than reusing noise-channel evidence. Target defaults used by ProblemCompiler are public reference facts, not production calibration.

The geometry layer already distinguishes nominal-register geometry from a position realization so future position-noise sampling can reuse pair planning. There is no public position-noise configuration or sampling API yet; current user runs always use the nominal register.

Time Integrators

Adaptive DOP853

adaptive_dop853 integrates the Schrodinger or Lindblad right-hand side with SciPy DOP853. CASCAQit splits execution at waveform knots and site-addressing frame boundaries so one solver segment never crosses a declared control discontinuity.

rtol, atol, and max_steps are consumed by the solver. Result evidence records accepted steps, function evaluations, segment count, step-size range, termination reason, and whether tolerances were applied. SciPy does not expose DOP853's rejected trial-step count, so that field remains unavailable.

Fixed-Step Krylov Action

fixed_step_krylov divides each Analog block into fixed slices, samples the Hamiltonian at each midpoint, and applies scipy.sparse.linalg.expm_multiply to compute the exponential action. CASCAQit does not maintain a separate production Krylov implementation with configurable restart or error bounds; the method name describes the current SciPy exponential-action path.

The trajectory engine always uses this fixed-step path. Density-matrix fixed-step execution combines it with symmetric Strang splitting.

Blockade Subspace

For an eligible Analog program without a finite van der Waals term, the engine can build computational basis states that do not excite any pair closer than a Target blockade radius. Evolution then runs in this explicit basis, with flip targets projected back into the same basis.

Subspace execution changes the state dimension as

2N⟶Db. 2^N \longrightarrow D_b.

It is not available when no blockade basis can be established. A finite van der Waals interaction does not imply an infinite hard-blockade constraint: automatic planning uses the full state vector, and an explicit standalone subspace request is rejected. Arbitrary Digital blocks are not silently projected into a blockade basis, so general Hybrid execution keeps the full state vector.

Density-Matrix Noise

ExactDensityMatrixKernel applies Digital unitaries on local ket and bra axes. Local Kraus channels use the same tensor strategy and do not construct global Kraus matrices.

Analog noise uses a matrix-free Lindblad right-hand side. The adaptive path integrates it with segmented DOP853. The fixed-step path uses:

half dephasing channel -> Krylov unitary action -> half dephasing channel

After evolution, the engine records trace, Hermiticity, and positivity evidence before numerical stabilization. Density matrices do not contain a vacuum-occupation axis, so physical atom loss is rejected and routed to trajectory execution.

Quantum Trajectories

BatchedTrajectoryKernel stores a batch of pure states and evolves them in bounded chunks. For each Analog time slice it applies:

stochastic half channel -> Krylov unitary action -> stochastic half channel

Each trajectory seed is derived from the root seed and trajectory index with SHA-256. Results therefore do not depend on thread scheduling or chunk size. The engine supports stochastic phase flips, Pauli channels, amplitude damping, and atom-loss occupation erasure. It reports ensemble estimates, standard error, and a 95% confidence interval where applicable.

Trajectory workers use a bounded thread pool. During parameter sweeps, scan concurrency owns the worker budget, so each trajectory item uses one internal worker and does not create a nested pool.

Noise Injection

The executable NoiseModel supports eight channels:

Channel Model Injection point
preparation Independent bit flip Initial state
dephasing Lindblad phase flip Analog evolution
gate Independent bit flip After each Digital gate
idle Finite-interval dephasing Digital idle interval
crosstalk Coherent XX Referenced control schedule
boundary Amplitude damping Hybrid block boundary
atom loss Occupation erasure Analog exit
readout Asymmetric confusion Terminal measurement

The first seven channels change the simulated state where applicable. Readout noise changes terminal outcomes and is recorded as a measurement model rather than state evolution. See Noise Models for parameters and validation rules.

The crosstalk row in this table is a user-configured noise channel with operator xx. It does not replace or absorb the deterministic van der Waals number_number interaction, even though both use the crosstalk ownership label.

Hybrid Continuity, Sampling, And Sweeps

Digital and Analog blocks in a typed HybridProgram share one state-vector, density-matrix, or trajectory lifecycle. A block boundary does not convert the state to counts or restart it from zero. result.state_transitions() exposes input and output hashes for each quantum block.

A Hybrid program may contain only Digital blocks. Its direct and scanned ideal execution use the Digital kernel without creating an Analog integrator; the selected integrator is not_applicable. See the parameter-scan lesson for a runnable example.

Terminal sampling uses state-vector probabilities, the density diagonal, or the trajectory ensemble mean. A fixed seed makes samples and counts reproducible. Typed Pauli observables are evaluated from the same final state source; trajectory observables include sampling uncertainty.

Sweep concurrency is bounded by the estimated per-run memory and retained result buffers. continue_on_error can use a worker pool. Strict fail_fast is serial so no point can start after the first observed failure.

Reference Scale

The following offline complex128 workloads have been exercised on an Apple M4 host with 10 CPU cores and 24 GiB RAM:

Workload Reference point
Digital state vector 24 qubits
Ideal Analog or Hybrid 18 sites
Exact density matrix 10 sites
Noisy Hybrid trajectory 16 sites, 256 trajectories

These are acceptance reference points, not fixed product limits. Runtime and memory remain exponential in the selected representation and depend on program duration, control discontinuities, solver tolerance, trajectory count, and host resources.

API And Capability Boundaries

Use LocalBackend with bound Digital, Analog, or typed HybridProgram inputs for the current scalable path. LocalAhsSimulator, LocalDigitalSimulator, HybridBlockSimulator, and direct HybridProgramIR planning remain available as small reference or legacy paths; their historical size and execution limits do not define the LocalBackend ceiling.

The optional Pulser adapter is a one-site Analog numerical reference, not a Native simulation engine. Current local execution also excludes GPU/MPS/distributed simulation, adaptive jump-time trajectories, a standalone production Krylov solver, Trotter-Suzuki execution, dynamic atom movement, mid-circuit measurement, reset, and real-time feedback.

Continue with Local Hybrid Simulation for runnable code, Shared Simulation State for lineage contracts, and Limitations for the complete release boundary.

SDK 1.0.8a · `b3110f80`