How to implement classical register in a quantum circuit in Amazon Braket ? I am trying to preproduce results of a circuit build in qiskit on AWS braket services. Thanks


1 Answer 1


I'll assume that your focus is on how to specify a classical register for your measurement results, please correct me if I'm wrong. In this case, you don't have to declare a classical register or specify which qubit must be measured with Braket. All the qubits of your circuit will be measured.

For instance, a simple Bell pair circuit will be written as:

from braket.circuits import Circuit
from braket.devices import LocalSimulator
device = LocalSimulator()

circuit = Circuit().h(0).cnot(0,1)

result = device.run(circuit, shots=1000).result()
counts = result.measurement_counts
# print counts

which prints Counter({'11': 505, '00': 495}).

You can find examples on how to use Braket at the amazon-braket-examples repository. In particular, you could have a look at this notebook (1_Running_quantum_circuits_on_simulators.ipynb) where other types of measurements are presented.

If you are interested in using classical logic and control flow mechanisms, you can write your programs directly in OpenQASM and execute it with a local simulator. More information in this section of the examples.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.