CLIP Attention Selector
Swap the text encoder's attention backend
- clip
- CLIP
This one's for people who care about attention backends and want to change them on the fly. CLIP Attention Selector swaps the text encoder's attention implementation - pytorch (SDPA), SageAttention, xformers, whatever you've got registered - without restarting ComfyUI. Normally picking your attention algorithm means a --use-sage-attention launch flag and a full restart to test the alternative. This node makes it a dropdown.
What "attention backend" even means
Attention is the heavy math at the core of both the diffusion model and the text encoder, and there are several interchangeable implementations of it. SDPA (PyTorch's built-in scaled-dot-product attention, shown here as "optimized") is the safe default. xformers is the older memory-efficient one. SageAttention is the current speed favorite - it quantizes the attention math for a real wall-clock win, popular with the video and high-res crowd. They should produce near-identical images; the difference is speed, VRAM, and occasionally a compatibility quirk.
The node's own description says it plainly: it "replaces text model's attention with another registered attention function." Key word registered - the dropdown only lists what's actually installed and available in your environment. If SageAttention isn't installed, it won't be an option.
Inputs and outputs
- clip (CLIP) in, patched CLIP out.
- attention (a dropdown, default "optimized") - pick the backend. "optimized" is SDPA and a fine default.
Wire it right after your CLIP loader, pass the patched CLIP into your text-encode nodes, done.
The honest reality check
Here's the thing nobody tells you: patching the text encoder's attention is almost never where your time goes. Encoding a prompt is a tiny, one-shot operation compared to the dozens of denoising steps the diffusion model runs. So swapping the CLIP backend will not meaningfully speed up your generations. If you're here to make things faster, the node you actually want is ModelAttentionSelector (same pack) - that one patches the diffusion model, which is where the compute lives.
So what's this for? Mostly compatibility and correctness testing. Some attention backends misbehave on specific hardware or with certain encoders, and being able to flip the CLIP over to plain SDPA without a restart is a genuine time-saver when you're chasing down a "why do my embeddings look wrong on this backend" bug. It's a debugging and consistency tool more than a performance one.
Install
No models, no extra deps beyond whatever attention libraries you've chosen to install (SageAttention and xformers are separate installs; SDPA ships with PyTorch):
- ComfyUI Manager: search "ComfyUI-ppm", install, restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/pamparamm/ComfyUI-ppm, then restart.
Gotchas
The dropdown only shows backends you've installed - if you expected SageAttention or xformers and don't see them, they're not in your environment, and that's an install problem, not a node problem. Also keep in mind the images shouldn't change between backends; if they do change noticeably, that's a sign the backend has a bug on your setup, which is exactly the situation this node helps you isolate by letting you flip back to "optimized" instantly.
Pack rule: if it errors after a ComfyUI-ppm update, delete and re-add the node. And for the record - for actual speed, reach for ModelAttentionSelector, not this one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| attention | COMBO | optimized | 5 options: optimized, sage, pytorch, sub_quad, split |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CLIP | CLIP | — |