# When is MeasureFock() planned to be implemented in the bosonic backend?

**URL:** <https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019>\
**Category:** Strawberry Fields\
**Created:** [June 6, 2023, 7:04pm UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019 "2023-06-06T19:04:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchapSF](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jchapsf/32/1713_2.png) [@jchapSF](https://discuss.pennylane.ai/u/jchapSF)\
**Post date:** [June 6, 2023, 7:04pm UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019/1 "2023-06-06T19:04:21Z")

</div>

I really like the speed of the Bosonic backend. I noticed that MeasureFock() hasn’t been implemented yet in the stable version. See below from [strawberryfields.backends.bosonicbackend.backend — Strawberry Fields 0.23.0 documentation](https://strawberryfields.readthedocs.io/en/stable/_modules/strawberryfields/backends/bosonicbackend/backend.html#BosonicBackend.measure_fock:)

def measure\_fock(self, modes, shots=1, select=None, \*\*kwargs):  
raise NotImplementedError(“Bosonic backend does not yet support Fock measurements.”)

Is there a planned release date for that yet?

Thanks,  
Joe

---

<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:** [June 6, 2023, 11:51pm UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019/2 "2023-06-06T23:51:54Z")

</div>

Hi @jchapSF,

It’s great to hear that you like the Bosonic backend! Unfortunately we don’t have any current plans for implementing this. If you really need this you could create your own fork of Strawberry Fields and add yourself the functionality that you need.

---

<div class="post-metadata">

**Author:** ![jchapSF](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jchapsf/32/1713_2.png) [@jchapSF](https://discuss.pennylane.ai/u/jchapSF)\
**Post date:** [June 7, 2023, 12:17am UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019/3 "2023-06-07T00:17:46Z")

</div>

Hi,

Thanks for the prompt reply. In fact, I am considering creating a fork and trying to add it myself, though that is sort of a last resort since I’m not so familiar with the innerworkings of SF yet. I found the github discussion on how the MeasureThreshold() function was added for the bosonic backend. Do you know of any advice for how to extend that to MeasureFock()? It seemed like Nicolas Quesada had some ideas of how to do it, just like he gave suggestions for how to do MeasureThreshold(), but just didn’t have time to do it.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![jchapSF](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jchapsf/32/1713_2.png) [@jchapSF](https://discuss.pennylane.ai/u/jchapSF)\
**Post date:** [June 7, 2023, 1:33am UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019/4 "2023-06-07T01:33:21Z")

</div>

Hi,

It appears from [[PRX Quantum 2, 040315 (2021) - Fast Simulation of Bosonic Qubits via Gaussian Functions in Phase Space](https://link.aps.org/doi/10.1103/PRXQuantum.2.040315)] that Eqn. 61 provides the approximate Bosonic representation of a Fock state and Sec. III C provides a method for using that representation as part of a non-Gaussian transformation. So by correctly implementing those two equations into Strawberry Fields appears to be a general but approximate implementation of MeasureFock(). There are probably some particulars and details that I haven’t noticed yet that need careful attention to do it correctly so it works for general inputs. Any advice?

Joe

---

<div class="post-metadata">

**Author:** ![Alvaro\_Ballon](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/alvaro_ballon/32/874_2.png) [@Alvaro\_Ballon](https://discuss.pennylane.ai/u/Alvaro_Ballon)\
**Post date:** [June 8, 2023, 5:38pm UTC](https://discuss.pennylane.ai/t/when-is-measurefock-planned-to-be-implemented-in-the-bosonic-backend/3019/5 "2023-06-08T17:38:37Z")

</div>

Hello @jchapSF

For now, we are not planning on implementing new features in Strawberry Fields, but rather just fix bugs. If you want to make a fork and implement the new feature for your personal use, you could use the code for [measure\_threshold](https://github.com/XanaduAI/strawberryfields/blob/9a9a352b5b8cf7b2915e45d1538b51d7d306cfc8/strawberryfields/backends/bosonicbackend/bosoniccircuit.py#L810) as a template. But rather than using the linear combination of Gaussians for a threshold measurement, you should use the [one for a fock state](https://github.com/XanaduAI/strawberryfields/blob/9a9a352b5b8cf7b2915e45d1538b51d7d306cfc8/strawberryfields/backends/bosonicbackend/backend.py#L673).

Hope this helps!

Alvaro
