Internals

These functions are for internal use for preparing IRs for simulation and validating properties to make sure all instructions and results are supported.

BraketSimulator._combine_operationsFunction
_combine_operations(program, shots::Int) -> Program

Combine explicit instructions and basis rotation instructions (if necessary). Validate that all operations are performed on qubits within qubit_count.

source
BraketSimulator._prepare_programFunction
_prepare_program(circuit_ir::OpenQasmProgram, inputs::Dict{String, <:Any}, shots::Int) -> (Program, Int)

Parse the OpenQASM3 source, apply any inputs provided for the simulation, and compute basis rotation instructions if running with non-zero shots. Return the Program after parsing and the qubit count of the circuit.

source
_prepare_program(circuit_ir::Program, inputs::Dict{String, <:Any}, shots::Int) -> (Program, Int)

Apply any inputs provided for the simulation. Return the Program (with bound parameters) and the qubit count of the circuit.

source
BraketSimulator._get_measured_qubitsFunction
_get_measured_qubits(program, qubit_count::Int) -> Vector{Int}

Get the qubits measured by the program. If Measure instructions are present in the program's instruction list, their targets are used to form the list of measured qubits. If not, all qubits from 0 to qubit_count-1 are measured.

source
BraketSimulator._compute_resultsFunction
_compute_results(::, simulator, program::Program, n_qubits::Int, shots::Int) -> Vector{ResultTypeValue}

Compute the results once simulator has finished applying all the instructions. The results depend on the IR type if shots>0:

  • For JAQCD IR (Program), the results array is empty because the Braket SDK computes the results from the IR directly.
  • For OpenQASM IR (OpenQasmProgram), the results array is empty only if no results are present in the parsed IR. Otherwise, the results array is populated with the parsed result types (to help the Braket SDK compute them from the sampled measurements) and a placeholder zero value.
source