KJNodes/experimentalgenerated

NABLA Attention KJ(NABLA_AttentionKJ)

This node achieves its functionality by overriding the model's attention computation function, specifically utilizing the NABLA sparse attention algorithm.

NABLA Attention KJ

model
latent
MODEL
window_time
11
window_width
3
window_height
3
sparsity
0.90
torch_compile
KJNodes

The NABLA Attention KJ node implements its functionality by overriding the model's attention computation function, specifically utilizing the NABLA sparse attention algorithm.

NABLA Attention KJ is an experimental node designed to modify the attention mechanism of video generation models. Its core function is to apply NABLA sparse attention to the model, aiming to optimize memory usage and computational efficiency during the video generation process.

Node Functionality

This node works by overriding the model's attention computation function, specifically using the NABLA sparse attention algorithm. It requires a newer version of PyTorch to support the flex_attention module and is currently primarily adapted for the Kadinsky5 video model. Its internal mechanism dynamically generates a sparse attention mask based on the provided latent shape and window parameters to limit the scope of attention computation.

Node Parameter Description - NABLA Attention KJ

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
modelMODELYes--The base model whose attention mechanism needs to be modified. This parameter is used to receive a standard generation model, and the node will override its internal attention computation method.
latentLATENTYes--Only used to get the latent shape

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
window_timeINTYes11≥ 1Temporal attention window size
window_widthINTYes3≥ 1Spatial attention window size
window_heightINTYes3≥ 1Spatial attention window size
sparsityFLOATYes0.90.0 – 1.0 (Step: 0.01)A parameter controlling the degree of attention sparsity, ranging from 0.0 to 1.0 with a step of 0.01. A higher value indicates sparser attention, meaning more correlations are ignored during computation.
torch_compileBOOLEANYesTrue-Most likely required for reasonable memory usage

Output

Parameter NameData TypeDescription
MODELMODELThe new model with NABLA sparse attention applied. This output model can be used for subsequent image or video generation steps.

Usage Scenario

In a workflow for generating coherent video sequences, you can insert this node after the model loading node. By adjusting the size of the temporal and spatial windows, you can control how many past frames the model attends to and how large an area within each frame it focuses on during video frame generation, thereby reducing computational load while ensuring temporal coherence.

Notes

Please note that this is an experimental node, and its stability and compatibility may be limited. It explicitly requires a newer version of PyTorch and is currently only confirmed to work with the Kadinsky5 model. Using it with other models may cause errors or unexpected results.

The NABLA Attention KJ node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…