Skip to content

QAOA MaxCut#845

Merged
NadavClassiq merged 14 commits intomainfrom
qaoa_branch
Mar 13, 2025
Merged

QAOA MaxCut#845
NadavClassiq merged 14 commits intomainfrom
qaoa_branch

Conversation

@NadavClassiq
Copy link
Collaborator

PR Description

Some notes

  • Please make sure that you placed the files in an appropriate folder

  • And that the files have indicative names.

  • Please note that Classiq runs automatic code linting, which may minorly alter some files.

    • If you're familiar with pre-commit, you may run pre-commit install, and then at each commit, your files will be altered in a similar way

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -0,0 +1,786 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 5, 2025

Choose a reason for hiding this comment

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

1 - Why the mixing operation is Digital? and the Phase Analog?

2 - "toward a partition that maximizes the number of cut edges.":

*towards

*maybe minimizes the hamiltonian? instead of the cut. and put the f_obj in negative sign


Reply via ReviewNB

Copy link
Collaborator Author

@NadavClassiq NadavClassiq Mar 10, 2025

Choose a reason for hiding this comment

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

1—The phase rotation is considered "analog" because it continuously modifies the state's phase in proportion to the cost function, while the mixer is "digital" because it is implemented using discrete quantum gate operations (e.g., RX rotations with discrete parameters) that drive transitions between basis states.

Should I eliminate this terminology? You have used it similarly in knasack

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was a bit different - the digital was a digital transformation (arithmetrics). The phase is indeed an analog operation. I wouldn't use this terminology because it is a bit confusing, and not needed for the example, but that's up to you

@@ -0,0 +1,786 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 5, 2025

Choose a reason for hiding this comment

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

Line #4.        num_layers: CInt,

maybe you don't need this - use the gammas\betas size instead


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I get:

AttributeError: 'CParamList' object has no attribute 'size'

Am I missing anything? Maybe in generative mode?...

I left it as it was for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe you should use .len

@@ -0,0 +1,786 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 5, 2025

Choose a reason for hiding this comment

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

Line #6.        params: CArray[CReal, NUM_LAYERS * 2],

Maybe worth an explanation - this is an execution parameter, to be set by the sample method later on in the classical optimization loop


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried clarifying, please resolve if it is clear.

@@ -0,0 +1,786 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 5, 2025

Choose a reason for hiding this comment

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

Line #9.        allocate(v.size, v)

no need to provide v.size, because it was declared in the main signature


Reply via ReviewNB

@@ -0,0 +1,786 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 5, 2025

Choose a reason for hiding this comment

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

Line #10.        hadamard_transform(v)  # here or aside?

remove the comment


Reply via ReviewNB

@@ -0,0 +1,802 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 12, 2025

Choose a reason for hiding this comment

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

"can be applied to graph-based optimization tasks" - I would change to "can be applied to unconstrained combinatorial optimization tasks"


Reply via ReviewNB

@@ -0,0 +1,802 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 12, 2025

Choose a reason for hiding this comment

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

Line #6.    G.add_nodes_from(graph_nodes)

no need to add nodes, enough to add edges


Reply via ReviewNB

@@ -0,0 +1,802 @@
{
Copy link
Collaborator

@orsa-classiq orsa-classiq Mar 12, 2025

Choose a reason for hiding this comment

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

hadamard_transform() - remove brackets

"As in vanilla QAOA" - what do you mean by that? isn't vanilla QAOA what you implement here?


Reply via ReviewNB

@orsa-classiq
Copy link
Collaborator

@NadavClassiq Please also do the following:

  1. fix the address of max-cut here: https://github.com/Classiq/classiq-library/blob/main/algorithms/README.md#L4
  2. add a 'metadata.json` file so the algorithm will be able to render on the platform
  3. remove the old max-cut implementation for applications dir

@NadavClassiq NadavClassiq merged commit 33735f1 into main Mar 13, 2025
2 checks passed
@NadavClassiq NadavClassiq deleted the qaoa_branch branch March 13, 2025 16:02
@github-actions
Copy link

🌈 Incredible, @NadavClassiq! You've merged your 16th PR! 🎯🎊

Your ongoing commitment to classiq-library is truly remarkable. You're a driving force in our community! 🚀
Your contributions are helping to shape the future of quantum computing! What exciting features or improvements do you envision next? 🔮

We are grateful for your dedication! 💫

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.

2 participants