2
$\begingroup$

I am trying to run simulation instances of a parametrized circuit in parallel but my algorithm is extremely slow. Excuse my ignorance, but I just want to be sure that the circuits are indeed running in parallel.

Here is my execution workflow:


backend = Aer.get_backend('statevector_simulator',
                          max_parallel_threads=N_threads,
                          max_parallel_experiments=N_threads,
                          optimization_level=3,
                         precision="single")

parametrized_circuits = CreateCircuits()

transpiled = transpile(parametrized_circuits, backend=backend)

experiments = []
for i in range(N):
    experiments.append(transpiled[i].assign_parameters(a))

job = execute(experiments, backend=backend, optimization_level=0)

So, my first question

1. Is the structure efficient? E.g. Are the circuits transpiled only once? Or does execute re-transpile them? (I have read this function is just a wrapper for transpile and run)

When I run my experiments in a 12-core node, most cores seem to be under-utilized (atmost 10%, some even lower), while the experiment taking ages to complete. I have also read this question regarding reordering. My results come out with the same order as if the circuits were simulated serially, which makes me even more suspicious.

2. Are my circuits really running in parallel? Is there something I miss?

$\endgroup$
4
  • 1
    $\begingroup$ On your first question: transpiled = transpile(parametrized_circuits, backend=backend) is unnecessary. execute will transpile on a bind circuited, which is much more efficient. The rumours are true, execute function is just a wrapper for transpile and run. $\endgroup$
    – luciano
    Oct 4, 2022 at 11:46
  • $\begingroup$ Also, optimization_level is not a backend option. You can checkout the backend options with backend.options $\endgroup$
    – luciano
    Oct 4, 2022 at 11:54
  • $\begingroup$ @luciano Then, should I transpile the parametrized circuits once and then repeatedly assign and run or just assign and execute (auto-transpile) at every run? $\endgroup$
    – consthatza
    Oct 5, 2022 at 10:14
  • 1
    $\begingroup$ if the transpilation process is not your bottleneck, then just execute. $\endgroup$
    – luciano
    Oct 5, 2022 at 10:39

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.