ProgramSetQuantumTaskResult

class braket.tasks.program_set_quantum_task_result.MeasuredEntry(measurements, counts, probabilities, measured_qubits, measurements_from_device, probabilities_from_device, program, inputs, observable)[source]

Bases: object

Result of a single executable in a program.

Parameters:
  • measurements (ndarray) – 2d array - row is shot and column is qubit. The columns are in the order of measured_qubits.

  • counts (Counter) – A Counter of measurements. Key is the measurements in a big endian binary string. Value is the number of times that measurement occurred.

  • probabilities (dict[str, float]) – A dictionary of probabilistic results. Key is the measurements in a big endian binary string. Value is the probability the measurement occurred.

  • measured_qubits (list[int]) – The indices of the measured qubits.

  • measurements_from_device (bool) – flag whether measurements were copied from device. If false, measurements are calculated from device data.

  • probabilities_from_device (bool) – flag whether measurement_probabilities were copied from device. If false, measurement_probabilities are calculated from device data.

  • program (str) – The program this executable ran.

  • inputs (dict[str, float] | None) – The input parameters to this program, if any.

  • observable (Observable | None) – The observable of this program, if any.

measurements: ndarray
counts: Counter
probabilities: dict[str, float]
measured_qubits: list[int]
measurements_from_device: bool
probabilities_from_device: bool
program: str
inputs: dict[str, float] | None
observable: Observable | None
property expectation: float | None

The expectation value of this entry’s observable if there is one.

Type:

float | None

class braket.tasks.program_set_quantum_task_result.CompositeEntry(entries, program, inputs, observables, shots_per_executable, additional_metadata)[source]

Bases: object

Results of a program in a program set

Parameters:
  • entries (list[MeasuredEntry]) – The results of each executable in this program

  • program (Program) – The program that was run

  • inputs (ParameterSets) – The input values this program was run with

  • observables (Sum | list[Observable] | None) – The Sum Hamiltonian or observables that were measured, if any.

  • shots_per_executable (int) – The number of shots each underlying executable was run with

  • additional_metadata (AdditionalMetadata | None) – Additional metadata about this program. None for entries produced by ProgramSetQuantumTaskResult.merge, since per-program metadata cannot be aggregated meaningfully across underlying tasks.

property entries: list[MeasuredEntry]

The results of each executable in this program.

Type:

list[MeasuredEntry]

property program: Program

The program that was run.

Type:

Program

property inputs: ParameterSets

The input values this program was run with.

Type:

ParameterSets

property observables: Sum | list[Observable] | None

The Sum Hamiltonian or observables measured, if any.

Type:

Sum | list[Observable] | None

property shots_per_executable: int

The number of shots each underlying executable was run with.

Type:

int

property additional_metadata: AdditionalMetadata | None

Additional metadata about this program.

For entries produced by ProgramSetQuantumTaskResult.merge, this will be None; Use the original per-task results for true per-program metadata.

Type:

AdditionalMetadata | None

expectation(i=None)[source]

float | None: The expectation value of the Hamiltonian whose terms are the observables of the underlying entries, if observables were specified.

Parameters:

i (int | None)

Return type:

float | None

class braket.tasks.program_set_quantum_task_result.ProgramSetQuantumTaskResult(entries, task_metadata, num_executables, program_set)[source]

Bases: object

The result of a program set task.

Parameters:
  • entries (list[CompositeEntry]) – The results of each program in this program set

  • task_metadata (ProgramSetTaskMetadata)

  • num_executables (int) – The total number of executables in this program set task

  • program_set (ProgramSet | None) – The program set that was run; if specified, information from the program set such as observable expectation values can be automatically computed.

property entries: list[CompositeEntry]

The results of each program in this program set.

Type:

list[CompositeEntry]

property task_metadata: ProgramSetTaskMetadata

The metadata of the task.

Type:

ProgramSetTaskMetadata

property num_executables: int

The total number of executables in this program set task.

Type:

int

property program_set: ProgramSet | None

The program set that was run, if provided to the constructor.

Type:

ProgramSet | None

static from_object(result_schema, program_set=None)[source]

Create ProgramSetQuantumTaskResult from ProgramSetTaskResult object.

Parameters:
  • result_schema (ProgramSetTaskResult) – The result returned by the device; programs and metadata may be specified as relative S3 paths, in which case they will be downloaded to populate the instance.

  • program_set (ProgramSet | None) – The program set that was run; if specified, information from the program set such as observable expectation values can be automatically computed. Default: None.

Return type:

ProgramSetQuantumTaskResult

Returns:

ProgramSetQuantumTaskResult – A ProgramSetQuantumTaskResult based on the given schema object; all data stored in S3 is downloaded.

static merge(results, program_set, index_map)[source]

Reconstruct a ProgramSetQuantumTaskResult from the task results produced by running each program set of program_set.split(...).

index_map is the per-executable map returned alongside the program sets by ProgramSet.split: index_map[k][j] gives the index, in the order of program_set, of the executable that the jth executable of the kth task represents. The kth task’s executables are read in order for its program set, namely across results[k].entries, and within each CompositeEntry across its entries.

The returned ProgramSetQuantumTaskResult has the same shape as if program_set had been run unsplit, namely one CompositeEntry per entry of program_set.entries, and MeasuredEntry objects in the order of the program.

Expectation values and Sum Hamiltonian expectations are computed for the original ProgramSet.

Parameters:
  • results (Sequence[ProgramSetQuantumTaskResult]) – The result of each task, in the same order as program_set.split’s return.

  • program_set (ProgramSet) – The original unsplit program set.

  • index_map (list[list[int]]) – The per-executable map from ProgramSet.split.

Return type:

ProgramSetQuantumTaskResult

Returns:

ProgramSetQuantumTaskResult – A result matching the shape of program_set.

Raises:

ValueError – If len(results) != len(index_map), if the total size of index_map doesn’t match program_set.total_executables, or if any task produces a different number of executables than its map expects.

property programs: list[Program]

The OpenQASM programs specified in the program set

Type:

list[Program]