Package: bosonsampling
Boson Sampling LibraryThe following library was developed to better understandAaronson-Arkhipov Boson Sampling (AABS)(the acronym "AABS" for the particular Boson Sampling setup was encountered in Kruse et al.'s paperA detailed study of Gaussian Boson Sampling)
by simulating the behavior of fock state inputs through a random unitary based linear interferometer and calculating the probabilities of certain fock state ouptuts.InstallationYou can eitherpip install bosonsamplingor clone the library and within the directory (as well as having your favorite python environment activate) run the following:pip install .UsageImportbosonsamplingfor core functionality and therandom_interferometer()function fromstrawberryfields.utilsto set up a random interferometer.importbosonsamplingasbsfromstrawberryfields.utilsimportrandom_interferometerCreate your random_interferometer# creates a 4x4 unitary matrixrandom_interferometer=random_interferometer(4)Create your input Fock states# 0 photons in mode 1# 1 photon in mode 2# 3 photons in mode 3# 4 photons in mode 4photons_in=[0,1,3,4]You can either:a. Measure the probability of a certain output statephotons_out=[0,0,0,8]output_probability=bs.output_probability(photons_in,photons_out,random_interferometer)b. OR Measure the probability of ALL output statesforphoton_out_configurationinbs.gen_output_configurations(sum(photons_in),len(photons_in)):output_probability=bs.output_probability(photons_in,photon_out_configuration,random_interferometer)print("Probability of photon output{0}:{1}".format(photon_out_configuration,output_probability))Example FilesExample files have been included to explain different possible usages withbosonsamplingand can be found in theexamplesfolder.All files prefixed withbs_are dedicated solely tobosonsampling.py.However, there are files prefixed withsf_that show how identical behavior can be obtained withStrawberry Fields(great for verifying results) and howbosonsamplingcan be used in conjunction with it as well.bs_single_photon_test.py- demonstrates a single photon entering the interferometer and calculating the probability of all possible outputsbs_multiple_photon_test.py- demonstrates multiple photons entering the interferometer and calculating the probability of all possible outputs, emphasizing howgen_output_configurations()can come in handy for such scenarios.bs_aabs_setup.py- demonstrates a setup similar to what would be called for in the Aaronson-Arkhipov paper with a multiple, single-photon fock state input with the modes right next to eachother and how the probability of detecting a "collision" (an output state that has multiple photons in a single mode) is incredibly lowbs_aabs_scaling.py- Is essentially a duplicate ofbs_aabs_setup.pybut has an outer loop designed to make the interferometer larger with each iteration but keeps the number of inputted photons identical so one can observe the decreasing probability of collision.sf_single_photon_test.py- Isbs_single_photon_test.pybut implemented with Xanadu's Strawberry Fields frameworksf_multiple_photon_test.py- Isbs_multiple_photon_test.pybut implemented with Xanadu's Strawberry Fields framework.ContributingIf you find a bug or have an idea to improve the library, please feel free to either make an Issue or a Pull Request with your suggested changes! If you are contributing code, please do note that this library attempts to follow thePEP-8 Style Guide for Python Codeas well as usingGoogle Style Python DocstringsCreditsThe following resources were used to develop the main functions
behind library:VideosQuantum Supremacy via Boson Sampling: Theory and Practice | Quantum Colloquiumby the Perimeter Institute with Scott Aaronson as the guest speaker.Provides the formula in the first few minutes for calculating the probability of a certain photon output configuration (although the papers below also have equivalent formulations).Quantum Complexity Theory: Lecture 9 - Boson Samplingby Sevag GharibianProvided an excellent explanation of the column and row indexing/copying required to generate a matrix, which is the basis for both the default and memory efficient implementations of the submatrix generator in the library.Generating integer partitionsby Jerome KelleherProvided the integer partitioning function which is used to help generate all possible output photon states
ingen_output_configurations()functionGet all permutations of a numpy arrayby Bill BellProvided a method of usingsympyto generate all unique permutations of a given
numpy array (works with ordinary lists too) and is part of thegen_output_configurations()functionPapersAn introduction to boson-samplingby Gard et al.A detailed study of Gaussian Boson Samplingprovided the origin of the AABS acronym used throughout the project and has a very nice illustration on page 2 that describes the column and row indexing necessary to generate the proper submatrix that Sevag Gharibian also goes over.WebsitesBoson sampling and the permanentprovided the basis for code insf_single_photon_test.pyandsf_multiple_photon_test.pyAdditional ResourcesThese are resources that did not contribute directly to the code but
were invaluable in learning more about boson sampling:Experimental Boson Samplingby Tillman et al.Introduction to boson-samplingby Peter RohdeGaussian Boson Sampling Complexity - Part 1by Andrew TanggaraNote: This video was barely consulted, but appred to be very well made and is given by Alex Arkhipov himself!Quantum computing with noninteracting particles - Alex Arkhipov