Nodes/ComfyUI-bleh/BlehSageAttentionSampler
ComfyUI Node

BlehSageAttentionSampler

SageAttention as a scoped sampler wrapper

By blepping·Created 3 years ago·Updated a day ago· 143
BlehSageAttentionSampler
  • sampler
  • SAMPLER
start_percent0.000
end_percent1.000
yaml_parameters

SageAttention is a quantized, memory-efficient attention kernel from the thu-ml team - not a bleh invention, just something bleh gives you a clean way to switch on. It replaces PyTorch's default attention math with something faster and lighter, and the win gets bigger the more attention costs to compute, which means you'll notice it most at high resolution or on video models rather than on a quick 512px SD 1.5 render.

This node wraps a SAMPLER and turns SageAttention on for the duration of that sampler call, scoped to a percentage window of sampling if you want it. That's the whole pitch: instead of a global switch you flip and forget (that's the other node, BlehGlobalSageAttention, which the README itself calls deprecated in favor of this one), you get a sampler-shaped wrapper with clean start/end boundaries.

Inputs are minimal. sampler is required - plug in whatever you're already using, from KSamplerSelect to something more exotic. start_percent/end_percent (0 to 1 by default, meaning the whole run) let you limit SageAttention to part of sampling, handy if you want to keep the first or last few percent on stock attention while chasing a specific artifact. yaml_parameters is the advanced escape hatch - it passes keys mostly straight through to the SageAttention function with no validation, which also means you can flip sageattn_function to sparge or sparge1 if you've separately installed SpargeAttention, though the author says he personally hasn't seen it outperform SageAttention 2. Output is a SAMPLER, same shape you fed in, ready for SamplerCustomAdvanced or wherever samplers plug in for you.

The install step is the one that trips people up, and it's worth being blunt about: SageAttention does not ship with this pack. The README says it plainly - "Requires manually installing SageAttention into your Python environment" - which means pip-installing a compiled CUDA extension yourself, separately from ComfyUI Manager's usual one-click node install. It should work with SageAttention 1.0 and 2.0.x, with 2.0.x wanting a newer CUDA toolchain. If you're on Windows, budget real time for this: getting Triton working (which SageAttention typically needs) is a known pain point across the ComfyUI ecosystem, painful enough that the community leans on one person's unofficial Windows Triton builds to make it work at all. Linux users generally have a much easier time.

A few things worth knowing before you assume it's broken. If nothing feels faster, first confirm SageAttention is actually intercepting anything - set sageattn_verbose: true in yaml_parameters and check your console; the README notes that some custom nodes don't honor the SageAttention patch by default, and the author is open to adding support if you report which one. Older SageAttention builds (pre-2.0.1) had much narrower head-size support and specifically didn't cover any of SD 1.5's head sizes - so a "zero difference" result on an SD 1.5 workflow might just mean your SageAttention version predates support for that model family, not that the node is misconfigured. And if you're running Z-Image: SageAttention is confirmed to cause patchy, glitched, or fully black output specifically on Z-Image Base (Turbo is unaffected), reproduced across multiple GPU generations. If output looks corrupted on Base, that's the first thing to rule out, not a bug in this node.

Categorysampling/custom_sampling/samplers

Inputs (4)

NameTypeDefaultDescription
samplerSAMPLER
start_percentoptFLOAT0.0000–1Time the effect becomes active as a percentage of sampling, not steps.
end_percentoptFLOAT1.0000–1Time the effect ends (inclusive) as a percentage of sampling, not steps.
yaml_parametersoptSTRINGAllows specifying custom parameters via YAML. These are mostly passed directly to the SageAttention function with no error checking. Must be empty or a YAML object.

Outputs (1)

NameTypeDescription
SAMPLERSAMPLER