# What is an easy way to implement QFT in strawberryfields?

**URL:** <https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371>\
**Category:** Strawberry Fields\
**Created:** [August 30, 2023, 12:11pm UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371 "2023-08-30T12:11:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prabhat\_Prabhat](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/prabhat_prabhat/32/1823_2.png) [@Prabhat\_Prabhat](https://discuss.pennylane.ai/u/Prabhat_Prabhat)\
**Post date:** [August 30, 2023, 12:11pm UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/1 "2023-08-30T12:11:57Z")

</div>

The Fourier Gate provided in the documentation gives a one-mode gate. Now, to create a multi-mode QFT for CV quantum algorithms, one can look at the mathematical structure of QFT from references. But since this process is very popular, I was wondering how can one implement QFT efficiently? Is there any implementation example somewhere?

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 5, 2023, 9:16pm UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/2 "2023-09-05T21:16:45Z")

</div>

Hi @Prabhat_Prabhat,

Thank you for your question. We have a module on the Xanadu Quantum Codebook dedicated to QFT. In particular, [submodule F.3](https://codebook.xanadu.ai/F.3) covers the n-qubit QFT. The code is not complete here, you’re presented with coding challenges for you to come to the answer.

That being said, maybe the demo on [arithmetic with QFT](https://pennylane.ai/qml/demos/tutorial_qft_arithmetics) is what you were looking for. Does this answer your question? Or were you looking for something different?

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 5, 2023, 9:21pm UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/3 "2023-09-05T21:21:38Z")

</div>

Hi @Prabhat_Prabhat, I just realized that you were looking for something for CV algorithms, not PennyLane. Unfortunately I don’t know of any implementation other than the gate you already found.

---

<div class="post-metadata">

**Author:** ![Prabhat\_Prabhat](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/prabhat_prabhat/32/1823_2.png) [@Prabhat\_Prabhat](https://discuss.pennylane.ai/u/Prabhat_Prabhat)\
**Post date:** [September 6, 2023, 4:48am UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/4 "2023-09-06T04:48:40Z")

</div>

No problem @CatalinaAlbornoz, I was just confused whether QFT for, let’s say, 5 qumodes will simply be FT gate applied to each of the 5 qumodes. Wondered maybe that’s why it doesn’t have any direct module in strawberry fields. Thank you anyway 🙂

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 8, 2023, 2:27am UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/5 "2023-09-08T02:27:38Z")

</div>

Hi @Prabhat_Prabhat, I’m not 100% sure about this. Let me check and get back to you on this.

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 11, 2023, 2:56pm UTC](https://discuss.pennylane.ai/t/what-is-an-easy-way-to-implement-qft-in-strawberryfields/3371/6 "2023-09-11T14:56:40Z")

</div>

Hi @Prabhat_Prabhat,

Here’s the answer from my colleague Rafael:

> Fourier transforms arise in many different ways in CV optics. When people say QFT for discrete variable systems, the usually mean to apply the unitary operator that corresponds the the “D times D” DFT matrix, where you might have n qubits with D = 2^n. You could define a similar thing for qudits, changing D = d^n. The problem is, if you want to go to the CV case, even a single mode has d = infinite. Given a single mode, if you use the number basis, then the Fourier transform is not the right thing because it is diagonal. If you use the position quadrature basis, then it does look like the right thing. If you have multiple modes, you could also be talking about the “mode label” Fourier transform, which would correspond to the beamsplitter network on n modes that uniformly mixes the intensities but where the amplitudes all have different phase coefficients corresponding to powers of nth roots of unity. All of these generalizations are just different ways in which the DFT matrix crops up in this context, but none of them is quite the same as the QFT operation in the qubit/qudit context (it forms a nontrivial subroutine in qubit algorithms). In contrast, these mode-type DFT implementations are quite simple to implement.

I hope this helps! Please let me know if you have any further questions.
