Skip to content

Enable parakeet duration guard (600s) — reject files near OOM boundary - #8484

Closed
beastoin wants to merge 1 commit into
mainfrom
fix/parakeet-enable-duration-guard
Closed

beastoin wants to merge 1 commit into
mainfrom
fix/parakeet-enable-duration-guard

Conversation

@beastoin

@beastoin beastoin commented Jun 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Context

PR #8428 deployed the auto-attention system, but Phase 2 (enabling ATTENTION_MODE=auto) was rolled back after 14 OOMs and 22% error rate in 27 minutes. Root cause: auto mode disables torch.compile, which increases VRAM ~3x under load.

Recommended approach (from @zen): keep full attention + torch.compile + duration guard. Omi audio is short (p50=34s, p95=59s) — no files need >10 min full attention. The duration guard rejects anything near the OOM boundary before it reaches the GPU.

What changes

Setting Before After
PARAKEET_MAX_FILE_DURATION 0 (disabled) 600 (reject >10 min)
PARAKEET_ATTENTION_MODE full full (unchanged)

Deployment

Single-step deploy — no behavior change except 413 rejection for >10 min files:

gh workflow run gcp_parakeet.yml -f environment=prod -f branch=main

Risk

Low — only adds a pre-inference guard. Files under 10 min (>99% of Omi traffic) are unaffected.

by AI for @beastoin

Review in cubic

Full attention + torch.compile (proven stable config) with duration
guard to reject files near the OOM boundary. Files >10 min would risk
OOM at batch_size>1, so reject them pre-inference with HTTP 413.

This replaces the auto-attention approach which required disabling
torch.compile and caused OOMs from increased VRAM usage.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@beastoin

Copy link
Copy Markdown
Collaborator Author

Superseded — PR #8428 reverted via #8485. A new clean PR will include this change (MAX_FILE_DURATION=600) alongside the safe subset of features.

@beastoin beastoin closed this Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @beastoin 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community! 💜

beastoin added a commit that referenced this pull request Jun 29, 2026
…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_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant