Skip to content

Commit

Permalink
Docs preview for PR #2590.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuda-quantum-bot committed Feb 11, 2025
1 parent 3335d6b commit 9971fa8
Show file tree
Hide file tree
Showing 103 changed files with 506 additions and 307 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "7aa9cc8f-4e42-401f-a1fd-665e5cda19c7",
"metadata": {},
"source": [
"## _*The Deutsch-Jozsa Algorithm*_\n",
"# The Deutsch-Jozsa Algorithm\n",
"\n",
"Here is the link to the original paper: [Deutsch-Jozsa algorithm](http://rspa.royalsocietypublishing.org/content/439/1907/553). This algorithm is an earlier demonstration of the computational advantage of quantum algorithm over classical one. It addresses the problem of identifying the nature of a hidden Boolean function, which is provided as an oracle. The function is guaranteed to be either:\n",
"\n",
Expand Down
3 changes: 3 additions & 0 deletions pr-2590/_sources/using/backends/sims/tnsims.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Specific aspects of the simulation can be configured by setting the following of
* **`CUDA_VISIBLE_DEVICES=X`**: Makes the process only see GPU X on multi-GPU nodes. Each MPI process must only see its own dedicated GPU. For example, if you run 8 MPI processes on a DGX system with 8 GPUs, each MPI process should be assigned its own dedicated GPU via `CUDA_VISIBLE_DEVICES` when invoking `mpiexec` (or `mpirun`) commands.
* **`OMP_PLACES=cores`**: Set this environment variable to improve CPU parallelization.
* **`OMP_NUM_THREADS=X`**: To enable CPU parallelization, set X to `NUMBER_OF_CORES_PER_NODE/NUMBER_OF_GPUS_PER_NODE`.
* **`CUDAQ_TENSORNET_CONTROLLED_RANK=X`**: Specify the number of controlled qubits whereby the full tensor body of the controlled gate is expanded. If the number of controlled qubits is greater than this value, the gate is applied as a controlled tensor operator to the tensor network state. Default value is 1.
* **`CUDAQ_TENSORNET_OBSERVE_CONTRACT_PATH_REUSE=X`**: Set this environment variable to `TRUE` (`ON`) or `FALSE` (`OFF`) to enable or disable contraction path reuse when computing expectation values. Default is `OFF`.
* **`CUDAQ_TENSORNET_NUM_HYPER_SAMPLES=X`**: Specify the number of hyper samples used in the tensor network contraction path finder. Default value is 8 if not specified.

.. note::

Expand Down
8 changes: 5 additions & 3 deletions pr-2590/api/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
8 changes: 5 additions & 3 deletions pr-2590/api/default_ops.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../applications/python/hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
12 changes: 7 additions & 5 deletions pr-2590/api/languages/cpp_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down Expand Up @@ -2613,8 +2615,8 @@ <h2>Noise Modeling<a class="headerlink" href="#noise-modeling" title="Permalink
</dd></dl>

<dl class="cpp function">
<dt class="sig sig-object cpp" id="_CPPv4N5cudaq13kraus_channel7get_opsEv">
<span class="target" id="classcudaq_1_1kraus__channel_1ad86a7f7a00f7cea74d4d3ab684e32a35"></span><span class="n"><span class="pre">std</span></span><span class="p"><span class="pre">::</span></span><span class="n"><span class="pre">vector</span></span><span class="p"><span class="pre">&lt;</span></span><a class="reference internal" href="#_CPPv4N5cudaq8kraus_opE" title="cudaq::kraus_op"><span class="n"><span class="pre">kraus_op</span></span></a><span class="p"><span class="pre">&gt;</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">get_ops</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv4N5cudaq13kraus_channel7get_opsEv" title="Permalink to this definition">¶</a><br /></dt>
<dt class="sig sig-object cpp" id="_CPPv4NK5cudaq13kraus_channel7get_opsEv">
<span class="target" id="classcudaq_1_1kraus__channel_1a81c44b3c4097d0c417377511164cce4c"></span><span class="n"><span class="pre">std</span></span><span class="p"><span class="pre">::</span></span><span class="n"><span class="pre">vector</span></span><span class="p"><span class="pre">&lt;</span></span><a class="reference internal" href="#_CPPv4N5cudaq8kraus_opE" title="cudaq::kraus_op"><span class="n"><span class="pre">kraus_op</span></span></a><span class="p"><span class="pre">&gt;</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">get_ops</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><span class="w"> </span><span class="k"><span class="pre">const</span></span><a class="headerlink" href="#_CPPv4NK5cudaq13kraus_channel7get_opsEv" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Return all kraus_ops in this channel. </p>
</dd></dl>

Expand Down
8 changes: 5 additions & 3 deletions pr-2590/api/languages/python_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../applications/python/hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
8 changes: 5 additions & 3 deletions pr-2590/applications/python/afqmc.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@
<li class="toctree-l3"><a class="reference internal" href="deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
8 changes: 5 additions & 3 deletions pr-2590/applications/python/bernstein_vazirani.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@
<li class="toctree-l3"><a class="reference internal" href="deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
8 changes: 5 additions & 3 deletions pr-2590/applications/python/cost_minimization.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@
<li class="toctree-l3"><a class="reference internal" href="deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2"><a class="reference internal" href="deutsch_jozsa.html">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="deutsch_jozsa.html#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down
18 changes: 10 additions & 8 deletions pr-2590/applications/python/deutsch_jozsa.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@
<li class="toctree-l3"><a class="reference internal" href="deutschs_algorithm.html#Deutsch's-Algorithm:">Deutsch’s Algorithm:</a></li>
</ul>
</li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"><em>The Deutsch-Jozsa Algorithm</em></a></li>
<li class="toctree-l2"><a class="reference internal" href="#The-Theory">The Theory</a></li>
<li class="toctree-l2"><a class="reference internal" href="#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">The Deutsch-Jozsa Algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#The-Theory">The Theory</a></li>
<li class="toctree-l3"><a class="reference internal" href="#The-Algorithm-Implementation">The Algorithm Implementation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="hamiltonian_simulation.html">Spin-Hamiltonian Simulation Using CUDA-Q</a><ul>
<li class="toctree-l3"><a class="reference internal" href="hamiltonian_simulation.html#Introduction">Introduction</a><ul>
<li class="toctree-l4"><a class="reference internal" href="hamiltonian_simulation.html#Heisenberg-Hamiltonian">Heisenberg Hamiltonian</a></li>
Expand Down Expand Up @@ -723,7 +725,7 @@
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../../using/applications.html">CUDA-Q Applications</a></li>
<li class="breadcrumb-item active"><em>The Deutsch-Jozsa Algorithm</em></li>
<li class="breadcrumb-item active">The Deutsch-Jozsa Algorithm</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/applications/python/deutsch_jozsa.ipynb.txt" rel="nofollow"> View page source</a>
</li>
Expand All @@ -737,17 +739,16 @@
<div itemprop="articleBody">

<section id="The-Deutsch-Jozsa-Algorithm">
<h1><em>The Deutsch-Jozsa Algorithm</em><a class="headerlink" href="#The-Deutsch-Jozsa-Algorithm" title="Permalink to this heading"></a></h1>
<h1>The Deutsch-Jozsa Algorithm<a class="headerlink" href="#The-Deutsch-Jozsa-Algorithm" title="Permalink to this heading"></a></h1>
<p>Here is the link to the original paper: <a class="reference external" href="http://rspa.royalsocietypublishing.org/content/439/1907/553">Deutsch-Jozsa algorithm</a>. This algorithm is an earlier demonstration of the computational advantage of quantum algorithm over classical one. It addresses the problem of identifying the nature of a hidden Boolean function, which is provided as an oracle. The function is guaranteed to be either:</p>
<ul class="simple">
<li><p><strong>Balanced</strong>, meaning it outputs 0 for exactly half of its possible inputs and 1 for the other half.</p></li>
<li><p><strong>Constant</strong>, meaning it outputs the same value (either 0 or 1) for all inputs.</p></li>
</ul>
<p>Classically, determining whether the function is balanced or constant requires evaluating the oracle multiple times. In the worst-case scenario, one would need to query at least half of the inputs to distinguish a constant function. However, the Deutsch-Jozsa algorithm demonstrates quantum superiority by solving this problem with a single query to the oracle, regardless of the input size.</p>
<p>This notebook implements the Deutsch-Jozsa algorithm as described in <a class="reference external" href="https://arxiv.org/pdf/quant-ph/9708016.pdf">Cleve et al. 1997</a>. The input for the oracle function <span class="math notranslate nohighlight">\(f\)</span> is a <span class="math notranslate nohighlight">\(n\)</span>-bit string. It means that for <span class="math notranslate nohighlight">\(x\ in \{0,1\}^n\)</span>, the value of <span class="math notranslate nohighlight">\(f(x)\)</span> is either constant, i.e., the same for all <span class="math notranslate nohighlight">\(x\)</span>, or balanced, i.e., exactly half of the <span class="math notranslate nohighlight">\(n\)</span>-bit string whose <span class="math notranslate nohighlight">\(f(x) = 0\)</span>.</p>
</section>
<section id="The-Theory">
<h1>The Theory<a class="headerlink" href="#The-Theory" title="Permalink to this heading"></a></h1>
<h2>The Theory<a class="headerlink" href="#The-Theory" title="Permalink to this heading"></a></h2>
<p>Here are the steps to implement the algorithm: 1. Start with initializing all input qubits and single auxiliary qubits to zero. The first <span class="math notranslate nohighlight">\(n-1\)</span> input qubits are used for querying the oracle, and the last auxiliary qubit is used for storing the answer of the oracle</p>
<div class="math notranslate nohighlight">
\[|0\ldots 0\rangle |0\rangle\]</div>
Expand All @@ -771,7 +772,7 @@ <h1>The Theory<a class="headerlink" href="#The-Theory" title="Permalink to this
</ol>
</section>
<section id="The-Algorithm-Implementation">
<h1>The Algorithm Implementation<a class="headerlink" href="#The-Algorithm-Implementation" title="Permalink to this heading"></a></h1>
<h2>The Algorithm Implementation<a class="headerlink" href="#The-Algorithm-Implementation" title="Permalink to this heading"></a></h2>
<p>Here is the CUDA-Q code following the steps outlined in the above theory section.</p>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[31]:
Expand Down Expand Up @@ -917,6 +918,7 @@ <h1>The Algorithm Implementation<a class="headerlink" href="#The-Algorithm-Imple
</pre></div>
</div>
</div>
</section>
</section>


Expand Down
Loading

0 comments on commit 9971fa8

Please sign in to comment.