Probability for states in photonic circuits

Hi! I’m interested in implementing a certain photonic circuit with an output of all of it’s possible fock states with their probabilities.
For example: if the circuit’s output is 50% |0101> and 50% |1010> instead of running it multiple times to obtain those states, in one run it will tell me what are all possible outcomes.
While using pennylane I’m using “probs”, is there something similar for strawberryfieds?

Hi @segev and welcome to the forum!

You can use state.all_fock_probs() to return the probabilities of all possible Fock basis states for the current circuit state. Please see the code below as an example where probs contains all the Fock basis state probabilities:

import strawberryfields as sf
from strawberryfields import ops

prog = sf.Program(3)

with prog.context as q:
    ops.Sgate(0.54) | q[0]
    ops.Sgate(0.54) | q[1]
    ops.Sgate(0.54) | q[2]
    ops.BSgate(0.43, 0.1) | (q[0], q[2])
    ops.BSgate(0.43, 0.1) | (q[1], q[2])

eng = sf.Engine("fock", backend_options={"cutoff_dim": 10})
result = eng.run(prog)
state = result.state
probs = state.all_fock_probs()

More information on how to use all_fock_probs is provided here. Please let me know if you have any questions.

Thank you! that’s exactly what I wanted!