Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor update to docs #126

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ An example of building the UCCD ansatz with a H2 molecule
import numpy as np
from qibo.models import VQE

from qibochem.driver.molecule import Molecule
from qibochem.ansatz.hf_reference import hf_circuit
from qibochem.ansatz.ucc import ucc_circuit
from qibochem.driver import Molecule
from qibochem.ansatz import hf_circuit, ucc_circuit

# Define the H2 molecule and obtain its 1-/2- electron integrals with PySCF
h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.7))])
Expand All @@ -45,6 +44,7 @@ vqe = VQE(circuit, hamiltonian)

initial_parameters = np.random.uniform(0.0, 2*np.pi, 8)
best, params, extra = vqe.minimize(initial_parameters)
print(f"VQE result: {best:.10f}")
```

## Citation policy
Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting-started/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Here is an example of building the UCCD ansatz with the H2 molecule to test your
import numpy as np
from qibo.models import VQE

from qibochem.driver.molecule import Molecule
from qibochem.driver import Molecule
from qibochem.ansatz import hf_circuit, ucc_circuit

# Define the H2 molecule and obtain its 1-/2- electron integrals with PySCF
Expand Down
2 changes: 2 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Contents
Qibocal docs <https://qibo.science/qibocal/stable/>
Qibosoq docs <https://qibo.science/qibosoq/stable/>
Qibochem docs <https://qibo.science/qibochem/stable/>
Qibotn docs <https://qibo.science/qibotn/stable/>
Qibo-cloud-backends docs <https://qibo.science/qibo-cloud-backends/stable/>

Indices and tables
==================
Expand Down
55 changes: 28 additions & 27 deletions doc/source/tutorials/adaptive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ This can be carried out until the difference between each iteration is small (<0


print("\nFinal circuit:")
print(circuit.draw())
circuit.draw()
print("\nCircuit statistics:")
print(circuit.summary())

Expand Down Expand Up @@ -316,32 +316,32 @@ Output:
Energy has converged; exiting while loop

Final circuit:
q0: ─X──────────────────────────────────────────────────────────────────── ...
q1: ─X──────────────────────────────────────────────────────────────────── ...
q2: ─X───o─H─o───RY─o─────RY───X─RY─────o─RY─o─X─H─o─────o─H─o───RY─o───── ...
q3: ─X───|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─|───|─────|───X───RY─|───X─ ...
q4: ─────|──────────|───|────|─|────|───|──────|───|───o─X─────o────|───|─ ...
q5: ─────|──────────|───|────|─|────|───|──────|───|───|───────|────|───|─ ...
q6: ───o─X─────o────|───|────o─o────|───|──────o───X─o─|───────|────|───|─ ...
q7: ───X───H───X────X─H─o───────────o─H─X────────H───X─X───H───X────X─H─o─ ...

q0: ... ────────────────────────────────────────────────────────────────────── ...
q1: ... ────────────────────────────────────────────────────────────────────── ...
q2: ... RY───X─RY─────o─RY─o─X─H─o─────o─H─o───RY─o─────RY───X─RY─────o─RY─o─X ...
q3: ... RY─X─|─RY─X───|─RY─X─|───|─────|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─| ...
q4: ... ───o─o────|───|──────o───X─o───|──────────|───|────|─|────|───|──────| ...
q5: ... ──────────|───|────────────|─o─X─────o────|───|────o─o────|───|──────o ...
q6: ... ──────────|───|────────────|─X───H───X────X─H─o───────────o─H─X─────── ...
q7: ... ──────────o─H─X────────H───X────────────────────────────────────────── ...

q0: ... ─────────o─H─o───RY─o─────RY───X─RY─────o─RY─o─X─H─o───
q1: ... ─────────|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─|───|───
q2: ... ─H─o─────|──────────|───|────|─|────|───|──────|───|───
q3: ... ───|─────|──────────|───|────|─|────|───|──────|───|───
q4: ... ───|───o─X─────o────|───|────o─o────|───|──────o───X─o─
q5: ... ───X─o─X───H───X────X─H─o───────────o─H─X────────H───X─
q6: ... ─H───X─────────────────────────────────────────────────
q7: ... ───────────────────────────────────────────────────────
0: ─X──────────────────────────────────────────────────────────────────── ...
1: ─X──────────────────────────────────────────────────────────────────── ...
2: ─X───o─H─o───RY─o─────RY───X─RY─────o─RY─o─X─H─o─────o─H─o───RY─o───── ...
3: ─X───|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─|───|─────|───X───RY─|───X─ ...
4: ─────|──────────|───|────|─|────|───|──────|───|───o─X─────o────|───|─ ...
5: ─────|──────────|───|────|─|────|───|──────|───|───|───────|────|───|─ ...
6: ───o─X─────o────|───|────o─o────|───|──────o───X─o─|───────|────|───|─ ...
7: ───X───H───X────X─H─o───────────o─H─X────────H───X─X───H───X────X─H─o─ ...

0: ... ────────────────────────────────────────────────────────────────────── ...
1: ... ────────────────────────────────────────────────────────────────────── ...
2: ... RY───X─RY─────o─RY─o─X─H─o─────o─H─o───RY─o─────RY───X─RY─────o─RY─o─X ...
3: ... RY─X─|─RY─X───|─RY─X─|───|─────|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─| ...
4: ... ───o─o────|───|──────o───X─o───|──────────|───|────|─|────|───|──────| ...
5: ... ──────────|───|────────────|─o─X─────o────|───|────o─o────|───|──────o ...
6: ... ──────────|───|────────────|─X───H───X────X─H─o───────────o─H─X─────── ...
7: ... ──────────o─H─X────────H───X────────────────────────────────────────── ...

0: ... ─────────o─H─o───RY─o─────RY───X─RY─────o─RY─o─X─H─o───
1: ... ─────────|───X───RY─|───X─RY─X─|─RY─X───|─RY─X─|───|───
2: ... ─H─o─────|──────────|───|────|─|────|───|──────|───|───
3: ... ───|─────|──────────|───|────|─|────|───|──────|───|───
4: ... ───|───o─X─────o────|───|────o─o────|───|──────o───X─o─
5: ... ───X─o─X───H───X────X─H─o───────────o─H─X────────H───X─
6: ... ─H───X─────────────────────────────────────────────────
7: ... ───────────────────────────────────────────────────────

Circuit statistics:
Circuit depth = 78
Expand All @@ -353,6 +353,7 @@ Output:
h: 24
x: 4


Recall that the full UCCSD circuit for our system had a circuit depth of 1874, with more than 1000 CNOT gates required.
In contrast, the use of a simpler circuit ansatz in conjunction with an adaptive approach allowed us to find a VQE energy that is within chemical accuracy,
while using only 56 CNOT gates and with a final gate depth of only 78.
Expand Down
Loading
Loading