I put a 7-speed onto a Wahoo Kickr core. I started with a 4.5mm spacer and found it was not enough. I then added another 1mm and that made it snug and aligned well with my drivetrain. Start with 4.5mm and see if that is sufficient. If the cassette slides a little then add however much more is needed.
You will likely need to file 2 notches into the 4.5mm spacer for the two rivets that protrude through the back of the cassette. See this forum discussion in which I included photos of the spacer. I remember seeing a video that showed this concept but I can’t find it now.