Skip to content

Throttle dynamic VRAM prepare logging#13704

Open
kijai wants to merge 4 commits intoComfy-Org:masterfrom
kijai:dynvram_log
Open

Throttle dynamic VRAM prepare logging#13704
kijai wants to merge 4 commits intoComfy-Org:masterfrom
kijai:dynvram_log

Conversation

@kijai
Copy link
Copy Markdown
Collaborator

@kijai kijai commented May 4, 2026

The "prepared for dynamic VRAM loading" line currently fires at INFO on every load() call, which spams the console when the same model is reloaded inside a tight loop (e.g. SDPoseKeypointExtractor running one forward pass per bbox per image). When a tqdm progress bar is active and the message would say the exact same thing as the previous load, drop it to DEBUG; the line is still recoverable under --verbose.

Example when running SDPose detection:

Before:

Requested to load Lotus
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  10%|██████                                                       | 1/10 [00:01<00:16,  1.81s/it]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  20%|████████████▏                                                | 2/10 [00:02<00:07,  1.08it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  30%|██████████████████▎                                          | 3/10 [00:02<00:04,  1.57it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  40%|████████████████████████▍                                    | 4/10 [00:02<00:03,  1.99it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  50%|██████████████████████████████▌                              | 5/10 [00:03<00:02,  2.32it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  60%|████████████████████████████████████▌                        | 6/10 [00:03<00:01,  2.62it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  70%|██████████████████████████████████████████▋                  | 7/10 [00:03<00:01,  2.84it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  80%|████████████████████████████████████████████████▊            | 8/10 [00:03<00:00,  2.97it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints:  90%|██████████████████████████████████████████████████████▉      | 9/10 [00:04<00:00,  3.07it/s]Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints: 100%|████████████████████████████████████████████████████████████| 10/10 [00:04<00:00,  2.23it/s]
Prompt executed in 5.10 seconds

After:

Requested to load Lotus
Model Lotus prepared for dynamic VRAM loading. 1668MB Staged. 0 patches attached.
Extracting keypoints: 100%|████████████████████████████████████████████████████████████| 10/10 [00:03<00:00,  3.33it/s]
Prompt executed in 3.04 seconds

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

The change adds a tqdm import and updates ModelPatcherDynamic.load() to de-duplicate its "prepared for dynamic VRAM loading" message. It computes a log_key from (patches_uuid, allocated_size, num_patches, len(self.backup), self.model.model_loaded_weight_memory), compares it to self._last_prepare_log_key, and selects DEBUG when repeated or INFO otherwise. The message is emitted via logging.log(level, ...) instead of always calling logging.info(...).

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title 'Throttle dynamic VRAM prepare logging' accurately describes the main change: reducing INFO log spam for repeated dynamic VRAM loading messages by implementing throttling/de-duplication logic.
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 explains the changes: throttling log levels for repeated dynamic VRAM loading messages when inside a tqdm loop, with concrete before/after examples demonstrating the spam reduction.

✏️ 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.

Comment thread comfy/model_patcher.py
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