# Leveraging GPUs without cuQuantum

**URL:** <https://discuss.pennylane.ai/t/leveraging-gpus-without-cuquantum/4468>\
**Category:** PennyLane Help\
**Created:** [April 19, 2024, 10:10pm UTC](https://discuss.pennylane.ai/t/leveraging-gpus-without-cuquantum/4468 "2024-04-19T22:10:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pormelrog](https://avatars.discourse-cdn.com/v4/letter/p/ea5d25/32.png) [@pormelrog](https://discuss.pennylane.ai/u/pormelrog)\
**Post date:** [April 19, 2024, 10:10pm UTC](https://discuss.pennylane.ai/t/leveraging-gpus-without-cuquantum/4468/1 "2024-04-19T22:10:05Z")

</div>

Hello,

is there some way of leveraging a non-cuQuantum-ready GPU like an RTX3060 to run quantum circuits?

In particular, I am also interested in how much speed up or increase in number of qubits I could achieve by running the circuit on such a GPU vs. a CPU like i5-12400F. At the moment I am using such a CPU with the lightning-kokkos plugin and OpenMPI. Are there some specific configurations or parameters I could adjust to increase the current performance of the last a setup?

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![mlxd](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mlxd/32/526_2.png) [@mlxd](https://discuss.pennylane.ai/u/mlxd)\
**Post date:** [April 22, 2024, 5:06pm UTC](https://discuss.pennylane.ai/t/leveraging-gpus-without-cuquantum/4468/2 "2024-04-22T17:06:49Z")

</div>

Hi @pormelrog

This is a very good question, and the answer will depend highly on your workload (circuit width and depth). For a quick demonstration of OpenMP performance with gate applications, LightningKokkos is your best bet initially (as you have found). If your circuit is quite deep, or beyond 20 qubits, running on a GPU is usually best.

If you want to use the ML frameworks directly, you can likely use `default.qubit` as a device, and load data using their locality methods (see [here](https://docs.pennylane.ai/en/stable/introduction/interfaces/torch.html#gpu-and-cuda-support)). Similarly, using the [JAX](https://docs.pennylane.ai/en/stable/introduction/interfaces/jax.html) interface allows you to target GPUs through jitting. For small workloads, these will likely be optimal, and especially if you are using backprop for gradients. For larger problems, backprop becomes infeasible due to memory contraints, and LGPU/LKokkos is with adjoint is likely the best option. However, if you don’t want/need gradients, you can set `diff_method=None` in the QNode, which should save some time in execution.

Now, if you have an RTX3060, you should be able to use LightningGPU with cuQuantum (this GPU is SM8.6, above the SM7.0 threshold of cuQuantum). Explicit install instructions can be found [here](https://pennylane.ai/install/#high-performance-computing-and-gpus), which in this case are:

```auto
pip install nvidia-cusparse-cu12 nvidia-cublas-cu12 nvidia-cuda-runtime-cu12 custatevec_cu12
pip install pennylane pennylane-lightning-gpu

```

However, you can also install LightningKokkos with the CUDA backend with a little bit more work:

```auto
git clone https://github.com/PennyLaneAI/pennylane-lightning
cd pennylane-lightning
pip install -r ./requirements-dev.txt
PL_BACKEND="lightning_qubit" pip install . # Setup up the Lightning framework
CMAKE_ARGS="-DKokkos_ENABLE_CUDA=ON" PL_BACKEND="lightning_kokkos" pip install .

```

This should use the same Kokkos-defined kernels, and rebuild them to target your native CUDA architecture directly.

Feel free to let us know if the above steps help. If there are performance considerations you’d like more feedback on, sharing a minimum-working example of your workload would help too.
