Module qi_job

class QIJob(backend, job_id, api, qobj=None)[source]

Bases: JobV1

A Qiskit job that is executed on the Quantum Inspire platform. A QIJob is normally created by calling run on QuantumInspireBackend qi_backend.

qc = QuantumCircuit(5, 5)
qc.h(0)
qc.cx(0, range(1, 5))
qc.measure_all()

qc = transpile(qc, qi_backend)
job = qi_backend.run(qc, shots=1024)
result = job.result()

The return value of run is an instance of QIJob (Qiskit job) and is the equivalent to the Quantum Inspire project. It is a container to handle one or more (asynchronous) Qiskit circuits or experiments. A Qiskit circuit is equivalent to a Quantum Inspire job.

To get the Quantum Inspire project-id from job do:

qi_project_id = job.job_id()

To get the list of Quantum Inspire jobs (in dictionary format) from job do:

qi_jobs = job.get_jobs()

QIJob can also be recreated using a job_id, being a Quantum Inspire project-id:

qi_backend = QI.get_backend('QX single-node simulator')
job = qi_backend.retrieve_job(job_id)

A QIJob object is normally not constructed directly.

Parameters:
  • backend (QuantumInspireBackend) – A Quantum Inspire backend.

  • job_id (str) – Id of the job as provided by the Quantum Inspire API.

  • api (QuantumInspireAPI) – A Quantum Inspire API.

  • qobj (Optional[QasmQobj]) – A Qiskit quantum object.

set_job_id(job_id)[source]

Overwrite the job_id with a new id.

Parameters:

job_id (str) – New id for the QIJob. Used in the use case for linking the job to the user-given QI project that must contain the job.

Return type:

None

submit()[source]

Submit a job to the Quantum Inspire platform.

Raises:

JobError – An error if the job has already been submitted.

Return type:

None

result(timeout=None, wait=0.5)[source]

Return the result for the experiments in the latest run for this project.

Parameters:
  • timeout (float | None) – Timeout in seconds.

  • wait (float) – Wait time between queries to the Quantum Inspire platform.

Returns:

QIResult object containing the result.

Raises:
  • JobTimeoutError – If timeout is reached.

  • QiskitBackendError – If an error occurs during simulation.

Return type:

QIResult

result_all_jobs(timeout=None, wait=0.5)[source]

Return the result for the experiments for all the existing jobs in the project.

Parameters:
  • timeout (float | None) – Timeout in seconds.

  • wait (float) – Wait time between queries to the Quantum Inspire platform.

Returns:

QIResult object containing the result.

Raises:
  • JobTimeoutError – If timeout is reached.

  • QiskitBackendError – If an error occurs during simulation.

Return type:

QIResult

cancel()[source]

Cancel the job and delete the project.

Return type:

None

get_jobs()[source]

Gets the Quantum Inspire jobs that were submitted in the latest run. These job were added with add_job.

Returns:

List of jobs with their properties for the jobs that were added for the experiments submitted when running this instance of QIJob. An empty list is returned when there were no jobs added.

Raises:

ApiError – If the job for the job identified does not exist.

Return type:

List[Dict[str, Any]]

add_job(job)[source]

Add a Quantum Inspire job to the list. The list contains the (Quantum Inspire) jobs created for the submitted experiments in this particular QIJob.

Parameters:

job (QuantumInspireJob) – QuantumInspireJob (submitted) that has to be added to the list of jobs created for the experiments in QIJob.

Return type:

None

queue_position(refresh=False)[source]

Return the position for this Job in the Quantum Inspire queue (when in status QUEUED). Currently, we don’t have this info available.

Parameters:

refresh (bool) – If True, re-query the server to get the latest value. Otherwise, return the cached value, when available. Not used.

Returns:

The queue position of the job. Currently, None (not available).

Return type:

int | None

status()[source]

Check the status of the jobs submitted in the latest run.

Returns:

The status of the job.

Return type:

JobStatus