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
1,066 changes: 1,066 additions & 0 deletions algorithms/differential_equations/time_marching/time_marching.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"friendly_name": "Time Marching Based Quantum Solver",
"description": "Solving time-dependent linear equations using a Time-Marching based strategy and QSVT",
"problem_domain_tags": ["linear equation"],
"qmod_type": ["algorithms"],
"level": ["advanced"]
}
106 changes: 106 additions & 0 deletions algorithms/differential_equations/time_marching/time_marching.qmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
qstruct TimeDependentBE {
index: qnum<2>;
time: qnum<2>;
block: qbit;
}

qstruct MagnusBE {
time_dependent: TimeDependentBE;
qsvt_exp_aux: qbit;
qsvt_exp_lcu: qbit;
}

qstruct LongSliceBE {
magnus: MagnusBE;
qsvt_amplification_aux: qbit;
}

qstruct FullBE {
time_slice: LongSliceBE;
counter: qnum<3.0>;
}

qfunc magnus_projector(qbe: MagnusBE, is_in_block: qbit) {
is_in_block ^= ((qbe.time_dependent.block == 0) and (qbe.time_dependent.time == 0)) and ((qbe.qsvt_exp_aux == 0) and (qbe.qsvt_exp_lcu == 0));
}

qfunc time_dependent_projector(qbe: TimeDependentBE, is_in_block: qbit) {
is_in_block ^= (qbe.block == 0) and (qbe.time == 0);
}

qfunc block_encode_time_dependent_A(a: real, b: real, qbe: TimeDependentBE) {
linear_pauli_rotations([Pauli::Y], [
(((b - a) * 2) / (2 ** qbe.time.size))
], [(2 * a)], qbe.time, qbe.block);
linear_pauli_rotations([Pauli::Y], [2], [0], qbe.index, qbe.block);
}

qfunc short_time_summation(a: real, b: real, qbe: TimeDependentBE) {
within {
hadamard_transform(qbe.time);
} apply {
block_encode_time_dependent_A(a, b, qbe);
}
}

qfunc short_time_magnus(a: real, b: real, qbe_st: MagnusBE) {
within {
H(qbe_st.qsvt_exp_lcu);
} apply {
qsvt_lcu([
4.7085,
3.0195,
0.0547,
4.7904,
0.0547,
3.0195,
(-17.2827)
], [
4.5651,
0.2495,
6.6887,
(-0.1862),
6.097,
0.4056,
0.2495,
(-20.5676)
], time_dependent_projector, time_dependent_projector, lambda(x) {
short_time_summation(a, b, x);
}, qbe_st.time_dependent, qbe_st.qsvt_exp_aux, qbe_st.qsvt_exp_lcu);
}
}

qfunc long_slice_evolution(a: real, b: real, qbe: LongSliceBE) {
qsvt([
4.1801,
2.3715,
4.6112,
4.5273,
(-1.7559),
4.6112,
8.6546,
(-20.9526)
], magnus_projector, magnus_projector, lambda(x) {
short_time_magnus(a, b, x);
}, qbe.magnus, qbe.qsvt_amplification_aux);
}

qfunc long_time_integrator_step(a: real, b: real, qbe_full: FullBE) {
long_slice_evolution(a, b, qbe_full.time_slice);
control ((((qbe_full.time_slice.magnus.time_dependent.block == 0) and (qbe_full.time_slice.magnus.time_dependent.time == 0)) and ((qbe_full.time_slice.magnus.qsvt_exp_aux == 0) and (qbe_full.time_slice.magnus.qsvt_exp_lcu == 0))) and (qbe_full.time_slice.qsvt_amplification_aux == 0)) {
qbe_full.counter += -1;
}
}

qfunc long_time_integrator(T: real, num_slices: int, qbe_full: FullBE) {
inplace_prepare_int(num_slices, qbe_full.counter);
repeat (i: num_slices) {
long_time_integrator_step((i * T) / num_slices, ((i + 1) * T) / num_slices, qbe_full);
}
}

qfunc main(output qbe: FullBE) {
allocate(qbe.size, qbe);
hadamard_transform(qbe.time_slice.magnus.time_dependent.index);
long_time_integrator(2, 4, qbe);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"cx",
"u2",
"y",
"ry",
"t",
"rx",
"cy",
"r",
"sxdg",
"cz",
"tdg",
"x",
"sdg",
"u1",
"u",
"h",
"sx",
"z",
"p",
"id",
"s",
"rz"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 0,
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 590453799
}
}
2 changes: 2 additions & 0 deletions requirements_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ testbook
torch
torchvision
galois
cvxpy
pyqsp==0.1.6
10 changes: 10 additions & 0 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ algorithms/deutsch_jozsa/simple_deutsch_jozsa.qmod: 16
algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb: 300
algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.qmod: 300
algorithms/differential_equations/hhl_jungle/hhl_jungle.ipynb: 450
algorithms/differential_equations/time_marching/time_marching.ipynb: 500
algorithms/differential_equations/time_marching/time_marching.qmod: 500
algorithms/grover/3_sat_grover/3_sat_grover.ipynb: 36
algorithms/grover/3_sat_grover/3_sat_grover.qmod: 48
algorithms/grover/3_sat_grover/3_sat_grover_large.qmod: 10
Expand Down Expand Up @@ -327,3 +329,11 @@ tutorials/workshops/grover_workshop/grover_workshop.qmod: 20
tutorials/workshops/hhl_workshop/hhl_workshop.ipynb: 300
tutorials/documentation_materials/classiq_101/hadamard_test/hadamard_test.ipynb: 44
tutorials/documentation_materials/classiq_101/hadamard_test/hadamard_test.qmod: 20
tutorials/technology_demonstrations/classiq_paper/quantum_walk/classiq_discrete_quantum_walk.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/quantum_walk/qiskit_discrete_quantum_walk.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/quantum_walk/tket_discrete_quantum_walk.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/quantum_walk/pennylane_catalyst_discrete_quantum_walk.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/qsvt/tket_qsvt_example.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/qsvt/classiq_qsvt.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/qsvt/pennylane_cat_qsvt_example.ipynb: 300
tutorials/technology_demonstrations/classiq_paper/qsvt/qiskit_qsvt.ipynb: 300
Loading