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

Model/ori roth classiq/cad 25543 update qmods #668

Merged
merged 1 commit into from
Dec 18, 2024
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
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_0_lambda___0_0_expanded___0(qvar___3_captured__inplace_one_hot_to_unary__4: qbit, qvar___2_captured__inplace_one_hot_to_unary__4: qbit) {
CX(qvar___3_captured__inplace_one_hot_to_unary__4, qvar___2_captured__inplace_one_hot_to_unary__4);
}

qfunc iteration_0_lambda___0_0_expanded___1(qvar___2_captured__inplace_one_hot_to_unary__4: qbit, qvar___1_captured__inplace_one_hot_to_unary__4: qbit) {
CX(qvar___2_captured__inplace_one_hot_to_unary__4, qvar___1_captured__inplace_one_hot_to_unary__4);
}

qfunc iteration_0_lambda___0_0_expanded___2(qvar___1_captured__inplace_one_hot_to_unary__4: qbit, qvar___0_captured__inplace_one_hot_to_unary__4: qbit) {
CX(qvar___1_captured__inplace_one_hot_to_unary__4, qvar___0_captured__inplace_one_hot_to_unary__4);
}

qfunc inplace_one_hot_to_unary_expanded___0(qvar: qbit[4]) {
iteration_0_lambda___0_0_expanded___0(qvar[3], qvar[2]);
iteration_0_lambda___0_0_expanded___1(qvar[2], qvar[1]);
iteration_0_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_1_lambda___0_0_expanded___0(y___0_captured__vector_product_phase__2: qbit) {
Z(y___0_captured__vector_product_phase__2);
}

qfunc iteration_1_lambda___0_0_expanded___1(y___1_captured__vector_product_phase__2: qbit) {
Z(y___1_captured__vector_product_phase__2);
}

qfunc iteration_1_lambda___0_0_expanded___2(y___2_captured__vector_product_phase__2: qbit) {
Z(y___2_captured__vector_product_phase__2);
}

qfunc iteration_1_lambda___0_0_expanded___3(y___3_captured__vector_product_phase__2: qbit) {
Z(y___3_captured__vector_product_phase__2);
}

qfunc iteration_1_lambda___0_0_expanded___4(y___4_captured__vector_product_phase__2: qbit) {
Z(y___4_captured__vector_product_phase__2);
}

qfunc iteration_1_lambda___0_0_expanded___5(y___5_captured__vector_product_phase__2: qbit) {
Z(y___5_captured__vector_product_phase__2);
}

qfunc vector_product_phase_expanded___0(y: qbit[6]) {
iteration_1_lambda___0_0_expanded___0(y[0]);
iteration_1_lambda___0_0_expanded___1(y[1]);
iteration_1_lambda___0_0_expanded___2(y[2]);
iteration_1_lambda___0_0_expanded___3(y[3]);
iteration_1_lambda___0_0_expanded___4(y[4]);
iteration_1_lambda___0_0_expanded___5(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_2_lambda___0_0_expanded___0(target___0_captured__apply_to_all__3: qbit) {
H(target___0_captured__apply_to_all__3);
}

qfunc iteration_2_lambda___0_0_expanded___1(target___1_captured__apply_to_all__3: qbit) {
H(target___1_captured__apply_to_all__3);
}

qfunc iteration_2_lambda___0_0_expanded___2(target___2_captured__apply_to_all__3: qbit) {
H(target___2_captured__apply_to_all__3);
}

qfunc iteration_2_lambda___0_0_expanded___3(target___3_captured__apply_to_all__3: qbit) {
H(target___3_captured__apply_to_all__3);
}

qfunc iteration_2_lambda___0_0_expanded___4(target___4_captured__apply_to_all__3: qbit) {
H(target___4_captured__apply_to_all__3);
}

qfunc iteration_2_lambda___0_0_expanded___5(target___5_captured__apply_to_all__3: qbit) {
H(target___5_captured__apply_to_all__3);
}

qfunc apply_to_all_expanded___0(target: qbit[6]) {
iteration_2_lambda___0_0_expanded___0(target[0]);
iteration_2_lambda___0_0_expanded___1(target[1]);
iteration_2_lambda___0_0_expanded___2(target[2]);
iteration_2_lambda___0_0_expanded___3(target[3]);
iteration_2_lambda___0_0_expanded___4(target[4]);
iteration_2_lambda___0_0_expanded___5(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
36 changes: 18 additions & 18 deletions algorithms/dqi/dqi_max_xorsat.synthesis_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"rz",
"cx",
"h",
"u1",
"r",
"sx",
"s",
"rx",
"y",
"cy",
"tdg",
"ry",
"u2",
"u",
"x",
"cz",
"cy",
"rx",
"id",
"z",
"u",
"sxdg",
"sdg",
"x",
"rz",
"sx",
"ry",
"t",
"p",
"id"
"u1",
"y",
"tdg",
"s",
"h",
"r",
"cx",
"sdg",
"cz"
],
"is_symmetric_connectivity": true
},
Expand All @@ -38,6 +38,6 @@
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": -1
"random_seed": 2676057990
}
}
Loading