diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff55267..88edbe7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: always_run: true - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files args: ['--maxkb=512'] @@ -31,22 +31,22 @@ repos: exclude: '^(ggml/|ggml-patches/|proto/riva-common/).*' - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 + rev: v22.1.8 hooks: - id: clang-format types_or: [c++, c, cuda] # ggml + vendored riva protos are upstream code — don't reformat. exclude: '^(ggml/|ggml-patches/|proto/riva-common/|build/|build-.*/).*' - - repo: https://github.com/psf/black - rev: 24.10.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.5.1 hooks: - id: black args: ['--skip-string-normalization', '--line-length=100'] exclude: '^(ggml/|proto/riva-common/|build/).*' - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 9.0.0b5 hooks: - id: isort name: isort (python) @@ -58,7 +58,7 @@ repos: - '--skip=build' - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.10.0.1 + rev: v0.11.0.1-1 hooks: - id: shellcheck args: ['--severity=warning'] diff --git a/app/health.cpp b/app/health.cpp index 865bada..d93e8ce 100644 --- a/app/health.cpp +++ b/app/health.cpp @@ -111,10 +111,11 @@ command_health(int argc, char** argv) { const auto retry_time = std::chrono::steady_clock::now(); if (retry_time >= deadline) break; - std::this_thread::sleep_for(std::min( - std::chrono::duration_cast( - std::chrono::milliseconds(250)), - deadline - retry_time)); + std::this_thread::sleep_for( + std::min( + std::chrono::duration_cast( + std::chrono::milliseconds(250)), + deadline - retry_time)); } while (true); return print_cli_error( "health", "not ready (" + last_error + ")", kCliExitRuntime, "not_ready"); diff --git a/conversion/asr.py b/conversion/asr.py index 08702fd..548726b 100644 --- a/conversion/asr.py +++ b/conversion/asr.py @@ -26,6 +26,7 @@ If `--head-type` is omitted, the head is auto-detected from the model_config.yaml inside the .nemo (presence of `joint` block ⇒ RNNT, `labels` only ⇒ CTC). """ + import math import re import sys diff --git a/conversion/pnc.py b/conversion/pnc.py index 1e8b17b..b81b05b 100644 --- a/conversion/pnc.py +++ b/conversion/pnc.py @@ -8,6 +8,7 @@ Emits arch="pnc": a BERT encoder + two token-classification heads (punct, capit) under the `pnc.*` namespace, plus the WordPiece vocab and label sets. """ + import tempfile from pathlib import Path from typing import Optional diff --git a/conversion/vad.py b/conversion/vad.py index bf4a1d4..b11e9f1 100644 --- a/conversion/vad.py +++ b/conversion/vad.py @@ -45,6 +45,7 @@ Both sources funnel through one emit routine keyed by the original silero state_dict tensor names. """ + import struct import sys from pathlib import Path diff --git a/src/asr/decoders/rnnt_modules.cpp b/src/asr/decoders/rnnt_modules.cpp index e4fded5..fd669af 100644 --- a/src/asr/decoders/rnnt_modules.cpp +++ b/src/asr/decoders/rnnt_modules.cpp @@ -245,8 +245,9 @@ RnntJointModule::build_joint_tail( auto logits = out_proj_->build_graph(session, act_bag, tc); if (B > 1) { auto l = logits.get_tensor(0); - logits.set_first_tensor(ggml_runtime::ggml_bf_tensor( - ggml_reshape_3d(bf_ctx.ctx, l.tensor, l.tensor->ne[0], T, B), l.buft)); + logits.set_first_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_reshape_3d(bf_ctx.ctx, l.tensor, l.tensor->ne[0], T, B), l.buft)); } if (argmax_only) { auto l = logits.get_tensor(0); diff --git a/src/asr/model.cpp b/src/asr/model.cpp index cac4953..05eca11 100644 --- a/src/asr/model.cpp +++ b/src/asr/model.cpp @@ -299,10 +299,12 @@ class RnntModel::RnntDecoderStages : public ggml_runtime::Module { auto c = s->model_tensor_container->get_tensor_by_name( rnnt_c_state_name(active_bank, i)); auto bf = tc->get_ctx_of_buffer_type(h.buft); - pred_in.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_get_rows(bf.ctx, h.tensor, slot_ids.tensor), h.buft)); - pred_in.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_get_rows(bf.ctx, c.tensor, slot_ids.tensor), c.buft)); + pred_in.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_get_rows(bf.ctx, h.tensor, slot_ids.tensor), h.buft)); + pred_in.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_get_rows(bf.ctx, c.tensor, slot_ids.tensor), c.buft)); } auto pred_out = pred_->build_graph(s, pred_in, tc); auto pred_proj = @@ -312,27 +314,31 @@ class RnntModel::RnntDecoderStages : public ggml_runtime::Module { ggml_runtime::TensorBag state_out; auto pred_state = s->model_tensor_container->get_tensor_by_name(kRnntPredProjectionState); - state_out.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_set_rows( - bf.ctx, pred_state.tensor, ggml_cont(bf.ctx, pred_proj.tensor), - slot_ids.tensor), - pred_proj.buft)); + state_out.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_set_rows( + bf.ctx, pred_state.tensor, ggml_cont(bf.ctx, pred_proj.tensor), + slot_ids.tensor), + pred_proj.buft)); for (int i = 0; i < cfg.pred_num_layers; i++) { auto h_dst = s->model_tensor_container->get_tensor_by_name( rnnt_h_state_name(candidate_bank, i)); auto c_dst = s->model_tensor_container->get_tensor_by_name( rnnt_c_state_name(candidate_bank, i)); - state_out.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_set_rows( - bf.ctx, h_dst.tensor, - ggml_cont(bf.ctx, pred_out.get_tensor(1 + 2 * i).tensor), slot_ids.tensor), - pred_out.get_tensor(1 + 2 * i).buft)); - state_out.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_set_rows( - bf.ctx, c_dst.tensor, - ggml_cont(bf.ctx, pred_out.get_tensor(1 + 2 * i + 1).tensor), - slot_ids.tensor), - pred_out.get_tensor(1 + 2 * i + 1).buft)); + state_out.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_set_rows( + bf.ctx, h_dst.tensor, + ggml_cont(bf.ctx, pred_out.get_tensor(1 + 2 * i).tensor), + slot_ids.tensor), + pred_out.get_tensor(1 + 2 * i).buft)); + state_out.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_set_rows( + bf.ctx, c_dst.tensor, + ggml_cont(bf.ctx, pred_out.get_tensor(1 + 2 * i + 1).tensor), + slot_ids.tensor), + pred_out.get_tensor(1 + 2 * i + 1).buft)); } if (!fused_tdt && !fused_rnnt) return state_out; diff --git a/src/asr/vad/silero_vad.cpp b/src/asr/vad/silero_vad.cpp index f95a359..9bd610d 100644 --- a/src/asr/vad/silero_vad.cpp +++ b/src/asr/vad/silero_vad.cpp @@ -178,10 +178,12 @@ class SileroVadModule : public ggml_runtime::Module { ggml_runtime::TensorBag out; out.add_tensor(ggml_runtime::ggml_bf_tensor(probabilities, buft)); // Commit the active recurrent-state rows in-graph. - out.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_set_rows(g, h_arena, ggml_cont(g, h_state), slot_ids.tensor), buft)); - out.add_tensor(ggml_runtime::ggml_bf_tensor( - ggml_set_rows(g, c_arena, ggml_cont(g, c_state), slot_ids.tensor), buft)); + out.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_set_rows(g, h_arena, ggml_cont(g, h_state), slot_ids.tensor), buft)); + out.add_tensor( + ggml_runtime::ggml_bf_tensor( + ggml_set_rows(g, c_arena, ggml_cont(g, c_state), slot_ids.tensor), buft)); return out; } diff --git a/tests/cpp/asr/test_endpointer.cpp b/tests/cpp/asr/test_endpointer.cpp index 7aea284..443c574 100644 --- a/tests/cpp/asr/test_endpointer.cpp +++ b/tests/cpp/asr/test_endpointer.cpp @@ -57,9 +57,9 @@ static void test_policy() { // Threshold 800 ms (riva default). The runner feeds (now_ms, last_speech_ms). { - VadEndpointer ep(VadEndpointerCfg{ - /*enable=*/true, /*vad_based=*/true, - /*stop_history_eou_ms=*/800.0f}); + VadEndpointer ep( + VadEndpointerCfg{/*enable=*/true, /*vad_based=*/true, + /*stop_history_eou_ms=*/800.0f}); // Speech up to 1000 ms, then silence. Poll every 100 ms. bool fired_before = false, fired_at = false, fired_after = false; for (double now = 1000.0; now < 1800.0; now += 100.0) // 0..800 ms silence diff --git a/tests/cpp/asr/test_postproc.cpp b/tests/cpp/asr/test_postproc.cpp index d533d61..37d414c 100644 --- a/tests/cpp/asr/test_postproc.cpp +++ b/tests/cpp/asr/test_postproc.cpp @@ -82,9 +82,10 @@ main() { check(prof.mask("oh darn the heck") == "oh d*** the h***", "whole-word masking"); // UTF-8 masking keeps the first codepoint and emits one '*' per remaining codepoint. check( - prof.mask("\xE0\xA4\xAF\xE0\xA4\xB9 " // यह - "\xE0\xA4\xA8\xE0\xA4\xA6\xE0\xA5\x80 " // नदी - "\xE0\xA4\xB9\xE0\xA5\x88") == // है + prof.mask( + "\xE0\xA4\xAF\xE0\xA4\xB9 " // यह + "\xE0\xA4\xA8\xE0\xA4\xA6\xE0\xA5\x80 " // नदी + "\xE0\xA4\xB9\xE0\xA5\x88") == // है "\xE0\xA4\xAF\xE0\xA4\xB9 \xE0\xA4\xA8** \xE0\xA4\xB9\xE0\xA5\x88", "UTF-8 (Devanagari) word masked per codepoint, valid UTF-8"); check(prof.mask("darn, it") == "d***, it", "trailing punctuation preserved"); diff --git a/tests/cpp/tts/test_grpc_tts_config.cpp b/tests/cpp/tts/test_grpc_tts_config.cpp index 58430e1..98a1f01 100644 --- a/tests/cpp/tts/test_grpc_tts_config.cpp +++ b/tests/cpp/tts/test_grpc_tts_config.cpp @@ -88,8 +88,9 @@ main() { source_path("models/magpie_tts_multilingual_357m/magpie_tts_multilingual_357m.f16.gguf")); const std::string codec_model = env_or_default( "NEMO_SPEECH_TEST_TTS_CODEC_MODEL", - source_path("models/nemo_nano_codec_22khz_1.89kbps_21.5fps/" - "nemo_nano_codec_22khz_1.89kbps_21.5fps.decoder.f16.gguf")); + source_path( + "models/nemo_nano_codec_22khz_1.89kbps_21.5fps/" + "nemo_nano_codec_22khz_1.89kbps_21.5fps.decoder.f16.gguf")); const std::string tokenizer_dir = env_or_default( "NEMO_SPEECH_TEST_TTS_TOKENIZER_DIR", source_path("models/magpie_tts_multilingual_357m/extracted"));