Add an exact structured Viterbi backend for CREPE smoothing#108
Open
ssmall256 wants to merge 1 commit intomarl:masterfrom
Open
Add an exact structured Viterbi backend for CREPE smoothing#108ssmall256 wants to merge 1 commit intomarl:masterfrom
ssmall256 wants to merge 1 commit intomarl:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an exact structured Viterbi backend to CREPE's optional temporal
smoothing step while preserving the current
hmmlearnimplementation as thedefault.
The patch is intentionally conservative:
What This Adds
crepe.predict(..., viterbi=True, viterbi_impl="legacy")hmmlearnpathcrepe.predict(..., viterbi=True, viterbi_impl="fast")viterbi_implsurface forprocess_file(...)--viterbi-impl {legacy,fast}scripts/benchmark_viterbi.pyWhy
CREPE's optional smoothing stage already uses a local triangular transition
prior over the
360pitch states, but the current implementation still routesthrough a generic dense
hmmlearn.CategoricalHMMdecode.This PR keeps the same transition probabilities, the same emission model, and
the same decoded path, but evaluates the recurrence only over reachable
predecessor states.
This is an exact implementation change, not an approximation.
Benchmark Notes
Local measurements showed a consistent decoder-core win.
Synthetic decoder core:
512frames:41.684 mslegacy ->12.210 msfast3.41x2048frames:162.994 mslegacy ->48.397 msfast3.37xReal activation benchmark on the bundled
tests/sweep.wavclip using thetinymodel:276frames):22.372 mslegacy ->6.445 msfast3.47xpredict(..., viterbi=True):97.782 mslegacy ->79.043 msfast1.24xI am not using those measurements to argue for an immediate default change in
this PR. The goal here is to land the exact fast path explicitly first.
Parity
On the exercised local workloads, parity was exact for:
hmmlearnsmootherFor the real sweep activation, the decoded cents arrays were exactly equal.
Validation
Commands used locally:
Reviewer Notes
viterbi_impl="legacy"viterbi_impl="fast"viterbiboolean remains unchangedimplementation should move after broader review
Scope
This PR is intentionally limited to the optional smoothing stage. It does not
change the CNN model, training code, or the non-Viterbi local-average decode
path.