Possible Paraformer timestamp issues in the Hugging Face full pipeline and GPU dynamic batching #3525
Replies: 1 comment
|
Thank you for the unusually complete report and for separating the two mechanisms. I independently checked this against FunASR Both findings are reproducible:
Please split these into two independent PRs if you are willing; that will keep review and rollback boundaries clear:
Fast CPU-only, network-free regressions covering those contracts are preferable for CI; the real-model H100 reproduction can remain integration evidence. Please keep EParaformer, English/BPE timestamp behavior, and any broader Paraformer-family flag normalization out of these two patches unless independently reproduced. Link both PRs back here. This confirms the two bugs and their reviewable scope, but each patch will still need its own exact-head tests and review before merge. |
Uh oh!
There was an error while loading. Please reload this page.
I originally picked this up from the Hugging Face Forum thread here:
FunASR using Hugging Face Hub with paraformer-zh errors
The text below was AI-generated from my notes and test results. I ran and checked the reproductions, comparisons, and linked notebooks myself.
I may be misunderstanding some intended API semantics, but I can reproducibly separate what looks like two timestamp-related issues in the current FunASR Paraformer path.
Since new Issues currently appear to be restricted in this repository, I am posting the reproduction here first. If these should become separate Issues or PRs, I can split them.
The setup itself seems intended to be supported: the
funasr/paraformer-zhHugging Face model card documents a full pipeline with VAD, punctuation, and speaker diarization, with timestamps and speaker labels in the output.Environment
The real-model reproduction was run with:
The full environment and executed outputs are available in the public notebook linked below.
1. Possible timestamp-request propagation mismatch
With the Hugging Face Paraformer full pipeline, timestamps were missing unless I explicitly added:
For example:
I reproduced the timestamp recovery on both CPU and T4.
What makes this look like an internal integration mismatch is that current
AutoModelrequests timestamps when a speaker model is present using:while plain
Paraformer.inference()uses:for its timestamp-generation branch.
So the effective path appears to be roughly:
The runtime A/B was:
If
pred_timestampis intentionally a separate user-facing requirement for Paraformer, then perhaps this is mainly a documentation/API-contract issue.If the full speaker pipeline is expected to request the timestamp automatically, then this looks more like a flag-propagation mismatch.
There is an older related report involving missing Paraformer timestamps with VAD:
Issue #1747: paraformer-en + VAD result has no
timestampI do not assume that issue has exactly the same root cause, but it seems related enough to mention.
Secondary schema symptom
When the timestamp path was missing, I also observed a different
sentence_infofallback schema.The fallback record contained:
"sentence"while the normal timestamp-enabled path contained the documented:
"text"This can turn the earlier timestamp failure into a later:
when application code follows the model-card example:
So I would treat that
KeyErroras a secondary symptom rather than the first failure.2. Separate GPU dynamic-batch timestamp-padding issue
After explicitly enabling
pred_timestamp=True, I found a second issue.This one is specifically associated with unequal-length VAD segments grouped into an ordinary GPU dynamic batch.
I used an exact public 20.000 s AISHELL-4 crop.
Input identity:
Observed result:
The abnormal timestamp tail therefore was:
Internal trace
For the unequal-length dynamic batch:
Before the fix, the timestamp helper received:
For the runtime predictor:
the valid timestamp extent is the per-sample encoder length plus one CIF tail frame:
For the shortest sample:
Plain Paraformer invokes the timestamp helper with
upsample_rate=1, corresponding to approximately 60 ms per frame in this path:The observed timestamp overshoot was approximately:
That was the first clue, but I also tested the mechanism directly.
3. Timestamp-only causal check
I kept the ordinary GPU dynamic batch unchanged.
The only behavioral modification was to trim the tensors immediately before timestamp conversion to the valid per-sample extent.
Recognition itself was not changed.
The timestamp-helper widths became:
The resulting timestamps changed from:
to:
At the same time:
This makes me suspect that the batch-maximum padded timestamp tensor extent is leaking into the timestamp conversion for shorter samples.
Current plain Paraformer passes:
without trimming those tensors using that sample's
encoder_out_lens[i]:funasr/models/paraformer/model.pyThe timestamp helper then derives its frame extent from the received tensor:
funasr/utils/timestamp_tools.pyThere is also precedent elsewhere in FunASR for trimming timestamp-predictor tensors using a per-sample encoder length before calling the same helper, for example in BiCIF Paraformer:
funasr/models/bicif_paraformer/model.py4. Narrow patch that passed the real-model reproduction
The smallest patch I tested successfully was local to the Paraformer timestamp call site.
The guard is deliberately conservative:
tail_mask is True;encoder_out_lens[i];tail_threshold > 0;tail_mask=False;tail_maskattribute.The patch was applied to the installed FunASR source, tested from fresh Python processes, and then the original source was restored.
Real-model result:
5. CPU-only regression is also possible
The real-model reproduction requires the model downloads and a GPU, so I do not think it needs to become a CI test.
A small deterministic regression can exercise the real
Paraformer.inference()call site with dummy encoder/predictor/decoder outputs and mock only the timestamp helper.For example, with:
the current call site produces:
After the narrow patch:
while the conservative cases remain unchanged:
So this can be covered by a fast CPU-only, network-free regression rather than a heavyweight integration test.
6. Public reproducer
I put the complete reproduction in two notebooks:
The notebook includes:
7. Scope / things I am not claiming
I would keep this fix narrow.
I have not established that the same patch is safe for:
tail_mask=False;tail_maskcontract;I also do not interpret successful execution of the speaker pipeline as proof that speaker-diarization accuracy is fixed. I did not measure DER.
Similarly, although automatically normalizing:
into:
looks tempting for the first issue, I would not make that a broad Paraformer-family change without separate compatibility testing.
Questions for maintainers
The two main questions I have are:
For plain Paraformer, is
pred_timestampintended to be automatically enabled whenAutoModelrequests timestamps for the speaker pipeline?If yes, the first finding may be a straightforward flag-propagation bug.
For
CifPredictorV2(tail_mask=True), is trimmingpre_peak_index[i]/alphas[i]toencoder_out_lens[i] + tail_framebeforets_prediction_lfr6_standard()consistent with the intended timestamp contract?The real-model and deterministic regressions both support this narrow behavior, but I would prefer confirmation before treating it as a general upstream fix.
If these are better tracked separately, I am happy to separate:
into distinct bug reports / PR scopes.
All reactions