Gradients and parameter sweeps

class AdjointProgram(*args, **kwargs)

A unitary circuit compiled for batched Pauli expectation values and adjoint derivatives on the CPU statevector.

Compile once, then evaluate many parameter rows. The differentiable parameters, in circuit order, are one angle for p, rx, ry, rz, cp, crx, cry and crz; theta, phi, lambda for u; theta, phi, lambda, gamma for cu. Each row of params replaces all of them.

Observables are Pauli strings (character q acts on qubit q), lists of (coefficient, Pauli string) terms, or maestro.Probabilities(qubits). An observable gives one value and Probabilities gives 2**k values; results list them side by side in order (num_values columns). Gates outside a readout’s causal cone are skipped when config.enable_causal_cone_reduction is set.

expectation_values(self, observables: object, params: object | None = None, config: maestro.SimulatorConfig = SimulatorConfig()) → dict

Values of every readout for each parameter row.

Returns a dict with ‘expectation_values’ of shape (batch, num_values).

jacobian(self, observables: object, params: object | None = None, config: maestro.SimulatorConfig = SimulatorConfig()) → dict

Values and their adjoint Jacobian for each parameter row, one backward sweep per value.

Returns a dict with ‘expectation_values’ (batch, num_values) and ‘jacobian’ (batch, num_values, num_params).

property num_params

(self) -> int

property num_qubits

(self) -> int

property parameters

The circuit’s own parameter values, in program order.

vjp(self, observables: object, cotangents: object, params: object | None = None, config: maestro.SimulatorConfig = SimulatorConfig()) → dict

Vector-Jacobian product, one backward sweep per row for all readouts.

cotangents has shape (batch, num_values). Returns a dict with ‘expectation_values’ (batch, num_values) and ‘vjp’ (batch, num_params).

adjoint_jacobian(circuit: maestro.circuits.QuantumCircuit, observables: object, params: object | None = None, config: maestro.SimulatorConfig = SimulatorConfig()) → dict

Adjoint Jacobian of expectation values and probabilities; see AdjointProgram.jacobian.

class PrefixCheckpointedSimulator(*args, **kwargs)
execute_suffix(self, suffix_circuit: maestro.circuits.QuantumCircuit, shots: int = 1024, noise_model: maestro.NoiseModel | None = None, noise_realizations: int = 64, noise_seed: int | None = None, num_measurements: int = 0) → dict

Execute suffix circuit from checkpointed prefix state.

property max_bond_dim

(self) -> int