Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git test2 #671

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
22b7f3d
Rename notebook: hamiltonian simulation guide
classiqdor Dec 12, 2024
4e838e7
Rename notebook: hamiltonian evolution
classiqdor Dec 12, 2024
b8c5d69
Rename notebook: exponentiation example
classiqdor Dec 12, 2024
7fe21ba
Rename notebook: hhl example
classiqdor Dec 12, 2024
45e1090
Rename notebook: application option pricing
classiqdor Dec 12, 2024
27b85c2
Rename notebook: example prepare state
classiqdor Dec 12, 2024
9d949df
Fix rename
classiqdor Dec 12, 2024
4049cf4
Add test for unique notebook names
classiqdor Dec 12, 2024
08ed7ee
Update timeouts to be relative paths
classiqdor Dec 12, 2024
0ca9a5b
Update test to test for relative paths
classiqdor Dec 12, 2024
2c2a91a
Fix
classiqdor Dec 12, 2024
9a39da7
Update error message
classiqdor Dec 12, 2024
b977aef
Allow functions qmods to have duplicates
classiqdor Dec 12, 2024
4954af6
changed dqi notebook name
orsa-classiq Dec 15, 2024
8a3c369
refactored set_partition, max_clique, ilp, ising
orsa-classiq Dec 8, 2024
1327fd2
removed knapsack binary notebook
orsa-classiq Dec 8, 2024
92b79c8
with max_k_vertex_cover
orsa-classiq Dec 8, 2024
177904b
updated notebooks accord\ing to CR comments and new CombiProblem inte…
orsa-classiq Dec 16, 2024
af28c7b
updated timeouts
orsa-classiq Dec 16, 2024
f61ef26
with portfolio optimization as well
orsa-classiq Dec 16, 2024
5c49b47
fixed failing notebooks
orsa-classiq Dec 16, 2024
7731ee6
Fix imports
ori-opher Dec 16, 2024
37ec88c
Update qmods
OriRothClassiq Dec 17, 2024
a0f25fc
Update qmods
OriRothClassiq Dec 17, 2024
2bba551
added missing timeouts
orsa-classiq Dec 18, 2024
6608e75
Update dqi Qmod
OriRothClassiq Dec 18, 2024
caebe67
adjusted integer using notebooks
orsa-classiq Dec 18, 2024
c6e73e7
test commit
orsa-classiq Dec 19, 2024
4bd0444
added galois to test requirements
orsa-classiq Dec 19, 2024
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
12 changes: 4 additions & 8 deletions algorithms/algebraic/hidden_shift/hidden_shift.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@
{
"name": "stdout",
"output_type": "stream",
"text": [
""
]
"text": []
}
],
"source": [
Expand Down Expand Up @@ -253,8 +251,7 @@
"output_type": "stream",
"text": [
"f_dual: (((((((((x[5]) & (y[0])) ^ ((x[2]) & (y[1]))) ^ ((x[7]) & (y[2]))) ^ ((x[0]) & (y[3]))) ^ ((x[6]) & (y[4]))) ^ ((x[3]) & (y[5]))) ^ ((x[1]) & (y[6]))) ^ ((x[4]) & (y[7]))) ^ ((((((((x[5]) & (x[2])) & (x[7])) & (x[0])) & (x[6])) & (x[3])) & (x[1])) & (x[4]))\n",
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
""
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n"
]
}
],
Expand Down Expand Up @@ -389,8 +386,7 @@
"output_type": "stream",
"text": [
"f: (((((((((x[0]) & (y[3])) ^ ((x[1]) & (y[6]))) ^ ((x[2]) & (y[1]))) ^ ((x[3]) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & (y[1])) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
""
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n"
]
}
],
Expand Down Expand Up @@ -589,7 +585,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions algorithms/algebraic/shor/shor_modular_exponentiation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
"from classiq.qmod import QNum, bind, control, within_apply\n",
"from classiq import *\n",
"from classiq.qmod.builtins.classical_functions import qft_const_adder_phase\n",
"\n",
"\n",
Expand Down Expand Up @@ -256,7 +256,7 @@
},
"outputs": [],
"source": [
"from classiq.qmod import QNum, inplace_prepare_int\n",
"from classiq import *\n",
"\n",
"modulo_num = 15\n",
"reg_len = math.ceil(math.log(modulo_num, 2)) + 1\n",
Expand Down Expand Up @@ -441,7 +441,7 @@
"metadata": {},
"outputs": [],
"source": [
"from classiq.qmod import SWAP, free\n",
"from classiq import *\n",
"from classiq.qmod.symbolic import min, mod_inverse\n",
"\n",
"\n",
Expand Down Expand Up @@ -535,7 +535,7 @@
"metadata": {},
"outputs": [],
"source": [
"from classiq.qmod import hadamard_transform\n",
"from classiq import *\n",
"\n",
"modulo_num = 6\n",
"reg_len = math.ceil(math.log(modulo_num, 2)) + 1\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ qfunc qsct_2d(xy_variable: qnum[2]) {
qct_type2(xy_variable[1]);
}

qfunc powered_hamiltonian_evolution(hamiltonian: PauliTerm[], scaling: real, p: int, qba: qbit[]) {
suzuki_trotter(hamiltonian, p * ((-6.28318530718) * scaling), 1, 1, qba);
}

qfunc inverse_amplitude_load(prefactor: real, phase: qnum, ind: qbit) {
ind *= prefactor / phase;
}
Expand All @@ -22,6 +18,10 @@ qfunc matrix_inversion_HHL(prefactor: real, my_unitary: qfunc (int, qbit[]), sta
}
}

qfunc powered_hamiltonian_evolution(hamiltonian: PauliTerm[], scaling: real, p: int, qba: qbit[]) {
suzuki_trotter(hamiltonian, p * ((-6.28318530718) * scaling), 1, 1, qba);
}

qfunc main(output x_variable: qnum<3, False, 0>, output y_variable: qnum<3, False, 0>, output phase: qnum, output indicator: qbit) {
xy_variable: qnum<3, False, 0>[2];
prepare_amplitudes([
Expand Down
2 changes: 1 addition & 1 deletion algorithms/dqi/dqi_max_xorsat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "9de82aaa-b542-49fa-810c-f008a28a4133",
"metadata": {},
"source": [
"# Optimizing max-XORSAT using the Decoded Quantum Interferometry algorithm"
"# Decoded Quantum Interferometry Algorithm"
]
},
{
Expand Down
104 changes: 15 additions & 89 deletions algorithms/dqi/dqi_max_xorsat.qmod
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,15 @@ qfunc binary_to_one_hot_expanded___0(input binary: qnum<2, False, 0>, output one
inplace_binary_to_one_hot_expanded___0(one_hot);
}

qfunc iteration_lambda___0_0_expanded___0(qvar___3_captured__inplace_one_hot_to_unary__5: qbit, qvar___2_captured__inplace_one_hot_to_unary__5: qbit) {
CX(qvar___3_captured__inplace_one_hot_to_unary__5, qvar___2_captured__inplace_one_hot_to_unary__5);
}

qfunc iteration_lambda___0_0_expanded___1(qvar___2_captured__inplace_one_hot_to_unary__5: qbit, qvar___1_captured__inplace_one_hot_to_unary__5: qbit) {
CX(qvar___2_captured__inplace_one_hot_to_unary__5, qvar___1_captured__inplace_one_hot_to_unary__5);
}

qfunc iteration_lambda___0_0_expanded___2(qvar___1_captured__inplace_one_hot_to_unary__5: qbit, qvar___0_captured__inplace_one_hot_to_unary__5: qbit) {
CX(qvar___1_captured__inplace_one_hot_to_unary__5, qvar___0_captured__inplace_one_hot_to_unary__5);
}

qfunc inplace_one_hot_to_unary_expanded___0(qvar: qbit[4]) {
iteration_lambda___0_0_expanded___0(qvar[3], qvar[2]);
iteration_lambda___0_0_expanded___1(qvar[2], qvar[1]);
iteration_lambda___0_0_expanded___2(qvar[1], qvar[0]);
qfunc inplace_one_hot_to_unary(qvar: qbit[]) {
repeat (i: qvar.len - 1) {
CX(qvar[(qvar.len - i) - 1], qvar[(qvar.len - i) - 2]);
}
X(qvar[0]);
}

qfunc one_hot_to_unary_expanded___0(input one_hot: qbit[4], output unary: qbit[3]) {
inplace_one_hot_to_unary_expanded___0(one_hot);
inplace_one_hot_to_unary(one_hot);
lsb: qbit;
one_hot -> {lsb, unary};
free(lsb);
Expand Down Expand Up @@ -165,37 +153,12 @@ qfunc prepare_dick_state_unary_input_expanded___5(qvar: qbit[6]) {
prepare_dick_state_unary_input_expanded___4(qvar[1:6]);
}

qfunc iteration_lambda___0_0_expanded___3(y___0_captured__vector_product_phase__3: qbit) {
Z(y___0_captured__vector_product_phase__3);
}

qfunc iteration_lambda___0_0_expanded___4(y___1_captured__vector_product_phase__3: qbit) {
Z(y___1_captured__vector_product_phase__3);
}

qfunc iteration_lambda___0_0_expanded___5(y___2_captured__vector_product_phase__3: qbit) {
Z(y___2_captured__vector_product_phase__3);
}

qfunc iteration_lambda___0_0_expanded___6(y___3_captured__vector_product_phase__3: qbit) {
Z(y___3_captured__vector_product_phase__3);
}

qfunc iteration_lambda___0_0_expanded___7(y___4_captured__vector_product_phase__3: qbit) {
Z(y___4_captured__vector_product_phase__3);
}

qfunc iteration_lambda___0_0_expanded___8(y___5_captured__vector_product_phase__3: qbit) {
Z(y___5_captured__vector_product_phase__3);
}

qfunc vector_product_phase_expanded___0(y: qbit[6]) {
iteration_lambda___0_0_expanded___3(y[0]);
iteration_lambda___0_0_expanded___4(y[1]);
iteration_lambda___0_0_expanded___5(y[2]);
iteration_lambda___0_0_expanded___6(y[3]);
iteration_lambda___0_0_expanded___7(y[4]);
iteration_lambda___0_0_expanded___8(y[5]);
qfunc vector_product_phase(v: int[], y: qbit[]) {
repeat (i: y.len) {
if (v[i] > 0) {
Z(y[i]);
}
}
}

qfunc matrix_vector_product_expanded___0(y: qbit[6], output out: qbit[6]) {
Expand All @@ -208,7 +171,7 @@ qfunc matrix_vector_product_expanded___0(y: qbit[6], output out: qbit[6]) {
out[5] ^= (0 ^ y[4]) ^ y[5];
}

qfunc syndrome_decode_lookuptable_expanded___0(syndrome: qnum<6, False, 0>, error: qnum<6, False, 0>) {
qfunc syndrome_decode_lookuptable(syndrome: qnum, error: qnum) {
control (syndrome == 0) {
error ^= 0;
}
Expand Down Expand Up @@ -277,43 +240,6 @@ qfunc syndrome_decode_lookuptable_expanded___0(syndrome: qnum<6, False, 0>, erro
}
}

qfunc iteration_lambda___0_0_expanded___9(target___0_captured__apply_to_all__4: qbit) {
H(target___0_captured__apply_to_all__4);
}

qfunc iteration_lambda___0_0_expanded___10(target___1_captured__apply_to_all__4: qbit) {
H(target___1_captured__apply_to_all__4);
}

qfunc iteration_lambda___0_0_expanded___11(target___2_captured__apply_to_all__4: qbit) {
H(target___2_captured__apply_to_all__4);
}

qfunc iteration_lambda___0_0_expanded___12(target___3_captured__apply_to_all__4: qbit) {
H(target___3_captured__apply_to_all__4);
}

qfunc iteration_lambda___0_0_expanded___13(target___4_captured__apply_to_all__4: qbit) {
H(target___4_captured__apply_to_all__4);
}

qfunc iteration_lambda___0_0_expanded___14(target___5_captured__apply_to_all__4: qbit) {
H(target___5_captured__apply_to_all__4);
}

qfunc apply_to_all_expanded___0(target: qbit[6]) {
iteration_lambda___0_0_expanded___9(target[0]);
iteration_lambda___0_0_expanded___10(target[1]);
iteration_lambda___0_0_expanded___11(target[2]);
iteration_lambda___0_0_expanded___12(target[3]);
iteration_lambda___0_0_expanded___13(target[4]);
iteration_lambda___0_0_expanded___14(target[5]);
}

qfunc hadamard_transform_expanded___0(target: qbit[6]) {
apply_to_all_expanded___0(target);
}

qfunc dqi_max_xor_sat_expanded___0(output y: qbit[6], output solution: qbit[6]) {
k_num_errors: qnum<2, False, 0>;
prepare_amplitudes([
Expand All @@ -326,10 +252,10 @@ qfunc dqi_max_xor_sat_expanded___0(output y: qbit[6], output solution: qbit[6])
binary_to_unary_expanded___0(k_num_errors, k_unary);
pad_zeros_expanded___0(k_unary, y);
prepare_dick_state_unary_input_expanded___5(y);
vector_product_phase_expanded___0(y);
vector_product_phase([1.0, 1.0, 1.0, 1.0, 1.0, 1.0], y);
matrix_vector_product_expanded___0(y, solution);
syndrome_decode_lookuptable_expanded___0(solution, y);
hadamard_transform_expanded___0(solution);
syndrome_decode_lookuptable(solution, y);
hadamard_transform(solution);
}

qfunc main(output y: qbit[6], output solution: qbit[6]) {
Expand Down
40 changes: 19 additions & 21 deletions algorithms/dqi/dqi_max_xorsat.synthesis_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,37 @@
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"z",
"u1",
"p",
"u2",
"cy",
"r",
"rx",
"id",
"y",
"sdg",
"z",
"u",
"sxdg",
"x",
"u2",
"s",
"ry",
"cx",
"rz",
"h",
"tdg",
"cz",
"u",
"rx",
"t",
"sx",
"sxdg"
"ry",
"t",
"p",
"u1",
"y",
"tdg",
"s",
"h",
"r",
"cx",
"sdg",
"cz"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"output_format": [
"qasm"
],
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 3679731798
"random_seed": 2676057990
}
}
2 changes: 1 addition & 1 deletion algorithms/grover/3_sat_grover/3_sat_grover.qmod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ qfunc sat_oracle(x: qbit[], res: qbit) {
}

qfunc main(output x: qbit[3]) {
allocate(3, x);
allocate(x.len, x);
grover_search(1, lambda(vars) {
phase_oracle(sat_oracle, vars);
}, x);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"constraints": {
"max_width": 20
"max_width": 20,
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"rz",
"cx",
"h",
"u1",
"r",
"sx",
"s",
"rx",
"y",
"cy",
"tdg",
"ry",
"u2",
"u",
"x",
"cz",
"z",
"sxdg",
"sdg",
"t",
"p",
"id"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": -1
}
}
2 changes: 1 addition & 1 deletion algorithms/grover/3_sat_grover/3_sat_grover_large.qmod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ qfunc sat_oracle_large(x: qbit[], res: qbit) {
}

qfunc main(output x: qbit[4]) {
allocate(4, x);
allocate(x.len, x);
grover_search(2, lambda(vars) {
phase_oracle(sat_oracle_large, vars);
}, x);
Expand Down
Loading
Loading