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


@wrap_testbook("quantumwalk_complex_network", timeout_seconds=2001)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref_pydantic("qprog"),
expected_width=6,
expected_depth=700,
)

# test notebook content
pass # Todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"friendly_name": "Quantum walk on complex network",
"description": "Quantum walk on complex network graphs using discrete-time quantum walk model.",
"problem_domain_tags": [],
"qmod_type": ["algorithms"],
"level": ["advanced", "demos"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
qfunc prepare_initial_state(x: qnum<2>, y: qnum<2>) {
hadamard_transform(x);
control (x == 0) {
inplace_prepare_state([
0.0,
0.333333333333333,
0.333333333333333,
0.333333333333333
], 0.0, y);
}
control (x == 1) {
inplace_prepare_state([0.5, 0.0, 0.5, 0.0], 0.0, y);
}
control (x == 2) {
inplace_prepare_state([0.5, 0.5, 0.0, 0.0], 0.0, y);
}
control (x == 3) {
inplace_prepare_state([1.0, 0.0, 0.0, 0.0], 0.0, y);
}
}

qfunc discrete_quantum_walk(time: int, coin_qfuncs: qfunc (qnum, qnum), shift_qfuncs: qfunc (qnum, qnum), x: qnum, y: qnum) {
power (time) {
coin_qfuncs(x, y);
shift_qfuncs(x, y);
}
}

qfunc my_coin(x: qnum<2>, y: qnum<2>) {
control (x == 0) {
grover_diffuser(lambda(y) {
inplace_prepare_state([
0.0,
0.333333333333333,
0.333333333333333,
0.333333333333333
], 0.0, y);
}, y);
}
control (x == 1) {
grover_diffuser(lambda(y) {
inplace_prepare_state([0.5, 0.0, 0.5, 0.0], 0.0, y);
}, y);
}
control (x == 2) {
grover_diffuser(lambda(y) {
inplace_prepare_state([0.5, 0.5, 0.0, 0.0], 0.0, y);
}, y);
}
control (x == 3) {
grover_diffuser(lambda(y) {
inplace_prepare_state([1.0, 0.0, 0.0, 0.0], 0.0, y);
}, y);
}
}

qfunc my_shift(x: qnum<2>, y: qnum<2>) {
multiswap(x, y);
}

qfunc main(output x: qnum<2>) {
y: qnum<2>;
allocate(2, x);
allocate(2, y);
prepare_initial_state(x, y);
discrete_quantum_walk(3, my_coin, my_shift, x, y);
drop(y);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"custom_hardware_settings": {
"basis_gates": [
"p",
"sdg",
"h",
"rx",
"id",
"s",
"sx",
"z",
"sxdg",
"t",
"x",
"r",
"ry",
"u",
"u1",
"y",
"cy",
"cx",
"tdg",
"cz",
"rz",
"u2"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"machine_precision": 8,
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 3632070240,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
}
}
Loading
Loading