Skip to content

Commit

Permalink
Docs preview for PR #2522.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuda-quantum-bot committed Jan 24, 2025
1 parent 6e5e039 commit 282cb98
Show file tree
Hide file tree
Showing 95 changed files with 565 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pr-2522/_sources/api/languages/python_api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ Data Types
.. autoclass:: cudaq.operator.cudm_state.CuDensityMatState
:members:

.. autoclass:: cudaq.operator.helpers.InitialState

.. autofunction:: cudaq.operator.cudm_state.to_cupy_array

.. autoclass:: cudaq::SampleResult
Expand Down
45 changes: 44 additions & 1 deletion pr-2522/_sources/using/backends/dynamics.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ For example, we can plot the Pauli expectation value for the above simulation as
In particular, for each time step, `evolve` captures an array of expectation values, one for each
observable. Hence, we convert them into sequences for plotting purposes.

Examples that illustrate how to use the ``dynamics`` target are available
in the `CUDA-Q repository <https://github.com/NVIDIA/cuda-quantum/tree/main/docs/sphinx/examples/python/dynamics>`__.

Operator
+++++++++++
Expand Down Expand Up @@ -272,4 +274,45 @@ backend target.
If the output is a '`None`' string, it indicates that your Torch installation does not support CUDA.
In this case, you need to install a CUDA-enabled Torch package via other mechanisms, e.g., building Torch from source or
using their Docker images.


Multi-GPU Multi-Node Execution
+++++++++++++++++++++++++++++++

.. _cudensitymat_mgmn:

CUDA-Q ``dynamics`` target supports parallel execution on multiple GPUs.
To enable parallel execution, the application must initialize MPI as follows.


.. tab:: Python

.. literalinclude:: ../../snippets/python/using/backends/dynamics.py
:language: python
:start-after: [Begin MPI]
:end-before: [End MPI]

.. code:: bash
mpiexec -np <N> python3 program.py
where ``N`` is the number of processes.


By initializing the MPI execution environment (via `cudaq.mpi.initialize()`) in the application code and
invoking it via an MPI launcher, we have activated the multi-node multi-GPU feature of the ``dynamics`` target.
Specifically, it will detect the number of processes (GPUs) and distribute the computation across all available GPUs.


.. note::
The number of MPI processes must be a power of 2, one GPU per process.

.. note::
Not all integrators are capable of handling distributed state. Errors will be raised if parallel execution is activated
but the selected integrator does not support distributed state.

.. warning::
As of cuQuantum version 24.11, there are a couple of `known limitations <https://docs.nvidia.com/cuda/cuquantum/24.11.0/cudensitymat/index.html>`__ for parallel execution:

- Computing the expectation value of a mixed quantum state is not supported. Thus, `collapse_operators` are not supported if expectation calculation is required.

- Some combinations of quantum states and quantum many-body operators are not supported. Errors will be raised in those cases.
6 changes: 6 additions & 0 deletions pr-2522/_sources/using/backends/simulators.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ Specific aspects of the simulation can be configured by setting the following of
As we use an opaque spin operator term as a placeholder for contraction path optimization, the resulting contraction path is not as optimal as if the actual spin operator is used.
For instance, if the spin operator is sparse (only acting on a few qubits), the contraction can be significantly simplified.
.. note::
:code:`tensornet` backends only return the overall expectation value for a :class:`cudaq.SpinOperator` when using the `cudaq::observe` method.
Term-by-term expectation values will not be available in the resulting `ObserveResult` object.
If needed, these values can be computed by calling `cudaq::observe` on individual terms instead.
Matrix product state
+++++++++++++++++++++++++++++++++++
Expand Down
2 changes: 2 additions & 0 deletions pr-2522/api/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#operator">Operator</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#time-dependent-dynamics">Time-Dependent Dynamics</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#numerical-integrators">Numerical Integrators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#multi-gpu-multi-node-execution">Multi-GPU Multi-Node Execution</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../using/install/install.html"> Installation</a><ul>
Expand Down Expand Up @@ -629,6 +630,7 @@
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.spin.y"><code class="docutils literal notranslate"><span class="pre">spin.y()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.spin.z"><code class="docutils literal notranslate"><span class="pre">spin.z()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.cudm_state.CuDensityMatState"><code class="docutils literal notranslate"><span class="pre">CuDensityMatState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.helpers.InitialState"><code class="docutils literal notranslate"><span class="pre">InitialState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.cudm_state.to_cupy_array"><code class="docutils literal notranslate"><span class="pre">to_cupy_array()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.SampleResult"><code class="docutils literal notranslate"><span class="pre">SampleResult</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.AsyncSampleResult"><code class="docutils literal notranslate"><span class="pre">AsyncSampleResult</span></code></a></li>
Expand Down
2 changes: 2 additions & 0 deletions pr-2522/api/default_ops.html
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#operator">Operator</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#time-dependent-dynamics">Time-Dependent Dynamics</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#numerical-integrators">Numerical Integrators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using/backends/dynamics.html#multi-gpu-multi-node-execution">Multi-GPU Multi-Node Execution</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../using/install/install.html"> Installation</a><ul>
Expand Down Expand Up @@ -631,6 +632,7 @@
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.spin.y"><code class="docutils literal notranslate"><span class="pre">spin.y()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.spin.z"><code class="docutils literal notranslate"><span class="pre">spin.z()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.cudm_state.CuDensityMatState"><code class="docutils literal notranslate"><span class="pre">CuDensityMatState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.helpers.InitialState"><code class="docutils literal notranslate"><span class="pre">InitialState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.operator.cudm_state.to_cupy_array"><code class="docutils literal notranslate"><span class="pre">to_cupy_array()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.SampleResult"><code class="docutils literal notranslate"><span class="pre">SampleResult</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="languages/python_api.html#cudaq.AsyncSampleResult"><code class="docutils literal notranslate"><span class="pre">AsyncSampleResult</span></code></a></li>
Expand Down
2 changes: 2 additions & 0 deletions pr-2522/api/languages/cpp_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../using/backends/dynamics.html#operator">Operator</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../using/backends/dynamics.html#time-dependent-dynamics">Time-Dependent Dynamics</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../using/backends/dynamics.html#numerical-integrators">Numerical Integrators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../using/backends/dynamics.html#multi-gpu-multi-node-execution">Multi-GPU Multi-Node Execution</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using/install/install.html"> Installation</a><ul>
Expand Down Expand Up @@ -629,6 +630,7 @@
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.spin.y"><code class="docutils literal notranslate"><span class="pre">spin.y()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.spin.z"><code class="docutils literal notranslate"><span class="pre">spin.z()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.operator.cudm_state.CuDensityMatState"><code class="docutils literal notranslate"><span class="pre">CuDensityMatState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.operator.helpers.InitialState"><code class="docutils literal notranslate"><span class="pre">InitialState</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.operator.cudm_state.to_cupy_array"><code class="docutils literal notranslate"><span class="pre">to_cupy_array()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.SampleResult"><code class="docutils literal notranslate"><span class="pre">SampleResult</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="python_api.html#cudaq.AsyncSampleResult"><code class="docutils literal notranslate"><span class="pre">AsyncSampleResult</span></code></a></li>
Expand Down
Loading

0 comments on commit 282cb98

Please sign in to comment.