hi all, and especially @jessegrabowski (following up on PR #8333!)
a couple of weeks back i made a regime switching volatility stress tester using 100k synthetic equity tick returns to check out PR #8333 for the new streaming trainer pipeline. the DataLoader → Trainer pipeline performed really well, ELBO was converged perfectly but parameter recovery failed completely. i used the NormalMixture model and the regime probabilities simply went to 50/50 due to the fact that mean field ADVI factorizes away the latent state sequence. the model had zero temporal memory, hence no way to know what regime the ticks belong to.
what i said at the time is that although it was not an issue in the Trainer itself, it opened up another interesting problem for me to look at, and as suggested by @zaxtax, it led me to investigate the pymc-extras state-space module. i’ve gone through the whole filter stack (StandardFilter, UnivariateFilter, KalmanSmoother, SquareRootFilter, and others), as well as the BayesianSARIMAX quite thoroughly.
based on all this research, i feel like i have stumbled upon a hole that i would really like to plug.
the SquareRootFilter (cholesky decomposition) is very robust numerically when dealing with the full batch case. however, currently, there is no way to carry the cholesky decomposition of the filter between chunks in the stream mode, which means that the filter resets itself each time a new batch arrives. on top of that, the KalmanSmoother needs a backwards pass over the entire dataset, which implies that solving the problem for the filter won’t be enough for the smoother.
the filtered state is your best guess given everything you’ve seen so far; however, the smoothed state (which uses information about the future too) is way more tight and what you need for retrospective regime detection and latent factor extraction. there’s a whole family of smoothers called fixed-lag smoothers that do something like this in the online fashion, using information only L steps behind, and, as far as i understand, there’s nothing like that in pymc-extras at all.
what i would really like to research is finding the equations that would allow for the sequential cholesky decomposition update across chunk boundaries, thus making the filter keep its memory indefinitely, plus finding the equations for a fixed-lag smoother that could be done in an online fashion. also, finding online EM updates for the parameters of the BayesianSARIMAX process so that the model itself could be updated in an online fashion without having to refit it via MCMC. this is precisely the thing i referred to in my PR comment.
it is interesting that i also found some information about the GSoC 2026 project ‘Scalable Online Bayesian State Space Models’ that deals with these questions, and this is what led me to the desire to look into this question more closely.
but before moving on to this, does this way of action makes sense considering the current state of the library? which particular point should i focus on first (the propagation of cholesky decomposition or the fixed-lag smoother or online EM)?
looking forward to implementing something valuable for the community!