Skip to content

docs: use scipy optimizer in QAOA MaxCut example#1819

Open
spital wants to merge 1 commit into
Quantinuum:mainfrom
spital:docs/qaoa-scipy-optimizer
Open

docs: use scipy optimizer in QAOA MaxCut example#1819
spital wants to merge 1 commit into
Quantinuum:mainfrom
spital:docs/qaoa-scipy-optimizer

Conversation

@spital
Copy link
Copy Markdown

@spital spital commented Jun 6, 2026

Summary

  • replace the random QAOA parameter sampling loop with a scipy.optimize.minimize variational loop using COBYLA
  • split QAOA execution from the optimizer objective so eval_qaoa_energy returns only scalar energy
  • run one final QAOA pass with the optimized parameters for validation and plotting
  • document the classical optimizer vs. Guppy quantum-program boundary, including the angle coefficient convention
  • add SciPy to the examples dependency group and refresh uv.lock

The performance/recompilation limitation remains documented in the notebook and is intentionally left to #1546.

Testing

  • uv lock --check
  • uv run ruff check
  • uv run ruff format --check
  • uv run pytest tests/integration/test_notebooks.py
  • uv run jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=1200 --output-dir /tmp/tmp.P7p9GROppQ --output qaoa_executed.ipynb examples/qaoa_maxcut_example.ipynb

Manual QAOA notebook execution reproduced the committed output:

array([5.099, 1.736, 2.63 , 4.751, 4.831, 2.361, 2.2  ])
'Success ratio: 0.4015'

AI disclosure

I used Codex, Claude, and Hermes as AI assistants to help prototype, review, compare related GitHub state, and draft this PR text. I manually reviewed the resulting diff, checked the GitHub issue/PR state, and locally ran the tests and notebook execution listed above. The implementation and PR are submitted with human oversight; any remaining mistakes are mine.

Closes #1545

@spital spital requested a review from a team as a code owner June 6, 2026 17:00
@spital spital requested a review from qartik June 6, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs]: Use a real-world classical optimizer in the QAOA MaxCut example

1 participant