Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid repeated transposition when using time-homogenous transition matrix #106

Closed
THargreaves opened this issue Sep 27, 2024 · 2 comments
Closed

Comments

@THargreaves
Copy link
Contributor

I wouldn't normally make this issue for fear it feels nit-picky, but given that speed is a primary focus of this package I thought I would mention it to see if there is interest in me making this change.

Currently the state prediction step is:

trans = transition_matrix(hmm, control_seq[t])
αₜ, αₜ₊₁ = view(α, :, t), view(α, :, t + 1)
mul!(αₜ₊₁, transpose(trans), αₜ)

This means that this transposition is performed every time step leading to inefficient memory access at each filtering step. For the time-homogenous HMM it might make sense to cache a copy of the transposed matrix.

A rough implementation of this change led to a roughly 10–15% reduction on the package benchmarks for the forward algorithm on my laptop.

@gdalle
Copy link
Owner

gdalle commented Sep 27, 2024

Good idea, thanks!

@gdalle
Copy link
Owner

gdalle commented Sep 29, 2024

As discussed in #107, this is not necessarily going to bring speedups, so let's close it for now. If someone finds an MWE with a clear performance boost we'll reopen.

@gdalle gdalle closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2024
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 a pull request may close this issue.

2 participants