Skip to content

Comfy Aimdo 0.4.10 + Dynamic --reserve-vram + --vram-headroom - #14480

Merged
comfyanonymous merged 2 commits into
Comfy-Org:masterfrom
rattus128:prs/aimdo-410-reserves
Jun 15, 2026
Merged

Comfy Aimdo 0.4.10 + Dynamic --reserve-vram + --vram-headroom#14480
comfyanonymous merged 2 commits into
Comfy-Org:masterfrom
rattus128:prs/aimdo-410-reserves

Conversation

@rattus128

@rattus128 rattus128 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

#14396

comfy-aimdo 0.4.10 implements:

1: double sync on VBAR free operations. There are still hard-to-reproduce observable de-syncs between the cuda observed free memory and the real actuals. Syncing after the fact may help and this should be reasonably cheap given that is was already synced before the free operation.

2: Implement two VRAM headroom configuration mechanisms. --reserve-vram by popular demand, and a more dynamic form --vram-headroom.

Example Test Conditions:

Linux, 5090, 96GB, LTX2.3
8GB VRAM held in use by a script
--reserve-vram 12

Before:

image

Comfy uses more than 32 - 12GB VRAM.

[INFO] Prompt executed in 26.13 seconds

After:

image

The 12GB headroom is usable by the display driver and the 8GB background script so roughly 3GB is unused ✅

[INFO] Prompt executed in 26.59 seconds

--vram-headroom 12 (instead of --reserve-vram):

image

The 12GB headroom is absolute ✅

[INFO] Prompt executed in 32.40 seconds

Regression Tests:

Linux, 5090, 96GB, Ace-step turbo XL ✅
Linux, 5090, 96GB, stable cascade -> flux 2 ✅
Windows, 5060, 16GB, wan 2x14B FP8 ✅

Implement --vram-headroom for dynamic vram as a hybrid debug/diagnostic
option that can be used for people who still report shared VRAM spills.
They can trial and error the setting to maintain a bit more headroom to
avoid shared VRAM spills.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new --vram-headroom CLI argument (float, default 0) is added to cli_args.py to specify extra free VRAM in GiB that DynamicVRAM should keep available. In main.py, comfy_aimdo.control.init() is updated to pass a simple_vram_headroom value derived from args.reserve_vram (GiB→bytes, or None when unset), and comfy_aimdo.control.init_devices() is updated to pass (device_index, headroom_bytes) tuples instead of device indices alone. The comfy-aimdo dependency is bumped from 0.4.9 to 0.4.10 in requirements.txt.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: upgrading comfy-aimdo to 0.4.10 and introducing two VRAM headroom configuration mechanisms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description check ✅ Passed The PR description accurately relates to the changeset, providing context for the comfy-aimdo 0.4.10 upgrade and explaining the two new VRAM headroom configuration mechanisms with test results.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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: 1

🤖 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 `@comfy/cli_args.py`:
- Line 148: The --vram-headroom argument in the parser.add_argument call accepts
unbounded float values without validation, allowing negative values that can
cause inverted behavior in byte conversions downstream in main.py. Add a
non-negative validator to the argument definition using argparse's type
parameter or choices mechanism to ensure only non-negative float values are
accepted at parse time, preventing invalid negative headroom values from
reaching the DynamicVRAM logic.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc81ab66-eca6-4e74-9b4a-a560e345b849

📥 Commits

Reviewing files that changed from the base of the PR and between 7d4194d and bdf1ffc744905069ead89736837e2fa30ae2d557.

📒 Files selected for processing (3)
  • comfy/cli_args.py
  • main.py
  • requirements.txt

Comment thread comfy/cli_args.py
@@ -145,6 +145,7 @@ def from_string(cls, value: str):
vram_group.add_argument("--cpu", action="store_true", help="To use the CPU for everything (slow).")

parser.add_argument("--reserve-vram", type=float, default=None, help="Set the amount of vram in GB you want to reserve for use by your OS/other software. By default some amount is reserved depending on your OS.")
parser.add_argument("--vram-headroom", type=float, default=0, help="Set the amount of vram in GB for DynamicVRAM to maintain as extra headroom above default. ComfyUI will try and keep this much VRAM completely free and unused, even counting VRAM from other apps.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate VRAM headroom inputs as non-negative at parse time.

Line 148 introduces an unbounded float; negative values flow into byte conversions in main.py (Lines 58 and 234), which can invert headroom behavior under DynamicVRAM. Add a non-negative validator for VRAM headroom inputs.

Suggested fix
+def non_negative_gb(value: str) -> float:
+    gb = float(value)
+    if gb < 0:
+        raise argparse.ArgumentTypeError("Value must be >= 0 GB.")
+    return gb
+
-parser.add_argument("--reserve-vram", type=float, default=None, help="Set the amount of vram in GB you want to reserve for use by your OS/other software. By default some amount is reserved depending on your OS.")
-parser.add_argument("--vram-headroom", type=float, default=0, help="Set the amount of vram in GB for DynamicVRAM to maintain as extra headroom above default. ComfyUI will try and keep this much VRAM completely free and unused, even counting VRAM from other apps.")
+parser.add_argument("--reserve-vram", type=non_negative_gb, default=None, help="Set the amount of vram in GB you want to reserve for use by your OS/other software. By default some amount is reserved depending on your OS.")
+parser.add_argument("--vram-headroom", type=non_negative_gb, default=0, help="Set the amount of vram in GB for DynamicVRAM to maintain as extra headroom above default. ComfyUI will try and keep this much VRAM completely free and unused, even counting VRAM from other apps.")

As per coding guidelines, comfy/** changes should prioritize memory-management safety and backward-compatible behavior.

🤖 Prompt for 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.

In `@comfy/cli_args.py` at line 148, The --vram-headroom argument in the
parser.add_argument call accepts unbounded float values without validation,
allowing negative values that can cause inverted behavior in byte conversions
downstream in main.py. Add a non-negative validator to the argument definition
using argparse's type parameter or choices mechanism to ensure only non-negative
float values are accepted at parse time, preventing invalid negative headroom
values from reaching the DynamicVRAM logic.

Source: Coding guidelines

Implement --reserve-vram as extra headroom on the simple method which
is semantically as close as possible to the stated functionality and
formet behaviour of non-dynamic VRAM.
@rattus128
rattus128 force-pushed the prs/aimdo-410-reserves branch from bdf1ffc to caedb3e Compare June 15, 2026 12:41
@rattus128 rattus128 mentioned this pull request Jun 15, 2026
@comfyanonymous
comfyanonymous merged commit ec4dec9 into Comfy-Org:master Jun 15, 2026
14 checks passed
zhangp365 pushed a commit to zhangp365/ComfyUI that referenced this pull request Jun 29, 2026
…Org#14480)

* main: implement --vram-headroom

Implement --vram-headroom for dynamic vram as a hybrid debug/diagnostic
option that can be used for people who still report shared VRAM spills.
They can trial and error the setting to maintain a bit more headroom to
avoid shared VRAM spills.

* main: implement --reserve-vram

Implement --reserve-vram as extra headroom on the simple method which
is semantically as close as possible to the stated functionality and
formet behaviour of non-dynamic VRAM.
@coderabbitai coderabbitai Bot mentioned this pull request Aug 2, 2026
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.

2 participants