Skip to content

Commit

Permalink
Docs preview for PR #1932.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuda-quantum-bot committed Jul 15, 2024
1 parent 7d01114 commit 1f103ff
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 39 deletions.
72 changes: 63 additions & 9 deletions pr-1932/api/languages/cpp_api.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pr-1932/api/languages/python_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ <h2>Data Types<a class="headerlink" href="#data-types" title="Permalink to this
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">random</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cudaq.SpinOperator.random" title="Permalink to this definition"></a></dt>
<dd><dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">random</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qubit_count</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">term_count</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">477589269</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#cudaq.SpinOperator" title="cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SpinOperator"><span class="pre">cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SpinOperator</span></a></span></span></dt>
<span class="sig-name descname"><span class="pre">random</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qubit_count</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">term_count</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">2336932542</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#cudaq.SpinOperator" title="cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SpinOperator"><span class="pre">cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SpinOperator</span></a></span></span></dt>
<dd></dd></dl>

<p>Return a random <a class="reference internal" href="#cudaq.SpinOperator" title="cudaq.SpinOperator"><code class="xref py py-class docutils literal notranslate"><span class="pre">SpinOperator</span></code></a> on the given number of qubits (<code class="code docutils literal notranslate"><span class="pre">qubit_count</span></code>) and composed of the given number of terms (<code class="code docutils literal notranslate"><span class="pre">term_count</span></code>). An optional seed value may also be provided.</p>
Expand Down
4 changes: 2 additions & 2 deletions pr-1932/examples/python/tutorials/deutschs_algorithm.html
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ <h2>XOR <span class="math notranslate nohighlight">\(\oplus\)</span><a class="he
</section>
<section id="Quantum-oracles">
<h2>Quantum oracles<a class="headerlink" href="#Quantum-oracles" title="Permalink to this heading"></a></h2>
<p><img alt="1f97d462cb4e4b1f8af61c8e2457d9cc" class="no-scaled-link" src="../../../_images/oracle.png" style="width: 300px; height: 150px;" /></p>
<p><img alt="1b0cee9f031147e7a378267f4af2bee4" class="no-scaled-link" src="../../../_images/oracle.png" style="width: 300px; height: 150px;" /></p>
<p>Suppose we have <span class="math notranslate nohighlight">\(f(x): \{0,1\} \longrightarrow \{0,1\}\)</span>. We can compute this function on a quantum computer using oracles which we treat as black box functions that yield the output with an appropriate sequence of logic gates.</p>
<p>Above you see an oracle represented as <span class="math notranslate nohighlight">\(U_f\)</span> which allows us to transform the state <span class="math notranslate nohighlight">\(\ket{x}\ket{y}\)</span> into:</p>
<div class="math notranslate nohighlight">
Expand Down Expand Up @@ -651,7 +651,7 @@ <h2>Quantum parallelism<a class="headerlink" href="#Quantum-parallelism" title="
<h2>Deutschs’ Algorithm:<a class="headerlink" href="#Deutschs'-Algorithm:" title="Permalink to this heading"></a></h2>
<p>Our aim is to find out if <span class="math notranslate nohighlight">\(f: \{0,1\} \longrightarrow \{0,1\}\)</span> is a constant or a balanced function? If constant, <span class="math notranslate nohighlight">\(f(0) = f(1)\)</span>, and if balanced, <span class="math notranslate nohighlight">\(f(0) \neq f(1)\)</span>.</p>
<p>We step through the circuit diagram below and follow the math after the application of each gate.</p>
<p><img alt="e47efc2a09d7424cab87224cf63d33f8" class="no-scaled-link" src="../../../_images/deutsch.png" style="width: 500px; height: 210px;" /></p>
<p><img alt="2200a78b6d444323bf79d9b817e85cdd" class="no-scaled-link" src="../../../_images/deutsch.png" style="width: 500px; height: 210px;" /></p>
<div class="math notranslate nohighlight">
\[\ket{\psi_0} = \ket{01}
\tag{1}\]</div>
Expand Down
30 changes: 24 additions & 6 deletions pr-1932/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -837,28 +837,40 @@ <h2 id="C">C</h2>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq15ExecutionResult9serializeEv">cudaq::ExecutionResult::serialize (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradientE">cudaq::gradient (C++ class)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient5cloneEv">cudaq::gradient::clone (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient7computeERKNSt6vectorIdEERKNSt8functionIFdNSt6vectorIdEEEEEd">cudaq::gradient::compute (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient7computeERKNSt6vectorIdEERNSt6vectorIdEERK7spin_opd">[1]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq8gradient8gradientER7KernelTRR10ArgsMapper">cudaq::gradient::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq8gradient8gradientERR13QuantumKernelRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I0EN5cudaq8gradient8gradientER7KernelT">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient8gradientEv">[4]</a>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq8gradient8gradientER7KernelT">cudaq::gradient::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq8gradient8gradientER7KernelTRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq8gradient8gradientERR13QuantumKernelRR10ArgsMapper">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq8gradient8gradientEv">[4]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I0DpEN5cudaq8gradient7setArgsEvR13QuantumKernelDpRR4Args">cudaq::gradient::setArgs (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I0EN5cudaq8gradient9setKernelEvR13QuantumKernel">cudaq::gradient::setKernel (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_differenceE">cudaq::gradients::central_difference (C++ class)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference5cloneEv">cudaq::gradients::central_difference::clone (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference7computeERKNSt6vectorIdEERKNSt8functionIFdNSt6vectorIdEEEEEd">cudaq::gradients::central_difference::compute (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference7computeERKNSt6vectorIdEERNSt6vectorIdEERK7spin_opd">[1]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18central_difference8gradientER7KernelTRR10ArgsMapper">cudaq::gradients::central_difference::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18central_difference8gradientERR13QuantumKernelRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I0EN5cudaq9gradients18central_difference8gradientER7KernelT">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference8gradientEv">[4]</a>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18central_difference8gradientER7KernelT">cudaq::gradients::central_difference::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18central_difference8gradientER7KernelTRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18central_difference8gradientERR13QuantumKernelRR10ArgsMapper">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18central_difference8gradientEv">[4]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_differenceE">cudaq::gradients::forward_difference (C++ class)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference5cloneEv">cudaq::gradients::forward_difference::clone (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference7computeERKNSt6vectorIdEERKNSt8functionIFdNSt6vectorIdEEEEEd">cudaq::gradients::forward_difference::compute (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference7computeERKNSt6vectorIdEERNSt6vectorIdEERK7spin_opd">[1]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18forward_difference8gradientER7KernelTRR10ArgsMapper">cudaq::gradients::forward_difference::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18forward_difference8gradientERR13QuantumKernelRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I0EN5cudaq9gradients18forward_difference8gradientER7KernelT">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference8gradientEv">[4]</a>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18forward_difference8gradientER7KernelT">cudaq::gradients::forward_difference::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18forward_difference8gradientER7KernelTRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients18forward_difference8gradientERR13QuantumKernelRR10ArgsMapper">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients18forward_difference8gradientEv">[4]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shiftE">cudaq::gradients::parameter_shift (C++ class)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift5cloneEv">cudaq::gradients::parameter_shift::clone (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift7computeERKNSt6vectorIdEERKNSt8functionIFdNSt6vectorIdEEEEEd">cudaq::gradients::parameter_shift::compute (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift7computeERKNSt6vectorIdEERNSt6vectorIdEERK7spin_opd">[1]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients15parameter_shift8gradientER7KernelTRR10ArgsMapper">cudaq::gradients::parameter_shift::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients15parameter_shift8gradientERR13QuantumKernelRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I0EN5cudaq9gradients15parameter_shift8gradientER7KernelT">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift8gradientEv">[4]</a>
<li><a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients15parameter_shift8gradientER7KernelT">cudaq::gradients::parameter_shift::gradient (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients15parameter_shift8gradientER7KernelTRR10ArgsMapper">[1]</a>, <a href="api/languages/cpp_api.html#_CPPv4I00EN5cudaq9gradients15parameter_shift8gradientERR13QuantumKernelRR10ArgsMapper">[2]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift8gradientERRNSt8functionIFvNSt6vectorIdEEEEE">[3]</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq9gradients15parameter_shift8gradientEv">[4]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4IDpEN5cudaq14kernel_builderE">cudaq::kernel_builder (C++ class)</a>
</li>
Expand Down Expand Up @@ -1001,17 +1013,19 @@ <h2 id="C">C</h2>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq3QPU27supportsConditionalFeedbackEv">cudaq::QPU::supportsConditionalFeedback (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq3QPU28supportsRemoteSerializedCodeEv">cudaq::QPU::supportsRemoteSerializedCode (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq3QPU17supportsRemoteVQEEv">cudaq::QPU::supportsRemoteVQE (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq3QPUD0Ev">cudaq::QPU::~QPU (C++ function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api/languages/cpp_api.html#_CPPv4I_NSt6size_tE_NSt6size_tE0EN5cudaq4qregE">cudaq::qreg (C++ class)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg4backENSt6size_tE">cudaq::qreg::back (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg4backEv">[1]</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg5beginEv">cudaq::qreg::begin (C++ function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg5clearEv">cudaq::qreg::clear (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg5frontENSt6size_tE">cudaq::qreg::front (C++ function)</a>, <a href="api/languages/cpp_api.html#_CPPv4N5cudaq4qreg5frontEv">[1]</a>
Expand Down Expand Up @@ -1081,6 +1095,8 @@ <h2 id="C">C</h2>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq16quantum_platform9is_remoteEKNSt6size_tE">cudaq::quantum_platform::is_remote (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq16quantum_platform12is_simulatorEKNSt6size_tE">cudaq::quantum_platform::is_simulator (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq16quantum_platform9launchVQEEKNSt6stringEPKvPN5cudaq8gradientEN5cudaq7spin_opERN5cudaq9optimizerEKiKNSt6size_tE">cudaq::quantum_platform::launchVQE (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4N5cudaq16quantum_platform14list_platformsEv">cudaq::quantum_platform::list_platforms (C++ function)</a>
</li>
Expand Down Expand Up @@ -1111,6 +1127,8 @@ <h2 id="C">C</h2>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq16quantum_platform29supports_conditional_feedbackEKNSt6size_tE">cudaq::quantum_platform::supports_conditional_feedback (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq16quantum_platform31supports_remote_serialized_codeEKNSt6size_tE">cudaq::quantum_platform::supports_remote_serialized_code (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq16quantum_platform19supports_remote_vqeEKNSt6size_tE">cudaq::quantum_platform::supports_remote_vqe (C++ function)</a>
</li>
<li><a href="api/languages/cpp_api.html#_CPPv4NK5cudaq16quantum_platform26supports_task_distributionEv">cudaq::quantum_platform::supports_task_distribution (C++ function)</a>
</li>
Expand Down
Binary file modified pr-1932/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion pr-1932/searchindex.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions pr-1932/sphinx/examples/cpp/algorithms/qaoa_maxcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ int main() {
-M_PI / 8.0, M_PI / 8.0, n_params, std::mt19937::default_seed);

// Call the optimizer
auto [opt_val, opt_params] = cudaq::vqe(
ansatz{}, Hp, optimizer, n_params, [&](std::vector<double> params) {
return std::make_tuple(params, n_qubits, n_layers);
});
auto [opt_val, opt_params] =
cudaq::vqe(ansatz{}, Hp, optimizer, n_params, n_qubits, n_layers);

// Print the optimized value and the parameters
printf("Optimal value = %.16lf\n", opt_val);
Expand Down
8 changes: 2 additions & 6 deletions pr-1932/sphinx/examples/cpp/algorithms/vqe_h2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,14 @@ int main() {

so4_fabric ansatz;

auto argMapper = [&](std::vector<double> x) {
return std::make_tuple(x, n_qubits, n_layers);
};

// Run VQE.
cudaq::optimizers::lbfgs optimizer;
optimizer.initial_parameters = init_params;
optimizer.max_eval = 20;
optimizer.max_line_search_trials = 10;
cudaq::gradients::central_difference gradient(ansatz, argMapper);
cudaq::gradients::central_difference gradient;
auto [opt_val, opt_params] =
cudaq::vqe(ansatz, gradient, H, optimizer, n_params, argMapper);
cudaq::vqe(ansatz, gradient, H, optimizer, n_params, n_qubits, n_layers);

printf("Optimal value = %.16lf\n", opt_val);
}
Loading

0 comments on commit 1f103ff

Please sign in to comment.