Numerical accuracy of the simulator and the fidelity of the model relative to a physical implementation

Hello, good morning, dear colleagues.

I have questions about the simulator’s numerical accuracy and the model’s fidelity compared to a physical implementation of simulations performed in the Strawberry Fields environment.My advisor questioned me about the fidelity of the results obtained in my simulations, and I need to provide a plausible explanation with a theoretical basis, if possible. Is there anywhere in the documentation that discusses and substantiates Strawberry Fields’ levels of numerical fidelity and accuracy?

import numpy as np
import strawberryfields as sf
from strawberryfields.ops import Coherent, BSgate, MeasureHeterodyne
import csv

# Define o número de modos e eventos
n_modes = 6
n_events = 500000
erro = 0.1  # para o valor zero
alpha = 2 + 0.0j
a = np.abs(alpha)

# Lista de situações com os diferentes estados de entrada para cada modo
situacoes = [
    ([np.pi, np.pi, 0, np.pi, np.pi, np.pi], 'resultados_condicao2_100mil_amostras_0p1_in_000_out_001_Geral_bosonic.csv'),
    ([np.pi, np.pi, 0, 0, 0, 0], 'resultados_condicao2_100mil_amostras_0p1_in_001_out_000_Geral_bosonic.csv'),
    ([np.pi, 0, np.pi, np.pi, np.pi, 0], 'resultados_condicao2_100mil_amostras_0p1_in_010_out_010_Geral_bosonic.csv'),
    ([np.pi, 0, 0, 0, 0, np.pi], 'resultados_condicao2_100mil_amostras_0p1_in_011_out_011_Geral_bosonic.csv'),

    ([0, np.pi, np.pi, np.pi, np.pi, 0], 'resultados_condicao2_100mil_amostras_0p1_in_100_out_100_Geral_bosonic.csv'),
    ([0, np.pi, 0, 0, 0, np.pi], 'resultados_condicao2_100mil_amostras_0p1_in_101_out_101_Geral_bosonic.csv'),
    ([0, 0, np.pi, np.pi, np.pi, np.pi], 'resultados_condicao2_100mil_amostras_0p1_in_110_out_111_Geral_bosonic.csv'),
    ([0, 0, np.pi, 0, 0, 0], 'resultados_condicao2_100mil_amostras_0p1_in_111_out_110_Geral_bosonic.csv'),

]

def simular_circuito(phase_config, output_file):
    resultados_condicao2 = []

    for _ in range(n_events):
        prog = sf.Program(n_modes)
        eng = sf.Engine("bosonic", backend_options={"cutoff_dim": 10})

        with prog.context as q:
            # Prepara os estados nos modos conforme a fase especificada
            Coherent(a, phase_config[0]) | q[0]
            Coherent(a, phase_config[1]) | q[1]
            Coherent(a, phase_config[2]) | q[2]
            Coherent(a, phase_config[3]) | q[3]
            Coherent(a, phase_config[4]) | q[4]
            Coherent(a, phase_config[5]) | q[5]

If you want help with diagnosing an error, please put the full error message below:

Strawberry Fields 0.23.0.
Phyton 3

And, finally, make sure to include the versions of your packages.

Hi @Antonio_Aguiar ,

The bosonic backend is based on linear combinations of Gaussians. This is based on the paper: Fast simulation of bosonic qubits via Gaussian functions in phase space. That papers has some mentions on accuracy, and mentions as well that cat states can be approximated to arbitrary precision.

We have three Strawberry Fields demos on the bosonic backed: introduction, Sampling quadratures of non-Gaussian states, and Studying realistic bosonic qubits. In this third demo you will notice the effect that having finite energy has in the result. If you know your finite-energy parameter, this can probably give you the information you need to calculate the accuracy for your specific problem. I encourage you to read the demos and the paper. The paper in particular talks about specific parameters that control the precision of the approximation.

Note: Remember that a cutoff_dim is not needed for the bosonic backend since it doesn’t use Fock states.

I hope this helps!