Density Matrix Simulators¶
Density Matrix¶
Density matrix simulation is helpful for understanding the impact of noise on quantum applications. Unlike state vectors simulation which manipulates the \(2^n\) state vector, density matrix simulations manipulate the \(2^n x 2^n\) density matrix which defines an ensemble of states. To learn how you can leverage the density-matrix-cpu
backend to study the impact of noise models on your applications, see the example here.
The Quantum Volume notebook also demonstrates a full application that leverages the density-matrix-cpu
backend.
To execute a program on the density-matrix-cpu
target, use the following commands:
python3 program.py [...] --target density-matrix-cpu
The target can also be defined in the application code by calling
cudaq.set_target('density-matrix-cpu')
If a target is set in the application code, this target will override the --target
command line flag given during program invocation.
nvq++ --target density-matrix-cpu program.cpp [...] -o program.x
./program.x
Stim¶
This backend provides a fast simulator for circuits containing only Clifford gates. Any non-Clifford gates (such as T gates and Toffoli gates) are not supported. This simulator is based on the Stim library.
To execute a program on the stim
target, use the following commands:
python3 program.py [...] --target stim
The target can also be defined in the application code by calling
cudaq.set_target('stim')
If a target is set in the application code, this target will override the --target
command line flag given during program invocation.
nvq++ --target stim program.cpp [...] -o program.x
./program.x
Note
CUDA-Q currently executes kernels using a “shot-by-shot” execution approach. This allows for conditional gate execution (i.e. full control flow), but it can be slower than executing Stim a single time and generating all the shots from that single execution.