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))]