explaingit

surrealbydesign/comfyui-krea2-sageattention-guard

Analysis updated 2026-05-18

1PythonAudience · developerComplexity · 4/5Setup · hard

TLDR

A patch for ComfyUI-KJNodes that makes SageAttention safe to use with Krea 2 image-generation models by adding detection and fallback logic instead of a blind global override.

Mindmap

mindmap
  root((krea2-sageattention-guard))
    Problem It Solves
      Global patch crashes Krea 2
      Black images tensor errors
    What Patch Adds
      Model detection
      Guarded override
      Fallback behavior
      Dry-run validation
    Contents
      Two patch files
      Baseline workflows
      Check script
    Requirements
      CUDA NVIDIA GPU
      ComfyUI KJNodes
      SageAttention install
      Krea 2 model files
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Apply the patch to your KJNodes install to enable SageAttention speedups on Krea 2 Turbo without crashing or getting black images.

USE CASE 2

Load one of the included verified baseline workflows to confirm your Krea 2 setup is working before building a more complex pipeline.

USE CASE 3

Use dry-run mode to verify the patch is active and see which attention paths are being accelerated in your current workflow.

What is it built with?

PythonComfyUISageAttentionCUDAgit patch

How does it compare?

surrealbydesign/comfyui-krea2-sageattention-guarda-bissell/unleash-liteabhiinnovates/whatsapp-hr-assistant
Stars111
LanguagePythonPythonPython
Setup difficultyhardhardhard
Complexity4/54/53/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires a CUDA-capable NVIDIA GPU, SageAttention installed, Krea 2 model files, and comfort applying git patches to an existing custom node package.

No license information was found in the README.

In plain English

ComfyUI is a tool for running AI image-generation models locally through a visual node-based interface. SageAttention is a technique that speeds up how certain models process attention calculations, a key step in generating images. KJNodes is a popular ComfyUI extension that includes a node for applying SageAttention as a speedup. Krea 2 is a locally runnable image-generation model, along with its faster Krea 2 Turbo variant. The problem this repository solves: applying the KJNodes SageAttention patch globally to a Krea 2 workflow can cause it to activate on attention calls that Krea 2's architecture does not support, resulting in crashes, corrupted images, black outputs, or hard-to-trace errors. The root cause is that Krea 2 has a text-fusion path that uses different tensor shapes than the main image-generation attention, and a blanket override trips over those unsupported paths. This repository provides two patch files that modify a single file inside an existing KJNodes installation. The patches add Krea 2 model detection, a guarded version of the SageAttention override that only activates for allowlisted attention calls, and a fallback to ComfyUI's original attention code for anything the speedup cannot handle safely. They also add logging so a user can see which paths are being accelerated and which are being skipped, plus an optional dry-run mode for confirming the patch is active before running a full generation. Installation means applying the two patch files to an existing KJNodes folder using standard git patch commands, not cloning this repo into ComfyUI's custom-nodes directory. The repository also includes ready-to-load workflows for Krea 2 and Krea 2 Turbo as verified baselines, a script to check whether the patches will apply cleanly before touching the live install, and instructions for reverting the changes. Testing was done on Windows with an RTX 5080 GPU, CUDA 12.9, and both SageAttention 1.0.6 and 2.2.0. Linux is untested. Requirements include a CUDA-capable NVIDIA GPU, a working SageAttention install, the Krea 2 model files, and comfort applying git patches to an existing custom node package.

Copy-paste prompts

Prompt 1
I'm running Krea 2 Turbo in ComfyUI with the KJNodes SageAttention patch but getting black images or crashes. Walk me through applying the krea2-sageattention-guard patch and what it changes.
Prompt 2
I want to check whether the krea2-sageattention-guard patches apply cleanly to my current KJNodes install before I change anything. Show me how to use check_patch_applies.py.
Prompt 3
After applying the sageattention guard patch, the dry_run option is not showing up in my node. Walk me through debugging this.
Prompt 4
I want to revert the krea2-sageattention-guard patches from my KJNodes folder. Show me the exact git commands in the correct order.

Frequently asked questions

What is comfyui-krea2-sageattention-guard?

A patch for ComfyUI-KJNodes that makes SageAttention safe to use with Krea 2 image-generation models by adding detection and fallback logic instead of a blind global override.

What language is comfyui-krea2-sageattention-guard written in?

Mainly Python. The stack also includes Python, ComfyUI, SageAttention.

What license does comfyui-krea2-sageattention-guard use?

No license information was found in the README.

How hard is comfyui-krea2-sageattention-guard to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is comfyui-krea2-sageattention-guard for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub surrealbydesign on gitmyhub

Verify against the repo before relying on details.