When punc_id_list is longer than timestamp_postprocessed (a mismatch
the function already logs a warning for), the entries past the end of
timestamp_postprocessed get timestamp=None from zip_longest. For the
sentence that starts on one of those entries, the is_sentence_start
flag was consumed unconditionally on the first iteration regardless of
whether timestamp was None, so sentence_start kept whatever value was
left over from the previous, unrelated sentence instead of being
reported as unknown.
The sibling function timestamp_sentence already handles this correctly
by resetting sentence_start to None after each flush and only setting
it once a real timestamp shows up. Mirror that logic here instead of
the one-shot is_sentence_start flag.
Before: a trailing sentence whose first word has no timestamp gets
start reused from the previous sentence (wrong, looks valid).
After: start is None for that sentence, matching timestamp_sentence.
* fix(amp): resolve autocast/GradScaler device type for non-CUDA accelerators
funasr/utils/amp.py pinned device_type="cuda" in the torch.amp compatibility shim, so on Ascend NPU (and XPU/MPS) builds torch.amp only warned "CUDA is not available ... Disabling autocast" and the context became a no-op: use_fp16/use_bf16 training silently ran in float32 and GradScaler(enabled=True) was silently disabled.
Resolve the device type from the running accelerator (torch.accelerator), the same policy funasr/models/fun_asr_nano/device_utils.py already applies to the inference path, and keep "cuda" as the historical no-op default when no accelerator is available so CPU behaviour is unchanged. GradScaler prefers an accelerator-specific implementation (e.g. torch.npu.amp.GradScaler) when one exists.
Signed-off-by: li-lizhe <[email protected]>
* fix(amp): honour an explicit device before choosing the GradScaler implementation
An explicit device (positional or keyword) now selects the scaler for that
device instead of the active accelerator, so GradScaler(device="cpu") no longer
reaches torch.npu.amp.GradScaler (its constructor has no device parameter and
raised TypeError) and GradScaler("cpu") no longer consumed "cpu" as init_scale.
The device argument is dropped before dispatching to an accelerator-specific
scaler and forwarded unchanged to the generic one; torch.cpu.amp is no longer
mistaken for a backend-specific scaler. Explicit keyword/positional/torch.device
coverage added.
Signed-off-by: li-lizhe <[email protected]>
* fix(amp): bind the generic GradScaler signature before native dispatch
The accelerator scalers do not share the generic torch.amp.GradScaler
positional order: torch_npu inserts `dynamic` before `enabled`, so
forwarding the caller's positional tail unchanged turned
GradScaler("npu", 1024.0, 2.0, 0.5, 2000, False) into an enabled static
scaler while the keyword form kept working. Bind a call written against
the generic signature to its parameter names first, drop the `device`
the accelerator constructor does not accept, and forward the rest by
name. Calls that do not match the generic signature keep the previous
plain re-export behaviour.
Tests: cover the positional enabled=False/True tail against a strict
torch_npu-signature stand-in (a *args/**kwargs recorder cannot detect a
shifted argument slot).
Signed-off-by: li-lizhe <[email protected]>
* docs(amp): narrow the _generic_arguments docstring claim
Signed-off-by: li-lizhe <[email protected]>
---------
Signed-off-by: li-lizhe <[email protected]>
* fix: use y.device instead of hardcoded .cuda() in data2vec compute_var
In compute_var(), zc = torch.tensor(y.size(0)).cuda() unconditionally
calls .cuda() which raises RuntimeError: Torch not compiled with CUDA
enabled on non-CUDA accelerators (Ascend NPU, XPU, HPU, MPS).
Use device=y.device to respect the input tensor's current device.
Signed-off-by: li-lizhe <[email protected]>
* test: add CPU/Gloo regression tests for data2vec compute_var
Cover both the uninitialized (no process group) branch and a real
2-rank Gloo process group with unequal local row counts, pinning the
device-agnostic contract introduced in the parent commit (PR #3710).
Signed-off-by: li-lizhe <[email protected]>
* fix(test): resolve compute_var import and f32_worker spawn pickle
* fix(test): ensure Manager and workers are cleaned up on failure paths
join(timeout) does not terminate a still-running worker, so a crashed or
hung rank could leak a subprocess on test failure. Wrap the two-rank
runner in try/finally that terminate()+join()s any alive worker and shuts
down the Manager.
Signed-off-by: li-lizhe <[email protected]>
---------
Signed-off-by: li-lizhe <[email protected]>
Apply ncpu to BLAS without rolling back torch OpenMP settings, compute only the required leading spectral pairs, and add regression coverage for repeated AutoModel construction and process-wide thread limits.
Prepare the 1.4.16 Python release, synchronize four-language release entry points, and make the native Transformers site contract follow the current package version.
Signed-off-by: LauraGPT <[email protected]>
Retain the contributor alias cleanup and remove the NumPy cap with verified CPU dependency, frontend, masking and clustering coverage.
NumPy 1.26.4 and 2.4.0 each pass 23 exact-head CI tests and 77 local tests plus 184 subtests. Existing EEND mel calls now use keyword arguments for modern librosa.
The related installation issue remains open pending published-package and reporter re-test.
Co-authored-by: linhongyu510 <[email protected]>
Signed-off-by: zhifu gao <[email protected]>