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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("classiq_discrete_quantum_walk", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=20, # actual width: 9
expected_depth=500, # actual depth: 243
)

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


@wrap_testbook("classiq_qsvt", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=30, # actual width: 18
expected_depth=1400, # actual depth: 701
)

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


@wrap_testbook("pennylane_cat_qsvt_example", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("pennylane_catalyst_discrete_quantum_walk", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
12 changes: 12 additions & 0 deletions tests/notebooks/classiq_paper/test_qiskit_discrete_quantum_walk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("qiskit_discrete_quantum_walk", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
12 changes: 12 additions & 0 deletions tests/notebooks/classiq_paper/test_qiskit_qsvt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("qiskit_qsvt", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
12 changes: 12 additions & 0 deletions tests/notebooks/classiq_paper/test_tket_discrete_quantum_walk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("tket_discrete_quantum_walk", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
12 changes: 12 additions & 0 deletions tests/notebooks/classiq_paper/test_tket_qsvt_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("tket_qsvt_example", timeout_seconds=300)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the notebook is empty, there's nothing to test
pass # TODO
5 changes: 1 addition & 4 deletions tests/notebooks/test_3_sat_grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from testbook.client import TestbookNotebookClient


@wrap_testbook(
"3_sat_grover",
timeout_seconds=36,
)
@wrap_testbook("3_sat_grover", timeout_seconds=36)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
Expand Down
16 changes: 16 additions & 0 deletions tests/notebooks/test_3sat_oracles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook("3sat_oracles", timeout_seconds=1800)
def test_notebook(tb: TestbookNotebookClient) -> None:
# the `qmod` and `qprog` are defined in a function
# need to rewrite the notebook in order to test it

# test notebook content
pass # Todo
# need to compare classiq times to qiskit times at some num_qubits value
38 changes: 38 additions & 0 deletions tests/notebooks/test_approximated_state_preparation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient


@wrap_testbook(
"approximated_state_preparation", timeout_seconds=3600
) # took 1860 seconds on my computer
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
for qmod in tb.ref("qmods"):
validate_quantum_model(qmod)

# test quantum programs
# classiq depths: [9874, 8721, 8259, 7908, 7677, 7447, 6986, 6755, 6525, 6295]
# cx-counts depths: [6548, 5748, 5428, 5196, 5036, 4876, 4556, 4396, 4236, 4076]
qprogs = tb.ref("qprogs")
depths = tb.ref("depths")
validate_quantum_program_size(
qprogs[0],
expected_width=tb.ref("NUM_QUBITS"),
expected_depth=10500, # actual depth: 9874
)
for i in range(1, len(qprogs)):
validate_quantum_program_size(
qprogs[i],
expected_width=tb.ref("NUM_QUBITS"),
expected_depth=depths[i - 1]
- 1, # the depth has to improve from the previous runs
)

# test notebook content
cx_counts = tb.ref("cx_counts")
for i in range(1, len(cx_counts)):
assert cx_counts[i] < cx_counts[i - 1]
28 changes: 28 additions & 0 deletions tests/notebooks/test_arithmetic_expressions.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("arithmetic_expressions", timeout_seconds=40)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
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=tb.ref("NUM_QUBITS_1"),
expected_depth=380, # actual depth: 321
)
validate_quantum_program_size(
tb.ref("qprog_2"),
expected_width=tb.ref("NUM_QUBITS_2"),
expected_depth=270, # actual depth: 228
)

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


@wrap_testbook("auxiliary_management", timeout_seconds=40)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=10, # actual width: 8
expected_depth=300, # actual depth: 247
)

# test notebook content
pass # TODO
6 changes: 5 additions & 1 deletion tests/notebooks/test_bernstein_vazirani.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
# test quantum programs
validate_quantum_program_size(tb.ref("qprog"), expected_width=6, expected_depth=5)
validate_quantum_program_size(
tb.ref("qprog"),
expected_width=6,
expected_depth=5,
)

# test notebook content
assert int(tb.ref("secret_integer_q")) == tb.ref("SECRET_INT")
50 changes: 50 additions & 0 deletions tests/notebooks/test_discrete_quantum_walk_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from tests.utils_for_testbook import (
validate_quantum_program_size,
validate_quantum_model,
wrap_testbook,
)
from testbook.client import TestbookNotebookClient

import itertools


@wrap_testbook("discrete_quantum_walk_circle", timeout_seconds=800)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
for qmod in itertools.chain(
tb.ref("qmods"),
tb.ref("qmods_width"),
tb.ref("qmods_cx"),
):
validate_quantum_model(qmod)

# test quantum programs
"""
classiq depths: [419, 749, 1195, 1773, 2499, 3389, 4099]
classiq cx_counts: [274, 514, 850, 1298, 1874, 2594, 3194]
classiq widths: [6, 7, 8, 9, 10, 11, 13]
"""
for qprog, num_qubits in zip(
tb.ref("qprogs_width"),
range(tb.ref("NUM_QUBITS_MIN"), tb.ref("NUM_QUBITS_MAX")),
):
validate_quantum_program_size(
qprog,
expected_width=None,
expected_depth=None,
)
"""
classiq depths: [193, 245, 335, 419, 509, 602, 704]
classiq cx_counts: [120, 152, 200, 260, 352, 436, 552]
classiq widths: [8, 9, 11, 12, 14, 15, 17]
"""
for qprog in tb.ref("qprogs_cx"):
validate_quantum_program_size(
qprog,
expected_width=2
* num_qubits, # that's the width that's being set as a constraint in the notebook
expected_depth=None,
)

# test notebook content
pass # Todo
5 changes: 1 addition & 4 deletions tests/notebooks/test_dqi_max_xorsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from testbook.client import TestbookNotebookClient


@wrap_testbook(
"dqi_max_xorsat",
timeout_seconds=200,
)
@wrap_testbook("dqi_max_xorsat", timeout_seconds=200)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_one_hot"))
Expand Down
5 changes: 1 addition & 4 deletions tests/notebooks/test_grover_max_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from testbook.client import TestbookNotebookClient


@wrap_testbook(
"grover_max_cut",
timeout_seconds=220,
)
@wrap_testbook("grover_max_cut", timeout_seconds=220)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
Expand Down
28 changes: 28 additions & 0 deletions tests/notebooks/test_hamiltonian_evolution.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("hamiltonian_evolution", timeout_seconds=1200)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
for qmod in tb.ref("qmods"):
validate_quantum_model(qmod)

# test quantum programs
for qprog in tb.ref("qprogs"):
validate_quantum_program_size(
qprog,
expected_width=None,
expected_depth=None,
)

# test notebook content
for cx_count_classiq, cx_count_qiskit in zip(
tb.ref("classiq_cx_counts"),
tb.ref("qiskit_cx_counts"),
):
assert cx_count_qiskit <= cx_count_qiskit
28 changes: 28 additions & 0 deletions tests/notebooks/test_hardware_aware_mcx.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("hardware_aware_mcx", timeout_seconds=56)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod"))
validate_quantum_model(tb.ref("qmod_linear"))
validate_quantum_model(tb.ref("qmod_all_to_all"))
# test quantum programs
validate_quantum_program_size(
tb.ref("qprog_linear"),
expected_width=20, # actual width: 17
expected_depth=1900, # actual depth: 1677
)
validate_quantum_program_size(
tb.ref("qprog_all_to_all"),
expected_width=20, # actual width: 18
expected_depth=1000, # actual depth: 828
)

# test notebook content
pass # Todo
5 changes: 1 addition & 4 deletions tests/notebooks/test_hhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from testbook.client import TestbookNotebookClient


@wrap_testbook(
"hhl",
timeout_seconds=312,
)
@wrap_testbook("hhl", timeout_seconds=312)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test models
validate_quantum_model(tb.ref("qmod_hhl_exact"))
Expand Down
Loading
Loading