You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
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.
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!
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 astlq.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!
The text was updated successfully, but these errors were encountered: