Skip to content

Fix off-by-one bugs - #466

Merged
slinderman merged 24 commits into
probml:mainfrom
nkbranigan:fix_off_by_one
Oct 11, 2026
Merged

slinderman merged 24 commits into
probml:mainfrom
nkbranigan:fix_off_by_one

Conversation

@nkbranigan

@nkbranigan nkbranigan commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator
  • Fixes [BUG] Incorrect summary statistics in LinearGaussianConjugateSSM.fit_blocked_gibbs #416 and related off-by-one bugs for time-varying inputs and parameters
    • Problem: Most of Dynamax uses the convention that latent states at $t$ depend on inputs and parameters at $t$, but in some parts the latent states at $t$ depended on inputs and parameters at $t-1$
  • Fixes additional bugs revealed during testing:
    • forecast outputs were all one time step too early
    • Parallel posterior sampling omitted inputs in its backward pass (previously would have crashed)
    • UKF indexed the wrong dimension for a time-varying dynamics covariance (previously would have crashed)
    • fixed_lag_smoother_hmm.ipynb used old API

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@nkbranigan
nkbranigan force-pushed the fix_off_by_one branch 3 times, most recently from 5e98234 to ad113e4 Compare October 5, 2026 00:31
@nkbranigan
nkbranigan marked this pull request as ready for review October 6, 2026 03:34

@slinderman slinderman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking all of these off-by-one errors down! Do the changes to the filtering code to special-case the last time step with predict=False lead to longer compilation times?

@slinderman
slinderman merged commit 09a6fc5 into probml:main Oct 11, 2026
8 checks passed
@nkbranigan
nkbranigan deleted the fix_off_by_one branch October 11, 2026 18:44
@nkbranigan

Copy link
Copy Markdown
Collaborator Author

Thank you for your review Scott! You’ve caught an issue I missed. The filtering changes do lead to longer compilation. For lgssm_filter, this PR is slower on my machine by ~50 ms with an outer jit (as in model.fit_em), and by ~500 ms with no outer jit (as in model.filter). The good news is that I think there’s a simple fix that restores compile times to what they were before this PR: #469.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Incorrect summary statistics in LinearGaussianConjugateSSM.fit_blocked_gibbs

2 participants