Closed jonn-smith closed 1 year ago
@jmschrei Do you have thoughts on this? If necessary I can post some data to reproduce the issue that this fixes.
Hi @jonn-smith
I'm currently rewriting pomegranate, in it's entirety, in PyTorch. Because of this, I'm not going to be able to merge bug fixes like this. Thanks for taking the time to look into this issue and debug it, though!
Thank you for your contribution. However, pomegranate has recently been rewritten from the ground up to use PyTorch instead of Cython, and so this PR is unfortunately out of date and will be closed.
In the code for the Viterbi path calculation, there was a heap overflow in the
path
variable as the final path is being traced back (hmm.pyx:2194
). This seems to only happen with some extremely long and repetitive sequences in my model.Valgrind reports it as follows:
Context in
hmm.c:25865
:This PR introduces a small multiplier in the memory allocation for
path
. This heuristic fixes the issue and Valgrind no longer reports the error (see attached before and after valgrind logs). valgrind.jts_hmm_patch.log valgrind.v0.14.8.logThis PR also renames a few variables for readability and has an updated the signature for
_viterbi
to include the length of thepath
variable (inint
s).I ran valgrind with the following options after recompiling python in debug mode and following the steps here:
Please let me know what you think.