Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculate_cut in the VQE example? #3

Closed
marionsilv opened this issue Jun 30, 2022 · 2 comments
Closed

calculate_cut in the VQE example? #3

marionsilv opened this issue Jun 30, 2022 · 2 comments

Comments

@marionsilv
Copy link

Hello! I have been trying to use your code to compute the MaxCut in the VQE jupyter notebook provided in the example sections. I tried to apply the calculate_cut function on the state as
tlq.calculate_cut(state, qubits1, qubits2, weights)
but I am having the following error
TypeError: only integer tensors of a single element can be converted to an index.

I see that the cut is calculated differently in the MBE example, but I would like to know if there is an analogue way of doing it with the VQE. Or should I just adapt my Hamiltonian to maximize the cut?
Any help is appreciated,
Thanks!

@taylorpatti
Copy link
Collaborator

Hi Marion,

The answer depends on how you would like to define the MaxCut of a VQE matrix.

In the Ising model Hamiltonian that we provide in the VQE example, we have both z and x-axis terms. If you remove the x-axis terms, then you indeed recover a classical Hamiltonian that encodes a MaxCut problem. You can use the calculate_cut function with the construct:
tlq.calculate_cut(torch.sign(pauli_terms), vertices1, vertices2, weights)
where torch.sign rounds your pauli_terms (the outcome of your single-qubit measurements) to +/- 1, and vertices are integer tensors in torch. The ground state of the Hamiltonian will encode your MaxCut.

If you leave in both the z and x-axis terms in the VQE example, then that Hamiltonian no longer encodes a MaxCut problem, so the definition of using calculate_cut on the output state is no longer clear. I'd be happy to help, but would need more information.

@marionsilv
Copy link
Author

Hi Taylor.

Thank you for the quick reply. I was indeed referring to the Ising model without the transversal field. I was somehow expecting that the MaxCut function would need two operators, like in the MBE case. I will try your implementation and I'll return to you if I have any other questions, I hope that is ok!

Best regards,
Marion.

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

No branches or pull requests

2 participants