Skip to content

Fix GPU memory accumulation across files in ASR batch inference demo - #439

Open
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
microsoft:mainfrom
ammar-iitm:fix/asr-batch-memory-accumulation
Open

Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
microsoft:mainfrom
ammar-iitm:fix/asr-batch-memory-accumulation

Conversation

@ammar-iitm

Copy link
Copy Markdown

Summary

  • Fixes [Bug] demo/vibevoice_asr_inference_from_file.py accumulates working memory across files in --audio_files batch #368: demo/vibevoice_asr_inference_from_file.py OOMs partway through a multi-file --audio_files run even though each file fits comfortably on its own.
  • transcribe_batch() never released the CUDA caching allocator's freed blocks between files/batches. Since audio files vary in length, each batch produces differently-shaped tensors, so freed memory blocks from one file's batch often aren't reusable for the next file's shapes — fragmentation compounds across the run.
  • Adds a _release_memory() step (gc.collect() + empty_cache() for cuda/xpu/mps) run at the end of each transcribe_batch() call, so allocator state is reset between files/batches.

Test plan

🤖 Generated with Claude Code

https://claude.ai/code/session_016fM2LafALmBK16KnFWjsp7

transcribe_batch() never released the CUDA caching allocator's freed
blocks between files. Since audio files vary in length, each batch
produces differently-shaped tensors, so freed blocks from one file's
batch often can't be reused for the next file's shapes. This
fragmentation compounds across a multi-file --audio_files run and can
OOM partway through even though each file fits fine on its own
(reported in microsoft#368).

Add a _release_memory() step (gc.collect + empty_cache for
cuda/xpu/mps) run after each batch in transcribe_batch().

Fixes microsoft#368

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016fM2LafALmBK16KnFWjsp7
@ammar-iitm

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree [company="default"]
@microsoft-github-policy-service agree
@microsoft-github-policy-service agree company="Microsoft"

@ammar-iitm

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree
@microsoft-github-policy-service agree company=""

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.

[Bug] demo/vibevoice_asr_inference_from_file.py accumulates working memory across files in --audio_files batch

1 participant