# Lightning.qubit CPU utilisation

**URL:** <https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833>\
**Category:** PennyLane Help\
**Created:** [February 9, 2021, 9:34am UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833 "2021-02-09T09:34:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Ellis](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/james_ellis/32/159_2.png) [@James\_Ellis](https://discuss.pennylane.ai/u/James_Ellis)\
**Post date:** [February 9, 2021, 9:34am UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/1 "2021-02-09T09:34:03Z")

</div>

Hi again,

Does lightning.qubit utilise all cores of a CPU or just one?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![antalszava](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/antalszava/32/171_2.png) [@antalszava](https://discuss.pennylane.ai/u/antalszava)\
**Post date:** [February 9, 2021, 5:32pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/2 "2021-02-09T17:32:46Z")

</div>

Hi @James_Ellis,

It utilises a single core at the moment, but exploring multi-threading is on our radar. 🙂

---

<div class="post-metadata">

**Author:** ![James\_Ellis](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/james_ellis/32/159_2.png) [@James\_Ellis](https://discuss.pennylane.ai/u/James_Ellis)\
**Post date:** [February 9, 2021, 10:50pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/3 "2021-02-09T22:50:57Z")

</div>

Thanks for the answer.

Does this mean it is possible to run multiple ‘lightning.qubit’ experiments at once?

---

<div class="post-metadata">

**Author:** ![antalszava](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/antalszava/32/171_2.png) [@antalszava](https://discuss.pennylane.ai/u/antalszava)\
**Post date:** [February 10, 2021, 4:27pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/4 "2021-02-10T16:27:55Z")

</div>

Hi @James_Ellis,

Yes, that would be feasible!

---

<div class="post-metadata">

**Author:** ![James\_Ellis](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/james_ellis/32/159_2.png) [@James\_Ellis](https://discuss.pennylane.ai/u/James_Ellis)\
**Post date:** [February 10, 2021, 5:33pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/5 "2021-02-10T17:33:05Z")

</div>

So if I have a quad core i7… could I run 4 experiments or 8 (because of hyper-threading) ?

---

<div class="post-metadata">

**Author:** ![antalszava](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/antalszava/32/171_2.png) [@antalszava](https://discuss.pennylane.ai/u/antalszava)\
**Post date:** [February 10, 2021, 11:47pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/6 "2021-02-10T23:47:15Z")

</div>

Hi @James_Ellis,

Creating a simulation with `lightning.qubit` device and executing quantum circuits would be contained within a single Python process that places calls to bound C++ functions.

Since we are not handling multi-threading or parallelism explicitly within PennyLane when using `lightning.qubit` with default options, creating multiple Python processes that contain experiments as described will behave similarly for multi-core machines as creating other Python processes. Most probably the ability to utilize multiple cores will help, though the incurred overhead of scheduling and using shared resources will also affect the performance.

Having said that we haven’t explored multi-core running scenarios too extensively, so would be interesting to see any findings on it! 🙂

---

<div class="post-metadata">

**Author:** ![James\_Ellis](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/james_ellis/32/159_2.png) [@James\_Ellis](https://discuss.pennylane.ai/u/James_Ellis)\
**Post date:** [February 16, 2021, 8:51am UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/7 "2021-02-16T08:51:06Z")

</div>

Thanks for the detailed reply!

So to summarise, does this mean I can’t run multiple qubit experiments in parallel in one python script? It would have to be over multiple python scripts?

---

<div class="post-metadata">

**Author:** ![theodor](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/theodor/32/178_2.png) [@theodor](https://discuss.pennylane.ai/u/theodor)\
**Post date:** [February 16, 2021, 5:31pm UTC](https://discuss.pennylane.ai/t/lightning-qubit-cpu-utilisation/833/8 "2021-02-16T17:31:55Z")

</div>

Hi @James_Ellis. You should be able to run multiple simulations in parallel using a single Python script, although you would have to parallelize it yourself using e.g. [Dask](https://docs.dask.org/en/latest/), which would help you set up up to one Python process per thread (i.e. 8 in your case, I believe).

There’s a quirk with Python called the [Global Interpreter Lock (GIL)](https://wiki.python.org/moin/GlobalInterpreterLock) that prevents multiple threads from executing Python code at the same time. Thus, you’d need to create separate Python processes that, as @antalszava mentioned above, need to share some resources and will incur some extra overhead. Dask, and other parallelisation packages, would be able to help you with that, without the need to understand or implement the nitty-gritty details yourself.

Let us know how it goes, or if you have any other issues or questions!
