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


@wrap_testbook("discrete_time_quantum_walk", timeout_seconds=2000)
def test_notebook(tb: TestbookNotebookClient) -> None:
# test quantum programs
validate_quantum_program_size(
tb.ref_pydantic("qprog_1d"),
expected_width=14,
expected_depth=500,
)

validate_quantum_program_size(
tb.ref_pydantic("qprog_2d"),
expected_width=18,
expected_depth=1200,
)

# test notebook content
pass # Todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"friendly_name": "Discrete time quantum walk",
"description": "Quantum walk on one dimentional lattice",
"problem_domain_tags": [],
"qmod_type": ["algorithms"],
"level": ["advanced", "demos"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
qfunc super_position(C: qnum) {
H(C);
S(C);
}

qfunc initial_state(x: qnum, C: qnum) {
x ^= 32;
super_position(C);
}

qfunc coin_opeator(C: qnum) {
hadamard_transform(C);
}

qfunc shift_right(x: qnum) {
x += 1;
}

qfunc shift_left(x: qnum) {
x += -1;
}

qfunc shift_opeartor(x: qnum, C: qnum) {
control (C == 1) {
shift_right(x);
}
control (C == 0) {
shift_left(x);
}
}

qfunc quantum_walk(x: qnum, C: qnum) {
coin_opeator(C);
shift_opeartor(x, C);
}

qfunc coin_walk(t: int, x: qnum, C: qnum) {
power (t) {
quantum_walk(x, C);
}
}

qfunc main(t: int, output x: qnum) {
C: qnum;
allocate(6, x);
allocate(1, C);
initial_state(x, C);
coin_walk(t, x, C);
drop(C);
}
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": [
"sx",
"u1",
"rz",
"t",
"x",
"r",
"cy",
"cz",
"ry",
"y",
"tdg",
"u",
"z",
"sxdg",
"rx",
"u2",
"cx",
"id",
"p",
"h",
"sdg",
"s"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"machine_precision": 8,
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 1946176496,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"friendly_name": "Discrete time quantum walk",
"description": "Quantum walk on 2 dimentional lattice",
"problem_domain_tags": [],
"qmod_type": ["algorithms"],
"level": ["advanced", "demos"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
qfunc coin_opeator(C: qnum) {
grover_diffuser(lambda(i) {
hadamard_transform(i);
}, C);
}

qfunc shift_plus(pos: qnum) {
pos += 1;
}

qfunc shift_minus(pos: qnum) {
pos += -1;
}

qfunc shift_opeartor(x: qnum, y: qnum, C: qnum) {
control (C == 0) {
shift_plus(x);
}
control (C == 1) {
shift_minus(x);
}
control (C == 2) {
shift_plus(y);
}
control (C == 3) {
shift_minus(y);
}
}

qfunc quantum_walk(x: qnum, y: qnum, C: qnum) {
coin_opeator(C);
shift_opeartor(x, y, C);
}

qfunc coin_walk(t: int, x: qnum, y: qnum, C: qnum) {
power (t) {
quantum_walk(x, y, C);
}
}

qfunc main(t: int, output x: qnum, output y: qnum) {
C: qnum;
allocate(5, x);
allocate(5, y);
x ^= 16;
y ^= 16;
prepare_amplitudes([0.5, 0.5, (-0.5), (-0.5)], 0.0, C);
coin_walk(t, x, y, C);
drop(C);
}
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": [
"sx",
"u1",
"rz",
"t",
"x",
"r",
"cy",
"cz",
"ry",
"y",
"tdg",
"u",
"z",
"sxdg",
"rx",
"u2",
"cx",
"id",
"p",
"h",
"sdg",
"s"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"machine_precision": 8,
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 3252689715,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
}
}
Loading
Loading