Simple math to speed up GDN prefill

In this short note we will briefly derive a helpful identity to speedup GDN prefill algorithm. In my simple Torch implementation of the algorithm that gave already a good speedup of about 18%. I assume for custom CUDA C++ kernel the gains can even be more pronounced. Please read my previous post on GDN for background. Reminder The state transition for GDN is as follows: S t = S t − 1 ( α t ( I − β…