Post selection problem

Hey I want to implement single qubit gates on the X8 hardware, first I’m trying to do so in SF.
The Idea is to generate the entangled modes using the S2 gate and then by post selecting 0/1 on the idler modes stay with a legitimate state in the signal mode (when I encode my qubit data using two modes in the singal modes with 1 photon in them)

I use the line:
ops.MeasureFock(select=(0/1)) | q[2]

To post select 0/1 photons and it works fine in SF (will it also work on the X8?) How do I get a table like “results.samples” that include only the desired post selected results?

In the X8 platform there is also a problem Im facing, even in very simple codes such as:

import strawberryfields as sf
from strawberryfields import ops
from strawberryfields import RemoteEngine
from collections import Counter

Definitions

prog = sf.Program(8, name=“remote_job1”)

with prog.context as q:

ops.S2gate(1.0) | (q[0], q[4])


ops.Rgate(-np.pi/2) | q[1]
ops.BSgate(np.pi/4,np.pi/2) | (q[0], q[1])
ops.Rgate(-np.pi/2) | q[1]


ops.MeasureFock() | q

##Get results##
eng = RemoteEngine(“X8”)
results = eng.run(prog, shots=20)
print(results.samples)

I get the error “There can be no operations before the S2gates.”
But clearly in the code trhere is no operation happening before the S2gates, what is the source of that?

Thank you in advance :slight_smile:

Hi @Ron_Ruimy — Welcome to the forum. As for your first question,

To post select 0/1 photons and it works fine in SF (will it also work on the X8?) How do I get a table like “results.samples” that include only the desired post selected results?

The hardware does not currently allow for post selection. If you simulate the results using the gaussian backend you will have to filter the results yourself after obtaining all the samples.

As for your second question, I believe you might want to compile your program using the Xunitary compiler before sending it to a remote engine.

1 Like

Hi @Ron_Ruimy after looking into this further, leveraging Xcov will actually kick out the right error message which says: the applied unitary on modes 0-3 must be identical to the unitary applied to modes 4-7.

We suggest taking a look at the operation decorator which can help make this easier. Found here

I tried using the Xcov compiler and really this new error message pops out
However applying the same unitary gates on modes 0-3 and 4-7 destroys what I want to achieve. Since I want to generate qubit states on modes 0-3 and “post select” on modes 4-7

say I want to create the initial state 1010 on modes 0-3 what I’m doing is applying two modes squeezing on 0+4 and 2+6, then at the end when I measure everything I will keep only the results where modes 2+6 are measured with 1 photon (and then I can understand in retro respective that I had the correct initial condition on modes 0-3), isn’t doing something like this possible on the X8?

Hey @Ron_Ruimy!

However applying the same unitary gates on modes 0-3 and 4-7 destroys what I want to achieve.

Unfortunately this is a current limitation of the X8 chip. You can get more details on the device here. Generally you can think of the device as performing a type of Gaussian boson sampling - it is not currently general purpose but there may be some interesting problems that can be encoded.

Have you tried running your code on simulator?