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

Dev #665

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

Dev #665

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
208f2f2
Rename notebook: hamiltonian simulation guide
classiqdor Dec 12, 2024
1bbf05a
Rename notebook: hamiltonian evolution
classiqdor Dec 12, 2024
8ce9ec8
Rename notebook: exponentiation example
classiqdor Dec 12, 2024
f66d2ff
Rename notebook: hhl example
classiqdor Dec 12, 2024
a990335
Rename notebook: application option pricing
classiqdor Dec 12, 2024
8138e8b
Rename notebook: example prepare state
classiqdor Dec 12, 2024
7973caa
Fix rename
classiqdor Dec 12, 2024
dfbbf7c
Add test for unique notebook names
classiqdor Dec 12, 2024
12d12f8
Update timeouts to be relative paths
classiqdor Dec 12, 2024
f67b063
Update test to test for relative paths
classiqdor Dec 12, 2024
05052b0
Fix
classiqdor Dec 12, 2024
dea56bf
Update error message
classiqdor Dec 12, 2024
6efd396
Allow functions qmods to have duplicates
classiqdor Dec 12, 2024
c43c28b
changed dqi notebook name
orsa-classiq Dec 15, 2024
4741165
refactored set_partition, max_clique, ilp, ising
orsa-classiq Dec 8, 2024
0206d63
removed knapsack binary notebook
orsa-classiq Dec 8, 2024
bcc9122
with max_k_vertex_cover
orsa-classiq Dec 8, 2024
52891f1
updated notebooks accord\ing to CR comments and new CombiProblem inte…
orsa-classiq Dec 16, 2024
9e6d990
updated timeouts
orsa-classiq Dec 16, 2024
cf51713
with portfolio optimization as well
orsa-classiq Dec 16, 2024
b9c7099
fixed failing notebooks
orsa-classiq Dec 16, 2024
f120365
Fix imports
ori-opher Dec 16, 2024
3756bc9
Update qmods
OriRothClassiq Dec 17, 2024
198ab50
Update qmods
OriRothClassiq Dec 17, 2024
55ad73a
added missing timeouts
orsa-classiq Dec 18, 2024
f44a2e4
Update dqi Qmod
OriRothClassiq Dec 18, 2024
f5de9ca
adjusted integer using notebooks
orsa-classiq Dec 18, 2024
bdc84d8
test commit
orsa-classiq Dec 19, 2024
3be6161
Fix file rename
classiqdor Dec 19, 2024
a5c46dc
adding SKEAPED_URLS list
Dec 19, 2024
f624118
delete outdated note (also required to match the suggested solution)
Dec 17, 2024
2d49741
delete unnecesarry note
Dec 17, 2024
e212004
delete outdated hint
Dec 17, 2024
48e35ff
fix probabilities to sum up to 1
Dec 17, 2024
01ac7b1
Made suggestions for the English
AnnePicus Dec 19, 2024
ede2fc2
updating notebook and tests requirements
Dec 22, 2024
36d4119
fixed control with variable in both arguments issue
orsa-classiq Dec 24, 2024
a0fa141
English suggestions to Introducing Quantum Functions with Quantum Mon…
AnnePicus Dec 24, 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
4 changes: 2 additions & 2 deletions .github/workflows/Internal-automatic-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:
jobs:
deploy-prod:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
uses: ./.github/workflows/deployment-qmod.yml
uses: ./.github/workflows/Utils-deployment-qmod.yml
with:
deploy-mode: production
secrets: inherit

deploy-dev:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev'
uses: ./.github/workflows/deployment-qmod.yml
uses: ./.github/workflows/Utils-deployment-qmod.yml
with:
deploy-mode: staging
secrets: inherit
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

Large diffs are not rendered by default.

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