Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions built-in-nodes/ContextWindowsManualNode.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "Context Windows (Manual) - ComfyUI Built-in Node Documentation"
description: "Context Windows (Manual) node provides manual context window control, implementing sliding window sampling techniques to process long sequence generation tasks while efficiently managing memory usage with multiple scheduling strategies."
sidebarTitle: "Context Windows (Manual)"
icon: "circle"
---

The `Context Windows (Manual)` node helps you process ultra-long content. It decomposes long sequences into multiple overlapping context windows for sampling, rather than processing the entire sequence at once, thereby saving memory and enabling high-quality results generation.

**How it works:**
Like using multiple segmented samples to generate different segments of a video, and finally synthesizing a complete video**
- Each window looks at a part (window processing)
- Windows overlap to ensure coherence (overlap areas)
- Finally, all parts are spliced into a complete image (result fusion)

```mermaid
%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#444444", "primaryTextColor": "#ffffff", "primaryBorderColor": "#cccccc", "lineColor": "transparent", "sectionBkgColor": "#f8f9fa", "altSectionBkgColor": "#e9ecef", "gridColor": "transparent", "section0": "#555555", "section1": "#777777", "section2": "#E6F3FF", "section3": "#bbbbbb", "activeTaskBkgColor": "#444444", "activeTaskBorderColor": "#cccccc", "cScale0": "#555555", "cScale1": "#777777", "cScale2": "#E6F3FF", "critBkgColor": "#E6F3FF", "critBorderColor": "#B3D9FF", "xyColor": "#333333", "axisTextColor": "#333333", "gridLineColor": "transparent"}}}%%
gantt
title Context Window Processing Example (length=21, overlap=5)
dateFormat X
axisFormat %s

section Original Sequence
Complete Content (length=81) : 0, 81

section Window Processing
Window 1 (0-20) : active, w1, 0, 21
Window 2 (16-36) : active, w2, 16, 37
Window 3 (32-52) : active, w3, 32, 53
Window 4 (48-68) : active, w4, 48, 69
Window 5 (64-81) : active, w5, 64, 81

section Overlap Areas
Overlap 1-2 : crit, o1, 16, 21
Overlap 2-3 : crit, o2, 32, 37
Overlap 3-4 : crit, o3, 48, 53
Overlap 4-5 : crit, o4, 64, 69
```


## Input Parameters

| Parameter Name | Function | Simple Explanation |
|---------------|----------|-------------------|
| `model` | Model Input | The model you want to process |
| `context_length` | Window Size | Length of each small window, the larger the range the more memory it occupies |
| `context_overlap` | Overlap Size | Overlapping part between windows, more overlap means smoother effect but slower processing |
| `context_schedule` | Processing Method | Choose how windows move, four modes available |
| `context_stride` | Movement Step | How much the window moves each time, only useful in uniform mode |
| `closed_loop` | Loop Mode | Whether to connect the last window back to the first, only useful in loop mode |
| `fuse_method` | Merge Method | Choose how overlapping parts merge, affects final effect |
| `dim` | Processing Dimension | Which direction to process, usually 0 (time direction) |

## Scheduling Strategy Selection

| Scheduling Strategy | Working Method |
|--------------------|----------------|
| **STATIC_STANDARD** | Window positions are fixed |
| **UNIFORM_STANDARD** | Windows move uniformly |
| **UNIFORM_LOOPED** | Windows move in a loop |
| **BATCHED** | Multiple windows processed simultaneously |

## Merge Methods

| Merge Method | Weight Distribution Method | Characteristics |
|-------------|---------------------------|-----------------|
| **PYRAMID** | Middle part most important, decreasing toward edges | Most natural effect, recommended |
| **RELATIVE** | Intelligent weight adjustment | Automatically adjusts based on position, natural effect |
| **FLAT** | Average weight distribution | Simple and direct, suitable for uniform content |
| **OVERLAP_LINEAR** | Linear gradient | Smoother transition |

## Output Results

| Parameter Name | Description |
|---------------|-------------|
| `model` | Processed model, can be directly connected to sampler for use |

## Typical Usage

```mermaid
graph LR
A[Model Loader] --> B[Context Windows Manual]
B --> C[KSampler]
C --> D[Output]

style A fill:#1976d2,color:#ffffff
style B fill:#f57c00,color:#ffffff
style C fill:#388e3c,color:#ffffff
style D fill:#2e7d32,color:#ffffff
```

**Usage Steps**:
1. Load model
2. Connect to Context Windows Manual node
3. Connect to sampler to generate results
127 changes: 127 additions & 0 deletions built-in-nodes/WanContextWindowsManualNode.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: "WAN Context Windows (Manual) - ComfyUI Built-in Node Documentation"
description: "WAN Context Windows (Manual) node is a specialized context window manual control node optimized for WAN (Wide Attention Network) models. It automatically converts standard context parameters to WAN-compatible format, implementing sliding window sampling for ultra-long sequence generation."
sidebarTitle: "WAN Context Windows (Manual)"
icon: "circle"
---

The `WAN Context Windows (Manual)` node is specifically designed for WAN models. It automatically adjusts parameters to allow WAN models to better handle long content.

**How it works:**
Like using multiple segmented samples to generate different segments of a video, and finally synthesizing a complete video**
- Each window looks at a part (window processing)
- Windows overlap to ensure coherence (overlap areas)
- Finally, all parts are spliced into a complete image (result fusion)

```mermaid
%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#444444", "primaryTextColor": "#ffffff", "primaryBorderColor": "#cccccc", "lineColor": "transparent", "sectionBkgColor": "#f8f9fa", "altSectionBkgColor": "#e9ecef", "gridColor": "transparent", "section0": "#555555", "section1": "#777777", "section2": "#E6F3FF", "section3": "#bbbbbb", "activeTaskBkgColor": "#444444", "activeTaskBorderColor": "#cccccc", "cScale0": "#555555", "cScale1": "#777777", "cScale2": "#E6F3FF", "critBkgColor": "#E6F3FF", "critBorderColor": "#B3D9FF", "xyColor": "#333333", "axisTextColor": "#333333", "gridLineColor": "transparent"}}}%%
gantt
title Context Window Processing Example (length=21, overlap=5)
dateFormat X
axisFormat %s

section Original Sequence
Complete Content (length=81) : 0, 81

section Window Processing
Window 1 (0-20) : active, w1, 0, 21
Window 2 (16-36) : active, w2, 16, 37
Window 3 (32-52) : active, w3, 32, 53
Window 4 (48-68) : active, w4, 48, 69
Window 5 (64-81) : active, w5, 64, 81

section Overlap Areas
Overlap 1-2 : crit, o1, 16, 21
Overlap 2-3 : crit, o2, 32, 37
Overlap 3-4 : crit, o3, 48, 53
Overlap 4-5 : crit, o4, 64, 69
```

## Input Parameters

| Parameter Name | Function | Simple Explanation |
|---------------|----------|-------------------|
| `model` | WAN Model Input | The WAN model you want to process |
| `context_length` | Window Size | Length of each small window, WAN will automatically adjust to multiples of 4. The larger the range the more memory it occupies |
| `context_overlap` | Overlap Size | Overlapping part between windows, more overlap means smoother effect but slower processing |
| `context_schedule` | Processing Method | Choose how windows move, four modes available |
| `context_stride` | Movement Step | How much the window moves each time, only useful in uniform mode |
| `closed_loop` | Loop Mode | Whether to connect the last window back to the first, only useful in loop mode |
| `fuse_method` | Merge Method | Choose how overlapping parts merge, affects final effect |
| `dim` | Processing Dimension | Fixed at 2, specifically optimized for WAN models |

### Scheduling Strategy Selection

| Scheduling Strategy | Working Method |
|--------------------|----------------|
| **STATIC_STANDARD** | Window positions are fixed |
| **UNIFORM_STANDARD** | Windows move uniformly |
| **UNIFORM_LOOPED** | Windows move in a loop |
| **BATCHED** | Multiple windows processed simultaneously |

### Merge Methods

| Merge Method | Weight Distribution Method | Characteristics |
|-------------|---------------------------|-----------------|
| **PYRAMID** | Middle part most important, decreasing toward edges | Most natural effect, recommended |
| **RELATIVE** | Intelligent weight adjustment | Automatically adjusts based on position, natural effect |
| **FLAT** | Average weight distribution | Simple and direct, suitable for uniform content |
| **OVERLAP_LINEAR** | Linear gradient | Smoother transition |

## Output Results

| Parameter Name | Data Type | Description |
|---------------|-----------|-------------|
| `model` | MODEL | Processed WAN model, can be directly connected to sampler for use |


### WAN Parameter Automatic Adjustment

```mermaid
graph LR
subgraph Your Input Values
A1[Window Size: 81]
A2[Overlap: 30]
end

subgraph Automatic Adjustment
B1[Adjust to multiples of 4]
B2[Adjust to multiples of 4]
B3[Fixed at 2]
end

subgraph WAN Actual Usage
C1[Actual Size: 21]
C2[Actual Overlap: 8]
C3[Dimension: 2]
end

A1 --> B1 --> C1
A2 --> B2 --> C2
B3 --> C3

style A1 fill:#172DD7,color:#ffffff
style A2 fill:#172DD7,color:#ffffff
style C1 fill:#F0FF41,color:#000000
style C2 fill:#F0FF41,color:#000000
style C3 fill:#F0FF41,color:#000000
```

## Typical Usage

```mermaid
graph LR
A[Model Loader (WAN Model)] --> B[WAN Context Windows Manual]
B --> C[KSampler]
C --> D[Final Output]

style A fill:#172DD7,color:#ffffff
style B fill:#E8F234,color:#000000
style C fill:#2E41E7,color:#ffffff
style D fill:#F0FF41,color:#000000
```

**Usage Steps**:
1. Load WAN model
2. Connect to WAN Context Windows Manual node
3. Connect to sampler to generate results
14 changes: 14 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@
]
}
]
},
{
"group": "Context",
"pages": [
"built-in-nodes/ContextWindowsManualNode",
"built-in-nodes/WanContextWindowsManualNode"
]
}
]
},
Expand Down Expand Up @@ -1029,6 +1036,13 @@
]
}
]
},
{
"group": "Context",
"pages": [
"zh-CN/built-in-nodes/ContextWindowsManualNode",
"zh-CN/built-in-nodes/WanContextWindowsManualNode"
]
}
]
},
Expand Down
95 changes: 95 additions & 0 deletions zh-CN/built-in-nodes/ContextWindowsManualNode.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "Context Windows (Manual) - ComfyUI 原生节点文档"
description: "Context Windows (Manual) 节点提供手动上下文窗口控制,实现滑动窗口采样技术处理长序列生成任务,有效管理显存使用并提供多种调度策略。"
sidebarTitle: "Context Windows (Manual)"
icon: "circle"
---

`Context Windows (Manual)` 节点帮你处理超长的内容。它将长序列分解为多个重叠的上下文窗口进行采样,而不是一次性处理整个序列,这样既节省内存又能生成高质量的结果。

**作用方式:**
就像用多个分段的采样分别生成不同分段的视频,最后合成一个完整视频**
- 每个窗口看一部分(窗口处理)
- 窗口之间有重叠确保连贯(重叠区域)
- 最后将所有部分拼接成完整的图像(结果融合)

```mermaid
%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#444444", "primaryTextColor": "#ffffff", "primaryBorderColor": "#cccccc", "lineColor": "transparent", "sectionBkgColor": "#f8f9fa", "altSectionBkgColor": "#e9ecef", "gridColor": "transparent", "section0": "#555555", "section1": "#777777", "section2": "#E6F3FF", "section3": "#bbbbbb", "activeTaskBkgColor": "#444444", "activeTaskBorderColor": "#cccccc", "cScale0": "#555555", "cScale1": "#777777", "cScale2": "#E6F3FF", "critBkgColor": "#E6F3FF", "critBorderColor": "#B3D9FF", "xyColor": "#333333", "axisTextColor": "#333333", "gridLineColor": "transparent"}}}%%
gantt
title 上下文窗口处理示例 (length=21, overlap=5)
dateFormat X
axisFormat %s

section 原始序列
完整内容 (长度81) : 0, 81

section 窗口处理
窗口1 (0-20) : active, w1, 0, 21
窗口2 (16-36) : active, w2, 16, 37
窗口3 (32-52) : active, w3, 32, 53
窗口4 (48-68) : active, w4, 48, 69
窗口5 (64-81) : active, w5, 64, 81

section 重叠区域
重叠1-2 : crit, o1, 16, 21
重叠2-3 : crit, o2, 32, 37
重叠3-4 : crit, o3, 48, 53
重叠4-5 : crit, o4, 64, 69
```


## 输入参数

| 参数名称 | 功能说明 | 简单解释 |
|---------|----------|----------|
| `model` | 模型输入 | 你要处理的模型 |
| `context_length` | 窗口大小 | 每个小窗口的长度,越大处理范围越广但占用内存更多 |
| `context_overlap` | 重叠大小 | 窗口之间重叠的部分,重叠越多效果越平滑但处理越慢 |
| `context_schedule` | 处理方式 | 选择窗口如何移动,有四种模式可选 |
| `context_stride` | 移动步长 | 窗口每次移动多少,只在均匀模式下有用 |
| `closed_loop` | 循环模式 | 是否让最后一个窗口连回第一个,只在循环模式下有用 |
| `fuse_method` | 合并方法 | 选择重叠部分如何合并,影响最终效果 |
| `dim` | 处理维度 | 在哪个方向上处理,通常是0(时间方向) |

## 调度策略选择

| 调度策略 | 工作方式 |
|---------|----------|
| **STATIC_STANDARD** | 窗口位置固定 |
| **UNIFORM_STANDARD** | 窗口均匀移动 |
| **UNIFORM_LOOPED** | 窗口循环移动 |
| **BATCHED** | 多个窗口同时处理 |

## 合并方法

| 合并方法 | 权重分布方式 | 特点 |
|---------|----------|----------|
| **PYRAMID** | 中间部分最重要,向两边递减 | 最自然的效果,推荐使用 |
| **RELATIVE** | 智能调整权重 | 根据位置自动调整,效果自然 |
| **FLAT** | 平均分配权重 | 简单直接,适合均匀内容 |
| **OVERLAP_LINEAR** | 线性渐变 | 过渡更平滑 |

## 输出结果

| 参数名称 | 说明 |
|---------|------|
| `model` | 处理好的模型,可以直接连接到采样器使用 |

## 典型用法

```mermaid
graph LR
A[Model Loader] --> B[Context Windows Manual]
B --> C[KSampler]
C --> D[输出]

style A fill:#1976d2,color:#ffffff
style B fill:#f57c00,color:#ffffff
style C fill:#388e3c,color:#ffffff
style D fill:#2e7d32,color:#ffffff
```

**使用步骤**:
1. 加载模型
2. 连到 Context Windows Manual 节点
3. 连到采样器生成结果
Loading