Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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)
Expand All @@ -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']
Expand Down
9 changes: 5 additions & 4 deletions app/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::steady_clock::duration>(
std::chrono::milliseconds(250)),
deadline - retry_time));
std::this_thread::sleep_for(
std::min(
std::chrono::duration_cast<std::chrono::steady_clock::duration>(
std::chrono::milliseconds(250)),
deadline - retry_time));
} while (true);
return print_cli_error(
"health", "not ready (" + last_error + ")", kCliExitRuntime, "not_ready");
Expand Down
1 change: 1 addition & 0 deletions conversion/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions conversion/pnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions conversion/vad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/asr/decoders/rnnt_modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
46 changes: 26 additions & 20 deletions src/asr/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions src/asr/vad/silero_vad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cpp/asr/test_endpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/cpp/asr/test_postproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 3 additions & 2 deletions tests/cpp/tts/test_grpc_tts_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down