Skip to content

Fix mel spectrogram preprocessor allocating gigabytes of planned memory#18238

Merged
manuelcandales merged 2 commits intorelease/1.2from
cherry-pick-18229-by-pytorch_bot_bot_
Mar 18, 2026
Merged

Fix mel spectrogram preprocessor allocating gigabytes of planned memory#18238
manuelcandales merged 2 commits intorelease/1.2from
cherry-pick-18229-by-pytorch_bot_bot_

Conversation

@pytorchbot
Copy link
Collaborator

The dynamic dimension max was computed as max_audio_len * n_samples
(samples per 30s chunk), not max_audio_len * sampling_rate. With
max_audio_len=300, this produced 144M samples (150 minutes) instead of
4.8M (5 minutes), causing a ~3.3 GB planned buffer for STFT
intermediates.

For streaming mode, the max was even worse: 600 * 480K = 288M samples,
producing a 6.6 GB planned buffer — even though streaming processes
~1640 samples per step.

Fix both paths:

  • Offline: use max_audio_len * sampling_rate (300s → 4.8M samples, ~110 MB)
  • Streaming: cap at 2 seconds (32K samples, ~0.7 MB)

Peak RSS for voxtral runner: (before) 9,556 MB, after (4,712 MB)

…ry (#18229)

The dynamic dimension max was computed as max_audio_len * n_samples
(samples per 30s chunk), not max_audio_len * sampling_rate. With
max_audio_len=300, this produced 144M samples (150 minutes) instead of
4.8M (5 minutes), causing a ~3.3 GB planned buffer for STFT
intermediates.

For streaming mode, the max was even worse: 600 * 480K = 288M samples,
producing a 6.6 GB planned buffer — even though streaming processes
~1640 samples per step.

Fix both paths:
- Offline: use max_audio_len * sampling_rate (300s → 4.8M samples, ~110
MB)
- Streaming: cap at 2 seconds (32K samples, ~0.7 MB)

 Peak RSS for voxtral runner: (before) 9,556 MB, after (4,712 MB)

(cherry picked from commit 776979f)
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 17, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18238

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 Cancelled Jobs

As of commit a759487 with merge base 8c0a60b (image):

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reduces excessive planned memory allocation when exporting WhisperAudioProcessor by correcting the dynamic input dimension upper bound used for torch.export, preventing multi-GB buffer plans in both offline and streaming preprocessors.

Changes:

  • Fix offline export dynamic max dimension to use max_audio_len * sampling_rate (samples), instead of max_audio_len * n_samples.
  • Add a streaming-specific export bound to keep the memory plan tight by capping max input samples (currently to 2 seconds).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@manuelcandales manuelcandales merged commit 0005180 into release/1.2 Mar 18, 2026
220 of 228 checks passed
@manuelcandales manuelcandales deleted the cherry-pick-18229-by-pytorch_bot_bot_ branch March 18, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/metal CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants