0
$\begingroup$

I have something to ask about Qiskit's transpiler. Before that, please check this document.

qiskit.compiler.transpile
https://qiskit.org/documentation/stubs/qiskit.compiler.transpile.html

In here, transpile function can get input as multiple quantum circuit as list and can transpile them in parallel.

I want to know how they can do in parallel.

$\endgroup$
1
$\begingroup$

It depends on your local environment and local configuration. By default if you're running on Linux with Python < 3.9 or macOS with Python < 3.8 then passing mutiple circuit's to transpile() will run in multiple process locally. This is done using Python's ProcessPoolExecutor to launch parallel processes and call transpile on each circuit in the input list in the process pool. The code for how Qiskit does this is in: https://github.com/Qiskit/qiskit-terra/blob/0.18.2/qiskit/tools/parallel.py (the parallel_map() function is what transpile() uses under the covers when you pass in >1 circuit).

Also, the defaults are adjustable so if you run on windows or with a newer python version you can still run in parallel but it's not enabled by default because there were some issues found using python's multiprocessing module in those environments. You can refer to https://qiskit.org/documentation/configuration.html on how to set the options controlling parallelism.

$\endgroup$
2
  • $\begingroup$ Really thank you for answering my question. I want to know one more thing. My experiment environment is window, not linux. So, I want to know how I can change the number of workers (Worker's in Pool) while I'm doing parallelism. $\endgroup$
    – 김동민
    22 hours ago
  • $\begingroup$ You can refer to the configuration documentation I linked before: qiskit.org/documentation/locale/ko_KR/configuration.html but tl;dr if you set the environment variable: QISKIT_PARALLEL=True (to enable parallelism on windows) and QISKIT_NUM_PROCS=n where n is the number of processes you want to run in. You can also set these options in a user config file too. It's worth noting that on windows you need to run your script that is executed in parallel inside if __name == "__main__: see: qiskit.org/documentation/… $\endgroup$ 16 hours ago

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