Skip to content

Commit 1c973fb

Browse files
committed
🌊🚒 FlowState Flux Engine - Safe Sage Attention Integration
Sage Attention is now implemented for users with KJ Nodes and Sage Attention library installed. For users missing either of those dependencies, the dropdown menu will simply include a "disabled" option only.
1 parent be3d655 commit 1c973fb

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

FlowState_FluxEngine.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from torchvision import transforms
3333
from PIL import Image, ImageDraw, ImageFont
3434
import warnings
35+
import importlib
3536

3637
import comfy.utils
3738
import comfy.sd
@@ -48,13 +49,35 @@
4849
from comfy_extras.nodes_custom_sampler import SamplerCustomAdvanced
4950
from comfy_extras.nodes_flux import FluxGuidance
5051

51-
from nodes import EmptyLatentImage
5252
from nodes import CLIPTextEncode
5353

54+
# --- IMPORT KIJAI (THE GOAT) SAGE ATTENTION UNTIL COMFY CORE IMPLEMENTS A NODE
55+
SAGE_ATTENTION_INSTALLED = False
56+
KJNODES_INSTALLED = False
57+
PatchSageAttention = None
58+
sageattn_modes = ['disabled']
59+
60+
try:
61+
kj_module_path = importlib.import_module('custom_nodes.ComfyUI-KJNodes.nodes.model_optimization_nodes')
62+
KJNODES_INSTALLED = True
63+
print('\t - 🟢 KJ Nodes available.')
64+
except:
65+
print('\t - 🚨 KJNODES NOT AVAILABLE')
66+
67+
try:
68+
importlib.import_module("sageattention")
69+
SAGE_ATTENTION_INSTALLED = True
70+
print('\t - 🟢 Sage Attention available.')
71+
except:
72+
print('\t - 🚨 SAGE ATTENTION NOT AVAILABLE')
73+
74+
75+
if SAGE_ATTENTION_INSTALLED and KJNODES_INSTALLED:
76+
print('\t - ✅ KJ Nodes & Sage Attention available.')
77+
print('\t - 🥳🎉 Activating Sage Attention for 🌊🚒 FlowState Flux Engine.')
78+
PatchSageAttention = kj_module_path.PathchSageAttentionKJ()
79+
sageattn_modes = kj_module_path.sageattn_modes
5480

55-
warnings.filterwarnings('ignore', message='clean_up_tokenization_spaces')
56-
warnings.filterwarnings('ignore', message='Torch was not compiled with flash attention')
57-
warnings.filterwarnings('ignore', category=FutureWarning)
5881

5982

6083
##
@@ -85,6 +108,7 @@ def INPUT_TYPES(s):
85108
'required': {
86109
'model_name': TYPE_DIFFUSION_MODELS_LIST(),
87110
'weight_dtype': TYPE_WEIGHT_DTYPE,
111+
'sage_attention': (sageattn_modes, ),
88112
'clip_1_name': TYPE_CLIPS_LIST(),
89113
'clip_2_name': TYPE_CLIPS_LIST(),
90114
'vae_name': TYPE_VAES_LIST(),
@@ -304,8 +328,8 @@ def sample(self, sampler_components):
304328
return img_batch_out, latent_batch_out
305329

306330
def execute(
307-
self, model_name, weight_dtype, clip_1_name, clip_2_name, vae_name, resolution, orientation, latent_type,
308-
custom_width, custom_height, custom_batch_size, image, seed, sampling_algorithm, scheduling_algorithm,
331+
self, model_name, weight_dtype, sage_attention, clip_1_name, clip_2_name, vae_name, resolution, orientation,
332+
latent_type, custom_width, custom_height, custom_batch_size, image, seed, sampling_algorithm, scheduling_algorithm,
309333
guidance, steps, denoise, prompt, input_img=None
310334
):
311335

@@ -321,7 +345,12 @@ def execute(
321345
f'\n - Loading {clip_2_name}...'
322346
f'\n - Loading {vae_name}...\n'
323347
)
324-
self.loaded_model = UNETLoader().load_unet(model_name, weight_dtype)[0]
348+
if sage_attention != 'disabled':
349+
self.loaded_model = UNETLoader().load_unet(model_name, weight_dtype)[0]
350+
self.loaded_model = PatchSageAttention.patch(self.loaded_model, sage_attention)[0]
351+
else:
352+
self.loaded_model = UNETLoader().load_unet(model_name, weight_dtype)[0]
353+
325354
self.loaded_clip = DualCLIPLoader().load_clip(clip_1_name, clip_2_name, 'flux', 'default')[0]
326355
self.loaded_vae = VAELoader().load_vae(vae_name)[0]
327356
else:

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ git clone https://github.com/flowstateeng/FlowState-Creator-Nodes.git
8383

8484
---
8585

86-
## 🎉 RELEASE v0.0.1 ● 09/14/25 - 5:30 pm (GMT-5)
86+
## 🎉 RELEASE v0.0.1 ● 09/15/25 - 11:30 am (GMT-5)
8787

8888
### 📋 Notes
89-
* Introduction of FlowState Latent Source
89+
* Introduction of 🌊🚒 FlowState Flux Engine: a Flux all-in-one. (See full description below.)
9090

9191
### 📆 Upcoming
92-
* Introduction of FlowState Flux Engine: a Flux all-in-one.
92+
* LoRA integration for the 🌊🚒 FlowState Flux Engine.
9393
* Introduction of FlowState Quick Edit: a two-stage node that performs a rapid base edit and then applies a high-detail refinement pass to the result.
9494
* Introduction of FlowState Asset Forge: efficiently generate professional-grade assets with maximum control & quality.
9595

9696
---
9797

9898
## 🖧 Current Nodes
99-
### [FlowState Latent Source](https://github.com/flowstateeng/FlowState-Creator-Nodes/blob/main/FlowState_LatentSource_.py)
99+
### [🌊🌱 FlowState Latent Source](https://github.com/flowstateeng/FlowState-Creator-Nodes/blob/main/FlowState_LatentSource.py)
100100
Simplify your latent options and clean up your workflow with FlowState Latent Source.
101101

102102
A simple switch to select between:
@@ -108,6 +108,20 @@ Vary the denoise on your sampler to control the amount of style transfer you wan
108108
<p align="center">
109109
<img width='650' src='https://github.com/flowstateeng/FlowState-Creator-Nodes/blob/main/imgs/FlowState%20Latent%20Source.png' alt='FS Latent Source Image'/>
110110
</p>
111+
112+
### [🌊🚒 FlowState Flux Engine](https://github.com/flowstateeng/FlowState-Creator-Nodes/blob/main/FlowState_FluxEngine.py)
113+
Streamline your entire generation workflow with the FlowState Flux Engine.
114+
115+
An all-in-one node that seamlessly combines:
116+
- Model, VAE, and CLIP loading (with Model Persistence to prevent subsequent reloads.)
117+
- Prompt conditioning & guidance.
118+
- Sage Attention model patching (for users with that capability)
119+
- The integrated FlowState Latent Source for flexible resolution selection & easy i2i style transfer.
120+
121+
Reduce your node clutter and go from concept to final image faster than ever within a single, powerful engine.
122+
<p align="center">
123+
<img width='650' src='https://github.com/flowstateeng/FlowState-Creator-Nodes/blob/main/imgs/FlowState%20Latent%20Source.png' alt='FS Latent Source Image'/>
124+
</p>
111125
<br/>
112126

113127
Video tutorials can be found on YouTube at [FlowState Creator Suite Playlist](https://www.youtube.com/playlist?list=PLopF-DMGUFkTulZRkSpRmKFcTENKFicws)
39 Bytes
Binary file not shown.
1017 Bytes
Binary file not shown.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "flowstate-creator-nodes"
33
description = "The ultimate suite of streamlined ComfyUI nodes for creative professionals."
4-
version = "0.0.6"
4+
version = "0.1.0"
55
license = {file = "LICENSE"}
66
dependencies = [
77
"git+https://github.com/kijai/ComfyUI-KJNodes.git"

0 commit comments

Comments
 (0)