PyTorch memory usage keeps increasing

I’m running GitHub - brandon929/FramePack: FramePack for macOS and Apple Silicon (FramePack video generation) on my M4 Mac Studio 128 GB ram using the nightly PyTorch libraries and while it works, the amount of memory used is not only huge, but keeps growing after every video generation. It starts out using around 85 GB per video and then each subsequent one uses another 20 GB or so until the point where my Mac needs to start swapping and the memory pressure goes into the yellow.

Basically I have to kill the server after every use or I run out of memory.

I asked the author and he said he’s not seeing that. He says it stays at a fairly stable 75 GB. Is there some kind of debugging I can enable to see where all the memory is going?