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
2 changes: 1 addition & 1 deletion algorithms/qaoa/knapsack/qaoa_knapsack.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
22 changes: 22 additions & 0 deletions algorithms/qaoa/maxcut/qaoa_max_cut.qmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
qfunc mixer_layer(beta: real, qba: qbit[]) {
apply_to_all(lambda(q) {
RX(beta, q);
}, qba);
}

qfunc qaoa_ansatz(cost_layer: qfunc (real, qbit[]), num_layers: int, gammas: real[], betas: real[], qba: qbit[]) {
hadamard_transform(qba);
repeat (i: num_layers) {
cost_layer(gammas[i], qba);
mixer_layer(betas[i], qba);
}
}

qfunc maxcut_cost_layer(gamma: real, v: qbit[]) {
phase (-((-((((((0 + ((v[0] * (1 - v[1])) + (v[1] * (1 - v[0])))) + ((v[0] * (1 - v[2])) + (v[2] * (1 - v[0])))) + ((v[1] * (1 - v[2])) + (v[2] * (1 - v[1])))) + ((v[1] * (1 - v[3])) + (v[3] * (1 - v[1])))) + ((v[2] * (1 - v[4])) + (v[4] * (1 - v[2])))) + ((v[3] * (1 - v[4])) + (v[4] * (1 - v[3]))))) / 6), gamma);
}

qfunc main(params: real[8], output v: qbit[5]) {
allocate(v.size, v);
qaoa_ansatz(maxcut_cost_layer, 4, params[0:4], params[4:8], v);
}
44 changes: 44 additions & 0 deletions algorithms/qaoa/maxcut/qaoa_max_cut.synthesis_options.json
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": [
"tdg",
"sx",
"h",
"ry",
"u",
"cz",
"rx",
"u1",
"y",
"x",
"id",
"u2",
"cy",
"sxdg",
"s",
"sdg",
"r",
"cx",
"rz",
"p",
"t",
"z"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 3,
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 415303440
}
}
798 changes: 798 additions & 0 deletions algorithms/qaoa/maxcut/qaoa_maxcut.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,5 @@ Qmod_tutorial_part1.ipynb: 500
Qmod_tutorial_part2.ipynb: 500
synthesis_tutorial.ipynb: 500
advection_equation_winning_submission.ipynb: 1200
qaoa_maxcut.ipynb: 300
qaoa_max_cut.qmod: 300
Loading