Skip to content
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
34 changes: 34 additions & 0 deletions tests/notebooks/test_discrete_quantum_walk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("discrete_quantum_walk", timeout_seconds=90)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_1"))
validate_quantum_model(tb.ref("qmod_2"))
validate_quantum_model(tb.ref("qmod_3"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_1"),
expected_width=10, # actual width: 8
expected_depth=200, # actual depth: 177
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=10, # actual width: 8
expected_depth=200, # actual depth: 177
)
validate_quantum_program_size(
tb.ref("qprog_3"),
expected_width=8, # actual width: 6
expected_depth=60, # actual depth: 46
)

# test notebook content
pass # Todo
24 changes: 24 additions & 0 deletions tests/notebooks/test_high_level_modeling_flexible_qpe.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("high_level_modeling_flexible_qpe", timeout_seconds=100)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_1"),
expected_width=10, # actual width: 7
expected_depth=2300, # actual depth: 2053
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=15, # actual width: 13
expected_depth=2700, # actual depth: 2339
)

# test notebook content
pass # Todo
28 changes: 28 additions & 0 deletions tests/notebooks/test_linear_combination_of_unitaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("linear_combination_of_unitaries", timeout_seconds=20)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_1"))
validate_quantum_model(tb.ref("qmod_2"))

# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_1"),
expected_width=5, # actual width: 4
expected_depth=500, # actual depth: 372
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=5, # actual width: 4
expected_depth=500, # actual depth: 372
)

# test notebook content
pass # Todo

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"id": "58e277dd",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"id": "1fe3de0d-c13c-42cc-babd-77c577372874",
"metadata": {},
"outputs": [],
Expand All @@ -195,7 +195,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 3,
"id": "82854a21",
"metadata": {},
"outputs": [],
Expand All @@ -211,8 +211,9 @@
" apply=lambda: select(controller, psi),\n",
" )\n",
"\n",
"quantum_model = create_model(main)\n",
"quantum_program = synthesize(quantum_model)"
"\n",
"qmod_1 = create_model(main)\n",
"qprog_1 = synthesize(qmod_1)"
]
},
{
Expand All @@ -225,20 +226,20 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"id": "262dd6f5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2sDTrI2KmNNYeCfOTeSOrt4W0sC?version=0.66.0\n"
"Opening: https://platform.classiq.io/circuit/2twhaKXfhxHpjDTuYqwIlUebB8c?version=0.70.0\n"
]
}
],
"source": [
"show(quantum_program)"
"show(qprog_1)"
]
},
{
Expand Down Expand Up @@ -290,15 +291,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 5,
"id": "03804a1a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2sqWYKfPmYSb9oL9myDA0jJsCye?version=0.66.1\n"
"Opening: https://platform.classiq.io/circuit/2twhb9xii5m4B8N1K4wz3d8EkTk?version=0.70.0\n"
]
}
],
Expand All @@ -321,7 +322,8 @@
" error_bound = 0.01\n",
" controller_probabilities = [0.5, 0.25, 0.25, 0]\n",
" inplace_prepare_state(controller_probabilities, error_bound, controller)\n",
" \n",
"\n",
"\n",
"@qfunc\n",
"def main(controller: Output[QNum], psi: Output[QNum]):\n",
" # Allocating the target and control qubits, respectively\n",
Expand All @@ -333,10 +335,11 @@
" apply=lambda: select(controller, psi),\n",
" )\n",
"\n",
"quantum_model = create_model(main)\n",
"quantum_program = synthesize(quantum_model)\n",
"\n",
"show(quantum_program)"
"qmod_2 = create_model(main, out_file=\"linear_combination_of_unitaries\")\n",
"qprog_2 = synthesize(qmod_2)\n",
"\n",
"show(qprog_2)"
]
},
{
Expand All @@ -351,16 +354,6 @@
"<a id='childs_notes'>[2]</a>: [Lecture Notes on\n",
"Quantum Algorithms (Andrew M. Childs)](https://www.cs.umd.edu/~amchilds/qa/qa.pdf)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5937706e",
"metadata": {},
"outputs": [],
"source": [
"write_qmod(quantum_model, \"linear_combination_of_unitaries\")"
]
}
],
"metadata": {
Expand Down