Repository navigation
Parakeet: auto attention + 1h duration guard + BF16 recast + VRAM leak tests - #8486
Conversation
- Track model dtype after BF16 conversion to recast after attention mode switches (prevents dtype mismatch causing OOM on long audio) - Recast to BF16 after change_attention_model in local mode init and in _switch_attention for both directions - Lower PARAKEET_AUTO_ATTN_THRESHOLD default from 600s to 300s for safer batch VRAM budget under concurrent requests Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Add soundfile as primary format detector (handles FLAC, OGG, etc.) - Fail closed on unprobeable uploads when duration guard is enabled (return inf → rejected with 413 before reaching GPU) - Move AUDIO_DURATION.observe after 413 guard and add isfinite check to prevent inf values from poisoning the histogram - Add _duration_limit_detail helper for human-readable 413 messages Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests for BF16 dtype recast after local mode init and attention mode switching in both directions. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- FLAC duration detection via soundfile - Unprobeable audio rejection on v1 and v2 endpoints - Verify inf values don't poison AUDIO_DURATION histogram Co-Authored-By: Claude Opus 4.6 <[email protected]>
ATTENTION_MODE=full (safe, torch.compile compatible) MAX_FILE_DURATION=600 (reject files >10min to prevent OOM) AUTO_ATTN_THRESHOLD=300 and LOCAL_ATTN_CONTEXT=128,128 configured but inactive while mode=full. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 5/5
- In
backend/tests/unit/test_parakeet_gpu_worker.py, leavingtorch_mod.cuda.is_bf16_supported.return_value = Trueon the sharedsys.modules["torch"]mock can leak state into later tests and cause order-dependent/flaky unit-test outcomes rather than product behavior regressions—reset or scope the mock (e.g., fixture teardown/context manager) before merging.
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_gpu_worker.py">
<violation number="1" location="backend/tests/unit/test_parakeet_gpu_worker.py:599">
P3: `torch_mod.cuda.is_bf16_supported.return_value` is set to `True` and never restored, leaking test state into subsequent tests via the shared `sys.modules["torch"]` mock.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| torch_mod = sys.modules["torch"] | ||
| orig_avail = torch_mod.cuda.is_available.return_value | ||
| torch_mod.cuda.is_available.return_value = True | ||
| torch_mod.cuda.is_bf16_supported.return_value = True |
There was a problem hiding this comment.
P3: torch_mod.cuda.is_bf16_supported.return_value is set to True and never restored, leaking test state into subsequent tests via the shared sys.modules["torch"] mock.
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_gpu_worker.py, line 599:
<comment>`torch_mod.cuda.is_bf16_supported.return_value` is set to `True` and never restored, leaking test state into subsequent tests via the shared `sys.modules["torch"]` mock.</comment>
<file context>
@@ -586,6 +586,37 @@ def test_local_mode_calls_change_attention_on_load(self):
+ torch_mod = sys.modules["torch"]
+ orig_avail = torch_mod.cuda.is_available.return_value
+ torch_mod.cuda.is_available.return_value = True
+ torch_mod.cuda.is_bf16_supported.return_value = True
+
+ with patch.dict(
</file context>
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 #8428 where disabling torch.compile tripled VRAM under batch load. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Standalone script that sends concurrent requests with increasing audio durations and monitors VRAM via nvidia-smi. Identifies the exact duration threshold where OOM occurs for a given config. Usage: PARAKEET_URL=http://localhost:8080 python reproduce_parakeet_oom.py Co-Authored-By: Claude Opus 4.6 <[email protected]>
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/scripts/reproduce_parakeet_oom.py">
<violation number="1" location="backend/scripts/reproduce_parakeet_oom.py:183">
P3: Unused variable `done_count` — incremented but never read</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| done_count = 0 | ||
| for f in as_completed(futures): | ||
| done_count += 1 |
There was a problem hiding this comment.
P3: Unused variable done_count — incremented but never read
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/scripts/reproduce_parakeet_oom.py, line 183:
<comment>Unused variable `done_count` — incremented but never read</comment>
<file context>
@@ -0,0 +1,251 @@
+
+ done_count = 0
+ for f in as_completed(futures):
+ done_count += 1
+ cur_used, _ = get_gpu_memory()
+ if cur_used and cur_used > peak_used:
</file context>
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for splitting out the safer Parakeet recovery path from the reverted OOM work. I reviewed the diff and this looks directionally good: the production chart keeps attention mode on full, adds a 600s pre-GPU duration guard, handles non-WAV duration probing with soundfile, fail-closes unknown-duration uploads while the guard is enabled, and avoids poisoning the duration histogram with non-finite values.
I’m leaving this as a positive signal rather than a formal approval because this changes the production Parakeet Helm config / runtime guardrails, so it should get human maintainer verification before merge.
Before merging, I’d like a maintainer to verify the deployment-specific pieces from the PR checklist:
- pod starts cleanly with the new Parakeet environment variables,
-
600s uploads are rejected before GPU enqueue in the deployed service,
- normal ~30–60s traffic still transcribes successfully under the production config,
- VRAM stays healthy after rollout.
No blocking code issue found from my static review. The CI checks shown on the PR are passing.
kodjima33
left a comment
There was a problem hiding this comment.
Backend: Parakeet duration guard + BF16 recast fix (beastoin) — approve only (large, deploy verification for maintainer).
ATTENTION_MODE=auto dynamically switches between full and local attention based on audio duration (threshold 300s). torch.compile is skipped in auto mode — our 20-min sustained load test on the exact prod image (a5a4262) showed no VRAM leak (slope +5.7 MiB/min, zero OOMs). 1h duration cap (3600s) provides safety for long files. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Standalone script that runs prolonged load against a parakeet pod and detects monotonic VRAM accumulation via linear regression slope. Four gates: peak VRAM < 85%, slope < 50 MiB/min, zero OOMs, recovery within 20% of baseline. Supports nvidia-smi (direct GPU) and process RSS (/metrics endpoint) monitoring modes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adds sustained load class that runs 5-min (configurable) test at 30 req/min and checks VRAM slope via linear regression. Catches the type of monotonic leak that caused the Phase 2 OOM — burst tests miss it because VRAM releases between batches. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
3 issues 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/container/test_parakeet_vram_stress.py">
<violation number="1" location="backend/tests/container/test_parakeet_vram_stress.py:437">
P2: pool.shutdown(wait=False) does not wait for in-flight tasks; time.sleep(10) is not guaranteed to be enough for all tasks to complete, so OOM count and success/fail tallies may be incomplete.</violation>
</file>
<file name="backend/charts/parakeet/prod_omi_parakeet_values.yaml">
<violation number="1" location="backend/charts/parakeet/prod_omi_parakeet_values.yaml:108">
P1: PARAKEET_ATTENTION_MODE set to "auto" but PR description states prod config should be "full" (torch.compile compatible). Auto mode was excluded due to OOM risk and described as "not enabled in production."</violation>
<violation number="2" location="backend/charts/parakeet/prod_omi_parakeet_values.yaml:114">
P1: PARAKEET_MAX_FILE_DURATION set to "3600" (1h) but PR description states prod guard is "600" (10 min). 1h limit defeats the pre-GPU duration guard's OOM protection purpose.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| - name: PARAKEET_LOCAL_ATTN_CONTEXT | ||
| value: "128,128" | ||
| - name: PARAKEET_MAX_FILE_DURATION | ||
| value: "3600" |
There was a problem hiding this comment.
P1: PARAKEET_MAX_FILE_DURATION set to "3600" (1h) but PR description states prod guard is "600" (10 min). 1h limit defeats the pre-GPU duration guard's OOM protection purpose.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/charts/parakeet/prod_omi_parakeet_values.yaml, line 114:
<comment>PARAKEET_MAX_FILE_DURATION set to "3600" (1h) but PR description states prod guard is "600" (10 min). 1h limit defeats the pre-GPU duration guard's OOM protection purpose.</comment>
<file context>
@@ -105,13 +105,13 @@ env:
value: "128,128"
- name: PARAKEET_MAX_FILE_DURATION
- value: "600"
+ value: "3600"
- name: HOSTED_SPEAKER_EMBEDDING_API_URL
value: "http://prod-omi-diarizer.prod-omi-backend.svc.cluster.local:8080"
</file context>
| value: "3600" | |
| value: "600" |
| - name: PARAKEET_CUDA_GRAPHS | ||
| value: "true" | ||
| - name: PARAKEET_ATTENTION_MODE | ||
| value: "auto" |
There was a problem hiding this comment.
P1: PARAKEET_ATTENTION_MODE set to "auto" but PR description states prod config should be "full" (torch.compile compatible). Auto mode was excluded due to OOM risk and described as "not enabled in production."
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/charts/parakeet/prod_omi_parakeet_values.yaml, line 108:
<comment>PARAKEET_ATTENTION_MODE set to "auto" but PR description states prod config should be "full" (torch.compile compatible). Auto mode was excluded due to OOM risk and described as "not enabled in production."</comment>
<file context>
@@ -105,13 +105,13 @@ env:
value: "true"
- name: PARAKEET_ATTENTION_MODE
- value: "full"
+ value: "auto"
- name: PARAKEET_AUTO_ATTN_THRESHOLD
value: "300"
</file context>
| value: "auto" | |
| value: "full" |
| except KeyboardInterrupt: | ||
| pass | ||
|
|
||
| pool.shutdown(wait=False) |
There was a problem hiding this comment.
P2: pool.shutdown(wait=False) does not wait for in-flight tasks; time.sleep(10) is not guaranteed to be enough for all tasks to complete, so OOM count and success/fail tallies may be incomplete.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/container/test_parakeet_vram_stress.py, line 437:
<comment>pool.shutdown(wait=False) does not wait for in-flight tasks; time.sleep(10) is not guaranteed to be enough for all tasks to complete, so OOM count and success/fail tallies may be incomplete.</comment>
<file context>
@@ -354,6 +354,127 @@ def test_no_oom_at_production_pattern(self, gpu_available):
+ except KeyboardInterrupt:
+ pass
+
+ pool.shutdown(wait=False)
+ time.sleep(10)
+ monitor.stop()
</file context>
| pool.shutdown(wait=False) | |
| pool.shutdown(wait=True) |
Chaos OOM Test Results — Mixed /v2/transcribe + /v3/stream20-minute sustained load on dev pod ( 632 requests, 100% success, zero OOMs, zero 500s.
VRAM analysis (112 samples over 20 min):
Latency: p50=3.3s, p95=74.4s (p95 dominated by WebSocket session duration, not GPU latency) Auto attention mode is stable under mixed chaos load — short and long files interleaved concurrently with WebSocket streams, no VRAM accumulation. by AI for @beastoin |
Chaos OOM Test — Reproduction GuideAll scripts are in this PR. Here's how to reproduce the full test suite. 1. Get test audio (LibriSpeech continuous segments)mkdir -p /tmp/librispeech_continuous
cd /tmp/librispeech_continuous
# Download LibriSpeech test-clean
wget -q https://www.openslr.org/resources/12/test-clean.tar.gz
tar xzf test-clean.tar.gz
# Concatenate into continuous segments of varying lengths
# (10-400s to trigger attention switching at 300s threshold)
pip install pydub
python3 -c "
from pydub import AudioSegment
import os, glob
flacs = sorted(glob.glob('LibriSpeech/test-clean/**/*.flac', recursive=True))
combined = AudioSegment.empty()
seg_id = 0
targets = [60]*5 + [75]*3 + [90]*3 + [120]*3 + [150]*2 + [200]*2 + [300, 350, 400]
for flac in flacs:
combined += AudioSegment.from_file(flac)
if seg_id < len(targets) and len(combined) >= targets[seg_id] * 1000:
out = f'continuous_{seg_id:02d}_{targets[seg_id]}s.wav'
combined.export(out, format='wav', parameters=['-ar', '16000', '-ac', '1'])
print(f' {out} ({len(combined)/1000:.0f}s)')
combined = AudioSegment.empty()
seg_id += 1
# One file specifically for attention switching (>300s)
if len(combined) > 0:
combined.export('attention_switch_400s.wav', format='wav', parameters=['-ar', '16000', '-ac', '1'])
"
rm -rf LibriSpeech test-clean.tar.gz
ls -la /tmp/librispeech_continuous/2. Deploy parakeet with auto attention mode# backend/charts/parakeet/dev_omi_parakeet_values.yaml (or prod)
env:
- name: PARAKEET_ATTENTION_MODE
value: "auto"
- name: PARAKEET_AUTO_ATTN_THRESHOLD
value: "300"
- name: PARAKEET_MAX_FILE_DURATION
value: "3600"
- name: PARAKEET_TORCH_COMPILE
value: "true" # configured but skipped by auto mode
- name: PARAKEET_CUDA_GRAPHS
value: "true"3. Port-forward to the podkubectl -n dev-omi-backend port-forward pod/<parakeet-pod> 10120:8080 &
curl -s http://127.0.0.1:10120/health4. Run the chaos OOM test (mixed /v2/transcribe + /v3/stream)pip install httpx websockets
# 20 min, 40 req/min, 30% WebSocket streams, 70% batch transcribe
python3 backend/scripts/parakeet_chaos_oom_test.py \
--server http://127.0.0.1:10120 \
--duration 1200 \
--rpm 40 \
--stream-ratio 0.3 \
--audio-dir /tmp/librispeech_continuous
# Quick smoke test (5 min, lower rate)
python3 backend/scripts/parakeet_chaos_oom_test.py \
--server http://127.0.0.1:10120 \
--duration 300 \
--rpm 20 \
--stream-ratio 0.3 \
--audio-dir /tmp/librispeech_continuousWhat it does: Sends mixed traffic — batch uploads (short 10-60s, medium 60-180s, long 180-400s) and WebSocket streams (30-120s) concurrently. Long files (>300s) trigger the auto attention switch from full→local. Short files interleaved switch it back. Monitors VRAM slope via linear regression, counts OOMs and 500 errors. Pass criteria: zero OOMs, zero 500s, VRAM slope < 50 MiB/min. 5. Run the sustained VRAM leak test (batch only, longer soak)# 20 min sustained at 60 req/min (pure /v2/transcribe)
python3 backend/scripts/parakeet_vram_leak_test.py \
--server http://127.0.0.1:10120 \
--duration 1200 \
--rpm 60 \
--audio-dir /tmp/librispeech_continuousPass criteria: peak VRAM < 85%, slope < 50 MiB/min, zero OOMs, recovery within 20% of baseline. 6. Run unit testscd backend
python3 -m pytest tests/unit/test_parakeet_gpu_worker.py -v
python3 -m pytest tests/unit/test_parakeet_endpoints.py -vScripts in this PR
by AI for @beastoin |
|
lgtm |
Deploy Monitor — T+20m Quick Health SweepDeploy confirmed at 02:51 UTC (merged 02:28 UTC).
Startup sequence (from pod events):
Pending verification (ops agent checking logs):
Next checkpoint: T+30m extended health (03:03 UTC). by AI for @beastoin |
Deploy Monitor — T+30m Extended CheckpointAll startup log markers verified by ops (mon):
VRAM baseline: 5709 MiB / 22563 MiB (25%) after model load — healthy headroom. Pod health at T+7m:
Status: PASS — all config changes applied correctly, model loaded cleanly, zero errors. Next checkpoint: T+1h initial impact check (03:33 UTC). by AI for @beastoin |
Deploy Monitor — T+1h Initial Impact CheckPod health at T+42m (03:33 UTC, off-peak window):
Config verification (confirmed at T+0 and T+30m):
Traffic context: Off-peak window (03:33 UTC). Low request volume expected — CPU at ~8% reflects this. Attention switching activity (files >300s) and latency trends will be more meaningful during peak hours. Status: PASS — pod stable, zero restarts, resource usage nominal. Waiting for ops log scan to verify: OOM count, error rate, attention switching activity, request throughput. Will update this checkpoint. Next checkpoint: T+2h (04:33 UTC). by AI for @beastoin |
Deploy Monitor — T+1h UPDATE: OOM Event DetectedSeverity: Single OOM event with self-recovery (no pod restart needed). Timeline (all times UTC):
Impact: Success rate ~89% over the monitoring window. All failures clustered in one 35s burst. Pod self-recovered without restart. Root cause analysis:
Key insight: The previous config ( Recommended fix: Set Config change needed ( PARAKEET_MAX_BATCH_SIZE: "8"Status: WARN — pod stable after recovery, but batch-size cap is needed to prevent recurrence under higher traffic. by AI for @beastoin |
Deploy Monitor — T+2h Stability CheckPod health (04:55 UTC, off-peak):
Post-OOM Stability (03:14 → 04:55 UTC):
Full 2h summary: 1,974/2,034 requests successful (97.1%). All 60 failures confined to the single 03:13 OOM burst. Zero errors since. Pod stability matches pre-deploy baseline (0 restarts). OOM Root Cause — Confirmed & Reproduced on Dev:
Fix Validated (PR #8535 — VRAM-aware dynamic batch sizing):
Assessment: PR #8486's auto attention feature works correctly. The OOM is a batch sizing gap (no VRAM budget in the batch engine), not an attention mode bug. PR #8535 adds the missing VRAM-aware admission control. Status: PASS — stable post-OOM, fix validated and ready for deploy. Next checkpoint: T+4h. |
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).
What changed from PR #8428
Production config
Test evidence
Scripts in this PR
backend/scripts/parakeet_chaos_oom_test.pybackend/scripts/parakeet_vram_leak_test.pybackend/scripts/reproduce_parakeet_oom.pybackend/tests/container/test_parakeet_vram_stress.pyTest plan
gcp_parakeet.ymland verify pod starts cleanlyReplaces reverted #8428 and closed #8484.
by AI for @beastoin