DumpMachine function


This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Diagnostics

Package: Microsoft.Quantum.QSharp.Foundation

Dumps the current target machine's status.

function DumpMachine<'T> (location : 'T) : Unit


location : 'T

Provides information on where to generate the machine's dump.

Output : Unit

Type Parameters



When run on the full-state simulator, the following snippet dumps the Bell state $(\ket{00} + \ket{11}) / \sqrt{2}$ to the console:

use left = Qubit();
use right = Qubit();
within {
    CNOT(left, right);
} apply {


This method allows you to dump information about the current status of the target machine into a file or some other location. The actual information generated and the semantics of location are specific to each target machine. However, providing an empty tuple as a location (()) or just omitting the location parameter typically means to generate the output to the console.

For the local full state simulator distributed as part of the Quantum Development Kit, this method expects a string with the path to a file in which it will write the wave function as a one-dimensional array of complex numbers, in which each element represents the amplitudes of the probability of measuring the corresponding state.