Running circuits#

Running circuits: one function, many backends.

run(circuit, backend='aer', shots=10000)

Backend strings:

'aer'

Qiskit Aer, ideal.

'aer:<FakeBackend>'

Aer with the noise model of an IBM fake backend, for example 'aer:FakeTorino' (see qiskit_ibm_runtime.fake_provider).

'braket_local'

Amazon Braket local state-vector simulator (circuit sent as OpenQASM 3; deferred-measurement circuits only).

'braket_dm:<p>'

Braket local density-matrix simulator with depolarising noise p after every gate.

'ibm:<backend name>'

IBM Quantum hardware through the Qiskit Runtime Sampler; needs a saved account.

'ibm:least_busy'

The least busy operational IBM device.

'braket:<device ARN>'

Amazon Braket managed simulator or QPU; needs AWS credentials; billed.

run() returns a dict of bit strings to counts in Qiskit’s convention (highest classical bit first), so the decode functions of quantum_mind.circuits.builders work unchanged for every backend.

Functions

run

Run a circuit and return counts.

to_qasm3

Export a circuit as OpenQASM 3 in Braket's gate names.

run_on_ibm_backend

Submit a circuit to an IBM device and return counts.

run_on_braket_device

Submit a circuit to an Amazon Braket device and return counts.

run(qc, backend='aer', shots=10000, seed=7)[source]#

Run a circuit and return counts.

Parameters:
  • qc (qiskit.QuantumCircuit)

  • backend (str, optional) – Backend string (see the module description).

  • shots (int, optional) – Number of shots.

  • seed (int, optional) – Simulator and transpiler seed.

Returns:

dict – {bit string: count} in Qiskit bit order.

Raises:

ValueError – For an unknown backend string.

to_qasm3(qc)[source]#

Export a circuit as OpenQASM 3 in Braket’s gate names.

The circuit is transpiled to {rz, sx, x, cx, measure}; sx becomes v and cx becomes cnot, and the stdgates include is removed.

Parameters:

qc (qiskit.QuantumCircuit)

Returns:

  • source (str) – OpenQASM 3 program.

  • transpiled (qiskit.QuantumCircuit)

Raises:

ValueError – If the circuit contains a reset (use the deferred-measurement form).

run_on_ibm_backend(qc, device, shots)[source]#

Submit a circuit to an IBM device and return counts.

Transpiles to the device’s instruction set and runs with the Qiskit Runtime Sampler primitive.

Parameters:
  • qc (qiskit.QuantumCircuit)

  • device (qiskit backend) – A real backend from QiskitRuntimeService, or a fake backend (local testing mode), so the same code path is exercised in the tests.

  • shots (int)

Returns:

dict – Counts.

run_on_braket_device(qc, device, shots)[source]#

Submit a circuit to an Amazon Braket device and return counts.

Parameters:
  • qc (qiskit.QuantumCircuit) – Deferred-measurement form (no reset).

  • device (braket device) – An AwsDevice (billed) or a LocalSimulator, which the tests use as a stand-in.

  • shots (int)

Returns:

dict – Counts in Qiskit bit order.