Repository navigation
Conversation
…odels Load two model instances on startup: a compiled model (full attention) for short files and an uncompiled model (local attention) for long files. This eliminates the torch.compile incompatibility with change_attention_model() that forced auto mode to disable compile for ALL traffic, causing 3x higher VRAM usage and OOM under sustained load. Key design: - attention_mode: "dual" loads both models (~2.4 GB additional VRAM) - Batch partitioning: files are routed by duration, not whole-batch routing - Unknown durations route to local model (safe default) - Both models warmed up at startup (compile cost paid once) - OOM recovery: torch.cuda.empty_cache() on CUDA OOM to prevent cascade - Rejects model_pool_size > 1 (incompatible with dual architecture) Closes #10 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Track recovered CUDA OOM events via _oom_recovered_count, exposed through GET /metrics as gpu.oom_recovered. Gives observability on recovered OOMs that would otherwise only appear in logs. Co-Authored-By: Claude Opus 4.6 <[email protected]>
… duration caching - Add OOM recovery to streaming batch dispatch (P1) - Reject dual + prefetch config (incompatible, P2) - Validate attention_mode against allowed values (P2) - Cache duration probes per batch to avoid repeated I/O (P3) - Fix black/isort formatting (P3) - Add tests: dual+prefetch rejection, invalid attention_mode Co-Authored-By: Claude Opus 4.6 <[email protected]>
Benchmark Results — Dual vs Auto ModeGPU: NVIDIA L4 (23034 MiB) · Container: nvcr.io/nvidia/nemo:26.02 (PyTorch 2.10) Throughput Comparison (same pod, same audio)
VRAM Profile
Note: Baseline includes ~6 GiB from existing pod server. Key Findings
Why dual mode wins at c=32With Dual mode loads a permanently compiled model for short files. No runtime graph mutation needed. The compiled model processes batches faster, keeping queue depth lower and batch sizes smaller under sustained load. RTFx = total_audio_seconds / wall_clock_seconds. Higher is better. |
Merge Gate — All Checkpoints Passed
Ready for review. This PR re-enables torch.compile for 99%+ of traffic via dual-model architecture, directly addressing the root cause of the prod OOM incident (auto mode disabled compile → 3x slower inference → queue buildup → oversized batches). Complementary to PR #11 (batch cap) — together they fix both compounding bugs from prod. |
Summary
Loads two model instances: a compiled model (full attention, torch.compile) for short files and an uncompiled model (local attention) for long files. Eliminates the torch.compile incompatibility that forced
attention_mode: autoto disable compile for ALL traffic, causing 3x slower inference, queue buildup, oversized batches, and OOM under sustained load.Model:
nvidia/parakeet-tdt-0.6b-v3(0.6B params)Root cause (from prod incident data)
mode=autodisablestorch.compileat startup (compile +change_attention_model()are incompatible)empty_cache()) → VRAM ratcheted 16→19→20→22 GiBKey fact: ZERO attention switches occurred in prod — zero files >300s. The OOM was from normal traffic at uncapped batch size with compile disabled.
Solution: dual-model architecture
torch.cuda.empty_cache()in all dispatch paths prevents tensor leak cascade (bug Thread-safe ASR inference server: 43 RPS on L4, 6.9 RPS on T4 #2)Architecture
attention_mode: "dual"— new config option that loads both models at startupConfig validation
dual + model_pool_size > 1raises at startup (incompatible)dual + prefetchraises at startup (incompatible with duration-based routing)attention_moderaises at startupmax_file_duration_secenforced before routingBenchmark Results
GPU: NVIDIA L4 (23034 MiB) · Container: nvcr.io/nvidia/nemo:26.02 (PyTorch 2.10)
Throughput: Dual vs Auto Mode
Audio: LibriSpeech test-clean (5.5s avg). RTFx = total_audio_seconds / wall_clock_seconds.
VRAM Budget (L4 23034 MiB)
Files Changed
Serving
examples/asr/serving/gpu_worker.py— dual model loading, batch partitioning routing, warmup, VRAM logging, OOM recovery in all dispatch paths, attention_info property, oom_recovered counterexamples/asr/serving/server.py— expose OOM counter and attention info in /metrics endpointexamples/asr/serving/conf/serving-batch.yaml— attention_mode: "dual" config with documentation for all 4 modesexamples/asr/serving/test_dual_model.py— 19 unit tests for routing, config validation, dispatch, attention infoTest Plan
Closes #10