Skip to content

Fix/falqon demo issue 1726#1729

Merged
CatalinaAlbornoz merged 14 commits intoPennyLaneAI:masterfrom
rosspeili:fix/falqon-demo-issue-1726
Apr 10, 2026
Merged

Fix/falqon demo issue 1726#1729
CatalinaAlbornoz merged 14 commits intoPennyLaneAI:masterfrom
rosspeili:fix/falqon-demo-issue-1726

Conversation

@rosspeili
Copy link
Copy Markdown
Contributor

Title: fix: correct Hc and commutator formulas, and build_hamiltonian coefficients in FALQON demo

Summary:
The FALQON demo's cost Hamiltonian formula, commutator formula, and build_hamiltonian() function all used incorrect coefficients. The root cause is a hidden 1/4 normalization applied by pennylane.qaoa.cost.edge_driver (used internally by qaoa.max_clique) that was not reflected in the demo's written math.

Specific corrections:

  • H_c formula: edge coefficient 33/4; added a note explaining the edge_driver normalization
  • [H_d, H_c] formula: first-sum coefficient 33/4, second-sum 31
  • i[H_d, H_c] formula: first-sum coefficient 63/2, second-sum 62
  • build_hamiltonian(): edge term coefficients 61.5, second-sum 62
  • Added a .. note:: block showing qml.commutator as a concise general-purpose alternative
  • Bumped dateOfLastModification in metadata.json

The FALQON algorithm converged correctly before and after this fix — the sign of β_k is preserved by the operator structure, so the guarantee d/dt ⟨H_c⟩ ≤ 0 holds regardless. This PR makes the written math match the actual code output.

Relevant references:

Possible Drawbacks:
None. The algorithm behaviour is unchanged; only the mathematical exposition is corrected.

Related GitHub Issues:
Closes #1726

@rosspeili rosspeili requested review from a team as code owners March 27, 2026 08:55
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

Your preview is ready 🎉!

You can view your changes here

Deployed at: 2026-04-10 15:01:05 UTC

…ts in FALQON demo

Fixes PennyLaneAI#1726 (PennyLaneAI#1726)

- Correct Hc formula: coefficient 3 -> 3/4 (hidden normalization in edge_driver)
- Add explanatory note about the 1/4 factor from pennylane.qaoa.cost.edge_driver
- Correct commutator [Hd, Hc] formula: first-sum coeff 3->3/4, second-sum coeff 3->1
- Correct i[Hd, Hc] formula: first-sum coeff 6->3/2, second-sum coeff 6->2
- Fix build_hamiltonian(): edge term coefficients 6->1.5, second-sum 6->2
- Add note block showing qml.commutator as a general-purpose alternative
- Bump dateOfLastModification in metadata.json
@rosspeili rosspeili force-pushed the fix/falqon-demo-issue-1726 branch from 69dae19 to 99540bb Compare March 27, 2026 09:01
Copy link
Copy Markdown
Contributor

@CatalinaAlbornoz CatalinaAlbornoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @rosspeili !

I left a couple of minor suggestions.

Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
CatalinaAlbornoz and others added 8 commits April 2, 2026 16:25
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
Co-authored-by: Catalina Albornoz <albornoz.catalina@hotmail.com>
@rosspeili
Copy link
Copy Markdown
Contributor Author

Thank you @CatalinaAlbornoz. I have committed all your suggestions. Will be more careful with comments and keep it as clean and tight as possible. <3

@CatalinaAlbornoz
Copy link
Copy Markdown
Contributor

No worries @rosspeili !

You did a great job.
This was an easy review in fact.

@CatalinaAlbornoz CatalinaAlbornoz self-requested a review April 6, 2026 21:33
Copy link
Copy Markdown
Contributor

@CatalinaAlbornoz CatalinaAlbornoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @rosspeili !

This PR looks ready 🚀

Copy link
Copy Markdown
Contributor

@drdren drdren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, it looks great to me! Thank you for this! I had a minor formatting request.

Comment on lines +223 to 227
# cost_h, driver_h = qaoa.max_clique(graph, constrained=False)
# comm_h = qml.simplify(1j * qml.commutator(driver_h, cost_h))
#

######################################################################
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make this note box smaller vertically? There is some extraneous whitespace we can remove.

Comment thread demonstrations_v2/tutorial_falqon/demo.py Outdated
Minor edit to remove empty line
@rosspeili
Copy link
Copy Markdown
Contributor Author

rosspeili commented Apr 7, 2026

Thank you @CatalinaAlbornoz, and @drdren 🙏 It seems I cannot merge, even with your two approvals, as it awaits one pending review from "core-release-managers"?

@CatalinaAlbornoz CatalinaAlbornoz enabled auto-merge (squash) April 10, 2026 14:55
@CatalinaAlbornoz CatalinaAlbornoz merged commit a954ef5 into PennyLaneAI:master Apr 10, 2026
8 checks passed
@rosspeili rosspeili deleted the fix/falqon-demo-issue-1726 branch April 10, 2026 15:01
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.

[BUG] the FALQON demo has issues in some formulas and code

3 participants