Backend.prob gives different results with respect to analyzer

We computed the output probabilities of an optical circuit by using both the analyzer algorithm and the method “prob” of the backend SLOS.

We noticed that the results of the analyzer (with or without postselection/heraliding) are different with respect to those obtained with the prob method. We detail here below how we implemented the code.

We are doing these tests because we tried to obtain the probabilities amplitudes by using probampli method, that has the same problem of prob, since prob = abs(probampli)**2. Is there any way to get the amplitude probabilities directly with the Analyzer?

import perceval as pcvl
import perceval.components as comp
import numpy as np

from perceval.components import catalog
from perceval.converters import QiskitConverter

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

nqubits = 2
circ = QuantumCircuit(nqubits)
circ.h(0)
circ.cx(0,1)

qiskit_converter = QiskitConverter(catalog, backend_name="Naive")
quantum_processor = qiskit_converter.convert(circ, use_postselection = False)
u = quantum_processor.linear_circuit()


u = u.compute_unitary(use_symbolic=False)
ub = (pcvl.Circuit(2)
      // pcvl.BS(theta=pcvl.Parameter("theta"))
      // (0, pcvl.PS(phi=pcvl.Parameter("φ_a"))))

pc = pcvl.Circuit.decomposition(u, ub, shape="triangle")

#WITH ANALYZER

cnot_processor = pcvl.Processor("SLOS", pc)

input_state = pcvl.BasicState([1, 0, 1, 0, 0, 1, 0, 1])

output_states = {
pcvl.BasicState([1, 0, 1, 0, 0, 1, 0, 1]): "00", pcvl.BasicState([1, 0, 0, 1, 0, 1, 0, 1]): "01", pcvl.BasicState([0, 1, 1, 0, 0, 1, 0, 1]): "10", pcvl.BasicState([0, 1, 0, 1, 0, 1, 0, 1]): "11"
}

analyzer = pcvl.algorithm.Analyzer(cnot_processor, [input_state], output_states = output_states)
p = analyzer.compute()


# WITH THE PROB METHOD 

backend = pcvl.backends.SLOSBackend(pc)

output_states = [
pcvl.BasicState([1, 0, 1, 0, 0, 1, 0, 1]), pcvl.BasicState([1, 0, 0, 1, 0, 1, 0, 1]), pcvl.BasicState([0, 1, 1, 0, 0, 1, 0, 1]), pcvl.BasicState([0, 1, 0, 1, 0, 1, 0, 1])]

probs = [backend.prob(input_state,output_states[i]) for i in range (0,len(output_states))]

Hi,

Thanks for your message.

The SLOS prob and probampli methods output the raw probability/amplitude of an input vs an output state. If you need this raw data in a non-noisy simulation, you should definitely go for it, instead of using the Analyzer. This avoids unwanted interactions with other systems (for instance the physical filtering which post-selects on the number of detected photons).

Now, when you need to introduce heralding/post-selection or an imperfect source, you have to use a Processor. However a processor aims at representing an actual QPU which is unable to output amplitudes. So, we implemented the Processor without the ability to produce an amplitude distribution.

On the different results between a backend call and the analyzer:
Starting from Perceval 0.7, the analyzer wants to be smart and filters out output states he sees as unwanted. In your example code, as you’re measuring output states with 4 photons each, the Analyzer will filter output states where 0 to 3 photons are detected on threshold detectors.
This is related to the mode_post_selection feature of the Processor. For more information, please see : Processor — perceval 0.7.3 documentation

We are aware that this assumption of threshold detection is hidden from the user and creates unexpected results. So we’re improving it for Perceval 0.8.0 and an Analyzer with a non-noisy processor will output raw probabilities again.

Hi Eric,

thank you for your reply.

Let us explain what we observed so far.

  1. When we use analyzer with postselection/heralding then we get some output probabilities of the qubit states and the performance (for example for the postselected CNOT gate performance = 1/9).

  2. When instead we use the analyzer without postselection/heralding we get a performance of one and a value for the output probabilities that when divided by the previous performance in 1) is equal to the probabilities that we obtained in 1).

This is exactly what we expect.

However, if we compute the output probabilities by using the prob method and divide the results by the performance in 1), we do not get the same output probabilities in 1). In fact, it seems that the correct factor is approximately the performance in 1) squared.

We need for our purposes to get the probabilities amplitude for the qubit states taking into account postselection/heralding.

Thank you for your help