ResultIR¶
from cascaqit import ResultIR
ResultIR ¶
ResultIR(
result_id: str,
program_hash: str,
target_id: str,
shots: int,
counts: dict[str, int],
samples: tuple[str, ...],
probabilities: dict[str, float] | None = None,
measurement_results: tuple[
MeasurementResultIR, ...
] = (),
state_result: StateResultIR | None = None,
observables: dict[str, Any] = dict(),
observable_batch: ObservableBatchResultIR | None = None,
bit_ordering: dict[str, Any] = (
lambda: {
"convention": UNSPECIFIED_BIT_ORDER_CONVENTION
}
)(),
occupation_encoding: OccupationEncoding = OccupationEncoding(),
diagnostics: tuple[DiagnosticsIR, ...] = (),
schema_version: str = SCHEMA_VERSION,
metadata: dict[str, Any] = dict(),
)
Store data returned by one program execution, usually obtained from Circuit.run(), AHSProgram.run() or a LocalBackend job.result(). For direct construction, result_id, program_hash and target_id identify the result and its source; shots, counts and samples hold sampling data. Callers supply those fields: constructing the object does not run or authenticate an experiment.
Probabilities is optional state-probability data and is None when unavailable or not requested; it is not counts/shots. observable_batch stores observables with estimator information, while observables contains other available scalars or metadata. bit_ordering and occupation_encoding describe bit order and occupancy. Diagnostics and metadata retain validation, execution and source records.
With one explicit measurement register, top-level counts, samples and probabilities match that register. With multiple registers, top-level counts and samples must be empty and probabilities None; read each register by key. state_result may separately retain full-state data. Partial measurement probabilities are not full-state probabilities.
from cascaqit import Circuit, ResultIR
result = Circuit(2).x(0).measure((1, 0), key="reordered").run(shots=16, seed=7)
assert result.measurement("reordered").counts == {"01": 16}
restored = ResultIR.from_json(result.to_json())
assert restored.stable_hash() == result.stable_hash()
See Digital execution records for a reading workflow. For noisy results, also distinguish the pre-readout state from recorded outcomes when interpreting probabilities, counts and observables.
Return MeasurementResultIR for key. Omit key only when exactly one explicit register exists. No registers, multiple registers without a key or an ambiguous key raise ValueError; an unknown key raises KeyError.
Return recorded SimulationExecutionConfigIR or None. This reads saved execution configuration without replanning on the current machine.
Return SimulationResourceUsageIR when recorded, otherwise None. Distinguish estimates, state-array sizes and measurements according to their fields; they are not all peak process memory.
Return recorded SimulationSolverEvidenceIR or None, exposing integrator, step and error-control information. Missing records do not imply zero error; this does not recompute a trajectory.
Return saved StateTransitionIR records as a tuple, empty when absent. They describe recorded handoffs without reconstructing missing intermediate state arrays.
Return InteractionReportIR records in Analog-block order, describing executed interaction configuration, geometry and pair summaries. Return an empty tuple when absent.
Return None when absent or the single report when exactly one exists. Multiple Analog reports raise ValueError; use interaction_reports in that case.
Read artifact references from metadata and return a tuple of ArtifactRefIR. This does not read the referenced files.
Return a new ResultIR replacing the metadata artifact-reference list with artifacts, rather than appending. This stores references without writing artifact files or uploading data.
Return a serialized dictionary. Empty measurement_results and absent state_result or observable_batch are omitted, preserving the absent-field convention. Other data comes from this result.
Return a JSON string, using stable compact formatting when indent=None or formatted output when indent is supplied. No file is written.
Return the SHA-256 digest of serialized result data and metadata. It identifies content without proving experimental correctness; adding metadata may also change the hash.
Restore ResultIR from a dictionary. Restore measurement, state, observable and diagnostic objects and check consistency of single/multiple-register fields. Missing required fields or invalid values can raise KeyError, TypeError or ValueError.
Parse a JSON object and call from_dict(), returning ResultIR. Invalid JSON raises a parsing error; a non-object root raises TypeError.