Swap-gate, SVD applied to MPS

,

Hello,

I am building an MPS alternating physical sites with “virtual” ancillary sites (vacuum modes); the goal is to simulate Beam Splitter interactions between physical modes in a Gaussian Boson Sampling scheme, where ancillary modes are for simulating losses at the end through BSs.

The BS application is modeled upon the official documentation, and per se it works fine. However I was trying to modify it to act on alternating modes as described above, and I followed the first proposal in the solution marked here, that is to contract-then-SVD in order to swap, apply the BS, swap back:

|mode>         |mode> }BS      |mode>
|vacuum>  =>   |mode> }BS  =>  |vacuum>
|mode>         |vacuum>        |mode>
|vacuum>       |vacuum>        |vacuum>

Doing so the first time (with the efficient swapping by SVD) between modes 1 and 3 goes fine, these are the resulting tensors:

ITensor ord=2: (dim=9|id=599|"n=1,Site") (dim=9|id=808|"U,Link") 
{norm=3.00 (Dense Real)}

ITensor ord=2: (dim=9|id=851|"n=2,Site") (dim=1|id=912|"U,Link") 
{norm=1.00 (Dense Real)}

ITensor ord=3: (dim=1|id=912|"U,Link") (dim=9|id=808|"U,Link") (dim=9|id=502|"n=3,Site") 
{norm=1.14 (Dense Real)}

ITensor ord=1: (dim=9|id=461|"n=4,Site") 
{norm=1.00 (Dense Real)}

But then if I try to do the same between now 1 and 2, to simulate losses, no swapping required, the BS does not work anymore, because the SVD gives memory errors.

So my question is: is this the wanted behaviour for the indices? Is the empty link index between 2 and 3 the issue? I don’t see how I could manage the indices differently to make it work.

Thank you so much, sorry but I am a complete beginner here.

EDIT: I solved it by using the combiner class, and combining the empty link index after the SVD with the respective site index, is this correct? The program now runs fine, not sure if this changes at all the numerical values I get in the end