Skip to content

Scale the default Whisper batch size to the detected GPU memory - #136

Merged
MrDix merged 2 commits into
mainfrom
feat/auto-batch-size
Jul 20, 2026
Merged

Scale the default Whisper batch size to the detected GPU memory#136
MrDix merged 2 commits into
mainfrom
feat/auto-batch-size

Conversation

@MrDix

@MrDix MrDix commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Problem

The fixed default batch size of 16 needs roughly 8 GB VRAM with the default Whisper model (large-v2). On smaller GPUs, runs crashed out-of-memory unless the user knew to lower --whisper_batch_size by hand - the installer could only print a tip. Field testing showed the values that run stable: 8 on a 6 GB card, 4 on a 4 GB card.

Change

--whisper_batch_size now defaults to auto: after GPU detection, the batch size resolves to the detected VRAM:

VRAM batch size
8+ GB (or CPU) 16 (historic default)
6 GB 8
4 GB 4

A lower batch size only slows transcription down - the result is unchanged, so this is safe to do automatically. The resolution happens at runtime (not install time), so it adapts if the hardware changes and works for CLI and GUI alike. The resolved value is printed at startup ("Whisper batch size: 4 (auto, scaled to GPU memory)") and is part of the transcription cache key as before (only resolved ints reach it).

Details:

  • CLI: explicit --whisper_batch_size <int> behaves exactly as before and wins over auto; the flag also accepts the literal auto. A failed VRAM query (driver in a bad state) falls back to the historic default of 16.
  • GUI: the Batch Size spinner gains an Auto position (value 0, the new default) which omits the CLI flag so the runtime scaling applies. Previously saved explicit values (e.g. 16 from the old default) keep working unchanged - users can hit the reset arrow to get Auto.
  • Interactive mode: pressing Enter now selects auto instead of 16.
  • The scary "GPU VRAM is less than 6GB. Program may crash" warning now explains the automatic scaling instead of predicting a crash.
  • Installer summaries (auto_install.bat/.sh) and the README no longer tell small-GPU users to tune the batch size by hand; the remaining tips (batch size 2/1, int8) stay for the still-out-of-memory case.

Testing

  • 7 new unit tests for the VRAM scaling (CPU, CUDA unavailable, 4/6/8/12 GB, VRAM query failure) and 2 for the GUI arg builder (Auto omits the flag, explicit values are forwarded).
  • Full GUI suite passes (184 passed).
  • Smoke-tested on a real 12 GB GPU: resolves to 16.
  • The 4 GB and 6 GB values come from field testing on real hardware (stable full conversions).

Summary by CodeRabbit

  • New Features

    • Whisper batch size now automatically adjusts based on available GPU memory.
    • Added “Auto” mode across CLI, GUI, and interactive configuration.
    • Users can still set a specific batch size manually.
  • Bug Fixes

    • Improved low-VRAM guidance and fallback recommendations to help prevent out-of-memory errors.
  • Documentation

    • Updated help text, installation messages, and troubleshooting guidance to explain automatic scaling and manual overrides.

The fixed default of 16 needs roughly 8 GB VRAM with the large-v2
model; on smaller GPUs the run crashed out-of-memory unless the user
knew to lower --whisper_batch_size by hand.

--whisper_batch_size now defaults to auto: after GPU detection the
batch size resolves to 16 (8+ GB), 8 (6 GB) or 4 (4 GB), field-tested
values that run stable on the respective cards. A lower batch size
only slows transcription down - the result is unchanged. CPU runs and
explicit --whisper_batch_size values behave exactly as before; the
flag also accepts the literal 'auto'.

GUI: the Batch Size spinner gains an 'Auto' position (0, new default)
that omits the CLI flag so the runtime scaling applies; saved explicit
values keep working. The scary sub-6GB VRAM warning now explains the
automatic scaling instead of predicting a crash, and the installer
summaries and README no longer tell small-GPU users to tune the batch
size by hand.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@MrDix, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12e800c1-2363-4992-aba8-ad899cab9465

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1418f and d663e92.

📒 Files selected for processing (9)
  • README.md
  • install/auto_install.bat
  • install/auto_install.sh
  • pytest/modules/DeviceDetection/test_device_detection.py
  • src/UltraSinger.py
  • src/gui/settings_tab.py
  • src/modules/DeviceDetection/device_detection.py
  • src/modules/common_print.py
  • src/modules/init_interactive_mode.py
📝 Walkthrough

Walkthrough

Whisper batch size now defaults to automatic GPU-memory scaling, with explicit CLI, interactive, and GUI overrides. Runtime detection selects sizes from available VRAM, tests cover fallback and threshold behavior, and help or installer guidance reflects the new defaults.

Changes

Automatic Whisper batch sizing

Layer / File(s) Summary
Batch-size resolution and runtime selection
src/Settings.py, src/modules/DeviceDetection/..., src/UltraSinger.py, pytest/modules/DeviceDetection/...
Automatic resolution selects batch sizes from CUDA VRAM, preserves fallback behavior, and is applied during requirement checks with coverage for supported scenarios.
CLI, interactive, and GUI auto mode
src/modules/init_interactive_mode.py, src/gui/config.py, src/gui/settings_tab.py, pytest/gui/...
CLI and interactive auto mode use unset values, while the GUI represents Auto as zero and forwards explicit batch sizes.
Help and installation guidance
src/modules/common_print.py, README.md, install/auto_install.*
Documentation and installer output describe VRAM-based scaling and smaller manual overrides for remaining memory issues.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant init_settings
  participant check_requirements
  participant auto_whisper_batch_size
  participant torch.cuda
  User->>init_settings: select auto or explicit batch size
  init_settings->>check_requirements: provide settings
  check_requirements->>auto_whisper_batch_size: resolve selected device
  auto_whisper_batch_size->>torch.cuda: query GPU availability and VRAM
  torch.cuda-->>auto_whisper_batch_size: VRAM information or error
  auto_whisper_batch_size-->>check_requirements: batch size
  check_requirements-->>User: print selected batch size
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: Whisper batch size now auto-scales based on detected GPU memory.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/auto-batch-size

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/modules/common_print.py`:
- Line 68: Synchronize all VRAM guidance with the runtime batch-size resolver:
update src/modules/common_print.py lines 68-68 and README.md lines 264-264 to
use the actual 16/8/4 GB thresholds, revise README.md lines 857-865 to remove
the contradictory 8 GB fit claims, and update install/auto_install.bat lines
223-229 and 241-249 plus install/auto_install.sh lines 249-255 and 266-273 so
unknown VRAM is not guaranteed to fit and 7 GB GPUs receive accurate guidance.

In `@src/modules/init_interactive_mode.py`:
- Around line 62-66: In the Whisper batch-size input flow, rename the misspelled
whipser_batch_size_response variable and only assign an explicit batch size when
the response is a positive integer; treat empty, non-numeric, and zero or
negative inputs as None so auto mode remains enabled.

In `@src/UltraSinger.py`:
- Around line 2007-2009: Validate the explicit value assigned to
settings.whisper_batch_size in the argument-parsing branch: preserve “auto” as
None, but require numeric values to be positive integers and reject zero or
negative inputs before inference proceeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43430c75-42fc-4f71-bff1-7d54d24aef6d

📥 Commits

Reviewing files that changed from the base of the PR and between ee0022d and 1d1418f.

📒 Files selected for processing (12)
  • README.md
  • install/auto_install.bat
  • install/auto_install.sh
  • pytest/gui/test_freestyle_threshold_widgets.py
  • pytest/modules/DeviceDetection/test_device_detection.py
  • src/Settings.py
  • src/UltraSinger.py
  • src/gui/config.py
  • src/gui/settings_tab.py
  • src/modules/DeviceDetection/device_detection.py
  • src/modules/common_print.py
  • src/modules/init_interactive_mode.py

Comment thread src/modules/common_print.py Outdated
Comment thread src/modules/init_interactive_mode.py Outdated
Comment thread src/UltraSinger.py Outdated
- Reject zero/negative --whisper_batch_size with a clear error (matching
  the existing range-validation pattern); 'auto' still maps to None.
- Interactive mode: only a positive integer selects an explicit batch
  size (zero/empty/non-numeric keep auto); fix the misspelled variable.
- Raise the top tier threshold to 7.5 GB so 7 GB cards get batch size 8
  (16 needs ~8 GB) while true 8 GB cards that report slightly less than
  8.0 still get 16; add tests for both boundary cases.
- Sync every user-facing description (help, README, GUI tooltip,
  installer summaries) to the actual tiers and soften the fit claims.
@MrDix
MrDix merged commit 31f786a into main Jul 20, 2026
2 checks passed
@MrDix
MrDix deleted the feat/auto-batch-size branch July 20, 2026 01:36
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.

1 participant