Skip to content

Fix parakeet batch=1 throughput collapse from flush_pending early reset - #8666

Merged
beastoin merged 2 commits into
mainfrom
fix/parakeet-flush-pending-batch1-8664
Jun 30, 2026
Merged

beastoin merged 2 commits into
mainfrom
fix/parakeet-flush-pending-batch1-8664

Conversation

@beastoin

@beastoin beastoin commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes batch=1 throughput collapse introduced in PR #8535. Production data showed 72.8% of GPU batches containing only 1 file (avg 1.6 files/batch), causing LB 504 timeouts.

Root cause: The early self._flush_pending = False reset inside _flush_batch() (line 273) allowed the 2ms flush timer to fire between individual request arrivals, producing batch=1 flushes instead of accumulating requests during GPU processing.

Fix: Remove the early reset so _flush_pending only resets in _guarded_flush()'s finally block. This keeps the gate held during the entire GPU inference cycle, letting requests accumulate while GPU is busy.

Changes

  • batch_engine.py: Remove early _flush_pending = False on line 273
  • test_flush_pending_batch1.py: New regression test — simulates staggered arrivals (20ms interval) with GPU latency (300ms), asserts batch accumulation
  • test_parakeet_batch_engine.py: Replace test_two_batches_inflight_concurrently (which depended on early reset) with test_sequential_batching_accumulates_requests
  • test.sh: Wire new regression test into CI

RED/GREEN evidence

  • RED (main, with early reset): batches=[1, 1, 10], batch1_count=2 → FAIL
  • GREEN (fix, without early reset): batches=[1, 11], batch1_count=1 → PASS

Test evidence

All 25 parakeet batch engine tests pass (24 existing + 1 new regression test). 239 total parakeet tests pass.

Changed-path coverage

Path ID Changed path Happy-path test Non-happy-path test L1 result L2 result
P1 batch_engine.py:_flush_batch — removed early _flush_pending=False reset Staggered arrivals accumulate into batches >1 during GPU processing: batches=[1, 11], avg=6.0 First-tick unavoidable batch=1 still allowed: batch1_count=1 ≤ 1 PASS (25/25 tests) PASS (production trace confirms root cause)

Risks

  • Concurrent batches via timer-triggered flushing no longer possible — batches are now sequential per _guarded_flush call. This is the pre-VRAM-aware dynamic batch sizing for parakeet #8535 behavior and is correct: the semaphore still allows max_inflight=2 concurrent GPU batches when submit() triggers immediate flush (queue >= max_batch_size).
  • No VRAM or duration logic changes.

Closes #8664

by AI for @beastoin

@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 2 files

Confidence score: 5/5

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

Re-trigger cubic

The early `self._flush_pending = False` inside `_flush_batch()` (added in
PR #8535) allowed the 2ms flush timer to fire between individual request
arrivals, producing batch=1 flushes instead of accumulating requests during
GPU processing. Production data showed 72.8% batch=1 (avg 1.6 files/batch)
causing LB 504 timeouts.

Fix: remove the early reset so `_flush_pending` only resets in
`_guarded_flush()`'s `finally` block, keeping the gate held during the
entire GPU inference cycle. Requests accumulate while GPU is busy.

Adds regression test simulating staggered arrivals with GPU latency.
Updates TestMaxInflight2 to verify accumulation behavior.

Closes #8664

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin
beastoin force-pushed the fix/parakeet-flush-pending-batch1-8664 branch from d4e730c to ec1c84a Compare June 30, 2026 04:21
@beastoin
beastoin merged commit d5fb107 into main Jun 30, 2026
7 checks passed
@beastoin
beastoin deleted the fix/parakeet-flush-pending-batch1-8664 branch June 30, 2026 05:44
@beastoin

Copy link
Copy Markdown
Collaborator Author

lgtm

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.

Parakeet: flush_pending early reset causes batch=1 throughput collapse

1 participant