autoqasm.instructions.measurements module

Quantum measurement on qubits.

Example of measuring qubit 0:

@aq.main
def my_program():
    measure(0)
autoqasm.instructions.measurements.measure(qubits: int | str | Qubit | _ClassicalVar | OQPyExpression | Qubit | Iterable[int | str | Qubit | _ClassicalVar | OQPyExpression | Qubit] | None = None) BitVar[source]

Add qubit measurement statements to the program and assign the measurement results to bit variables.

Parameters:

qubits (QubitIdentifierType | Iterable[QubitIdentifierType] | None) – The target qubits to measure. If None, all qubits will be measured. Default is None.

Returns:

BitVar – Bit variable the measurement results are assigned to.

autoqasm.instructions.measurements.measure_ff(target: int | str | Qubit | _ClassicalVar | OQPyExpression | Qubit, feedback_key: int, **kwargs) None[source]

Measure a qubit and store its result under a classical feedback key.

The measurement result is not bound to a Python variable; instead it is stored by the runtime under the integer feedback_key so that it can be consumed later in the same program by a classically-controlled operation such as autoqasm.instructions.cc_prx().

This is an IQM experimental capability. See braket.experimental_capabilities.iqm.classical_control.MeasureFF for the corresponding Braket SDK surface.

Parameters:
  • target (QubitIdentifierType) – The qubit to measure.

  • feedback_key (int) – Integer key under which the measurement result is recorded. Must match the feedback_key passed to any subsequent cc_prx call that depends on this measurement.