#VS2017 – Releasing #Qubits using Reset() and ResetAll() in Q# on Microsoft Quantum Development Kit


Yesterday I wrote on the MResetZ() which allows us to get the status of a Qubit and release it. Well, at the end of each Q# operation, all the used Qubits need to be released for the simulator to work properly.

The following sample code will show a bad sample where a Qubit is used and not released correctly:

So, in runtime we will find this amazing and cool error:




  Message=Released qubits are not in zero state.


Microsoft Quantum Development Kit offers us a series of operations that help us to release Qubits: Reset() and ResetAll(). As its name indicates Reset() is intended to release a single Qubit and ResetAll() to release an array of Qubits.

Given a single Qubit, Reset() evaluates the Qubit state and ensures that the Qubit is in the state |0⟩ so it can be safely released.

The following 2 operations show examples of how to use these operations


Happy QCoding!

Greetings @ Toronto

El Bruno


My Posts



9 thoughts on “#VS2017 – Releasing #Qubits using Reset() and ResetAll() in Q# on Microsoft Quantum Development Kit”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.