Skip to content

Commit afb58cc

Browse files
Add quantum walk on complex networks
1 parent 13aec12 commit afb58cc

File tree

5 files changed

+404
-0
lines changed

5 files changed

+404
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from tests.utils_for_testbook import (
2+
validate_quantum_program_size,
3+
validate_quantum_model,
4+
wrap_testbook,
5+
)
6+
from testbook.client import TestbookNotebookClient
7+
8+
9+
@wrap_testbook("quantumwalk_complex_network", timeout_seconds=2001)
10+
def test_notebook(tb: TestbookNotebookClient) -> None:
11+
# test quantum programs
12+
validate_quantum_program_size(
13+
tb.ref_pydantic("qprog"),
14+
expected_width=6,
15+
expected_depth=700,
16+
)
17+
18+
# test notebook content
19+
pass # Todo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"friendly_name": "Quantum walk on complex network",
3+
"description": "Quantum walk on complex network graphs using discrete-time quantum walk model.",
4+
"problem_domain_tags": [],
5+
"qmod_type": ["algorithms"],
6+
"level": ["advanced", "demos"]
7+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
qfunc prepare_initial_state(x: qnum<2>, y: qnum<2>) {
2+
hadamard_transform(x);
3+
control (x == 0) {
4+
inplace_prepare_state([
5+
0.0,
6+
0.333333333333333,
7+
0.333333333333333,
8+
0.333333333333333
9+
], 0.0, y);
10+
}
11+
control (x == 1) {
12+
inplace_prepare_state([0.5, 0.0, 0.5, 0.0], 0.0, y);
13+
}
14+
control (x == 2) {
15+
inplace_prepare_state([0.5, 0.5, 0.0, 0.0], 0.0, y);
16+
}
17+
control (x == 3) {
18+
inplace_prepare_state([1.0, 0.0, 0.0, 0.0], 0.0, y);
19+
}
20+
}
21+
22+
qfunc discrete_quantum_walk(time: int, coin_qfuncs: qfunc (qnum, qnum), shift_qfuncs: qfunc (qnum, qnum), x: qnum, y: qnum) {
23+
power (time) {
24+
coin_qfuncs(x, y);
25+
shift_qfuncs(x, y);
26+
}
27+
}
28+
29+
qfunc my_coin(x: qnum<2>, y: qnum<2>) {
30+
control (x == 0) {
31+
grover_diffuser(lambda(y) {
32+
inplace_prepare_state([
33+
0.0,
34+
0.333333333333333,
35+
0.333333333333333,
36+
0.333333333333333
37+
], 0.0, y);
38+
}, y);
39+
}
40+
control (x == 1) {
41+
grover_diffuser(lambda(y) {
42+
inplace_prepare_state([0.5, 0.0, 0.5, 0.0], 0.0, y);
43+
}, y);
44+
}
45+
control (x == 2) {
46+
grover_diffuser(lambda(y) {
47+
inplace_prepare_state([0.5, 0.5, 0.0, 0.0], 0.0, y);
48+
}, y);
49+
}
50+
control (x == 3) {
51+
grover_diffuser(lambda(y) {
52+
inplace_prepare_state([1.0, 0.0, 0.0, 0.0], 0.0, y);
53+
}, y);
54+
}
55+
}
56+
57+
qfunc my_shift(x: qnum<2>, y: qnum<2>) {
58+
multiswap(x, y);
59+
}
60+
61+
qfunc main(output x: qnum<2>) {
62+
y: qnum<2>;
63+
allocate(2, x);
64+
allocate(2, y);
65+
prepare_initial_state(x, y);
66+
discrete_quantum_walk(3, my_coin, my_shift, x, y);
67+
drop(y);
68+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"constraints": {
3+
"max_gate_count": {},
4+
"optimization_parameter": "no_opt"
5+
},
6+
"preferences": {
7+
"custom_hardware_settings": {
8+
"basis_gates": [
9+
"p",
10+
"sdg",
11+
"h",
12+
"rx",
13+
"id",
14+
"s",
15+
"sx",
16+
"z",
17+
"sxdg",
18+
"t",
19+
"x",
20+
"r",
21+
"ry",
22+
"u",
23+
"u1",
24+
"y",
25+
"cy",
26+
"cx",
27+
"tdg",
28+
"cz",
29+
"rz",
30+
"u2"
31+
],
32+
"is_symmetric_connectivity": true
33+
},
34+
"debug_mode": true,
35+
"machine_precision": 8,
36+
"optimization_level": 1,
37+
"output_format": ["qasm"],
38+
"pretty_qasm": true,
39+
"random_seed": 3632070240,
40+
"synthesize_all_separately": false,
41+
"timeout_seconds": 300,
42+
"transpilation_option": "auto optimize"
43+
}
44+
}

0 commit comments

Comments
 (0)