@ptrblck Yep, that was exactly what I was doing wrong. Thanks a lot for pointing out the problem!
On a side note, is this how people normally write time series models? I mean detaching the temporary variables and writing so many register_buffers seem quite inelegant!