Skip to content

Cap parakeet max batch size to 8 for auto attention mode - #8533

Closed
beastoin wants to merge 1 commit into
mainfrom
fix/parakeet-batch-size-cap-8486
Closed

beastoin wants to merge 1 commit into
mainfrom
fix/parakeet-batch-size-cap-8486

Conversation

@beastoin

@beastoin beastoin commented Jun 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds PARAKEET_MAX_BATCH_SIZE=8 to prod parakeet Helm values
  • Prevents VRAM exhaustion when auto attention mode disables torch.compile

Context

Follow-up to PR #8486 (auto attention + 1h duration guard). Post-deploy monitoring detected a CUDA OOM at T+22min when a batch of 12 concurrent files exhausted ~93% VRAM. Auto mode disables torch.compile, which increases VRAM per batch item ~3x vs compiled mode. The default max_batch_size=32 is too high for the uncompiled path.

OOM event: Single burst at 03:13 UTC, pod self-recovered in ~35s (0 restarts), 200+ successful requests after recovery. Batch size cap at 8 keeps estimated VRAM under ~70%.

Test plan

  • Verify Helm values render correctly (helm template)
  • Deploy via gcp_parakeet.yml with Helm upgrade
  • Confirm new pod has PARAKEET_MAX_BATCH_SIZE=8 env var
  • Monitor for zero OOMs under normal traffic
  • zen to reproduce and validate on dev with burst testing

Fixes OOM observed in #8486 post-deploy monitoring.

🤖 Generated with Claude Code

Review in cubic

Auto attention mode disables torch.compile, which increases VRAM per
batch item ~3x vs compiled mode. The default max_batch_size=32 allowed
a burst of 12 concurrent files to exhaust VRAM (93%) and OOM at T+22m
post-deploy. Capping at 8 keeps estimated VRAM under 70%.

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

zen's VRAM analysis — static cap=8 is a bandaid

zen validated the 3x VRAM ratio empirically on L4:

  • With torch.compile: 45.5 bytes/T² per batch item
  • Without torch.compile: 136.6 bytes/T² per batch item (3.0x exactly)

The VRAM math matches prod almost exactly: predicted 20,973 MiB vs observed 20,430 MiB for 12 files at ~250s avg.

Problem with static cap=8: At B=8 with 300s files (just under auto threshold), estimated VRAM = ~20.3 GiB — marginal OOM territory. Static cap either OOMs on long files or wastes throughput on short files where B=32 is safe.

Proper fix: VRAM-aware dynamic batch sizing:

max_safe_B = available_vram / (coefficient × T_max²)
  • 30s files (T=375): allows B=32 (full throughput)
  • 120s files (T=1500): caps to B=8
  • 300s files (T=3750): caps to B=1-2

This PR remains valid as an immediate hotfix — most prod traffic is short files where B=8 is fine. VRAM-aware admission should follow as a proper solution.

by AI for @beastoin

@beastoin

Copy link
Copy Markdown
Collaborator Author

OOM Root Cause Confirmed — Audio Duration Analysis

Grafana data from ops (mon) confirms the exact failure mode:

No files ≥300s were processed — auto attention switching is working correctly and was never triggered. The OOM was caused by a burst of files in the 120-300s danger zone: long enough for massive O(T²) softmax attention matrices, but just under the 300s threshold to trigger local attention.

Metric Pre-OOM (03:13) At OOM (03:14) Post-OOM (03:18)
p50 duration 30s 99s 26s
p95 duration 102s 280s 57s
p99 duration 116s 296s (4s shy of threshold) 59s
Files 120-300s 0 23 normal

Key finding: p99 hit 296s during the OOM — a burst of 23 files in the 120-300s range arrived in one minute. These files use full attention (quadratic VRAM scaling) because they're under the 300s auto threshold. With batch_size=12 and ~250s avg duration, the full attention softmax exhausted VRAM.

Implications for the fix:

  1. Static cap=8 (this PR) helps but doesn't solve the fundamental issue — B=8 with 280s files would still hit ~18 GiB
  2. VRAM-aware dynamic batch sizing (zen's formula) is the proper fix — it naturally caps B=1-2 for 280s files
  3. Lowering the auto attention threshold (e.g. 120s instead of 300s) could also help by switching more files to local attention, but needs quality impact analysis

by AI for @beastoin

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified the change — PARAKEET_MAX_BATCH_SIZE is consumed at backend/parakeet/main.py:136 (max_batch_size=int(os.getenv("PARAKEET_MAX_BATCH_SIZE", "32"))), so the cap to 8 takes effect correctly. YAML renders fine and there are no merge conflicts.

This is a sound, minimal hotfix for the post-#8486 OOM: capping the uncompiled auto-attention path at batch size 8 is conservative — worst case is marginally lower throughput, not a safety regression. Checks are green.

One thing worth noting: #8535 proposes VRAM-aware dynamic batch sizing as a more comprehensive follow-up. The two approaches are complementary rather than conflicting — this PR stops the bleeding now, and #8535 could refine it later if the static cap proves too conservative. Recommend merging this as the immediate fix.

(Omi PR monitor review · glm-5.2)

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed — looks good for this area; approving (not merging per area policy).

@beastoin beastoin closed this Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

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! 💜

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.

3 participants