Repository navigation
Fix parakeet OOM on long audio: auto attention switching + duration guard - #8428
Conversation
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]>
Check audio duration before batching in /v1/transcribe and /v2/transcribe. Return 413 if file exceeds PARAKEET_MAX_FILE_DURATION. Catch AudioDurationExceededError from gpu_worker as fallback. Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests cover: attention mode config validation, local/auto mode model loading, attention switching, duration guard (oversized/normal/disabled), soundfile/wave fallback, and auto attention switching for long/short audio. Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests cover: pre-batch 413 for oversized WAV, pass under limit, AudioDurationExceededError fallback, guard disabled when zero, for both /v1/transcribe and /v2/transcribe endpoints. Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Reviewer Note: Helm Chart ValuesThe reviewer flagged that the Helm chart values files don't set the new env vars. This is intentional — the new env vars have safe defaults:
These are opt-in features configured at deploy time. Updating chart values is a separate deployment decision after this code lands. The existing by AI for @beastoin |
There was a problem hiding this comment.
5 issues found across 4 files
Confidence score: 3/5
- In
backend/parakeet/gpu_worker.py, the duration fallback currently maps unreadable/missing audio into a 413-style duration error when the guard is enabled, which can hide real I/O failures and return misleading client responses; split I/O-read exceptions from true oversize-duration checks before merging. - In
backend/parakeet/main.py, the/v2/transcribe413 path appears to incrementparakeet_requests_totaltwice (rejected/error), which will skew dashboards and alerting if merged as-is; setstatustorejectedand remove branch-specific increments sofinallyrecords exactly once. - In
backend/parakeet/gpu_worker.py, local attention context parsing does not enforce the required two-value format, so bad config can slip through and fail later during attention switching at runtime; add strict shape/arity validation with a clear config error up front. - In
backend/tests/unit/test_parakeet_endpoints.py,_make_wav_bytes(duration_s=3600.0)allocates ~110MB despite the guard being disabled, creating avoidable test memory pressure and slower CI; reduce the fixture duration to a minimal value that still exercises the same path.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_parakeet_endpoints.py">
<violation number="1" location="backend/tests/unit/test_parakeet_endpoints.py:323">
P2: `_make_wav_bytes(duration_s=3600.0)` creates a ~110MB WAV byte string in memory, but since `_max_file_duration_sec = 0.0` (guard disabled), a 1-second file would exercise the same code path at ~32KB.</violation>
</file>
<file name="backend/parakeet/gpu_worker.py">
<violation number="1" location="backend/parakeet/gpu_worker.py:77">
P2: Local attention context parsing does not validate the required two-value format. Misconfigured values can pass parsing and fail later during model attention switching.</violation>
<violation number="2" location="backend/parakeet/gpu_worker.py:314">
P2: Duration fallback conflates I/O failures with oversized audio when guard is enabled. Missing/unreadable files are converted into 413-style duration errors instead of surfacing the real read error.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| return {"text": "ok", "timestamp": {"segment": [{"segment": "ok", "start": 0.0, "end": 1.0}]}} | ||
|
|
||
| engine.submit = AsyncMock(side_effect=fake_submit) | ||
| wav_data = _make_wav_bytes(duration_s=3600.0, sample_rate=16000) |
There was a problem hiding this comment.
P2: _make_wav_bytes(duration_s=3600.0) creates a ~110MB WAV byte string in memory, but since _max_file_duration_sec = 0.0 (guard disabled), a 1-second file would exercise the same code path at ~32KB.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/unit/test_parakeet_endpoints.py, line 323:
<comment>`_make_wav_bytes(duration_s=3600.0)` creates a ~110MB WAV byte string in memory, but since `_max_file_duration_sec = 0.0` (guard disabled), a 1-second file would exercise the same code path at ~32KB.</comment>
<file context>
@@ -256,6 +256,76 @@ async def fake_submit(path, timestamps=True, owns_file=False):
+ return {"text": "ok", "timestamp": {"segment": [{"segment": "ok", "start": 0.0, "end": 1.0}]}}
+
+ engine.submit = AsyncMock(side_effect=fake_submit)
+ wav_data = _make_wav_bytes(duration_s=3600.0, sample_rate=16000)
+ client = TestClient(app, raise_server_exceptions=False)
+ resp = client.post("/v1/transcribe", files={"file": ("huge.wav", wav_data, "audio/wav")})
</file context>
| raise ValueError(f"PARAKEET_ATTENTION_MODE must be one of {_VALID_ATTN_MODES}, got '{self._attn_mode}'") | ||
| self._attn_auto_threshold_sec = float(os.getenv("PARAKEET_AUTO_ATTN_THRESHOLD", "600")) | ||
| ctx_raw = os.getenv("PARAKEET_LOCAL_ATTN_CONTEXT", "128,128") | ||
| self._attn_local_context = [int(x.strip()) for x in ctx_raw.split(",")] |
There was a problem hiding this comment.
P2: Local attention context parsing does not validate the required two-value format. Misconfigured values can pass parsing and fail later during model attention switching.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/parakeet/gpu_worker.py, line 77:
<comment>Local attention context parsing does not validate the required two-value format. Misconfigured values can pass parsing and fail later during model attention switching.</comment>
<file context>
@@ -61,6 +69,14 @@ def __init__(self):
+ raise ValueError(f"PARAKEET_ATTENTION_MODE must be one of {_VALID_ATTN_MODES}, got '{self._attn_mode}'")
+ self._attn_auto_threshold_sec = float(os.getenv("PARAKEET_AUTO_ATTN_THRESHOLD", "600"))
+ ctx_raw = os.getenv("PARAKEET_LOCAL_ATTN_CONTEXT", "128,128")
+ self._attn_local_context = [int(x.strip()) for x in ctx_raw.split(",")]
+ self._attn_is_local = False
+ self._max_file_duration_sec = float(os.getenv("PARAKEET_MAX_FILE_DURATION", "0"))
</file context>
| self._attn_local_context = [int(x.strip()) for x in ctx_raw.split(",")] | |
| ctx_parts = [x.strip() for x in ctx_raw.split(",")] | |
| if len(ctx_parts) != 2: | |
| raise ValueError("PARAKEET_LOCAL_ATTN_CONTEXT must be '<left>,<right>'") | |
| self._attn_local_context = [int(x) for x in ctx_parts] |
| try: | ||
| with _wave.open(path) as wf: | ||
| return wf.getnframes() / wf.getframerate() | ||
| except Exception as exc: |
There was a problem hiding this comment.
P2: Duration fallback conflates I/O failures with oversized audio when guard is enabled. Missing/unreadable files are converted into 413-style duration errors instead of surfacing the real read error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/parakeet/gpu_worker.py, line 314:
<comment>Duration fallback conflates I/O failures with oversized audio when guard is enabled. Missing/unreadable files are converted into 413-style duration errors instead of surfacing the real read error.</comment>
<file context>
@@ -268,12 +302,56 @@ def _compute_embedding(self, payload: dict):
+ try:
+ with _wave.open(path) as wf:
+ return wf.getnframes() / wf.getframerate()
+ except Exception as exc:
+ logger.warning(f"Cannot determine audio duration for {path}: {exc}")
+ if self._max_file_duration_sec > 0:
</file context>
Duration guard 413s were incrementing both 'rejected' and 'error' counters. Now use status='rejected' consistently, counted once in the finally block. Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests: auto switching back full->local->full, threshold boundary (exact value triggers local), duration guard boundary (exact at limit passes, just over raises). Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests: v2 passes when under limit with diarize, v1 boundary test for exact limit duration (passes, not rejected). Refs: #8426 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Review Cycle Fixes (3 commits)Addressed tester feedback:
Test counts: 55 gpu_worker + 24 endpoint = 79 tests, all pass. by AI for @beastoin |
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_parakeet_endpoints.py">
<violation number="1" location="backend/tests/unit/test_parakeet_endpoints.py:344">
P2: Test module-level state leaks on assertion failure — `mod._max_file_duration_sec` reset at line-end assignment never runs if assertion fails, breaking isolation for subsequent tests</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
CP9 Live Test Evidence — Dev Parakeet Pod (L4 GPU)Pod: Container Tests — All Pass
ASR Industrial Benchmark7,823 total requests, 0 failures (0.000% error rate) Concurrency Sweep:
Audio Duration Sweep (cc=16):
Sustained Load (3 min, cc=32):
Quality (TTS + LibriSpeech): All samples pass, 0% WER on TTS VerdictAll gates pass. No regression from current production baseline. The new attention mode/duration guard code paths are safe with default config (full attention, guard disabled). Ready for merge. by AI for @beastoin |
change_attention_model creates new linear layers in float32. When model was loaded with BF16, inputs arrive as bfloat16 but new attention weights are float32, causing RuntimeError in F.linear. Re-cast model to the load dtype after every switch. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@beastoin The auto-switch BF16 fix in by AI for @beastoin |
change_attention_model at startup also creates float32 layers. Re-cast model to load dtype after switching in _load_model too, not just in _switch_attention (auto mode). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
BF16 dtype mismatch fix (commits cb9350f, 3c19850)Root cause: Fix: Re-cast model to load dtype after every attention switch:
Note: NeMo's reference server doesn't use BF16, so they never hit this bug. This is an omi-specific issue from our BF16 optimization. Tests added: 4 new tests (59 total gpu_worker, 24 endpoints)
Evidence: Verified on dev L4 GPU pod — the 601s/620s audio that was crashing with HTTP 500 now needs re-verification after redeploy. by AI for @beastoin |
ASR Benchmark Results — Auto Attention Mode (BF16 Fix Verified)Server: parakeet @ dev pod (commit 0037d0d) | GPU: NVIDIA L4 (24GB) | Model: parakeet-tdt-0.6b-v3 Auto Attention Duration Sweep (BF16 Fix Validation)
Quality TestAll samples passed. 0 WER failures on TTS samples. Concurrency Scaling (cc=16 @ ~8s audio)
Recommended operating point: cc=16 (RPS 22.7, p99 < 2s) Duration Scaling (cc=16)
Sustained Load (3 min @ cc=32)
Container Tests
Total Validation
by AI for @beastoin |
|
@beastoin by AI for @beastoin |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Reviewer Feedback Addressed (2 commits)Fixed the batch-contamination path flagged by reviewer — Fix: Tests added:
Test counts: 59 gpu_worker + 26 endpoint = 85 tests, all pass. by AI for @beastoin |
|
@beastoin No issues found. I checked the PR against #8426 and the NeMo adoption scope: attention mode configuration/switching, BF16 recast after attention swaps, pre-batch duration rejection, worker-side duration guard, and 413 handling for both v1/v2 all line up with the requested behavior; by AI for @beastoin |
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_parakeet_endpoints.py">
<violation number="1" location="backend/tests/unit/test_parakeet_endpoints.py:323">
P2: `_make_wav_bytes(duration_s=3600.0)` creates a ~110MB WAV byte string in memory, but since `_max_file_duration_sec = 0.0` (guard disabled), a 1-second file would exercise the same code path at ~32KB.</violation>
</file>
<file name="backend/parakeet/gpu_worker.py">
<violation number="1" location="backend/parakeet/gpu_worker.py:77">
P2: Local attention context parsing does not validate the required two-value format. Misconfigured values can pass parsing and fail later during model attention switching.</violation>
<violation number="2" location="backend/parakeet/gpu_worker.py:314">
P2: Duration fallback conflates I/O failures with oversized audio when guard is enabled. Missing/unreadable files are converted into 413-style duration errors instead of surfacing the real read error.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
ASR Industrial Benchmark — LibriSpeech test-clean (PR #8428)Reran with proper industrial corpus. 100 LibriSpeech test-clean WAV files (natural speech, realistic duration distribution). RTFx computed from actual WAV header durations. Model: nvidia/parakeet-tdt-0.6b-v3 | GPU: NVIDIA L4 (24GB) | Config: attention=auto, BF16=on, torch.compile=off Corpus
Hero Metrics
Concurrency Scaling
Recommended operating point: cc=16 (100x realtime, p99 1.6s) Sustained Load (3 min @ cc=32)
Comparison
Note: This benchmark runs with Methodology
by AI for @beastoin |
Long-Audio Benchmark — 30 min & 1 hour (PR #8428)Benchmark with production-length audio: 30 minutes and 1 hour of concatenated LibriSpeech test-clean speech. Files >600s trigger auto attention switching from full → local mode. This is the core feature this PR adds — enabling long-duration transcription without OOM. Model: nvidia/parakeet-tdt-0.6b-v3 | GPU: NVIDIA L4 (24GB) | Config: attention=auto, threshold=600s, max_duration=3600s, BF16=on Results
Aggregate
Key Observations
Methodology
by AI for @beastoin |
|
Maintainer review (automated): This is a solid, well-scoped fix. I verified the diff and ran all 41 new unit tests locally (26 gpu_worker + 15 endpoint) — all green. A few notes: What checks out
Two observations for a human maintainer
Not approving — deferring that product judgment to a maintainer. Nice work on the fail-closed design and the test coverage. 🙌 |
kodjima33
left a comment
There was a problem hiding this comment.
Parakeet attention-mode system + duration guard to avoid OOM on long audio. Solid tests, CI green. Approve-only: 670-line new capability/feature, not a scoped defect fix.
VRAM Analysis — Empirical Measurements on L4 (24 GB)Architecture (from NeMo config): FastConformer XLarge — Empirical VRAM (nvidia-smi during inference, single request, full attention, torch.compile OFF):
Corrected scaling: 136.6 bytes/T² (measured), where T = audio_seconds / 0.08. Key findings:
NVIDIA documentation confirms quadratic scaling:
Measured by @zen on L4 dev pod. Math verified against NeMo source ( by AI for @beastoin |
Empirical VRAM measurements show 4× concurrent 5-min files use 12.2 GB (50% of L4) with full attention. Lowering the auto-switch threshold to 300s (5 min) makes files >= 5 min use local attention (linear VRAM), eliminating batch OOM risk for concurrent long-audio requests. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Phase 1 of deploy: ATTENTION_MODE=full (current behavior unchanged), THRESHOLD=300, MAX_FILE_DURATION=0 (disabled). Phase 2 will switch to mode=auto after verifying clean startup. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Deployment Plan (Two-Phase)Workflow: Phase 1 — Safe deploy (no behavior change)Env vars added to prod Helm values with safe defaults (commit PARAKEET_ATTENTION_MODE=full # current behavior, unchanged
PARAKEET_AUTO_ATTN_THRESHOLD=300 # ready for Phase 2
PARAKEET_LOCAL_ATTN_CONTEXT=128,128
PARAKEET_MAX_FILE_DURATION=0 # disabledAfter merge: gh workflow run gcp_parakeet.yml -f environment=prod -f branch=mainVerify:
Phase 2 — Enable auto attentionUpdate two values in PARAKEET_ATTENTION_MODE=auto # enables switching
PARAKEET_MAX_FILE_DURATION=7200 # reject >2hr files
Re-run workflow, verify:
Rollback
Rollback triggers: OOM increase, error rate >1%, p99 doubles for >5 min, CrashLoopBackOff, HPA at max. Timeline: ~75-120 min totalDeployment plan by @mon. by AI for @beastoin |
|
lgtm |
Deploy Monitor — T+0 (2026-06-28 03:15 UTC)PR: #8428 — Parakeet auto attention switching + duration guard
Monitoring schedule: T+20m, T+30m, T+1h, T+2h, T+4h, then every 4h through T+24h. Next checkpoint: T+20m (03:35 UTC) — quick health sweep. by AI for @beastoin |
Deploy Monitor — Phase 1 Complete (T+20m)Status: PASS ✅
Phase 1 soak in progress (15-30 min). Monitoring for regressions in error rate, p99 latency, and RTFx as traffic flows through the new pod. Pre-deploy baseline (old pod, ~4.7 days uptime):
Next: Phase 1 soak results → Phase 2 (enable by AI for @beastoin |
Deploy Monitor — T+30m Extended CheckpointPhase 1 Soak: PASS ✅ — Proceeding to Phase 2
Traffic context: off-peak (03:37 UTC), 16 requests served — all successful. Phase 2 starting now:
Next checkpoint: T+1h (04:15 UTC) — Phase 2 verification. by AI for @beastoin |
Deploy Monitor — T+1h Checkpoint (04:15 UTC)Phase 2 Status: PASS ✅ Both phases deployed and verified. Auto attention switching is live in production.
Traffic context: off-peak (~03:40-04:15 UTC). 78 requests served, all short wearable audio (<5 min) staying in full attention mode. Auto-switching path is armed — will trigger when >5 min files arrive during peak hours (16-21 UTC). Deploy timeline:
No rollback triggers hit. Continuing sustained monitoring. Next checkpoint: T+2h (05:15 UTC). by AI for @beastoin |
Deploy Monitor — ROLLBACK (T+1h27m)Phase 2 Status: ROLLED BACK ❌
Root cause: The irony: the OOM prevention feature caused more OOMs because its prerequisite (disabling torch.compile) increases VRAM usage on normal short-file traffic. Rollback action: Partial rollback via Fix needed: Auto attention mode needs to work WITH torch.compile, not against it. Options being evaluated. by AI for @beastoin |
Deploy Post-Mortem — Phase 2 RollbackWhat happened: Phase 2 ( Root cause: Auto mode disables Lesson learned: torch.compile is load-bearing for VRAM efficiency in production. Any feature that requires disabling it needs VRAM budget analysis under production batch load, not just single-file benchmarks. Resolution — PR #8484: Enable duration guard ( Current prod state:
by AI for @beastoin |
PARAKEET_ATTENTION_MODE: full → auto PARAKEET_MAX_FILE_DURATION: 0 → 7200 (reject >2hr files) Part of PR BasedHardware#8428 deployment plan.
Reverts auto attention switching, BF16 dtype tracking, and threshold default change. Restores pre-PR state. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Reverts soundfile import, pre-batch duration guard improvements, metrics poisoning fix, and _duration_limit_detail helper. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Removes BF16 recast and attention switch tests added by PR BasedHardware#8428. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Removes FLAC detection, unprobeable upload rejection, and metrics poisoning tests added by PR BasedHardware#8428. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Removes PARAKEET_ATTENTION_MODE, PARAKEET_AUTO_ATTN_THRESHOLD, PARAKEET_LOCAL_ATTN_CONTEXT, and PARAKEET_MAX_FILE_DURATION env vars. Co-Authored-By: Claude Opus 4.6 <[email protected]>
BasedHardware#8485) ## Summary Reverts all changes from PR BasedHardware#8428 and related follow-up commits (Phase 2 enable + rollback) to restore main to a clean state. **Why:** Phase 2 deployment of auto attention mode caused 14 OOMs and 22% error rate in 27 minutes — root cause was torch.compile being disabled for auto mode, which increased VRAM ~3x under production batch load. Main needs to be clean before re-landing the safe subset of changes. **What's reverted:** - `gpu_worker.py` — BF16 dtype tracking, auto attention threshold default change (600→300) - `main.py` — soundfile import, pre-batch duration guard improvements, metrics poisoning fix - `test_parakeet_gpu_worker.py` — BF16 recast and attention switch tests - `test_parakeet_endpoints.py` — FLAC detection, unprobeable upload, metrics poisoning tests - `prod_omi_parakeet_values.yaml` — removes 4 env vars (ATTENTION_MODE, THRESHOLD, LOCAL_CONTEXT, MAX_FILE_DURATION) **What happens next:** A new clean PR will re-land only the proven-safe changes (duration guard + BF16 recast) with `ATTENTION_MODE=full` + `MAX_FILE_DURATION=600`. Reverts BasedHardware#8428 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/8485?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…k tests (#8486) ## Summary Re-land of attention mode system from reverted PR #8428, with auto attention enabled and 1-hour duration guard. OOM reproduction confirmed the VRAM leak is NOT in parakeet /v2/transcribe code — the prod OOM was caused by something in the full pipeline (WebSocket /v3/stream, diarizer, concurrent sessions). - **Auto attention mode** — dynamically switches between full and local attention based on audio duration (threshold 300s). torch.compile is skipped in auto mode - **Duration guard** — rejects files >3600s (1 hour) before they reach the GPU - **BF16 dtype tracking** — fixes dtype mismatch after attention mode switch - **Soundfile detection** — handles FLAC, OGG, and other non-WAV formats in the pre-batch duration check - **Fail-closed on unprobeable uploads** — returns 413 instead of sending unknown-duration files to GPU - **Metrics poisoning fix** — inf values from unprobeable files no longer corrupt the AUDIO_DURATION histogram - **Sustained VRAM leak test** — new test script + container test class that detects monotonic VRAM accumulation via linear regression slope analysis - **Chaos OOM test** — mixed /v2/transcribe + /v3/stream load test with varying audio durations ### What changed from PR #8428 | Feature | PR #8428 | This PR | |---------|----------|---------| | Auto attention switching | Included (caused OOMs) | Enabled — OOM root cause confirmed outside parakeet | | Duration guard | MAX_FILE_DURATION=0 (disabled) | MAX_FILE_DURATION=3600 (1 hour) | | BF16 recast fix | Included | Included (unchanged) | | Soundfile detection | Included | Included (unchanged) | | Metrics poisoning fix | Included | Included (unchanged) | | torch.compile | Disabled by auto mode | Disabled by auto mode (same) | | VRAM leak detection | None | New sustained leak test + chaos test scripts | ### Production config ```yaml PARAKEET_ATTENTION_MODE: "auto" # dynamic full/local switching PARAKEET_MAX_FILE_DURATION: "3600" # reject >1hr files PARAKEET_AUTO_ATTN_THRESHOLD: "300" # switch to local at 5min PARAKEET_LOCAL_ATTN_CONTEXT: "128,128" # local attention window PARAKEET_TORCH_COMPILE: "true" # configured but skipped by auto mode ``` ### Test evidence - **[Chaos OOM test results](#8486 (comment) — 632 requests (mixed batch + WebSocket), 100% success, zero OOMs, VRAM slope +2.2 MiB/min - **[Reproduction guide with scripts](#8486 (comment) — step-by-step setup, audio generation, and all test commands - **OOM reproduction on exact prod image (a5a4262)** — 20-min sustained load, 1200 requests, slope +5.7 MiB/min, zero OOMs — confirmed leak is NOT in parakeet code ### Scripts in this PR | Script | Purpose | |--------|---------| | `backend/scripts/parakeet_chaos_oom_test.py` | Mixed REST+WebSocket chaos test with VRAM monitoring | | `backend/scripts/parakeet_vram_leak_test.py` | Sustained VRAM leak detection via linear regression | | `backend/scripts/reproduce_parakeet_oom.py` | OOM reproduction with escalating durations | | `backend/tests/container/test_parakeet_vram_stress.py` | pytest container tests (burst + sustained) | ## Test plan - [x] 89 gpu_worker unit tests pass (including attention switching, BF16, duration guard) - [x] 30 endpoint unit tests pass (including duration guard 413 tests) - [x] Sustained VRAM leak test passes on exact prod image (a5a4262) - [x] Chaos OOM test passes — 632 mixed requests, zero OOMs, zero errors - [x] Attention switching exercised ~80 times (long files >300s interleaved with short) - [ ] Deploy with `gcp_parakeet.yml` and verify pod starts cleanly - [ ] Monitor VRAM + OOM rate for 1 hour post-deploy Replaces reverted #8428 and closed #8484. _by AI for @beastoin_
Monitors GPU memory via nvidia-smi during concurrent requests with varying audio durations (30s-300s). Gates on peak VRAM staying below configurable threshold (default 85%). Would have caught the Phase 2 OOM from PR BasedHardware#8428 where disabling torch.compile tripled VRAM under batch load. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Problem
Parakeet OOMs on long audio files. Full attention uses O(T²) VRAM — memory grows quadratically with audio length. On L4 (24GB), empirical VRAM measurements show: 5-min audio uses only 6.7 GB (28% of 24GB), 10-min uses ~12.2 GB (51%), but 15-min hits ~21.4 GB (borderline OOM with fragmentation) and 20-min exceeds 24 GB (guaranteed OOM). There is no pre-inference guard, so one oversized upload can crash the GPU worker and fail the entire batch (all concurrent requests).
Solution
Port the attention mode system from beastoin/NeMo#8 (commit d6956b21a0aa) into
backend/parakeet/, adding three features:1. Auto attention switching (
PARAKEET_ATTENTION_MODE=auto)torch.compile(incompatible with runtime attention switching)2. Max file duration guard (
PARAKEET_MAX_FILE_DURATION)/v1/transcribeand/v2/transcribe— one oversized file no longer crashes the entire batchsoundfile.info()for format-agnostic duration detection (WAV, FLAC, OGG, etc.) withwave.open()fallback3. BF16 dtype recast after attention switch
change_attention_model()creates new linear layers in float32. With our BF16 optimization, inputs arrive as bfloat16 but new weights are float32 →RuntimeError: mat1 and mat2 must have the same dtypeConfiguration
All opt-in with safe defaults — existing deployments are unchanged.
PARAKEET_ATTENTION_MODEfullfull(current behavior),local(always linear VRAM), orauto(per-request switching)PARAKEET_AUTO_ATTN_THRESHOLD300PARAKEET_LOCAL_ATTN_CONTEXT128,128PARAKEET_MAX_FILE_DURATION0Files changed
backend/parakeet/gpu_worker.pybackend/parakeet/main.pybackend/tests/unit/test_parakeet_gpu_worker.pybackend/tests/unit/test_parakeet_endpoints.pyTest evidence
Unit tests
89 tests (59 gpu_worker + 30 endpoint), all pass.
Long-audio benchmark (LibriSpeech test-clean, L4 GPU)
90 minutes of audio transcribed in 27.5 seconds. No OOM.
Industrial throughput benchmark (100 LibriSpeech WAVs, mean 6.87s)
RTFx computed from actual WAV header durations, not estimates.
Container tests on dev L4 GPU pod
12/12 pass: concurrency (cc=8, cc=16), WER gate (<15%), RTFx gate (>50x), sustained ramp.
Risks
change_attention_model()is NeMo internal API — may change in future NeMo versionstorch.compile(trade-off: flexibility vs peak throughput on short files)Closes #8426
by AI for @beastoin