1
$\begingroup$

I don't know why the code keeps sending jobs. The code is:

backend = service.backend('ibmq_qasm_simulator')
parameters = np.array([0.3,0.4])
p = parameters.size // 2

options = Options(optimizzation_level=2)
sampler = Sampler(session=backend, options=options)
qaoa = QAOA(sampler = sampler, optimizer = ADAM(), reps=p, initial_point = parameters)

result = qaoa.compute_minimum_eigenvalue(qubit_op)

What am I missing?

EDIT: qubit_op comes from:

def get_operator(weight_matrix: np.ndarray) -> tuple[SparsePauliOp, float]:
    num_nodes = len(weight_matrix)
    pauli_list = []
    coeffs = []
    shift = 0

    for i in range(num_nodes):
        for j in range(i):
            if weight_matrix[i, j] != 0:
                x_p = np.zeros(num_nodes, dtype=bool)
                z_p = np.zeros(num_nodes, dtype=bool)
                z_p[i] = True
                z_p[j] = True
                pauli_list.append(Pauli((z_p, x_p)))
                coeffs.append(-0.5)
                shift += 0.5

    for i in range(num_nodes):
        for j in range(num_nodes):
            if i != j:
                x_p = np.zeros(num_nodes, dtype=bool)
                z_p = np.zeros(num_nodes, dtype=bool)
                z_p[i] = True
                z_p[j] = True
                pauli_list.append(Pauli((z_p, x_p)))
                coeffs.append(1.0)
            else:
                shift += 1

    return SparsePauliOp(pauli_list, coeffs=coeffs), shift

qubit_op, offset = get_operator(weight_matrix)
$\endgroup$
8
  • $\begingroup$ Hi and welcome to Quantum Computing SE. How many variables do you have? How many jobs have been sent? $\endgroup$ Apr 28 at 17:39
  • 1
    $\begingroup$ It sent almost 300 jobs before I stopped the kernel. I put only two parameters and p=1 as you can see from the code above, the graph is a 5 node weighted graph. The code is really similar to the one in: qiskit.org/documentation/tutorials/algorithms/05_qaoa.html I took the functions from there. $\endgroup$ Apr 29 at 18:12
  • $\begingroup$ And how is you qubit_op defined? I do not see any objective function in your code. Just for you information, I run 6-variable QUBO problem on real 7-qubit processor with QAOA and around 160 iterations were needed. $\endgroup$ May 1 at 7:09
  • $\begingroup$ I just started studying this topic and I didn't know that QAOA needs to send more than one job, I thought that one job was enough for all the iterations needed. I added to the question the function get_operator where qubit_op comes from. I will try to run the program whit a small graph and see what happens. $\endgroup$ May 1 at 16:04
  • $\begingroup$ I tried with a 2-vertex graph and I had to stop the kernel manually after it reached more than 1000 jobs sent to the ibmq_qasm_simulator $\endgroup$ May 1 at 17:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.