# Pennylane performance vs alternatives?

**URL:** <https://discuss.pennylane.ai/t/pennylane-performance-vs-alternatives/5096>\
**Category:** PennyLane Help\
**Created:** [August 28, 2024, 1:06am UTC](https://discuss.pennylane.ai/t/pennylane-performance-vs-alternatives/5096 "2024-08-28T01:06:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![schance995](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@schance995](https://discuss.pennylane.ai/u/schance995)\
**Post date:** [August 28, 2024, 1:06am UTC](https://discuss.pennylane.ai/t/pennylane-performance-vs-alternatives/5096/1 "2024-08-28T01:06:51Z")

</div>

There are some recent QML frameworks that claim to have greater performance than Pennylane:

1. [TorchQuantum](https://github.com/mit-han-lab/torchquantum/) claims a 246x speedup over Pennylane (CPU-only) in figure 12 of [their paper](https://arxiv.org/pdf/2107.10845)
2. [TensorCircuit](https://github.com/tencent-quantum-lab/tensorcircuit) also claims 10-100x speedups over Pennylane (both CPU and GPU) in tables 6,7,8 of [their paper](https://quantum-journal.org/papers/q-2023-02-02-912/pdf/)

I’m curious to know what the Pennylane developers think about these benchmarking claims, and if there have been any significant performance gains within Pennylane since these papers have come out.

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [August 29, 2024, 1:40pm UTC](https://discuss.pennylane.ai/t/pennylane-performance-vs-alternatives/5096/2 "2024-08-29T13:40:00Z")

</div>

Hey @schance995!

Interesting question. The short answer with a lot of comparative studies like these is (1) that they aren’t using the other libraries as efficiently as they can and (2) this is a 2 year old paper! Lots has improved in PennyLane since then 😅. The long answer:

The [first citation](https://arxiv.org/pdf/2107.10845) (i.e. fig 12) deals with training over data, i.e., the cost function is a sum over many data points, so `cost(x) = sum_data cost(x, data)`. Indeed PennyLane can be slow with a naive for-loop implementation for these instances (will be much better when used with Catalyst, though). However, using things like `vmap` significantly speeds up this process, which is most likely what they are doing and mean with tensorized (vectorized) batch processing. Besides that, they seem to use parameter-shift, further explaining the huge performance regression

> Moreover, Pennylane can only use parameter shift to obtain gradients, which is inherently sequential, so no parallelization on batch and gate dimension can be achieved.

This is not generally true ☝. There are many differentiation methods that are available to use with PennyLane 🙂.

Similar story for the [second citation](https://quantum-journal.org/papers/q-2023-02-02-912/pdf/) (tables 6, 7, 8), though they also seem to compare just `value_and_grad` evaluationss on lightning and (I guess?) with default qubit + jax on GPU.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![schance995](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@schance995](https://discuss.pennylane.ai/u/schance995)\
**Post date:** [September 6, 2024, 5:03pm UTC](https://discuss.pennylane.ai/t/pennylane-performance-vs-alternatives/5096/3 "2024-09-06T17:03:50Z")

</div>

Good points! I hope that future Pennylane and Catalyst benchmarks can be more consistent in their comparisons with other libraries.
