4
$\begingroup$

Using the execute function, assuming the parameter experiments is a list[QuantumCircuit], would each circuit execute on the device in the order specified by the list?

$\endgroup$

1 Answer 1

2
$\begingroup$

If the parameter experiments is a list[QuantumCircuit], then the qiskit.execute_function function will run the circuits using a parallel map, and append the results in the returned list in the order they finish.

After the parallel run, you can sort the results list to match the ordering of the input circuits. For an example of how to do so, see https://quantumcomputing.stackexchange.com/a/23382/13991.

Edit:

Lists of jobs sent to actual IBMQ quantum devices are processed through the parallel map function as well, but appear to be submitted asynchronously. Tracking a run down through the stack, you'll find:

IBMQJobManager.run
    ${\rightarrow}$ ManagedJobSet.run
        ${\rightarrow}$ ManagedJob.submit
            ${\rightarrow}$concurrent.futures.ThreadPoolExecutor.submit

ManagedJob.submit invokes ThreadPoolExecutor.submit with callable _async_submit:

def _async_submit(
    self,
    circuits: Union[QuantumCircuit, Schedule, List[Union[QuantumCircuit, Schedule]]],
    job_name: str,
    backend: IBMQBackend,
    submit_lock: Lock,
    job_tags: Optional[List[str]] = None,
    **run_config: Dict
) -> None:
    """Run circuits asynchronously and populate instance attributes.
    Args:
        circuits: Circuits to run.
        job_name: Name of the job.
        backend: Backend to execute the experiments on.
        submit_lock: Lock used to synchronize job submission.
        job_tags: Tags to be assigned to the job.
        **run_config: Extra arguments used to configure the run.
    """

It doesn't seem to be the case that the order in which circuits are executed necessarily matches the order in which they are specified. However, you should be able to find the mechanism that dicates execution / submission order by following the IBMQJobManager.run bread trail that I've started to layout above.

$\endgroup$
2
  • $\begingroup$ Is this for simulation, or does this apply to IBMs quantum devices as well? If so, could you point me to a resource explaining how parallel executions are processed on actual quantum devices? $\endgroup$ Commented Jul 26, 2022 at 14:36
  • $\begingroup$ Answer revised above. Hopefully thats helps $\endgroup$
    – ryanhill1
    Commented Jul 26, 2022 at 17:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.