Pennylane-qulacs number of cores

I’m puzzled with how can I set the number of cores to be used by pennylane-qulacs. When I run it in multicore mode, it consumes all the available cores, I hope there is a way to specify how many cores are allowed. I couldn’t manage to find a solution by looking at the docs. Thanks.

Hi @cnktysz. Welcome to the Discussion Forum. :tada:

I believe Qulacs is using OpenMP for parallelization, so it should be possible to change the number of threads used by setting the environment variable OMP_NUM_THREADS to the specific number of threads that you want to use (e.g. export OMP_NUM_THREADS=4 for using 4 threads in a Bash shell). Setting OMP_NUM_THREADS=1 practically turns off multi-threaded use, while deleting the variable all-together sets it back to the default setting.

Unfortunately, as far as I know, there is currently no other, straight-forward way of changing the number of threads/cores that Qulacs uses for its simulations.

1 Like

Hi @theodor, setting the OMP_NUM_THREADS did the trick. Now, I am able to choose the amount of threads/cores I want to use. Thank you.


That’s great @cnktysz! I’m glad it helped.

Feel free to ask any more questions that might pop up in the future.

1 Like