Conversation
|
| Branch | cm/qaoa_example |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 141.73 x 1e3(0.00%)Baseline: 141.73 x 1e3 | 143.15 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 6,620.00(0.00%)Baseline: 6,620.00 | 6,686.20 (99.01%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 17.52 x 1e3(0.00%)Baseline: 17.52 x 1e3 | 17.69 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 581.00(0.00%)Baseline: 581.00 | 586.81 (99.01%) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1331 +/- ##
=======================================
Coverage 93.39% 93.39%
=======================================
Files 128 128
Lines 11970 11970
=======================================
Hits 11179 11179
Misses 791 791 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds an example notebook demonstrating QAOA (Quantum Approximate Optimization Algorithm) implementation in Guppy, ported from a pytket example. The implementation correctly solves a maxcut problem for a seven-vertex graph but faces performance challenges requiring optimization work.
Key Changes:
- Implementation of QAOA algorithm in Guppy with basic classical optimization
- Exclusion of the new notebook from CI tests due to 1+ minute runtime exceeding the 120s timeout
- Documentation additions (noted as incomplete in PR description)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Remove long running QAOA notebook from C.I. tests | ||
| # Hopefully we can add it back in when we can speed it up. | ||
| notebook_files.remove( | ||
| Path("/home/runner/work/guppylang/guppylang/examples/qaoa_maxcut_example.ipynb") |
There was a problem hiding this comment.
The hardcoded absolute path /home/runner/work/guppylang/guppylang/ will fail in local development environments and other CI systems. Use a relative path construction like Path(__file__).parent.parent.parent / 'examples' / 'qaoa_maxcut_example.ipynb' to match the pattern used for notebook_files discovery.
| Path("/home/runner/work/guppylang/guppylang/examples/qaoa_maxcut_example.ipynb") | |
| Path(__file__).parent.parent.parent / "examples" / "qaoa_maxcut_example.ipynb" |
|
A few typos:
A few questions:
|
|
Thanks a lot for the comments. I'll respond to them now. |
I'm not sure I see what is missing from the equation. I think the coefficent of |
Thanks. These were all formatting issues. I've fixed them now. |

EDIT: As of 2nd March I've finished off the explanatory text and acknowledged some of the performance limitations.
Implementation of QAOA in Guppy. The code was based on an pytket example notebook implementing QAOA which I ported over to Guppy.
The implementation works and gives the correct answer for the maxcut instnace for a seven vertex graph. However there are some outstanding issues.
I expect the overhead is in the repeated compilation of Guppy functions on every QAOA iteration (100 iterations in this case, 2000 shots, 7 qubits).
This was running afoul of the 120s timeout imposed by C.I. (The runners are slower than my local machine) This in turn means that I've had to skip the notebook execution test here which is unfortunate. See the changes I made to the
test_notebooks.pyfile.solve_maxcut_instance. Note that this is not the cause of the slow runtime as the same optimisation strategy is applied in the pytket version.I'd like to use a scipy optimizer or something but that would require a fair bit of refactoring. I only get a float back from
scipy.optimize.minimizeso I need to refactor to account for the fact that I'm not getting aQsysResultback in the loop.