Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Summary
Upstream NeMo (2025) shipped a complete production streaming inference framework at nemo.collections.asr.inference that solves many problems we fixed manually in PRs #2 and #4. We should rebase our serving layer on this framework to leverage upstream capabilities while preserving our thread-safety and performance fixes.
What upstream provides that we currently reimplement
| Capability | Our implementation (gpu_worker.py) | Upstream (CacheAwareRNNTPipeline) |
|---|---|---|
| Chunk buffering | Manual 5120-sample accumulation | BatchedCacheFeatureBufferer with mel-spec caching |
| Final transcript | last_partial workaround for empty final_transcript |
TranscribeStepOutput with structured final/partial/current_step |
| Endpointing | Idle timeout only (no speech-based EOU) | RNNTGreedyEndpointing (800ms window, configurable) |
| Multi-stream batching | 1 stream per inference step | ContinuousBatchedRequestStreamer (batch_size=64, num_slots=256) |
| ITN | None | StreamingTextProcessor with inverse text normalization |
| Confidence scores | None | Entropy/max_prob confidence estimation |
| Latency measurement | None | LAAL (Length-Aware Average Lagging) |
| Session lifecycle | Manual dict-based sessions | PipelineInterface with open/close_session, state pool |
| Cache management | Manual encoder cache tracking | CacheAwareContextManager with slot-based pooling |
| Prompt vectors | Manual one-hot construction | _build_prompt_vectors() with prompt config validation |
| Per-stream biasing | None | enable_per_stream_biasing in decoder |
Key upstream files
nemo/collections/asr/inference/pipelines/cache_aware_rnnt_pipeline.py— main pipelinenemo/collections/asr/inference/pipelines/base_pipeline.py— session lifecycle, state poolnemo/collections/asr/inference/pipelines/pipeline_interface.py— interface contractnemo/collections/asr/inference/model_wrappers/cache_aware_rnnt_inference_wrapper.py— model wrapper withexecute_step()nemo/collections/asr/inference/streaming/— buffering, decoders, endpointing, framing, statenemo/collections/asr/inference/factory/pipeline_builder.py— factory patternexamples/asr/conf/asr_streaming_inference/cache_aware_rnnt.yaml— production configexamples/asr/asr_streaming_inference/asr_streaming_infer.py— entry point with warmup, RTFx, LAAL
What we MUST preserve from our fork
From PR #2 (batch/Parakeet thread-safety)
- CUDA Graph gating on Turing GPUs —
cuda_graphs: falsefor compute capability 7.5 (T4). Upstream config already hasuse_cuda_graph_decoder: falsebut our explicit T4 config guard must remain. - freeze/unfreeze race fix —
transcribe()concurrent calls crash on_frozen_grad_map. Our fix bypasses undertorch.inference_mode(). - Cross-thread CUDA tensor GC — pinned-memory tensors from RNNT decoder generators, GC on wrong thread = segfault. Our
gc.disable()+ controlledgc.collect()on GPU thread. - Automatic GC on async thread — Python GC triggers on event loop thread, frees CUDA pinned-memory cross-thread.
From PR #4 (streaming/Nemotron framework fixes)
- Prompt vectors in execute_step() — multilingual model produces blank output without prompt vectors. Note: upstream's
CacheAwareRNNTInferenceWrapper.execute_step()now includes this fix independently — verify parity. - Mel spectrogram fragmentation — 40ms chunks produce garbled output. Note: upstream's
BatchedCacheFeatureBuffererhandles this — verify parity.
From PR #4 (serving layer)
- Buffer drain loop — process ALL buffered chunks per WS message (while loop, not if)
- Idle timeout reaper — background asyncio task for configurable idle timeout
- gc.disable() + gc.collect() pattern — module-level GC disable, gen-0 collect per batch on GPU thread, full collect every N batches
- Single GPU thread ownership — all CUDA operations on dedicated thread
Plan
Phase 1: Streaming rebase
- Replace manual streaming in
gpu_worker.pywithCacheAwareRNNTPipeline - Keep WebSocket server layer (
server.py,stream_engine.py) — upstream has no transport - Keep GPU worker thread pattern — wrap pipeline calls inside dedicated thread
- Keep
gc.disable()+ controlled GC pattern - Verify prompt vectors work identically (upstream has the fix now)
- Verify chunk buffering handles 40ms WebSocket chunks correctly
Phase 2: Batch path verification
- Ensure batch transcription path (
batch_engine.py) is unaffected - Verify all PR Thread-safe ASR inference server: 43 RPS on L4, 6.9 RPS on T4 #2 thread-safety fixes remain active
- Verify T4 CUDA graph gating remains in config
Phase 3: Benchmarks (regression gate)
- Concurrency sweep on L4: must match or exceed PR feat(serving): Nemotron 3.5 ASR Streaming 0.6B serving example + multilingual RNNT fixes #4 results (257 streams, 0 failures)
- WER on LibriSpeech test-clean: must match or beat 12.1% corpus WER
- Max concurrency binary search: must match or exceed c=56 (129 sess/min, p99 2.8s)
- Batch mode: must match PR Thread-safe ASR inference server: 43 RPS on L4, 6.9 RPS on T4 #2 results (43 RPS sustained on L4)
Phase 4: New capabilities (from upstream adoption)
- Enable
RNNTGreedyEndpointingfor speech-based EOU detection - Enable multi-stream batched inference (up to 64 streams per step)
- Add ITN support
- Add confidence scores to API response
- Add LAAL latency measurement
Non-goals
- Do NOT touch the batch transcription path (Parakeet TDT) — it uses
model.transcribe()directly, not the streaming pipeline - Do NOT upgrade NeMo base image or PyTorch version — NGC 26.02 (PyTorch 2.6 + CUDA 12.8) is battle-tested
- Do NOT remove our thread-safety fixes even if upstream appears to have them — verify independently first
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity