Context I am trying to use the sf.fock engine to do the following: I have 4 concurrent modes. Each iteration, I apply an interferometer to all 4 modes and then I measure the first 2 modes. So actually the last two modes of my system get feedbacked every iteration.

I get the following error: ValueError: Number of measurement operators must match number of spatial modes. What am I doing wrong?

Hi @Robbe — Currently time-domain programs can only be run on the Gaussian backend. Admittedly the error message you are getting is completely uninformative; it is trying to find MeasureHomodyne statements inside the program and failing to do so. Would be grateful if you could start an issue in the SF repo.

First I tried measuring a wire and then resetting a number of photons to that wire to do some calculations (to do the next time iteration). That gave an error saying that all operations must be in front of the detectors. I suppose this is a result of the ‘delayed measurement principle’, but doesn’t this limit time domain calculations?

Thank you for your answer on the repo issue. I still have a few questions:

I’m not quite sure why I need to use N=[2,2] instead of N=4. What’s the difference between spatial modes and concurrent modes? I don’t see how I can split my 4 modes in 2 bands of 2 modes, because each iteration my interferometer works on all 4 modes.

Does the shift_by function in the time domain tutorial give possible workaround that doesn’t require the local files to be changed? Or is the amount of time iterations then limited by the number of wires? (In other words: is this just the same as the ‘brute force’ implementation that I mentioned in my last question?)

Could TDMprogram also be used in PennyLane in some way (to enable training the parameters of the interferometer? Do you know if/when it would be added to PennyLane?

You have two spatial modes because you have two measurements at the end. The number of spatial modes is equivalent to the number of modes that are measured inside each time-domain iteration.

You can in principle write a regular sf.Program and shift the modes manually, however, we have not given much thought to how things would work in the Fock backends and cannot guarantee correct behaviour.

Likely not, at least at the moment. TDMPrograms have (stochastic-outcome) measurements at the end which are incompatible with differentiability.