qiskit-optimization icon indicating copy to clipboard operation
qiskit-optimization copied to clipboard

Job failed unexpectedly with QAOAProgram

Open lasys opened this issue 4 years ago • 1 comments

Information

  • Qiskit Optimization version: 0.2
  • Qiskit version: 0.27
  • Python version: 3.7.11
  • Operating system: Linux

What is the current behavior?

In the IBM Quantum Dashboard the Job is listed as failed and the program output is:

---------------------------------------------------------------------------
RuntimeJobFailureError                    Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/qiskit_optimization/runtime/vqe_program.py in compute_minimum_eigenvalue(self, operator, aux_operators)
    277         try:
--> 278             result = job.result()
    279         except Exception as exc:

3 frames
/usr/local/lib/python3.7/dist-packages/qiskit/providers/ibmq/runtime/runtime_job.py in result(self, timeout, wait, decoder)
    147             if self._status == JobStatus.ERROR:
--> 148                 raise RuntimeJobFailureError(f"Unable to retrieve result for job {self.job_id()}. "
    149                                              f"Job has failed:\n{result_raw}")

RuntimeJobFailureError: 'Unable to retrieve result for job c44gccjmkn8sds6s2940. Job has failed:\n'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
<ipython-input-8-d4bb8551e7b0> in <module>()
     32                          measurement_error_mitigation=True)
     33 
---> 34 runtime_result = runtime_qaoa.compute_minimum_eigenvalue(pauli)

/usr/local/lib/python3.7/dist-packages/qiskit_optimization/runtime/qaoa_program.py in compute_minimum_eigenvalue(self, operator, aux_operators)
    158             mixer_operator=self.mixer,
    159         )
--> 160         return super().compute_minimum_eigenvalue(operator, aux_operators)

/usr/local/lib/python3.7/dist-packages/qiskit_optimization/runtime/vqe_program.py in compute_minimum_eigenvalue(self, operator, aux_operators)
    278             result = job.result()
    279         except Exception as exc:
--> 280             raise RuntimeError(f"The job {job.job_id()} failed unexpectedly.") from exc
    281 
    282         # re-build result from serialized return value

RuntimeError: The job c44gccjmkn8sds6s2940 failed unexpectedly.

Steps to reproduce the problem

import networkx as nx
import numpy as np
from qiskit_optimization.runtime import QAOAProgram
from qiskit_optimization.converters import QuadraticProgramToQubo
from qiskit_optimization.applications.max_cut import Maxcut

# Generate a graph of 5 nodes
n = 5
graph = nx.Graph()
graph.add_nodes_from(np.arange(0, n, 1))
elist= [(0, 1, 3), (0, 2, 1), (1, 2, 1), (3, 2, 6), (3, 4, 1), (4, 2, 2)]
graph.add_weighted_edges_from(elist)

max_cut = Maxcut(graph)
qubit_op = max_cut.to_quadratic_program()
conv_toQubo = QuadraticProgramToQubo()
max_cut_qubo = conv_toQubo.convert(qubit_op)
pauli, f = max_cut_qubo.to_ising()

optimizer = {'name': 'SPSA',
             'maxiter': 50}

backend = provider.get_backend('ibmq_qasm_simulator')

runtime_qaoa = QAOAProgram(
                         callback=None,
                         optimizer=optimizer,
                         initial_point=None,
                         provider=provider,
                         backend=backend,
                         shots=8192,
                         measurement_error_mitigation=True)

runtime_result = runtime_qaoa.compute_minimum_eigenvalue(pauli)

What is the expected behavior?

Job should run without error.

Suggested solutions

Maybe the problem is QAOAAnsatz , because when i use QAOAAnsatz as ansatz in VQEProgram the Job also failed.

lasys avatar Aug 03 '21 09:08 lasys

This problem should be resolved, there was an issue with the runtime programs in general. 🙂 @lasys could you check if the code runs for you again?

Cryoris avatar Apr 04 '22 09:04 Cryoris

Since QAOAProgram was deprecated with the release v0.3, I close this issue.

t-imamichi avatar Nov 30 '22 14:11 t-imamichi