Skip to content
Merged

Qaoa #1345

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
462 changes: 0 additions & 462 deletions algorithms/qaoa/knapsack/qaoa_knapsack.ipynb

This file was deleted.

7 changes: 0 additions & 7 deletions algorithms/qaoa/knapsack/qaoa_knapsack.metadata.json

This file was deleted.

792 changes: 0 additions & 792 deletions algorithms/qaoa/maxcut/qaoa_max_cut.ipynb

This file was deleted.

1,155 changes: 1,155 additions & 0 deletions algorithms/qaoa/qaoa.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"custom_hardware_settings": {
"basis_gates": [
"h",
"y",
"u1",
"id",
"cz",
"sdg",
"sxdg",
"cx",
"u2",
"sx",
"p",
"rx",
"tdg",
"x",
"y",
"r",
"rz",
"id",
"t",
"s",
"z",
"h",
"ry",
"u",
"r",
"s",
"cy",
"cz",
"sdg",
"x",
"tdg",
"ry"
"rx",
"p",
"sx",
"u1",
"cx",
"u2",
"cy"
],
"is_symmetric_connectivity": true
},
Expand All @@ -35,7 +36,7 @@
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 3552888076,
"random_seed": 3469803058,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"custom_hardware_settings": {
"basis_gates": [
"tdg",
"u",
"h",
"sx",
"cz",
"x",
"id",
"r",
"cz",
"sdg",
"u2",
"p",
"z",
"sxdg",
"tdg",
"x",
"y",
"r",
"rz",
"t",
"sxdg",
"u1",
"cy",
"s",
"z",
"h",
"ry",
"u",
"rx",
"rz",
"p",
"sx",
"u1",
"cx",
"ry",
"s"
"u2",
"cy"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"machine_precision": 8,
"optimization_level": 3,
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 2629849665,
"random_seed": 3901172516,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
Expand Down
19 changes: 12 additions & 7 deletions tests/notebooks/test_qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

@wrap_testbook("qaoa", timeout_seconds=450)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
# test quantum programs
validate_quantum_program_size(
tb.ref_pydantic("qprog"),
expected_width=9, # actual width: 7
expected_depth=1250, # actual depth: 1072
tb.ref_pydantic("qprog_maxcut"),
expected_width=5,
expected_depth=80,
)
validate_quantum_program_size(
tb.ref_pydantic("qprog_knapsack"),
expected_width=18, # actual width: 18
expected_depth=2500, # actual depth: 2323
)

# test notebook content
assert tb.ref("depth_classiq") < tb.ref("depth_qiskit")
assert tb.ref("cx_counts_classiq") < tb.ref("cx_counts_qiskit")
# maxcut_cost = tb.ref("maxcut_cost")
# for i, pc in enumerate(tb.ref_numpy("best_outcomes")):
# cost_value = maxcut_cost(pc.state["v"])
# assert np.isclose(cost_value, -5 / 6)
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from testbook.client import TestbookNotebookClient


@wrap_testbook("qaoa_knapsack", timeout_seconds=300)
@wrap_testbook("qaoa_demonstration", timeout_seconds=450)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref_pydantic("qprog"),
expected_width=18, # actual width: 18
expected_depth=2500, # actual depth: 2323
expected_width=9, # actual width: 7
expected_depth=1250, # actual depth: 1072
)

# test notebook content
pass # TODO
assert tb.ref("depth_classiq") < tb.ref("depth_qiskit")
assert tb.ref("cx_counts_classiq") < tb.ref("cx_counts_qiskit")
23 changes: 0 additions & 23 deletions tests/notebooks/test_qaoa_max_cut.py

This file was deleted.

5 changes: 2 additions & 3 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ prepare_uniform_interval_state.qmod: 10
prepare_uniform_trimmed_state.qmod: 10
protein_folding.ipynb: 240
protein_folding.qmod: 240
qaoa.ipynb: 450
qaoa_in_qaoa.ipynb: 1799
qaoa_in_qaoa.qmod: 1799
qaoa_knapsack.ipynb: 300
qaoa.ipynb: 600
qaoa_demonstration.ipynb: 450
qaoa_knapsack.qmod: 300
qaoa_max_cut.ipynb: 300
qaoa_max_cut.qmod: 300
qct_qst.ipynb: 30
qct_qst_type1.qmod: 20
Expand Down
Loading