Skip to content

Commit 90490fc

Browse files
committed
deploy: 9cf2eee
1 parent e9ce7f6 commit 90490fc

57 files changed

Lines changed: 8 additions & 9107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

genindex.html

Lines changed: 0 additions & 315 deletions
Large diffs are not rendered by default.

objects.inv

-574 Bytes
Binary file not shown.

py-modindex.html

Lines changed: 0 additions & 568 deletions
This file was deleted.

qxmt.ansatze.base.html

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -517,121 +517,6 @@ <h1>qxmt.ansatze.base module</h1>
517517

518518
<section id="qxmt-ansatze-base-module">
519519
<h1>qxmt.ansatze.base module<a class="headerlink" href="#qxmt-ansatze-base-module" title="Link to this heading">#</a></h1>
520-
<dl class="py class">
521-
<dt class="sig sig-object py">
522-
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">qxmt.ansatze.base.</span></span><span class="sig-name descname"><span class="pre">BaseAnsatz</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">device</span></span></em><span class="sig-paren">)</span></dt>
523-
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">ABC</span></code></p>
524-
<p>Base class for quantum circuit ansatzes.</p>
525-
<p>This abstract base class defines the interface for quantum circuit ansatzes.
526-
It provides common functionality for circuit visualization and execution.</p>
527-
<dl class="field-list simple">
528-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
529-
<dd class="field-odd"><p><strong>device</strong> (<em>BaseDevice</em>) – Quantum device to use for the ansatz.</p>
530-
</dd>
531-
</dl>
532-
<div class="admonition note">
533-
<p class="admonition-title">Note</p>
534-
<p>Subclasses must implement the circuit method to define the quantum circuit.</p>
535-
</div>
536-
<dl class="py method">
537-
<dt class="sig sig-object py">
538-
<em class="property"><span class="k"><span class="pre">abstractmethod</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">circuit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span></dt>
539-
<dd><p>Define the quantum circuit for the ansatz.</p>
540-
<p>This method must be implemented by subclasses to define the quantum circuit
541-
structure and operations.</p>
542-
<dl class="field-list simple">
543-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
544-
<dd class="field-odd"><ul class="simple">
545-
<li><p><strong>*args</strong> – Variable length argument list.</p></li>
546-
<li><p><strong>**kwargs</strong> – Arbitrary keyword arguments.</p></li>
547-
</ul>
548-
</dd>
549-
<dt class="field-even">Return type<span class="colon">:</span></dt>
550-
<dd class="field-even"><p>None</p>
551-
</dd>
552-
</dl>
553-
<div class="admonition note">
554-
<p class="admonition-title">Note</p>
555-
<p>The implementation should define the quantum circuit using the device’s
556-
operations.</p>
557-
</div>
558-
</dd></dl>
559-
560-
<dl class="py method">
561-
<dt class="sig sig-object py">
562-
<span class="sig-name descname"><span class="pre">draw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format='default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logger=&lt;Logger</span> <span class="pre">qxmt.ansatze.base</span> <span class="pre">(INFO)&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">**kwargs</span></span></em><span class="sig-paren">)</span></dt>
563-
<dd><p>Draw the quantum circuit using the platform’s draw function.</p>
564-
<p>This method visualizes the quantum circuit in either text or graphical format.</p>
565-
<dl class="field-list simple">
566-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
567-
<dd class="field-odd"><ul class="simple">
568-
<li><p><strong>params</strong> (<em>ndarray</em>) – Parameters for the circuit.</p></li>
569-
<li><p><strong>format</strong> (<em>str</em>) – Format of the drawing. Choose between “default” (text) or “mpl” (matplotlib).
570-
Defaults to “default”.</p></li>
571-
<li><p><strong>logger</strong> (<em>Logger</em>) – Logger object for output. Defaults to module-level logger.</p></li>
572-
<li><p><strong>**kwargs</strong> (<em>Any</em>) – Additional arguments for the drawing function.</p></li>
573-
</ul>
574-
</dd>
575-
<dt class="field-even">Raises<span class="colon">:</span></dt>
576-
<dd class="field-even"><ul class="simple">
577-
<li><p><strong>NotImplementedError</strong> – If the platform is not supported.</p></li>
578-
<li><p><strong>ValueError</strong> – If the format is invalid.</p></li>
579-
</ul>
580-
</dd>
581-
<dt class="field-odd">Return type<span class="colon">:</span></dt>
582-
<dd class="field-odd"><p>None</p>
583-
</dd>
584-
</dl>
585-
<div class="admonition note">
586-
<p class="admonition-title">Note</p>
587-
<p>For matplotlib format, the figure will be displayed using plt.show().</p>
588-
</div>
589-
</dd></dl>
590-
591-
</dd></dl>
592-
593-
<dl class="py class">
594-
<dt class="sig sig-object py">
595-
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">qxmt.ansatze.base.</span></span><span class="sig-name descname"><span class="pre">BaseVQEAnsatz</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">device</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hamiltonian</span></span></em><span class="sig-paren">)</span></dt>
596-
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">BaseAnsatz</span></code></p>
597-
<p>Base class for Variational Quantum Eigensolver (VQE) ansatzes.</p>
598-
<p>This abstract base class extends BaseAnsatz to provide functionality specific
599-
to VQE calculations, including Hamiltonian validation and expectation value
600-
measurement.</p>
601-
<dl class="field-list simple">
602-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
603-
<dd class="field-odd"><ul class="simple">
604-
<li><p><strong>device</strong> (<em>BaseDevice</em>) – Quantum device to use for the ansatz.</p></li>
605-
<li><p><strong>hamiltonian</strong> (<em>BaseHamiltonian</em>) – Hamiltonian to use for the VQE calculation.</p></li>
606-
</ul>
607-
</dd>
608-
</dl>
609-
<div class="admonition note">
610-
<p class="admonition-title">Note</p>
611-
<p>Subclasses must implement the circuit method to define the variational circuit.</p>
612-
</div>
613-
<dl class="py method">
614-
<dt class="sig sig-object py">
615-
<em class="property"><span class="k"><span class="pre">abstractmethod</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">circuit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em><span class="sig-paren">)</span></dt>
616-
<dd><p>Define the variational circuit for the VQE ansatz.</p>
617-
<p>This method must be implemented by subclasses to define the variational circuit.</p>
618-
<dl class="field-list simple">
619-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
620-
<dd class="field-odd"><p><strong>params</strong> (<em>ndarray</em>) – Parameters for the variational circuit.</p>
621-
</dd>
622-
<dt class="field-even">Return type<span class="colon">:</span></dt>
623-
<dd class="field-even"><p>None</p>
624-
</dd>
625-
</dl>
626-
<div class="admonition note">
627-
<p class="admonition-title">Note</p>
628-
<p>The implementation should define a parameterized quantum circuit that
629-
can be optimized to find the ground state of the Hamiltonian.</p>
630-
</div>
631-
</dd></dl>
632-
633-
</dd></dl>
634-
635520
</section>
636521

637522

qxmt.ansatze.builder.html

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -517,31 +517,6 @@ <h1>qxmt.ansatze.builder module</h1>
517517

518518
<section id="qxmt-ansatze-builder-module">
519519
<h1>qxmt.ansatze.builder module<a class="headerlink" href="#qxmt-ansatze-builder-module" title="Link to this heading">#</a></h1>
520-
<dl class="py class">
521-
<dt class="sig sig-object py">
522-
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">qxmt.ansatze.builder.</span></span><span class="sig-name descname"><span class="pre">AnsatzBuilder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">config</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hamiltonian</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
523-
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
524-
<dl class="field-list simple">
525-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
526-
<dd class="field-odd"><ul class="simple">
527-
<li><p><strong>config</strong> (<em>AnsatzConfig</em>)</p></li>
528-
<li><p><strong>device</strong> (<em>BaseDevice</em>)</p></li>
529-
<li><p><strong>hamiltonian</strong> (<em>BaseHamiltonian</em><em> | </em><em>None</em>)</p></li>
530-
</ul>
531-
</dd>
532-
</dl>
533-
<dl class="py method">
534-
<dt class="sig sig-object py">
535-
<span class="sig-name descname"><span class="pre">build</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
536-
<dd><dl class="field-list simple">
537-
<dt class="field-odd">Return type<span class="colon">:</span></dt>
538-
<dd class="field-odd"><p><em>BaseAnsatz</em></p>
539-
</dd>
540-
</dl>
541-
</dd></dl>
542-
543-
</dd></dl>
544-
545520
</section>
546521

547522

qxmt.ansatze.pennylane.all_singles_doubles.html

Lines changed: 0 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -517,192 +517,6 @@ <h1>qxmt.ansatze.pennylane.all_singles_doubles module</h1>
517517

518518
<section id="qxmt-ansatze-pennylane-all-singles-doubles-module">
519519
<h1>qxmt.ansatze.pennylane.all_singles_doubles module<a class="headerlink" href="#qxmt-ansatze-pennylane-all-singles-doubles-module" title="Link to this heading">#</a></h1>
520-
<dl class="py class">
521-
<dt class="sig sig-object py">
522-
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">qxmt.ansatze.pennylane.all_singles_doubles.</span></span><span class="sig-name descname"><span class="pre">AllSinglesDoublesAnsatz</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">device</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hamiltonian</span></span></em><span class="sig-paren">)</span></dt>
523-
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">BaseVQEAnsatz</span></code></p>
524-
<p>All Singles and Doubles (AllSinglesDoubles) ansatz for quantum chemistry.</p>
525-
<p>The AllSinglesDoubles ansatz is a fundamental variational quantum circuit for quantum chemistry
526-
calculations that systematically includes all possible single and double excitations from the
527-
Hartree-Fock reference state. This ansatz is particularly effective for strongly correlated
528-
molecular systems where both single and double excitations contribute significantly to the
529-
ground state wavefunction.</p>
530-
<p>The ansatz constructs a quantum state by applying parameterized excitation operators:</p>
531-
<p>|ψ⟩ = exp(∑ᵢ θᵢ Tᵢ) |HF⟩</p>
532-
<p>where Tᵢ represents single and double excitation operators, θᵢ are variational parameters,
533-
and |HF⟩ is the Hartree-Fock reference state.</p>
534-
<p>Key features:
535-
- Includes all chemically relevant single and double excitations
536-
- Maintains particle number conservation and proper spin symmetry
537-
- Provides systematic improvement over simpler ansätze like hardware-efficient circuits
538-
- Well-suited for molecules with moderate correlation effects
539-
- Computationally efficient compared to higher-order excitations</p>
540-
<p>The number of parameters scales polynomially with system size, making it tractable for
541-
near-term quantum devices while providing sufficient flexibility for accurate ground
542-
state preparation in many molecular systems.</p>
543-
<dl class="field-list simple">
544-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
545-
<dd class="field-odd"><ul class="simple">
546-
<li><p><strong>device</strong> (<em>BaseDevice</em>) – Quantum device for executing the variational circuit.</p></li>
547-
<li><p><strong>hamiltonian</strong> (<em>MolecularHamiltonian</em>) – Molecular Hamiltonian defining the quantum chemistry
548-
problem, including information about electrons, orbitals, and molecular geometry.</p></li>
549-
</ul>
550-
</dd>
551-
</dl>
552-
<dl class="py attribute">
553-
<dt class="sig sig-object py">
554-
<span class="sig-name descname"><span class="pre">hamiltonian</span></span></dt>
555-
<dd><p>Molecular Hamiltonian for the ansatz.</p>
556-
<dl class="field-list simple">
557-
<dt class="field-odd">Type<span class="colon">:</span></dt>
558-
<dd class="field-odd"><p>MolecularHamiltonian</p>
559-
</dd>
560-
</dl>
561-
</dd></dl>
562-
563-
<dl class="py attribute">
564-
<dt class="sig sig-object py">
565-
<span class="sig-name descname"><span class="pre">wires</span></span></dt>
566-
<dd><p>Qubit indices used in the quantum circuit.</p>
567-
<dl class="field-list simple">
568-
<dt class="field-odd">Type<span class="colon">:</span></dt>
569-
<dd class="field-odd"><p>range</p>
570-
</dd>
571-
</dl>
572-
</dd></dl>
573-
574-
<dl class="py attribute">
575-
<dt class="sig sig-object py">
576-
<span class="sig-name descname"><span class="pre">hf_state</span></span></dt>
577-
<dd><p>Hartree-Fock reference state as the initial quantum state.</p>
578-
<dl class="field-list simple">
579-
<dt class="field-odd">Type<span class="colon">:</span></dt>
580-
<dd class="field-odd"><p>np.ndarray</p>
581-
</dd>
582-
</dl>
583-
</dd></dl>
584-
585-
<dl class="py attribute">
586-
<dt class="sig sig-object py">
587-
<span class="sig-name descname"><span class="pre">singles</span></span></dt>
588-
<dd><p>Indices of all possible single excitations from occupied to virtual orbitals.</p>
589-
<dl class="field-list simple">
590-
<dt class="field-odd">Type<span class="colon">:</span></dt>
591-
<dd class="field-odd"><p>list</p>
592-
</dd>
593-
</dl>
594-
</dd></dl>
595-
596-
<dl class="py attribute">
597-
<dt class="sig sig-object py">
598-
<span class="sig-name descname"><span class="pre">doubles</span></span></dt>
599-
<dd><p>Indices of all possible double excitations from occupied to virtual orbitals.</p>
600-
<dl class="field-list simple">
601-
<dt class="field-odd">Type<span class="colon">:</span></dt>
602-
<dd class="field-odd"><p>list</p>
603-
</dd>
604-
</dl>
605-
</dd></dl>
606-
607-
<dl class="py attribute">
608-
<dt class="sig sig-object py">
609-
<span class="sig-name descname"><span class="pre">n_params</span></span></dt>
610-
<dd><p>Total number of variational parameters (sum of singles and doubles).</p>
611-
<dl class="field-list simple">
612-
<dt class="field-odd">Type<span class="colon">:</span></dt>
613-
<dd class="field-odd"><p>int</p>
614-
</dd>
615-
</dl>
616-
</dd></dl>
617-
618-
<p class="rubric">Example</p>
619-
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span><span class="w"> </span><span class="nn">qxmt.hamiltonians.pennylane.molecular</span><span class="w"> </span><span class="kn">import</span> <span class="n">MolecularHamiltonian</span>
620-
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span><span class="w"> </span><span class="nn">qxmt.devices</span><span class="w"> </span><span class="kn">import</span> <span class="n">BaseDevice</span>
621-
<span class="gp">&gt;&gt;&gt;</span>
622-
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Create Hamiltonian and device for H2 molecule</span>
623-
<span class="gp">&gt;&gt;&gt; </span><span class="n">hamiltonian</span> <span class="o">=</span> <span class="n">MolecularHamiltonian</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
624-
<span class="gp">&gt;&gt;&gt; </span><span class="n">device</span> <span class="o">=</span> <span class="n">BaseDevice</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
625-
<span class="gp">&gt;&gt;&gt;</span>
626-
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Initialize AllSinglesDoubles ansatz</span>
627-
<span class="gp">&gt;&gt;&gt; </span><span class="n">ansatz</span> <span class="o">=</span> <span class="n">AllSinglesDoublesAnsatz</span><span class="p">(</span><span class="n">device</span><span class="p">,</span> <span class="n">hamiltonian</span><span class="p">)</span>
628-
<span class="gp">&gt;&gt;&gt;</span>
629-
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Initialize parameters (typically small random values)</span>
630-
<span class="gp">&gt;&gt;&gt; </span><span class="n">params</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">,</span> <span class="n">ansatz</span><span class="o">.</span><span class="n">n_params</span><span class="p">)</span>
631-
<span class="gp">&gt;&gt;&gt;</span>
632-
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Build and execute quantum circuit</span>
633-
<span class="gp">&gt;&gt;&gt; </span><span class="n">ansatz</span><span class="o">.</span><span class="n">circuit</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
634-
</pre></div>
635-
</div>
636-
<p class="rubric">References</p>
637-
<ul class="simple">
638-
<li><p>PennyLane documentation: <a class="reference external" href="https://docs.pennylane.ai/en/stable/code/api/pennylane.AllSinglesDoubles.html">https://docs.pennylane.ai/en/stable/code/api/pennylane.AllSinglesDoubles.html</a></p></li>
639-
</ul>
640-
<div class="admonition note">
641-
<p class="admonition-title">Note</p>
642-
<p>This ansatz is ideal for molecules where single and double excitations dominate the
643-
correlation energy. For systems requiring higher-order excitations, consider more
644-
sophisticated ansätze like kUpCCGSD or adaptive approaches.</p>
645-
</div>
646-
<dl class="py method">
647-
<dt class="sig sig-object py">
648-
<span class="sig-name descname"><span class="pre">circuit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em><span class="sig-paren">)</span></dt>
649-
<dd><p>Construct the AllSinglesDoubles quantum circuit.</p>
650-
<dl class="field-list simple">
651-
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
652-
<dd class="field-odd"><p><strong>params</strong> (<em>np.ndarray</em>) – Parameters for the AllSinglesDoubles circuit. The length of this array
653-
should match the number of single and double excitations.</p>
654-
</dd>
655-
<dt class="field-even">Return type<span class="colon">:</span></dt>
656-
<dd class="field-even"><p>None</p>
657-
</dd>
658-
</dl>
659-
<div class="admonition note">
660-
<p class="admonition-title">Note</p>
661-
<p>The AllSinglesDoubles operation includes all possible single and double excitations from the
662-
Hartree-Fock reference state.</p>
663-
</div>
664-
</dd></dl>
665-
666-
<dl class="py method">
667-
<dt class="sig sig-object py">
668-
<span class="sig-name descname"><span class="pre">prepare_excitation</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
669-
<dd><p>Prepare the single and double excitations.</p>
670-
<p>This method generates all possible single and double excitations from the Hartree-Fock state.</p>
671-
<p>The results are stored in the following attributes:
672-
- self.singles: List of single excitation indices
673-
- self.doubles: List of double excitation indices</p>
674-
<div class="admonition note">
675-
<p class="admonition-title">Note</p>
676-
<p>The number of excitations depends on the number of electrons and orbitals in the system.</p>
677-
</div>
678-
<dl class="field-list simple">
679-
<dt class="field-odd">Return type<span class="colon">:</span></dt>
680-
<dd class="field-odd"><p>None</p>
681-
</dd>
682-
</dl>
683-
</dd></dl>
684-
685-
<dl class="py method">
686-
<dt class="sig sig-object py">
687-
<span class="sig-name descname"><span class="pre">prepare_hf_state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
688-
<dd><p>Prepare the Hartree-Fock reference state.</p>
689-
<p>This method creates the Hartree-Fock reference state using PennyLane’s qchem module.
690-
The Hartree-Fock state is a product state where the first n electrons occupy the lowest
691-
energy orbitals.</p>
692-
<p>The state is stored in self.hf_state as a numpy array.</p>
693-
<div class="admonition note">
694-
<p class="admonition-title">Note</p>
695-
<p>The number of electrons and orbitals are obtained from the Hamiltonian.</p>
696-
</div>
697-
<dl class="field-list simple">
698-
<dt class="field-odd">Return type<span class="colon">:</span></dt>
699-
<dd class="field-odd"><p>None</p>
700-
</dd>
701-
</dl>
702-
</dd></dl>
703-
704-
</dd></dl>
705-
706520
</section>
707521

708522

0 commit comments

Comments
 (0)