MCPcopy Create free account
hub / github.com/blepping/ComfyUI-bleh

github.com/blepping/ComfyUI-bleh @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
519 symbols 1,170 edges 21 files 5 documented · 1% updated 42d ago★ 1394 open issues

Browse by type

Functions 398 Types & classes 121
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

BLEH

A ComfyUI nodes collection of utility and model patching functions. Also includes improved previewer that allows previewing batches during generation.

For recent user-visible changes, please see the ChangeLog.

Features

  • Better TAESD previews (see below).
  • Visual previews for some audio models (currently only ACE-Steps).
  • Multi-frame video previews for most common video models (Wan 2.2, 2.1, Hunyuan, LTX 2.3, etc). See the section on video encode/decode.
  • Allow setting seed, timestep range and step interval for HyperTile (look for the BlehHyperTile node).
  • Allow applying Kohya Deep Shrink to multiple blocks, also allow gradually fading out the downscale factor (look for the BlehDeepShrink node).
  • Allow discarding penultimate sigma (look for the BlehDiscardPenultimateSigma node). This can be useful if you find certain samplers are ruining your image by spewing a bunch of noise into it at the very end (usually only an issue with dpm2 a or SDE samplers).
  • Allow more conveniently switching between samplers during sampling (look for the BlehInsaneChainSampler node).
  • Apply arbitrary model patches at an interval and/or for a percentage of sampling (look for the BlehModelPatchConditional node).
  • Ensure a seed is set even when add_noise is turned off in a sampler. Yes, that's right: if you don't have add_noise enabled no seed gets set for samplers like euler_a and it's not possible to reproduce generations. (look for the BlehForceSeedSampler node). For SamplerCustomAdvanced you can use BlehDisableNoise to accomplish the same thing.
  • Allows swapping to a refiner model at a predefined time (look for the BlehRefinerAfter node).
  • Allow defining arbitrary model patches (look for the BlehBlockOps node).
  • Experimental blockwise CFG type effect (look for the BlehBlockCFG node).
  • SageAttention support either globally or as a sampler wrapper. Look for the BlehSageAttentionSampler and BlehGlobalSageAttention nodes.

Configuration

Copy either blehconfig.yaml.example to blehconfig.yaml and edit the copy. Bleh will also check for a blehconfig.json file when starting up if the YAML one doesn't exist. I recommend using YAML here.

Restart ComfyUI to apply any new changes.

Better Previews

There are links to the various TAE models used for high quality previewing near the bottom of this README.

  • Supports setting max preview size (ComfyUI default is hardcoded to 512 max).
  • Supports showing previews for more than the first latent in the batch.
  • Supports throttling previews. Do you really need your expensive high quality preview to get updated 3 times a second?
  • Supports LTX (2.0 and 2.3). Note: You need to use the BlehFixGuiderPreviewing node for LTX. See the description of it below.

The previewer can now show visual previews for ACE-Steps (1.0 and 1.5) latents. If you want to disable that feature, you can add aceaudio to the blacklist_formats list. For example if you are using a YAML configuration file you could do: blacklist_formats: ["aceaudio"]

General settings defaults:

Key Default Description
enabled true Toggles whether enhanced TAESD previews are enabled
max_size 768 Max width or height for previews. Note this does not affect TAESD decoding, just the preview image
max_width max_size Same as max_size except allows setting the width independently. Previews may not work well with non-square max dimensions.
max_height max_size Same as max_size except allows setting the height independently. Previews may not work well with non-square max dimensions.
max_batch 4 Max number of latents in a batch to preview
max_batch_cols 2 Max number of columns to use when previewing batches
throttle_secs 2 Max frequency to decode the latents for previewing. 0.25 would be every quarter second, 2 would be once every two seconds
maxed_batch_step_mode false When false, you will see the first max_batch previews, when true you will see previews spread across the batch. Also applies to video frames.
preview_device null null (use the default device) or a string with a PyTorch device name like "cpu", "cuda:0", etc. Can be used to run TAESD previews on CPU or other available devices. Not recommended to change this unless you really need to, using the CPU device may prevent out of memory errors but will likely significantly slow down generation.
preview_dtype bfloat16 null (use the default device) or a string with a PyTorch dtype name like float32, bfloat16, float16 (probably the only ones that will work).
compile_previewer false Controls whether the previewer gets compiled with torch.compile. May be a boolean or an object in which case the object will be used as argument to torch.compile. Note: May cause a delay/memory spike on the first preview.
oom_fallback latent2rgb May be set to none or latent2rgb. Controls what happens if trying to decode the preview runs out of memory.
oom_retry true If set to false, we will give up and use the oom_fallback behavior after hitting the first OOM. Otherwise, we'll attempt to decode with the normal previewer each time a preview is requested, even if that previously ran out of memory.
whitelist_formats (empty list) List of latent formats to whitelist. See example YAML config for more information.
whitelist_formats (empty list) List of latent formats to blacklist. See example YAML config for more information.

Note: Most options here that refer to batches will also apply to video models and in that case frames will be treated like batch items. Batches aren't supported when generating videos.

Image model settings defaults:

Key Default Description
skip_upscale_layers 0 The TAESD model has three upscale layers, each doubles the size of the result. Skipping some of them will significantly speed up TAESD previews at the cost of smaller preview image results. You can set this to -1 to automatically pop layers until at least one dimension is within the max width/height or -2 to aggressively pop until both dimensions are within the limit.

More detailed explanation for skipping upscale layers: Latents (the thing you're running the TAESD preview on) are 8 times smaller than the image you get decoding by normal VAE or TAESD. The TAESD decoder has three upscale layers, each doubling the size: 1 * 2 * 2 * 2 = 8. So for example if normal decoding would get you a 1280x1280 image, skipping one TAESD upscale layer will get you a 640x640 result, skipping two will get you 320x320 and so on. I did some testing running TAESD decode on CPU for a 1280x1280 image: the base speed is about 1.95 sec base, 1.15 sec with one upscale layer skipped, 0.44 sec with two upscale layers skipped and 0.16 sec with all three upscale layers popped (of course you only get a 160x160 preview at that point). The upshot is if you are using TAESD to preview large images or batches or you want to run TAESD on CPU (normally pretty slow) you would probably benefit from setting skip_upscale_layers to 1 or 2. Also if your max preview size is 768 and you are decoding a 1280x1280 image, it's just going to get scaled down to 768x768 anyway.

Video model settings defaults:

Key Default Description
video_parallel false Use parallel mode when decoding video latents. May actually use more memory than a full VAE decode.
video_max_frames -1 Maximum frames to include in a preview. Frame limiting is treated like batch limiting. -1 means unlimited.
video_temporal_upscale_level 0 Number of temporal upscale blocks to use, 0 will not do any temporal upscaling, 2 means full temporal upscaling.
animate_preview none One of none, video, batch or both. Controls when animated previews are generated. When animating batch previews, batch items will be frames in the animation.

These defaults are conservative. I would recommend setting throttle_secs to something relatively high (like 5-10) especially if you are generating batches at high resolution.

Slightly more detailed explanation for maxed_batch_step_mode: If max previews is set to 3 and the batch size is 15 you will see previews for indexes 0, 5, 10. Or to put it a different way, it steps through the batch by batch_size / max_previews rounded up. This behavior may be useful for previewing generations with a high batch count like when using AnimateDiff.

Last preview endpoint settings defaults:

The last preview endpoint will serve up either a webpage that auto-updates the last preview /bleh/last_preview.html or a static image of the last preview /bleh/last_preview. It is disabled by default.

Key Default Description
publish_last_preview false Enables publishing last previews.
publish_last_preview_min_refresh 5 When auto updating last previews, it will occur at most every this many seconds.
only_animate_last_preview true When enabled, animated previews only appear in the last preview endpoint, not the sampler.

Last preview notes:

  • Leaving only_animate_last_preview on the default is reasonable. Unless you're using "Nodes 2.0", previews can't animate in the sampler so sending them just wastes resources.
  • If you turn on the last preview endpoint, anyone that can access your ComfyUI instance can see what you're generating. However external access to ComfyUI is disabled by default and if someone can access the instance they can do whatever they want, including seeing your previews and queue history so there isn't much of a risk to turning this on (to the best of my knowledge).

Note: Other node packs that patch ComfyUI's previewer behavior may interfere with this feature. One I am aware of is ComfyUI-VideoHelperSuite - if you have displaying animated previews turned on, it will overwrite Bleh's patched previewer. Or possibly, depending on the load order, Bleh will prevent it from working correctly.

BlehModelPatchConditional

Note: Very experimental.

This node takes a default model and a matched model. When the interval or start/end percentage match, the matched model will apply, otherwise the default one will. This can be used to apply something like HyperTile, Self Attention Guidance or other arbitrary model patches conditionally.

The first sampling step that matches the timestep range always applies matched, after that the following behavior applies: If the interval is positive then you just get matched every interval steps. It is also possible to set interval to a negative value, for example -3 would mean out of every three steps, the first two use matched and the third doesn't.

Notes and limitations: Not all types of model modifications/patches can be intercepted with a node like this. You also almost certainly can't use this to mix different models: both inputs should be instances of the same loaded model. It's also probably a bad idea to apply further patches on top of the BlehModelPatchConditional node output: it should most likely be the last thing before a sampler or something that actually uses the model.

BlehHyperTile

Adds the ability to set a seed and timestep range that HyperTile gets applied for. Not well tested, and I just assumed the Inspire version works which may or may not be the case.

It is also possible to set an interval for HyperTile steps, this time it is just normal sampling steps that match the timestep range. The first sampling step that matches the timestep range always applies HyperTile, after that the following behavior applies: If the interval is positive then you just get HyperTile every interval steps. It is also possible to set interval to a negative value, for example -3 would mean out of every three steps, the first two have HyperTile and the third doesn't.

Note: Timesteps start from 999 and count down to 0 and also are not necessarily linear. Figuring out exactly which sampling step a timestep applies to is left as an exercise for you, dear node user. As an example, Karras and exponential samplers essentially rush to low timesteps and spend quite a bit of time there.

HyperTile credits:

The node was originally taken by Comfy from taken from: https://github.com/tfernd/HyperTile/

Then the Inspire node pack took it from the base ComfyUI node: https://github.com/ltdrdata/ComfyUI-Inspire-Pack

Then I took it from the Inspire node pack. The original license was MIT so I assume yoinking it into this repo is probably okay.

BlehDeepShrink

AKA PatchModelAddDownScale AKA Kohya Deep Shrink. Compared to the built-in Deep Shrink node this version has the following differences:

  1. Instead of choosing a block to apply the downscale effect to, you can enter a comma-separated list of blocks. This may or not actually be useful but it seems like you can get interesting effects applying it to multiple blocks. Try 2,3 or 1,2,3.
  2. Adds a start_fadeout_percent input. When this is less than end_percent the downscale will be scaled to end at end_percent. For example, if downscale_factor=2.0, start_percent=0.0, end_percent=0.5 and start_fadeout_percent=0.0 then at 25% you could expect downscale_factor to be around 1.5. This is because we are deep shrinking between 0 and 50% and we are halfway through the effect range. (downscale_factor=1.0 would of course be a no-op and values below 1 don't seem to work.)
  3. Expands the options for upscale and downscale types, you can a

Core symbols most depended-on inside this repo

Shape

Method 317
Class 121
Function 81

Languages

Python100%

Modules by API surface

py/latent_utils.py100 symbols
py/nodes/ops.py99 symbols
py/nodes/misc.py74 symbols
py/better_previews/tae_vid.py44 symbols
py/nodes/modelPatchConditional.py37 symbols
py/better_previews/previewer.py37 symbols
py/nodes/sageAttention.py32 symbols
py/nodes/samplers.py18 symbols
py/nodes/blockCFG.py18 symbols
py/wavelet_functions.py13 symbols
py/nodes/hyperTile.py11 symbols
py/nodes/taevid.py10 symbols

For agents

$ claude mcp add ComfyUI-bleh \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page