Giter VIP home page Giter VIP logo

bosonic's Introduction

Bosonic: A Quantum Optics Library

Test Status Badge Coverage Badge MIT License Badge

Bosonic is a library developed for the simulation of photonic systems whose inputs are indistinguishable bosons (in the case of the authors' interest, photons). In particular, it focuses on the rapid computation of the multi-particle transfer functions for these systems and supports computation of the gradient of a cost function with respect to the system parameters. It was originally developed for the devleopment of our Quantum Optical Neural Networks [1] and contains specialized functionality for their simulation and optimization.

Key focuses of this library were two-fold:

  1. Speed: Key functionality is written in optimized Cython with support for OpenMP threading
  2. Pervasive autograd support: We rely heavily on the use of the Autograd [1] library for gradient computation and efficient optimization of system parameters. Wherever optimized forward-pass functions are written in Cython, there should be explicit support for autograd coded as well. This is not currently universally true, but there is support for all major functions.

Key Functionality

Multi-particle Unitary Evolution

The core motivation for this package was the rapid computation of the multi-particle unitary transform as a function of the single particle unitary and the number of bosonic inputs. That is, if we have a four dimensional unitary U, and we know there are 3 photons at the input, we want to know the transformation over the $\binom{4+3-1, 3}$-dimensional basis $[3,0,0,0], [2,1,0,0], [2,0,1,0], ... etc.

This is supported by the function bosonic.aa_phi, which is named after Aaronson and Arkhipov, who specified the form of this function that we use as their Φ(U) function in [2]. For example, we can demonstrate the famous Hong-Ou-Mandel effect with a beamsplitter:

>>> import bosonic as b
>>> import numpy as np
>>> U = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)
>>> phiU = b.aa_phi(U, 2)
>>> print(phiU)
[[ 0.5       +0.j  0.70710678+0.j  0.5       +0.j]
 [ 0.70710678+0.j  0.        +0.j -0.70710678+0.j]
 [ 0.5       +0.j -0.70710678+0.j  0.5       +0.j]]
>>> print(b.fock.basis(2, 2))
[[2, 0], [1, 1], [0, 2]]
>>> input = np.array([[0], [1], [0]], dtype=complex)
>>> phiU = b.aa_phi(U, 2)
>>> print(phiU.dot(input))
[[ 0.70710678+0.j]
 [ 0.        +0.j]
 [-0.70710678+0.j]]
 >>> print(np.abs(phiU.dot(input))**2)
[[0.5]
 [0. ]
 [0.5]]

Here, we build the unitary corresponding to a 50/50 beamsplitter in U. As shown the line after we print phiU, the basis here is [2, 0], [1, 1], and [0, 2]. So the state corresponding to one photon incident at each of the inputs is [0, 1, 0]. In the final line, two lines, we see that the output is an equal superposition over two photons at one output and two photons at the other, with no probability of the photons leaving by different ports.

Quantum Optical Neural Networks

As described in [1], we've developed a proposed architecture for quantum optical neural networks that involves tiling arbitrary unitary transformations with single-site nonlinearities. See the paper for more details, but here's a visual summary of the architecture:

Quantum Optical Neural Network Architecture

Installation

Cloning this repository is currently the only way to get bosonic on your system. Before doing that, you'll need the python package Cython installed, to build bosonic properly. Something like this should work on linux (using your preferred python package manager instead of pip, if desired):

$ pip install Cython
$ git clone [email protected]:steinbrecher/bosonic.git
$ cd bosonic
$ pip install .

On Mac, you'll need gcc from homebrew and libopenmp as well:

$ brew install gcc
$ brew install libomp
$ pip install Cython
$ git clone [email protected]:steinbrecher/bosonic.git
$ cd bosonic
$ CC=gcc-8 pip install .

You should then be able to test that bosonic is installed correctly by running

$ python setup.py test

References

[1] Steinbrecher, G. R., Olson, J. P., Englund, D., & Carolan, J. (2018). Quantum optical neural networks. arXiv preprint arXiv:1808.10047. https://arxiv.org/abs/1808.10047

[2] Aaronson, Scott, and Alex Arkhipov. "The computational complexity of linear optics." Proceedings of the forty-third annual ACM symposium on Theory of computing. ACM, 2011. https://arxiv.org/pdf/1011.3245.pdf

bosonic's People

Contributors

jacquescarolan avatar steinbrecher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bosonic's Issues

fock.basis_size gives overflow error

Example:
print(len(bosonic.fock.basis(11,4))) gives correct result
print(bosonic.fock.basis_size(11,4)) gives the following error:

File "bosonic\fock.pyx", line 109, in bosonic.fock.basis_size
OverflowError: Python int too large to convert to C long

Possible solution:
I forked the code, (converted to python 3) and changed bosonic.fock.basis_size to:

def basis_size(int n, int m):
    cdef int res = scipy.special.binom(n+m-1,n)
    return res

A more efficient solution should be possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.