Skip to content

Add duration-aware batch scheduling to prevent OOM on long audio #3

Closed as not planned

Description

@beastoin

Problem

The serving example (examples/asr/serving/) has no protection against OOM when processing long audio files. Currently:

  • Upload limit is file size only (100MB), not audio duration
  • Batch size is fixed at 32 regardless of audio length
  • model.transcribe() receives files directly with no duration check
  • Parakeet TDT v3 supports up to 3 hours of audio per file (local attention mode)

A batch of 32 × 30-minute files will OOM on L4 (24GB VRAM). Even a few 1-hour files at batch=32 is risky. As audio duration increases, encoder memory scales linearly — fixed batch sizing doesn't account for this.

Proposed Solution

Add a duration-aware batch scheduler to the GPU worker / batch engine:

1. Pre-flight duration check

  • Read audio duration (via soundfile or torchaudio.info) before queuing
  • Reject files exceeding a configurable max_audio_duration (default: 3 hours for v3, 24 min for v2)

2. Adaptive batch sizing based on VRAM budget

  • Estimate VRAM per file: base_vram + per_second_vram × duration
  • Calibrate per_second_vram empirically on first few requests (or use conservative default)
  • Compute max batch size that fits within a VRAM budget (e.g., 80% of free VRAM)
  • Example: 8s files → batch=32, 60s files → batch=8, 30min files → batch=1

3. Auto-chunking for very long audio (optional)

  • For files exceeding a threshold (e.g., 10-15 minutes), split into overlapping segments
  • Process segments as separate batch items
  • Stitch results using LCS merge on overlap regions
  • TDT duration predictions provide natural alignment info for stitching

4. Configuration

Context

  • Parakeet TDT 0.6B v3 supports 3-hour audio via local attention — users will send long files
  • L4 has 24GB VRAM, model uses ~4-5GB, leaving ~19GB for inference
  • Production workloads (Omi) see p50=34s, p95=59s audio — already approaching limits at batch=32
  • This is a prerequisite for reliable production deployment with mixed audio lengths

Affected Files

  • examples/asr/serving/gpu_worker.py — batch transcribe method, VRAM estimation
  • examples/asr/serving/batch_engine.py — batch formation logic
  • examples/asr/serving/server.py — duration validation on upload
  • examples/asr/serving/conf/serving-batch.yaml — new config fields

Activity

  1. added
    enhancement
    on Jun 16, 2026
  2. beastoin commented on Jun 28, 2026

    @beastoin
    OwnerAuthor

    Closing as superseded by #9 (VRAM-aware batch sizing — PR #11) and #10 (dual-model architecture — PR #12). Together they provide duration-aware batch scheduling with VRAM budget caps and compiled-model throughput for the majority of traffic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions