Skip to content

Adapt VQE- Paper Implementation Challenge #899

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dabf589
Adding ideas for Adapt-VQE before new code
Dacastillo Mar 28, 2025
7841b08
Adding best and new version of code
Dacastillo Apr 2, 2025
404ba53
Removing other codes
Dacastillo Apr 2, 2025
3393695
building adapt VQE code
Dacastillo Apr 3, 2025
59f26ad
building adapt VQE code 2
Dacastillo Apr 3, 2025
9b8ab4f
building adapt VQE code 3
Dacastillo Apr 3, 2025
dd5d40d
building adapt VQE code 3
Dacastillo Apr 3, 2025
94a3228
Testing if the code compiles
Dacastillo Apr 5, 2025
66e1e90
Testing if the code compiles 2
Dacastillo Apr 6, 2025
670ece8
Testing if the code compiles 3
Dacastillo Apr 6, 2025
675568c
Testing if the code compiles. Now with tests!
Dacastillo Apr 6, 2025
69d5f98
Testing if the code compiles. Now with tests! 2
Dacastillo Apr 6, 2025
e32b64f
Testing if the code compiles. Now with tests! 3
Dacastillo Apr 6, 2025
2e15362
Testing if the code compiles. Now with tests! 4
Dacastillo Apr 6, 2025
203af33
Testing if the code compiles. Now with tests! 5
Dacastillo Apr 6, 2025
518bdf0
Testing if the code compiles. Now with tests! 6
Dacastillo Apr 6, 2025
46b133b
comment authenticate for testing
Dacastillo Apr 6, 2025
d778fe8
comment authenticate for testing 2
Dacastillo Apr 6, 2025
d16639f
comment authenticate for testing 3
Dacastillo Apr 6, 2025
e815a7d
comment authenticate for testing 4
Dacastillo Apr 6, 2025
618e39c
comment authenticate for testing 4
Dacastillo Apr 6, 2025
8a1156e
revision of notebook
Dacastillo Apr 7, 2025
923e030
revision of notebook 2
Dacastillo Apr 7, 2025
57a2a2d
revision of notebook 3
Dacastillo Apr 7, 2025
fa49d89
revision of notebook 4
Dacastillo Apr 7, 2025
b3335e2
revision of notebook 5
Dacastillo Apr 7, 2025
2182410
revision of notebook 5
Dacastillo Apr 8, 2025
05ff401
reedition for compiling
Dacastillo Apr 8, 2025
b259228
reedition for compiling 2
Dacastillo Apr 8, 2025
e276c85
cleaning and code adding
Dacastillo Apr 14, 2025
681423c
cleaning and code adding 2
Dacastillo Apr 14, 2025
7ef9a3f
cleaning and code adding 3
Dacastillo Apr 14, 2025
c202f9d
cleaning and code adding 4
Dacastillo Apr 14, 2025
798d689
Merge branch 'main' into vqe-testing
Dacastillo Apr 14, 2025
ed468a9
Implementation of qubit-adaptVQE
Dacastillo Apr 26, 2025
9220e8e
Implementation of qubit-adaptVQE
Dacastillo Apr 26, 2025
fe8026c
Implementation of qubit-adaptVQE
Dacastillo Apr 26, 2025
d18ba3a
Implementation of qubit-adaptVQE 2
Dacastillo Apr 27, 2025
85c042e
Implementation of qubit-adaptVQE 3
Dacastillo Apr 27, 2025
0d887ac
Implementation of qubit-adaptVQE 4
Dacastillo Apr 28, 2025
c66f0fb
Implementation of qubit-adaptVQE 5
Dacastillo Apr 28, 2025
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
qfunc main(t: real[30], output qbv: qbit[]) {
allocate(molecule_problem_to_hamiltonian(MoleculeProblem {
mapping=FermionMapping::JORDAN_WIGNER,
z2_symmetries=False,
molecule=Molecule {
atoms=[
ChemistryAtom {
element=Element::H,
position=Position {x=0.0, y=0.0, z=0.0}
},
ChemistryAtom {
element=Element::H,
position=Position {x=0.0, y=0.0, z=3.5}
}
],
spin=1,
charge=0
},
freeze_core=False,
remove_orbitals=[]
})[0].pauli.len, qbv);
molecule_hartree_fock(MoleculeProblem {
mapping=FermionMapping::JORDAN_WIGNER,
z2_symmetries=False,
molecule=Molecule {
atoms=[
ChemistryAtom {
element=Element::H,
position=Position {x=0.0, y=0.0, z=0.0}
},
ChemistryAtom {
element=Element::H,
position=Position {x=0.0, y=0.0, z=3.5}
}
],
spin=1,
charge=0
},
freeze_core=False,
remove_orbitals=[]
}, qbv);
full_hea(4, [1, 1, 1, 1, 1, 1], t, [
[0, 1],
[0, 2],
[0, 3],
[1, 2],
[1, 3],
[2, 3]
], 1, [lambda(angle, q) {
RX(angle, q);
}, lambda(angle, q) {
RX(angle, q);
}, lambda(angle, q) {
RX(angle, q);
}], [lambda(angle, q1, q2) {
CRX(angle, q1, q2);
}, lambda(angle, q1, q2) {
CRX(angle, q1, q2);
}, lambda(angle, q1, q2) {
CRX(angle, q1, q2);
}], qbv);
}

cscope ```
vqe_result = vqe(
hamiltonian=molecule_problem_to_hamiltonian(struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER, z2_symmetries=False, molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H, position=struct_literal(Position, x=0.0, y=0.0, z=0.0)), struct_literal(ChemistryAtom, element=Element.H, position=struct_literal(Position, x=0.0, y=0.0, z=3.5))], spin=1, charge=0), freeze_core=False, remove_orbitals=[])), maximize=False,
initial_point=[],
optimizer=Optimizer.COBYLA,
max_iteration=20,
tolerance=0,
step_size=0,
skip_compute_variance=False,
alpha_cvar=1.0,

)
save({'vqe_result': vqe_result})

molecule_result = molecule_ground_state_solution_post_process(struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER, z2_symmetries=False, molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H, position=struct_literal(Position, x=0.0, y=0.0, z=0.0)), struct_literal(ChemistryAtom, element=Element.H, position=struct_literal(Position, x=0.0, y=0.0, z=3.5))], spin=1, charge=0), freeze_core=False, remove_orbitals=[]),vqe_result)
save({'molecule_result': molecule_result})
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"t",
"x",
"u1",
"cz",
"u2",
"rx",
"id",
"sxdg",
"cy",
"z",
"ry",
"rz",
"tdg",
"u",
"p",
"y",
"sx",
"r",
"cx",
"s",
"sdg",
"h"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 3,
"output_format": [
"qasm"
],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 1066485126
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"u2",
"r",
"cy",
"t",
"sdg",
"x",
"z",
"s",
"h",
"sxdg",
"p",
"u",
"rx",
"rz",
"y",
"cz",
"tdg",
"cx",
"sx",
"u1",
"id",
"ry"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 3,
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 723171489
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.9"
}
},
"nbformat": 4,
Expand Down
24 changes: 24 additions & 0 deletions tests/notebooks/test_adapt_vqe_energy_curve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient

@wrap_testbook("adapt_vqe_energy_curve", timeout_seconds=600)
def test_notebook(tb: TestbookNotebookClient) -> None:
"""
A notebook for a hybrid classical quantum neural network.
The test verifies that the pre-trained model is indeed well trained.
"""
# test models
for qmod in tb.ref("qmods"):
validate_quantum_model(qmod)
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=1, # actual width: 1
expected_depth=10, # actual depth: 4
)
# test notebook content
pass # TODO
5 changes: 5 additions & 0 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
3_sat_grover.qmod: 48
3_sat_grover_large.qmod: 10
3sat_oracles.ipynb: 1800

adapt_vqe_energy_curve.ipynb: 600
adapt_vqe_energy_curve.qmod: 600

CRX.qmod: 10
CX.qmod: 10
HW1_QClass2024.ipynb: 200
Expand All @@ -22,6 +26,7 @@ SWAP.qmod: 10
U.qmod: 10
WS_iQuHack_2025_final.ipynb: 200
X.qmod: 10

add_bell_states.qmod: 10
advection_equation_2nd_place_submission.ipynb: 500
advection_equation_winning_submission.ipynb: 1200
Expand Down
Loading