Repository navigation
fix(serving): EOU detection + configurable attention mode for long audio - #8
Conversation
…ranscribe_step The pipeline's cleanup_after_response() clears state.final_transcript="" after every transcribe_step() call, so our get_state() reads always saw empty finals — EOU events were silently lost. TranscribeStepOutput captures the state BEFORE cleanup, fixing EOU detection and enabling proper sentence-boundary signaling to WebSocket clients. Also removes manual delete_state() in _stream_close() — the pipeline handles state deletion automatically for is_last=True frames. Closes #7 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…tch, accumulate finals P1: Multiple frames for the same stream in one transcribe_step() call caused the pipeline context manager to serve stale cache to later frames. Now processes frames in rounds with unique stream_ids per batch. P3: _stream_chunk() loop overwrote `final` each iteration, silently dropping EOU events when multiple pipeline frames were emitted from one WebSocket chunk. Now accumulates finals across iterations. Co-Authored-By: Claude Opus 4.6 <[email protected]>
… batched together Use pop() instead of get() on output_by_int_id so only the first WorkItem per stream consumes the TranscribeStepOutput list. Subsequent items for the same stream (if any) get empty results, preventing double-counting of finals in committed_text. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Benchmark Results — Nemotron ASR Streaming 0.6BGPU: NVIDIA L4 | VRAM: ~5.7GB | Container: nvcr.io/nvidia/nemo:26.02 + fork Tier 1: Quality (WER)
Tier 2: Concurrency Sweep
Key Observations
🤖 Generated with Claude Code |
All Checkpoints Passed — Ready for Review
Summary: Rebased serving layer on upstream Awaiting manager review and merge approval. |
L4 Deployment Pool Benchmark ResultsGPU: NVIDIA L4 (parakeet-pool, g2-standard-8) · Node: gke-dev-omi-gke-parakeet-pool-424dcda4-q5yf · Container: nvcr.io/nvidia/nemo:26.02 · Memory: 28Gi Benchmark run on the shared L4 parakeet-pool (same hardware as dev-omi-parakeet deployment). Quality (Tier 1)
Concurrency Sweep (Tier 2)
All tiers pass on L4 deployment hardware. WER identical to previous temp-pod benchmark (7.4%). Zero failures at max concurrency c=56. |
Batch Mode Benchmark Results (L4 Deployment Pool)GPU: NVIDIA L4 (parakeet-pool, g2-standard-8) · Model: nvidia/parakeet-tdt-0.6b-v3 · compile: false · Container: nvcr.io/nvidia/nemo:26.02 Important note on methodology: All benchmarks use real LibriSpeech test-clean speech, not silence or TTS. PR #2's original batch benchmarks used silent WAV files ( Quality (Tier 1)
Concurrency Sweep (Tier 2)
Peak throughput: 16.2 RPS at c=32 (with real speech, compile disabled). Zero failures across all concurrency levels. Comparison: PR #2 vs PR #8 batch benchmarks
|
Benchmark Results — Streaming Mode (PR #8 vs PR #4 Baseline)GPU: NVIDIA L4 · Model: nvidia/parakeet-tdt-0.6b · Container: nvcr.io/nvidia/nemo:26.02 Quality (WER)
Concurrency Sweep (200 streams per level, real-time pacing, 160ms chunks)
Sustained Load (c=4, ~3 min)
Batch Mode (separate run, same pod)
Verdict
Overall: ✅ PASS — No regressions. WER improved, EOU bug fixed, throughput stable across all concurrency levels (c=1 through c=64). |
Separates git clone (alpine/git, 2Gi) from NeMo server (26Gi) to avoid OOM during concurrent git + model load operations. Proven stable on parakeet-pool L4 nodes (g2-standard-8, 32Gi). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Benchmark Results — Streaming Mode (PR #8 vs PR #4 Baseline) — CORRECTEDGPU: NVIDIA L4 · Model: nvidia/parakeet-tdt-0.6b · Container: nvcr.io/nvidia/nemo:26.02 Quality (WER)
Concurrency Sweep (200 streams per level, real-time pacing, 160ms chunks)RTFx = total_audio_duration / wall_time (aggregate throughput, higher is better)
Sustained Load (c=4, ~3 min)
Batch Mode (separate run, same pod)
Verdict
Overall: ✅ PASS — No regressions. WER improved, EOU bug fixed, throughput improved across all concurrency levels (c=1 through c=64). |
Previous pod spec disabled torch.compile for batch mode (leftover from T4 workaround), losing 20-30% throughput. Also add explicit cuda_graphs: true to serving-batch.yaml (was relying on default). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Benchmark Results — Complete (Streaming + Batch) — FINALGPU: NVIDIA L4 · Container: nvcr.io/nvidia/nemo:26.02 (PyTorch 2.6 + CUDA 12.8) Streaming Mode (nvidia/nemotron-3.5-asr-streaming-0.6b)Config: compile=false (no benefit for RNNT streaming), latency_mode=480ms Quality
Concurrency Sweep (RTFx = total_audio / wall_time, higher = better)
Sustained Load (c=4, 3.3 min)
Batch Mode (nvidia/parakeet-tdt-0.6b-v3)Config: compile=true, cuda_graphs=false Quality
WER difference is due to Parakeet TDT's punctuation vs unpunctuated LibriSpeech references — not a regression. Concurrency Sweep
Bug Found During Benchmark
Infrastructure Findings
Verdict
Overall: ✅ PASS |
cuda_graphs: true causes cudaErrorIllegalAddress at c=32+ on L4 (not just T4 as previously documented). Disable cuda_graphs in batch config for production stability. Also increase /tmp emptyDir to 5Gi for torch.compile kernel cache. Benchmark: compile=true, cuda_graphs=false gives 13.2 RPS peak at c=64 with 0 failures across all concurrency levels. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The amp config flag was inert — batch path called model.transcribe() without autocast. Now wraps with torch.autocast(cuda, fp16) when amp: true, reducing memory and potentially improving throughput. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Benchmarked AMP (torch.autocast fp16) on L4 with compile=true: - Without AMP: 9.1 RPS at c=16, 13.2 RPS at c=64 - With AMP: 5.2 RPS at c=16, 6.1 RPS at c=64 (~43% slower) torch.compile already optimizes the FP32 path. Adding autocast causes graph breaks and precision mismatches that degrade throughput. NeMo models handle their own internal precision. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Optimal Config Report — Streaming + Batch on L4Systematic benchmark of configuration options. All tests: LibriSpeech test-clean (real speech), NVIDIA L4 GPU, nvcr.io/nvidia/nemo:26.02. Streaming Mode (nvidia/nemotron-3.5-asr-streaming-0.6b)Latency Mode Comparison (50 samples per test)
Verdict: 480ms is the optimal default — nearly identical WER (0.2% difference) with better perceived latency on partial results. Use 1040ms only if accuracy is the absolute priority and slight delay in partial transcripts is acceptable. Optimal Streaming Configstream_model:
name: "nvidia/nemotron-3.5-asr-streaming-0.6b"
device: "cuda:0"
compile: false # inert in code; no benefit for cache-aware RNNT
amp: true
latency_mode: "480ms" # right_context=6, best quality/latency balance
source_language: "English"
stream:
max_concurrent_streams: 64 # match actual L4 capacity (not 128)
chunk_duration_ms: 160
sample_rate: 16000
max_stream_duration: 0
idle_timeout: 300Batch Mode (nvidia/parakeet-tdt-0.6b-v3)torch.compile + AMP Comparison (200 samples)
AMP hurts with torch.compile — 43% slower. torch.compile already optimizes the FP32 path; adding autocast causes graph breaks. cuda_graphs crashes at c=32+ — Batch Size Comparison (c=16, compile=true, amp=on*)
*AMP was active during batch_size test — relative ranking holds regardless. batch_size=32 is optimal. Optimal Batch Configbatch_model:
name: "nvidia/parakeet-tdt-0.6b-v3"
device: "cuda:0"
compile: true # +20-30% throughput (60s warmup, needs 5Gi /tmp)
amp: true # currently inert in code — does not hurt or help
cuda_graphs: false # MUST be false — crashes at c=32+ on both L4 and T4
batcher:
max_batch_size: 32 # optimal with torch.compile
max_wait_seconds: 0.002
max_queue_depth: 4096
max_upload_bytes: 104857600Infrastructure Requirements
Summary of Code Findings
|
PR #2 vs PR #8 — Batch Baseline Comparison (Real Speech)Dataset: 200 LibriSpeech test-clean files, 1818.5s total audio (avg 9.1s/file) PR #2 (compile=true, cuda_graphs=true, amp=inert)
PR #8 (compile=true, cuda_graphs=false, amp=off)
Analysis
Conclusion: PR #2's claimed 43–49 RPS was measured with silent WAV files (RNNT early exit). With real speech, PR #2 peaks at ~11 RPS and is only stable up to c=16. PR #8 with |
Production Validation — Parakeet Prod Metrics vs BenchmarkProduction parakeet pod (single L4, g2-standard-8, 3.2 days uptime, 147K requests): RTFx Reconciliation
Why prod overall RTFx is low (3.5x)Prod processes 0.54 req/s — the GPU spends most time waiting for requests. Batch sizes reflect this:
At higher load, throughput matches benchmark numbers. The 3.5x is a utilization metric, not a capability metric. Prod vs benchmark audio length effectProd avg audio: 51.7s/request. Benchmark avg: 9.1s/file. Longer audio amortizes fixed per-request overhead (upload, model warmup, response serialization), giving higher per-file RTFx. This explains prod v1 showing 130x vs benchmark c=1 showing 12.3x — same GPU, different file lengths. |
Peak Performance Results — L4 Full Concurrency SweepGPU: NVIDIA L4 · Container: nvcr.io/nvidia/nemo:26.02 · Dataset: LibriSpeech test-clean (real speech) Batch Mode (compile=true, cuda_graphs=false, batch_size=32)200 files, 1818.5s total audio (avg 9.1s/file)
Peak batch throughput: 15.0 RPS / 136x RTFx at c=256 — 0 failures up to c=512 Streaming Mode (latency_mode=480ms, max_concurrent_streams=256)50 files per test, realtime-paced 160ms chunks
Peak streaming throughput: 65.1 sess/min at c=128 — 0 failures up to c=256 Optimal Production Config (single L4)
Capacity math (single L4)
|
Audio Duration Impact on Performance — L4GPU: NVIDIA L4 (22GB VRAM) · Model: parakeet-tdt-0.6b-v3 · Config: compile=true, cuda_graphs=false, batch_size=32 RTFx vs Audio Duration (batch c=1, single file)
Max Concurrency vs Audio Duration
Peak Throughput by Duration (best concurrency level)
VRAM Scaling (from OOM errors)
Production Recommendations
GPU sizing for long audio (no chunking)
|
…audio Parakeet TDT uses full O(T²) attention by default, which OOMs on L4 at ~11min. Adding local_attn: true switches to rel_pos_local_attn (O(T×W)) at inference time, enabling 2-3 hours on L4 with ~5-6GB VRAM. New config options: batch_model.local_attn: true/false (default: false) batch_model.local_attn_context: [128, 128] (default) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Audio Duration Benchmark + Local Attention Fix — L4New config: Duration Scaling — Full Attention vs Local Attention (c=1)
WER Impact
Negligible accuracy loss. Concurrency — Local Attention (9.1s LibriSpeech files)
Peak: 13.6 RPS (vs 15.0 with full attn) — 9% throughput cost for 6x longer max duration. Concurrency — Local Attention (long files)
VRAM Usage — Local Attention
Summary: Optimal Config per Use Case
Implementation: 4 lines added to |
…ng audio Three attention modes for batch transcription: - full: O(T²) VRAM, max ~10min on L4, best short-file throughput - local: O(T×W) VRAM, max ~1h on L4, +0.7% WER / -9% throughput - auto: switches per-request based on audio duration threshold (disables torch.compile since compiled graphs can't be modified) New config options: batch_model.attention_mode: full | local | auto (default: auto) batch_model.auto_local_attn_threshold_sec: 600 (default) batch_model.local_attn_context: [128, 128] (default) batch_model.max_file_duration_sec: 3600 (rejects files over limit) Also bumps max_upload_bytes to 512MB to support 30min+ files. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…attention mode torchaudio.info may fail on some temp file formats. Fall back to Python's wave module for WAV files. Log warnings when duration detection fails instead of silently returning 0. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Auto Attention Mode — Verification ResultsPod: Config: attention_mode: "auto"
auto_local_attn_threshold_sec: 600 # 10min threshold
local_attn_context: [128, 128]
max_file_duration_sec: 3600 # 1h limitTest Scenarios
Server Logs (chronological)Key Observations
Attention Mode Summary
Recommendation: Use |
…ode docs - Fix all performance numbers to reflect real-speech benchmarks (not silent WAVs) - Batch: 15.0 RPS / 136x RTFx (was 43 RPS / 343x from silence) - Streaming: c=128 peak / 65.1 sess/min (was c=56 / 129 sess/min) - Document cuda_graphs crashes on both L4 and T4 (was T4-only) - Add attention mode system docs (full/local/auto) - Add audio duration vs performance table - Add EOU fix to thread-safety section - Update case study with accurate numbers - Document max_file_duration_sec and HTTP 413 behavior Co-Authored-By: Claude Opus 4.6 <[email protected]>
WER Correction — Batch ModeRoot CausePrevious batch WER measurements (14.0-14.7%) were inflated by a text normalization bug. The WER calculation used Parakeet TDT outputs punctuated text (e.g. FixApply standard ASR text normalization before WER calculation: lowercase + remove all punctuation + collapse whitespace. This matches NVIDIA's published benchmarks and the industry standard (Whisper's Corrected Results (200 LibriSpeech test-clean samples)
Verified on 50 samples (live)
The 12.5% on the last sample is Updated Numbers
The fix is in |
Batch WER was inflated from 2.0% to 14.0% because jiwer.wer() was called with only .lower() — no punctuation removal. Parakeet TDT outputs punctuated text but LibriSpeech refs have none, so every comma/period became a substitution error. Replace _strip_punct() (trailing-only) with _normalize_text() that lowercases, removes all punctuation, and collapses whitespace. This matches NVIDIA's published benchmarks and the industry standard. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Switch from simple regex normalization to whisper-normalizer's EnglishTextNormalizer — the industry standard used by NVIDIA's own NeMo speechlm2 metrics. Handles British/American spelling (honour→ honor), contractions (it's→it is), abbreviations (Mr.→mister), and number normalization. Falls back to regex if not installed. WER: 2.01% (regex) → 1.88% (whisper normalizer) on 200 LibriSpeech test-clean samples with Parakeet TDT 0.6B. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…cripts - Create shared wer_utils.py: jiwer + EnglishTextNormalizer for corpus-level WER - stress_test.py: replace manual Levenshtein with jiwer, fix pre-lowercased refs/hyps before normalizer, switch from macro-average to corpus-level WER - stream_benchmark.py: add WER computation to quality_check() with per-sample and corpus-level metrics - benchmark.py, chaos_benchmark.py, chaos_sweep.py: document as performance-only (no WER measurement) - serving-batch.yaml: remove hardcoded "+0.7% WER" claim - README.md: fix stale "LibriSpeech test-clean" throughput claim, remove hardcoded WER numbers, add wer_utils.py to file listing - benchmark-report.html: fix misleading "Failures / WER" label Co-Authored-By: Claude Opus 4.6 <[email protected]>
…kerfile - stress_test.py: collect full-length refs/hyps for corpus WER instead of using truncated entry["reference"] (100 chars) and entry["hypothesis"] (200 chars) - stress_test.py: lowercase hypothesis before keyword matching (expected words are lowercase, hypothesis no longer pre-lowercased) - Dockerfile.stream: add wer_utils.py to COPY and jiwer/whisper-normalizer to pip install (stream_benchmark.py imports wer_utils) Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ipts use TTS Explicitly document that README WER numbers were measured on an L4 GPU pod with LibriSpeech test-clean + jiwer corpus-level WER, while the included benchmark scripts use espeak-ng TTS for quick validation. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Industry-Standard WER Evaluation FixesCodex audit identified 6 categories of deviation from industry-standard WER methodology across all benchmark scripts. All fixed in commits f93c041..937a54f (3 commits, 3 review rounds). New: Shared
|
| File | Issue | Fix |
|---|---|---|
stress_test.py |
Manual Levenshtein WER | Replaced with jiwer.wer() via wer_utils |
stress_test.py |
Macro-average WER | Switched to corpus-level WER |
stress_test.py |
Pre-lowercased refs/hyps before normalizer | Pass raw text to normalizer |
stress_test.py |
Regex fallback if whisper-normalizer missing | Removed — hard dependency now |
stress_test.py |
Truncated refs/hyps in corpus WER | Fixed: full texts collected separately |
stress_test.py |
Case-sensitive keyword matching | Fixed: lowercase before matching |
stream_benchmark.py |
No WER in quality_check() | Added per-sample + corpus-level WER |
benchmark.py |
No WER disclaimer | Documented as performance-only |
chaos_benchmark.py |
No WER disclaimer | Documented as performance/chaos-only |
chaos_sweep.py |
No WER disclaimer | Documented as performance/chaos-only |
serving-batch.yaml |
Hardcoded "+0.7% WER" | Removed specific number |
README.md |
Stale LibriSpeech claim for throughput | Clarified: throughput uses TTS, WER uses LibriSpeech |
README.md |
Unclear WER provenance | Added methodology note: measured on L4 pod, scripts use TTS for quick validation |
benchmark-report.html |
Misleading "Failures / WER" | Fixed to "Failures" |
Dockerfile.stream |
Missing wer_utils.py + deps | Added COPY + pip install jiwer/whisper-normalizer |
Review Status
- Codex review: Approved (round 3/3, all findings resolved)
- CP7: Set (review approved)
- CP8: Needs re-run (code changed after prior benchmarks)
Benchmark Re-run — Post WER Evaluation FixesGPU: L4 (24GB) · Container: nvcr.io/nvidia/nemo:26.02 · Branch: feat/upstream-pipeline-rebase @ 937a54f Tier 1: Quality (WER Evaluation)
All 3 TTS samples transcribed perfectly. LibriSpeech sample matched 2/4 keywords with 23 words output. Tier 2: Concurrency (Throughput)
Throughput matches prior benchmarks (15 RPS at c=32). Zero failures at all concurrency levels. Conclusion
|
…shTextNormalizer Re-measured on 200 LibriSpeech test-clean samples using industry-standard methodology (jiwer corpus-level WER + Whisper EnglishTextNormalizer). Previous 2.0% was with simple regex normalization. Full benchmark verified on L4 (full attn + compile): - WER: 1.84% (200 samples, 0 errors) - Peak RPS: 14.7 (c=256), 17.4 (c=512) - RTFx: 133x (c=256), 158x (c=512) - 0 failures at all levels up to c=512 Co-Authored-By: Claude Opus 4.6 <[email protected]>
RTFx was previously computed by multiplying TTS-audio RPS (15.0) by LibriSpeech avg duration (9.1s), mixing two different audio sources. Re-ran full concurrency sweep with LibriSpeech test-clean audio (200 samples, avg 9.1s). Corrected numbers: - Peak RPS: 19.5 at c=256 (was 15.0 with shorter TTS audio) - Peak RTFx: 178x at c=256 (was 136x from mixed calculation) - 0 failures at all levels up to c=512 Added per-concurrency-level table with RPS, RTFx, p50, p99 for full transparency. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
lgtm |
Port from beastoin/NeMo#8: three attention modes (full/local/auto), configurable max file duration with AudioDurationExceededError, soundfile+wave duration detection, and auto attention switching. Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
Fix EOU (end-of-utterance) detection in streaming ASR, add configurable attention modes for long audio support (up to 1h on L4), and upgrade all benchmark scripts to industry-standard WER evaluation methodology.
Models: nvidia/parakeet-tdt-0.6b-v3 (batch, 110M params) · nvidia/nemotron-3.5-asr-streaming-0.6b (streaming, 600M params)
Closes #7
Streaming Fix
EOU events silently lost (commit
be81298)get_state()called aftertranscribe_step()returns emptyfinal_transcriptbecausecleanup_after_response()already cleared itTranscribeStepOutputreturn values directly instead of re-reading stateDuplicate committed_text (commit
a638b32)committed_textaccumulated duplicatesAttention Mode System
Local attention for long audio (commit
117d65e)attention_mode: "local"— O(T*W) VRAM scaling, handles up to 1h on L4rel_pos_local_attnwith configurable sliding windowAuto attention switching (commit
cf3624c)attention_mode: "auto"— per-request switching based on audio durationauto_local_attn_threshold_secuse full attention; longer files switch to localBatch Optimization
85a3a06,5df8c6a)cudaErrorIllegalAddressat c=32+ on both L4 and T4cuda_graphs: falsein configWER Evaluation Overhaul
fd97b32through3063d42)wer_utils.py: jiwer + Whisper EnglishTextNormalizer + corpus-level WERstream_benchmark.pyquality_check()RTFx Correction
9db7017)Benchmark Results
GPU: L4 (24GB) · Container: nvcr.io/nvidia/nemo:26.02 (PyTorch 2.6 + CUDA 12.8) · Audio: LibriSpeech test-clean (avg 9.1s) · Verified: 2026-06-27
Quality
Batch Performance (full attention + torch.compile, LibriSpeech audio)
Streaming Performance
Files Changed
Serving Code
gpu_worker.py— EOU fix (TranscribeStepOutput), attention mode switching, cuda_graphs fixserver.py— HTTP 413 for over-limit filesDockerfile.stream— Added wer_utils.py + jiwer/whisper-normalizer depsBenchmark & Evaluation
wer_utils.py— NEW shared WER module (jiwer + EnglishTextNormalizer, corpus-level)stress_test.py— jiwer WER, corpus-level, fixed pre-normalization bugsstream_benchmark.py— Added WER computation to quality_check()benchmark.py— Documented as performance-onlychaos_benchmark.py— Documented as performance/chaos-onlychaos_sweep.py— Documented as performance/chaos-onlyConfiguration & Docs
conf/serving-batch.yaml— Attention mode config, removed hardcoded WER claimsREADME.md— Corrected benchmarks (LibriSpeech-consistent RTFx), concurrency sweep tablebenchmark-report.html— Fixed misleading labelrequirements-serving.txt— Added jiwer, whisper-normalizerk8s/benchmark-pod-l4.yaml— NEW L4 benchmark pod with init containerTest Plan