From 5e8ca574a099d7c3f89610dce69dc56f5c9b399e Mon Sep 17 00:00:00 2001 From: ComfyUI Wiki Date: Sun, 17 Aug 2025 09:54:39 +0800 Subject: [PATCH 1/3] add context windows docs --- built-in-nodes/ContextWindowsManualNode.mdx | 208 +++++++++++++++++ .../WanContextWindowsManualNode.mdx | 180 +++++++++++++++ .../ContextWindowsManualNode.mdx | 209 ++++++++++++++++++ .../WanContextWindowsManualNode.mdx | 181 +++++++++++++++ 4 files changed, 778 insertions(+) create mode 100644 built-in-nodes/ContextWindowsManualNode.mdx create mode 100644 built-in-nodes/WanContextWindowsManualNode.mdx create mode 100644 zh-CN/built-in-nodes/ContextWindowsManualNode.mdx create mode 100644 zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx diff --git a/built-in-nodes/ContextWindowsManualNode.mdx b/built-in-nodes/ContextWindowsManualNode.mdx new file mode 100644 index 00000000..a366457d --- /dev/null +++ b/built-in-nodes/ContextWindowsManualNode.mdx @@ -0,0 +1,208 @@ +--- +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: "window-maximize" +--- + +The `Context Windows (Manual)` node provides complete manual control over context windows. It decomposes long sequences into multiple overlapping context windows for sampling, rather than processing the entire sequence at once, thereby effectively managing memory usage and enabling high-quality long sequence generation. + +```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 | Detailed Description | +|----------------|----------|----------------------| +| `model` | Model Input | Base model object that requires context window processing | +| `context_length` | Window Length Control | Length of each context window. Larger values provide broader processing range but require more memory | +| `context_overlap` | Window Overlap Setting | Size of overlapping area between adjacent windows, ensuring content coherence. More overlap provides smoother results but increases processing time | +| `context_schedule` | Scheduling Strategy | Controls how windows move and arrange across the sequence, including static, uniform, looped, and batched modes | +| `context_stride` | Movement Step Size | Step size for window movement, only effective in UNIFORM scheduling mode, controls fine-grained window movement | +| `closed_loop` | Loop Mode Switch | Whether to connect the last window with the first to form a loop, only effective in LOOPED scheduling mode | +| `fuse_method` | Fusion Method | Algorithm for merging overlap areas, affects smoothness of window transitions and final results | +| `dim` | Application Dimension | Specifies which data dimension to apply context window processing, typically 0 (time dimension) | + +## Context Scheduling Strategies + +| Scheduling Strategy | Working Method | Best Use Cases | +|--------------------|--------------|--------------| +| **STATIC_STANDARD** | Fixed window positions | Processing fixed region content, tasks requiring precise position control | +| **UNIFORM_STANDARD** | Windows move uniformly by set step size | Continuous processing of long sequences, such as long text or long video sequences | +| **UNIFORM_LOOPED** | Uniform movement with head-to-tail connection | Cyclic content processing, such as background music or repetitive pattern generation | +| **BATCHED** | Multiple windows processed in parallel batches | Efficient processing of large amounts of data, suitable for sufficient memory situations | + +## Fusion Methods + +| Fusion Method | Weight Distribution | Effect Characteristics | +|--------------|--------------------|-----------------------| +| **PYRAMID** | Highest weight at center, decreasing toward edges | Most natural transition effect, recommended for most scenarios | +| **FLAT** | Equal weight distribution in overlap areas | Simple and direct fusion, suitable for uniform content | +| **COS** | Cosine curve-shaped weight distribution | Very smooth transition, suitable for content requiring gentle effects | + +## Output Results + +| Parameter Name | Description | +|---------------|-------------| +| `model` | Model object with applied context window processing, can be directly connected to samplers for generation | + +## Node Principle + +The `Context Windows (Manual)` decomposes long sequences into multiple overlapping windows for processing: + +### Workflow Diagram + +```mermaid +graph TD + A[Model Input] --> B[Parameter Configuration] + B --> C{Choose Scheduling Strategy} + C -->|STATIC_STANDARD| D[Static Windows] + C -->|UNIFORM_STANDARD| E[Uniform Movement] + C -->|UNIFORM_LOOPED| F[Loop Movement] + C -->|BATCHED| G[Batch Processing] + + D --> H[Window Sampling] + E --> H + F --> H + G --> H + + H --> I{Fusion Strategy} + I -->|PYRAMID| J[Pyramid Fusion
High Center Weight] + I -->|FLAT| K[Average Fusion
Equal Weight Distribution] + I -->|COS| L[Cosine Fusion
Smooth Transition] + + J --> M[Complete Sequence Output] + K --> M + L --> M + + style A fill:#1976d2,color:#ffffff + style M fill:#2e7d32,color:#ffffff + style B fill:#ef6c00,color:#ffffff + style H fill:#c2185b,color:#ffffff +``` + +### Scheduling Strategy Comparison + +```mermaid +graph LR + subgraph STATIC["STATIC_STANDARD - Static Windows"] + S1[Window 1: Fixed Position] + S2[Window 2: Fixed Position] + S3[Window 3: Fixed Position] + S1 -.-> S2 + S2 -.-> S3 + end + + subgraph UNIFORM["UNIFORM_STANDARD - Uniform Movement"] + U1[Window 1] --> U2[Window 2] --> U3[Window 3] --> U4[Window 4] + end + + subgraph LOOPED["UNIFORM_LOOPED - Loop Movement"] + L1[Window 1] --> L2[Window 2] --> L3[Window 3] --> L1 + end + + subgraph BATCH["BATCHED - Batch Processing"] + B1[Window 1] + B2[Window 2] + B3[Window 3] + B1 -.Parallel.-> B2 + B2 -.Parallel.-> B3 + end + + style STATIC fill:#d32f2f,color:#ffffff + style UNIFORM fill:#388e3c,color:#ffffff + style LOOPED fill:#1976d2,color:#ffffff + style BATCH fill:#f57c00,color:#ffffff +``` + +### Fusion Method Comparison + +```mermaid +graph TB + subgraph Overlap Area Fusion + A[Overlap Area] --> B{Choose Fusion Method} + + B -->|PYRAMID| C[Pyramid Weight] + B -->|FLAT| D[Average Weight] + B -->|COS| E[Cosine Weight] + + C --> F[Weight Distribution:
1.0→0.8→0.6→0.4→0.2→0.0] + D --> G[Weight Distribution:
0.5→0.5→0.5→0.5→0.5→0.5] + E --> H[Weight Distribution:
1.0→0.9→0.7→0.3→0.1→0.0] + + F --> I[Most Natural Transition] + G --> J[Simple and Direct] + H --> K[Smoothest Transition] + end + + style C fill:#388e3c,color:#ffffff + style D fill:#1976d2,color:#ffffff + style E fill:#f57c00,color:#ffffff +``` + +### Simple Understanding + +Like viewing a large painting through multiple small windows: +- Each window views a portion (window processing) +- Windows overlap to ensure coherence (overlap areas) +- Finally, all portions are stitched together into a complete image (result fusion) + +## Recommended Settings + +**Beginner Recommendation**: Keep default values (length: 16, overlap: 4) + +**For Higher Quality**: Increase overlap value to 6-8 + +**For Processing Very Long Content**: Increase window length to 32-64 + +## Advantages and Limitations + +**Advantages**: +- ✅ Saves memory usage +- ✅ Supports ultra-long sequence processing + +**Notes**: +- ⚠️ Processing time will be slightly longer +- ⚠️ Requires more system memory + +## 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 + +With the `Context Windows (Manual)` node, you can easily process ultra-long sequences without worrying about memory limitations. \ No newline at end of file diff --git a/built-in-nodes/WanContextWindowsManualNode.mdx b/built-in-nodes/WanContextWindowsManualNode.mdx new file mode 100644 index 00000000..4203d6fa --- /dev/null +++ b/built-in-nodes/WanContextWindowsManualNode.mdx @@ -0,0 +1,180 @@ +--- +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: "window-maximize" +--- + +The `WAN Context Windows (Manual)` node is a context window controller specifically designed for WAN (Wide Attention Network) models. It automatically converts user-friendly context parameters to the internal format required by WAN models, implementing efficient sliding window sampling that is particularly suitable for long sequence generation tasks. + +```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 WAN Context Window Processing Example (length=21, overlap=8) + dateFormat X + axisFormat %s + + section Original Sequence + Complete Content (length=100) : 0, 81 + + section Window Division + Window 1 (0-20) : active, window1, 0, 21 + Window 2 (13-33) : active, window2, 13, 34 + Window 3 (26-46) : active, window3, 26, 47 + Window 4 (39-59) : active, window4, 39, 60 + + section Overlap Areas + Overlap 1-2 : crit, overlap1, 13, 21 + Overlap 2-3 : crit, overlap2, 26, 34 + Overlap 3-4 : crit, overlap3, 39, 47 +``` + +## Input Parameters Details + +| Parameter Name | Function | Detailed Description | +|---------------|----------|----------------------| +| `model` | WAN Model Input | WAN model object that requires context window processing | +| `context_length` | Window Length Control | Length of each context window. WAN models automatically adjust to multiples of 4. Larger values provide broader processing range but higher memory usage | +| `context_overlap` | Window Overlap Setting | Size of overlapping area between adjacent windows, ensuring content coherence between windows. More overlap provides smoother results but longer processing time | +| `context_schedule` | Scheduling Strategy Selection | Controls how windows move and arrange across the sequence, including static, uniform, looped, and batched modes | +| `context_stride` | Movement Step Size | Step size for window movement, only effective in UNIFORM scheduling mode, controls fine-grained window movement | +| `closed_loop` | Loop Mode Switch | Whether to connect the last window with the first to form a loop, only effective in LOOPED scheduling mode | +| `fuse_method` | Fusion Method | Algorithm for merging overlap areas, affects smoothness of window transitions and final results | + +### Context Scheduling Strategy Details + +| Scheduling Strategy | Working Method | Best Use Cases | +|--------------------|---------------|----------------| +| **STATIC_STANDARD** | Fixed window positions | Processing fixed region content, tasks requiring precise position control | +| **UNIFORM_STANDARD** | Windows move uniformly by set step size | Continuous processing of long sequences, such as long text or long video sequences | +| **UNIFORM_LOOPED** | Uniform movement with head-to-tail connection | Cyclic content processing, such as background music or repetitive pattern generation | +| **BATCHED** | Multiple windows processed in parallel batches | Efficient processing of large amounts of data, suitable for sufficient memory situations | + +### Fusion Method Details + +| Fusion Method | Weight Distribution | Effect Characteristics | +|--------------|--------------------|-----------------------| +| **PYRAMID** | Highest weight at center, decreasing toward edges | Most natural transition effect, recommended for most scenarios | +| **FLAT** | Equal weight distribution in overlap areas | Simple and direct fusion, suitable for uniform content | +| **COS** | Cosine curve-shaped weight distribution | Very smooth transition, suitable for content requiring gentle effects | + +## Output Results + +| Parameter Name | Data Type | Description | +|---------------|-----------|-------------| +| `model` | MODEL | WAN model object with applied context window processing | + +## Node Principle: Cinematic Shot Division Strategy + +Imagine you need to shoot an ultra-long panoramic movie, but the camera's field of view is limited. The `WAN Context Windows (Manual)` is like a **professional shot division director**: + +### Workflow Diagram + +```mermaid +graph TD + A[WAN Model Input] --> B[Automatic Parameter Adjustment] + B --> C{Context Scheduling Strategy} + C -->|STATIC_STANDARD| D[Fixed Position Windows] + C -->|UNIFORM_STANDARD| E[Uniform Moving Windows] + C -->|UNIFORM_LOOPED| F[Loop Moving Windows] + C -->|BATCHED| G[Batch Parallel Windows] + + D --> H[Segmented Sampling] + E --> H + F --> H + G --> H + + H --> I[Window Fusion] + I --> J{Fusion Method} + J -->|PYRAMID| K[Pyramid Weight Fusion] + J -->|FLAT| L[Average Weight Fusion] + J -->|COS| M[Cosine Weight Fusion] + + K --> N[Complete Sequence Output] + L --> N + M --> N + + style A fill:#172DD7,color:#ffffff + style N fill:#F0FF41,color:#000000 + style B fill:#2E41E7,color:#ffffff +``` + +### WAN Automatic Parameter Conversion + +```mermaid +graph LR + subgraph User Input + A1[context_length: 81] + A2[context_overlap: 30] + end + + subgraph Automatic Conversion Formula + B1["((length-1) ÷ 4) + 1"] + B2["((overlap-1) ÷ 4) + 1"] + B3[dim = 2 fixed] + end + + subgraph WAN Internal Parameters + C1[Actual length: 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 +``` + +### Simple Understanding + +The `WAN Context Windows (Manual)` is like using multiple small lenses to shoot a long movie: +- Each lens captures a small segment of content (window processing) +- Lenses overlap to ensure continuity (window overlap) +- Finally, all shots are intelligently stitched into a complete film (fusion output) + +## Recommended Configuration + +**Beginner Recommendation**: Keep default values (length: 81, overlap: 30) + +**For Higher Quality**: Increase overlap value to 40-50 + +**For Processing Ultra-Long Content**: Increase window length to 100-150 + +## Performance and Limitations + +### Advantages +- ✅ **Memory-Friendly**: Segmented processing avoids large memory requirements +- ✅ **WAN Optimized**: Specifically tuned for WAN models +- ✅ **Automatic Parameter Adjustment**: No need for manual calculation and conversion +- ✅ **Multiple Strategies**: Flexible scheduling and fusion options + +### Considerations +- ⚠️ Processing time will be slightly longer than standard methods +- ⚠️ Requires more memory to store window information + +## Typical Usage + +```mermaid +graph LR + A[WAN Model Loader] --> 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 + +With the `WAN Context Windows (Manual)` node, you can easily handle long sequence generation tasks without worrying about memory limitations. \ No newline at end of file diff --git a/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx b/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx new file mode 100644 index 00000000..5a6c3373 --- /dev/null +++ b/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx @@ -0,0 +1,209 @@ +--- +title: "Context Windows (Manual) - ComfyUI 原生节点文档" +description: "Context Windows (Manual) 节点提供手动上下文窗口控制,实现滑动窗口采样技术处理长序列生成任务,有效管理显存使用并提供多种调度策略。" +sidebarTitle: "Context Windows (Manual)" +icon: "window-maximize" +--- + +`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` | 移动步长 | 窗口每次移动的步长大小,仅在 UNIFORM 调度模式下生效,控制窗口移动的精细程度 | +| `closed_loop` | 循环模式开关 | 是否将最后一个窗口与第一个窗口连接形成循环,仅在 LOOPED 调度模式下生效 | +| `fuse_method` | 融合方法 | 决定重叠区域如何合并的算法,影响窗口间过渡的平滑程度和最终效果 | +| `dim` | 应用维度 | 指定在哪个数据维度上应用上下文窗口处理,通常为0(时间维度) | + +## 上下文调度策略 + +| 调度策略 | 工作方式 | 最佳使用场景 | +|---------|----------|-------------| +| **STATIC_STANDARD** | 窗口位置固定不动 | 处理固定区域内容,需要精确控制位置的任务 | +| **UNIFORM_STANDARD** | 窗口按设定步长均匀移动 | 长序列的连续处理,如长文本或长视频序列 | +| **UNIFORM_LOOPED** | 均匀移动并首尾相连 | 循环内容处理,如背景音乐、重复图案生成 | +| **BATCHED** | 多个窗口并行批处理 | 大量数据的高效处理,适合显存充足的情况 | + +## 融合方法 + +| 融合方法 | 权重分布方式 | 效果特点 | +|---------|-------------|----------| +| **PYRAMID** | 中心区域权重最高,向边缘递减 | 最自然的过渡效果,推荐大多数场景使用 | +| **FLAT** | 重叠区域平均分配权重 | 简单直接的融合,适合均匀内容 | +| **COS** | 余弦曲线形状的权重分布 | 非常平滑的过渡,适合需要柔和效果的内容 | + +## 输出结果 + +| 参数名称 | 说明 | +|---------|------| +| `model` | 应用了上下文窗口处理的模型对象,可直接连接到采样器进行生成 | + +## 节点原理 + +`Context Windows (Manual)` 将长序列分解为多个重叠的窗口进行处理: + +### 工作流程图 + +```mermaid +graph TD + A[模型输入] --> B[参数配置] + B --> C{选择调度策略} + C -->|STATIC_STANDARD| D[静态窗口] + C -->|UNIFORM_STANDARD| E[均匀移动] + C -->|UNIFORM_LOOPED| F[循环移动] + C -->|BATCHED| G[批量处理] + + D --> H[窗口采样] + E --> H + F --> H + G --> H + + H --> I{融合策略} + I -->|PYRAMID| J[金字塔融合
中心权重高] + I -->|FLAT| K[平均融合
等权重分配] + I -->|COS| L[余弦融合
平滑过渡] + + J --> M[完整序列输出] + K --> M + L --> M + + style A fill:#1976d2,color:#ffffff + style M fill:#2e7d32,color:#ffffff + style B fill:#ef6c00,color:#ffffff + style H fill:#c2185b,color:#ffffff +``` + +### 调度策略对比 + +```mermaid +graph LR + subgraph STATIC["STATIC_STANDARD - 静态窗口"] + S1[窗口1: 位置固定] + S2[窗口2: 位置固定] + S3[窗口3: 位置固定] + S1 -.-> S2 + S2 -.-> S3 + end + + subgraph UNIFORM["UNIFORM_STANDARD - 均匀移动"] + U1[窗口1] --> U2[窗口2] --> U3[窗口3] --> U4[窗口4] + end + + subgraph LOOPED["UNIFORM_LOOPED - 循环移动"] + L1[窗口1] --> L2[窗口2] --> L3[窗口3] --> L1 + end + + subgraph BATCH["BATCHED - 批量处理"] + B1[窗口1] + B2[窗口2] + B3[窗口3] + B1 -.并行.-> B2 + B2 -.并行.-> B3 + end + + style STATIC fill:#d32f2f,color:#ffffff + style UNIFORM fill:#388e3c,color:#ffffff + style LOOPED fill:#1976d2,color:#ffffff + style BATCH fill:#f57c00,color:#ffffff +``` + +### 融合方法对比 + +```mermaid +graph TB + subgraph 重叠区域融合 + A[重叠区域] --> B{融合方法选择} + + B -->|PYRAMID| C[金字塔权重] + B -->|FLAT| D[平均权重] + B -->|COS| E[余弦权重] + + C --> F[权重分布:
1.0→0.8→0.6→0.4→0.2→0.0] + D --> G[权重分布:
0.5→0.5→0.5→0.5→0.5→0.5] + E --> H[权重分布:
1.0→0.9→0.7→0.3→0.1→0.0] + + F --> I[最自然过渡] + G --> J[简单直接] + H --> K[最平滑过渡] + end + + style C fill:#388e3c,color:#ffffff + style D fill:#1976d2,color:#ffffff + style E fill:#f57c00,color:#ffffff +``` + +### 简单理解 + +就像用多个小窗口看一幅大画: +- 每个窗口看一部分(窗口处理) +- 窗口之间有重叠确保连贯(重叠区域) +- 最后将所有部分拼接成完整的图像(结果融合) + +## 推荐设置 + +**新手推荐**:保持默认值即可(length: 16, overlap: 4) + +**需要更高质量**:增加重叠值到 6-8 + +**处理超长内容**:增加窗口长度到 32-64 + +## 优劣势 + +**优势**: +- ✅ 节约显存使用 +- ✅ 支持超长序列处理 + +**注意**: +- ⚠️ 处理时间会稍长 +- ⚠️ 需要更多系统内存 + +## 典型用法 + +```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. 连接到采样器生成结果 + +通过 `Context Windows (Manual)` 节点,您可以轻松处理超长序列,无需担心显存限制。 \ No newline at end of file diff --git a/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx b/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx new file mode 100644 index 00000000..49f299d8 --- /dev/null +++ b/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx @@ -0,0 +1,181 @@ +--- +title: "WAN Context Windows (Manual) - ComfyUI 原生节点文档" +description: "WAN Context Windows (Manual) 节点专门为 WAN (Wide Attention Network) 模型优化的上下文窗口手动控制节点。它将普通的上下文参数自动转换为 WAN 兼容格式,实现滑动窗口采样以处理超长序列生成。" +sidebarTitle: "WAN Context Windows (Manual)" +icon: "window-maximize" +--- + +`WAN Context Windows (Manual)` 节点是专门为 WAN (Wide Attention Network) 模型设计的上下文窗口控制器。它自动将用户友好的上下文参数转换为 WAN 模型所需的内部格式,实现高效的滑动窗口采样,特别适用于长序列生成任务。 + + +```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 WAN 上下文窗口处理示例 (length=21, overlap=8) + dateFormat X + axisFormat %s + + section 原始序列 + 完整内容 (长度100) : 0, 81 + + section 窗口划分 + 窗口1 (0-20) : active, window1, 0, 21 + 窗口2 (13-33) : active, window2, 13, 34 + 窗口3 (26-46) : active, window3, 26, 47 + 窗口4 (39-59) : active, window4, 39, 60 + + section 重叠区域 + 重叠1-2 : crit, overlap1, 13, 21 + 重叠2-3 : crit, overlap2, 26, 34 + 重叠3-4 : crit, overlap3, 39, 47 +``` + +## 输入参数详解 + +| 参数名称 | 功能说明 | 详细解释 | +|---------|----------|----------| +| `model` | WAN 模型输入 | 需要应用上下文窗口处理的 WAN 模型对象 | +| `context_length` | 窗口长度控制 | 每个上下文窗口的长度,WAN 模型会自动按 4 的倍数调整。值越大处理范围越广但显存占用更高 | +| `context_overlap` | 窗口重叠设置 | 相邻窗口间的重叠区域大小,确保窗口间内容连贯性。重叠越多越平滑但处理时间更长 | +| `context_schedule` | 调度策略选择 | 控制窗口如何在序列上移动和排布,包括静态、均匀、循环、批处理四种模式 | +| `context_stride` | 移动步长 | 窗口每次移动的步长大小,仅在 UNIFORM 调度模式下生效,控制窗口移动的精细程度 | +| `closed_loop` | 循环模式开关 | 是否将最后一个窗口与第一个窗口连接形成循环,仅在 LOOPED 调度模式下生效 | +| `fuse_method` | 融合方法 | 决定重叠区域如何合并的算法,影响窗口间过渡的平滑程度和最终效果 | + +### 上下文调度策略详解 + +| 调度策略 | 工作方式 | 最佳使用场景 | +|---------|----------|-------------| +| **STATIC_STANDARD** | 窗口位置固定不动 | 处理固定区域内容,需要精确控制位置的任务 | +| **UNIFORM_STANDARD** | 窗口按设定步长均匀移动 | 长序列的连续处理,如长文本或长视频序列 | +| **UNIFORM_LOOPED** | 均匀移动并首尾相连 | 循环内容处理,如背景音乐、重复图案生成 | +| **BATCHED** | 多个窗口并行批处理 | 大量数据的高效处理,适合显存充足的情况 | + +### 融合方法详解 + +| 融合方法 | 权重分布方式 | 效果特点 | +|---------|-------------|----------| +| **PYRAMID** | 中心区域权重最高,向边缘递减 | 最自然的过渡效果,推荐大多数场景使用 | +| **FLAT** | 重叠区域平均分配权重 | 简单直接的融合,适合均匀内容 | +| **COS** | 余弦曲线形状的权重分布 | 非常平滑的过渡,适合需要柔和效果的内容 | + +## 输出结果 + +| 参数名称 | 数据类型 | 说明 | +|---------|---------|------| +| `model` | MODEL | 应用了上下文窗口处理的 WAN 模型对象 | + +## 节点原理:电影制作的分镜头策略 + +想象你要拍摄一部超长的全景电影,但摄像机的视野有限。`WAN Context Windows (Manual)` 就像是**专业的分镜头导演**: + +### 工作流程图 + +```mermaid +graph TD + A[WAN 模型输入] --> B[参数自动调整] + B --> C{上下文调度策略} + C -->|STATIC_STANDARD| D[固定位置窗口] + C -->|UNIFORM_STANDARD| E[均匀移动窗口] + C -->|UNIFORM_LOOPED| F[循环移动窗口] + C -->|BATCHED| G[批量并行窗口] + + D --> H[分段采样] + E --> H + F --> H + G --> H + + H --> I[窗口融合] + I --> J{融合方法} + J -->|PYRAMID| K[金字塔权重融合] + J -->|FLAT| L[平均权重融合] + J -->|COS| M[余弦权重融合] + + K --> N[输出完整序列] + L --> N + M --> N + + style A fill:#172DD7,color:#ffffff + style N fill:#F0FF41,color:#000000 + style B fill:#2E41E7,color:#ffffff +``` + +### WAN 参数自动转换 + +```mermaid +graph LR + subgraph 用户输入 + A1[context_length: 81] + A2[context_overlap: 30] + end + + subgraph 自动转换公式 + B1["((length-1) ÷ 4) + 1"] + B2["((overlap-1) ÷ 4) + 1"] + B3[dim = 2 固定] + end + + subgraph WAN内部参数 + C1[实际length: 21] + C2[实际overlap: 8] + C3[维度: 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 +``` + +### 简单理解 + +`WAN Context Windows (Manual)` 就像用多个小镜头拍摄一部长电影: +- 每个镜头拍摄一小段内容(窗口处理) +- 镜头之间有重叠确保连贯性(窗口重叠) +- 最后将所有镜头智能拼接成完整影片(融合输出) + +## 推荐配置 + +**新手推荐**:保持默认值即可(length: 81, overlap: 30) + +**需要更高质量**:增加重叠值到 40-50 + +**处理超长内容**:增加窗口长度到 100-150 + +## 性能与限制 + +### 优势 +- ✅ **显存友好**:分段处理避免大显存需求 +- ✅ **WAN 优化**:专门为 WAN 模型调优 +- ✅ **参数自动调整**:无需手动计算转换 +- ✅ **多种策略**:灵活的调度和融合选项 + +### 注意事项 +- ⚠️ 处理时间会比普通方式稍长 +- ⚠️ 需要更多显存来存储窗口信息 + +## 典型用法 + +```mermaid +graph LR + A[WAN Model Loader] --> B[WAN Context Windows Manual] + B --> C[KSampler] + C --> D[最终输出] + + style A fill:#172DD7,color:#ffffff + style B fill:#E8F234,color:#000000 + style C fill:#2E41E7,color:#ffffff + style D fill:#F0FF41,color:#000000 +``` + +**使用步骤**: +1. 加载 WAN 模型 +2. 连接到 WAN Context Windows Manual 节点 +3. 连接到采样器生成结果 + +通过 `WAN Context Windows (Manual)` 节点,您可以轻松处理长序列生成任务,无需担心显存限制。 \ No newline at end of file From d346e376029abff573ae40a7942a12d590ee826a Mon Sep 17 00:00:00 2001 From: ComfyUI Wiki Date: Sun, 7 Sep 2025 20:00:06 +0800 Subject: [PATCH 2/3] Update navigation --- docs.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs.json b/docs.json index 029c5798..a1fa3efc 100644 --- a/docs.json +++ b/docs.json @@ -465,6 +465,13 @@ ] } ] + }, + { + "group": "Context", + "pages": [ + "built-in-nodes/ContextWindowsManualNode", + "built-in-nodes/WanContextWindowsManualNode" + ] } ] }, @@ -1029,6 +1036,13 @@ ] } ] + }, + { + "group": "Context", + "pages": [ + "zh-CN/built-in-nodes/ContextWindowsManualNode", + "zh-CN/built-in-nodes/WanContextWindowsManualNode" + ] } ] }, From f2157f7aae5606f1b9689be117324e33b3259f7e Mon Sep 17 00:00:00 2001 From: ComfyUI Wiki Date: Sun, 7 Sep 2025 21:57:29 +0800 Subject: [PATCH 3/3] Update context window docs --- built-in-nodes/ContextWindowsManualNode.mdx | 191 ++++-------------- .../WanContextWindowsManualNode.mdx | 183 ++++++----------- .../ContextWindowsManualNode.mdx | 190 ++++------------- .../WanContextWindowsManualNode.mdx | 178 ++++++---------- 4 files changed, 204 insertions(+), 538 deletions(-) diff --git a/built-in-nodes/ContextWindowsManualNode.mdx b/built-in-nodes/ContextWindowsManualNode.mdx index a366457d..d2209bb0 100644 --- a/built-in-nodes/ContextWindowsManualNode.mdx +++ b/built-in-nodes/ContextWindowsManualNode.mdx @@ -2,10 +2,16 @@ 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: "window-maximize" +icon: "circle" --- -The `Context Windows (Manual)` node provides complete manual control over context windows. It decomposes long sequences into multiple overlapping context windows for sampling, rather than processing the entire sequence at once, thereby effectively managing memory usage and enabling high-quality long sequence generation. +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"}}}%% @@ -31,160 +37,43 @@ gantt Overlap 4-5 : crit, o4, 64, 69 ``` -## Input Parameters - -| Parameter Name | Function | Detailed Description | -|----------------|----------|----------------------| -| `model` | Model Input | Base model object that requires context window processing | -| `context_length` | Window Length Control | Length of each context window. Larger values provide broader processing range but require more memory | -| `context_overlap` | Window Overlap Setting | Size of overlapping area between adjacent windows, ensuring content coherence. More overlap provides smoother results but increases processing time | -| `context_schedule` | Scheduling Strategy | Controls how windows move and arrange across the sequence, including static, uniform, looped, and batched modes | -| `context_stride` | Movement Step Size | Step size for window movement, only effective in UNIFORM scheduling mode, controls fine-grained window movement | -| `closed_loop` | Loop Mode Switch | Whether to connect the last window with the first to form a loop, only effective in LOOPED scheduling mode | -| `fuse_method` | Fusion Method | Algorithm for merging overlap areas, affects smoothness of window transitions and final results | -| `dim` | Application Dimension | Specifies which data dimension to apply context window processing, typically 0 (time dimension) | - -## Context Scheduling Strategies - -| Scheduling Strategy | Working Method | Best Use Cases | -|--------------------|--------------|--------------| -| **STATIC_STANDARD** | Fixed window positions | Processing fixed region content, tasks requiring precise position control | -| **UNIFORM_STANDARD** | Windows move uniformly by set step size | Continuous processing of long sequences, such as long text or long video sequences | -| **UNIFORM_LOOPED** | Uniform movement with head-to-tail connection | Cyclic content processing, such as background music or repetitive pattern generation | -| **BATCHED** | Multiple windows processed in parallel batches | Efficient processing of large amounts of data, suitable for sufficient memory situations | -## Fusion Methods +## Input Parameters -| Fusion Method | Weight Distribution | Effect Characteristics | -|--------------|--------------------|-----------------------| -| **PYRAMID** | Highest weight at center, decreasing toward edges | Most natural transition effect, recommended for most scenarios | -| **FLAT** | Equal weight distribution in overlap areas | Simple and direct fusion, suitable for uniform content | -| **COS** | Cosine curve-shaped weight distribution | Very smooth transition, suitable for content requiring gentle effects | +| 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` | Model object with applied context window processing, can be directly connected to samplers for generation | - -## Node Principle - -The `Context Windows (Manual)` decomposes long sequences into multiple overlapping windows for processing: - -### Workflow Diagram - -```mermaid -graph TD - A[Model Input] --> B[Parameter Configuration] - B --> C{Choose Scheduling Strategy} - C -->|STATIC_STANDARD| D[Static Windows] - C -->|UNIFORM_STANDARD| E[Uniform Movement] - C -->|UNIFORM_LOOPED| F[Loop Movement] - C -->|BATCHED| G[Batch Processing] - - D --> H[Window Sampling] - E --> H - F --> H - G --> H - - H --> I{Fusion Strategy} - I -->|PYRAMID| J[Pyramid Fusion
High Center Weight] - I -->|FLAT| K[Average Fusion
Equal Weight Distribution] - I -->|COS| L[Cosine Fusion
Smooth Transition] - - J --> M[Complete Sequence Output] - K --> M - L --> M - - style A fill:#1976d2,color:#ffffff - style M fill:#2e7d32,color:#ffffff - style B fill:#ef6c00,color:#ffffff - style H fill:#c2185b,color:#ffffff -``` - -### Scheduling Strategy Comparison - -```mermaid -graph LR - subgraph STATIC["STATIC_STANDARD - Static Windows"] - S1[Window 1: Fixed Position] - S2[Window 2: Fixed Position] - S3[Window 3: Fixed Position] - S1 -.-> S2 - S2 -.-> S3 - end - - subgraph UNIFORM["UNIFORM_STANDARD - Uniform Movement"] - U1[Window 1] --> U2[Window 2] --> U3[Window 3] --> U4[Window 4] - end - - subgraph LOOPED["UNIFORM_LOOPED - Loop Movement"] - L1[Window 1] --> L2[Window 2] --> L3[Window 3] --> L1 - end - - subgraph BATCH["BATCHED - Batch Processing"] - B1[Window 1] - B2[Window 2] - B3[Window 3] - B1 -.Parallel.-> B2 - B2 -.Parallel.-> B3 - end - - style STATIC fill:#d32f2f,color:#ffffff - style UNIFORM fill:#388e3c,color:#ffffff - style LOOPED fill:#1976d2,color:#ffffff - style BATCH fill:#f57c00,color:#ffffff -``` - -### Fusion Method Comparison - -```mermaid -graph TB - subgraph Overlap Area Fusion - A[Overlap Area] --> B{Choose Fusion Method} - - B -->|PYRAMID| C[Pyramid Weight] - B -->|FLAT| D[Average Weight] - B -->|COS| E[Cosine Weight] - - C --> F[Weight Distribution:
1.0→0.8→0.6→0.4→0.2→0.0] - D --> G[Weight Distribution:
0.5→0.5→0.5→0.5→0.5→0.5] - E --> H[Weight Distribution:
1.0→0.9→0.7→0.3→0.1→0.0] - - F --> I[Most Natural Transition] - G --> J[Simple and Direct] - H --> K[Smoothest Transition] - end - - style C fill:#388e3c,color:#ffffff - style D fill:#1976d2,color:#ffffff - style E fill:#f57c00,color:#ffffff -``` - -### Simple Understanding - -Like viewing a large painting through multiple small windows: -- Each window views a portion (window processing) -- Windows overlap to ensure coherence (overlap areas) -- Finally, all portions are stitched together into a complete image (result fusion) - -## Recommended Settings - -**Beginner Recommendation**: Keep default values (length: 16, overlap: 4) - -**For Higher Quality**: Increase overlap value to 6-8 - -**For Processing Very Long Content**: Increase window length to 32-64 - -## Advantages and Limitations - -**Advantages**: -- ✅ Saves memory usage -- ✅ Supports ultra-long sequence processing - -**Notes**: -- ⚠️ Processing time will be slightly longer -- ⚠️ Requires more system memory +| `model` | Processed model, can be directly connected to sampler for use | ## Typical Usage @@ -203,6 +92,4 @@ graph LR **Usage Steps**: 1. Load model 2. Connect to Context Windows Manual node -3. Connect to sampler to generate results - -With the `Context Windows (Manual)` node, you can easily process ultra-long sequences without worrying about memory limitations. \ No newline at end of file +3. Connect to sampler to generate results \ No newline at end of file diff --git a/built-in-nodes/WanContextWindowsManualNode.mdx b/built-in-nodes/WanContextWindowsManualNode.mdx index 4203d6fa..99694136 100644 --- a/built-in-nodes/WanContextWindowsManualNode.mdx +++ b/built-in-nodes/WanContextWindowsManualNode.mdx @@ -2,121 +2,97 @@ 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: "window-maximize" +icon: "circle" --- -The `WAN Context Windows (Manual)` node is a context window controller specifically designed for WAN (Wide Attention Network) models. It automatically converts user-friendly context parameters to the internal format required by WAN models, implementing efficient sliding window sampling that is particularly suitable for long sequence generation tasks. +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 WAN Context Window Processing Example (length=21, overlap=8) + title Context Window Processing Example (length=21, overlap=5) dateFormat X axisFormat %s section Original Sequence - Complete Content (length=100) : 0, 81 + Complete Content (length=81) : 0, 81 - section Window Division - Window 1 (0-20) : active, window1, 0, 21 - Window 2 (13-33) : active, window2, 13, 34 - Window 3 (26-46) : active, window3, 26, 47 - Window 4 (39-59) : active, window4, 39, 60 + 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, overlap1, 13, 21 - Overlap 2-3 : crit, overlap2, 26, 34 - Overlap 3-4 : crit, overlap3, 39, 47 + 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 Details - -| Parameter Name | Function | Detailed Description | -|---------------|----------|----------------------| -| `model` | WAN Model Input | WAN model object that requires context window processing | -| `context_length` | Window Length Control | Length of each context window. WAN models automatically adjust to multiples of 4. Larger values provide broader processing range but higher memory usage | -| `context_overlap` | Window Overlap Setting | Size of overlapping area between adjacent windows, ensuring content coherence between windows. More overlap provides smoother results but longer processing time | -| `context_schedule` | Scheduling Strategy Selection | Controls how windows move and arrange across the sequence, including static, uniform, looped, and batched modes | -| `context_stride` | Movement Step Size | Step size for window movement, only effective in UNIFORM scheduling mode, controls fine-grained window movement | -| `closed_loop` | Loop Mode Switch | Whether to connect the last window with the first to form a loop, only effective in LOOPED scheduling mode | -| `fuse_method` | Fusion Method | Algorithm for merging overlap areas, affects smoothness of window transitions and final results | - -### Context Scheduling Strategy Details - -| Scheduling Strategy | Working Method | Best Use Cases | -|--------------------|---------------|----------------| -| **STATIC_STANDARD** | Fixed window positions | Processing fixed region content, tasks requiring precise position control | -| **UNIFORM_STANDARD** | Windows move uniformly by set step size | Continuous processing of long sequences, such as long text or long video sequences | -| **UNIFORM_LOOPED** | Uniform movement with head-to-tail connection | Cyclic content processing, such as background music or repetitive pattern generation | -| **BATCHED** | Multiple windows processed in parallel batches | Efficient processing of large amounts of data, suitable for sufficient memory situations | - -### Fusion Method Details - -| Fusion Method | Weight Distribution | Effect Characteristics | -|--------------|--------------------|-----------------------| -| **PYRAMID** | Highest weight at center, decreasing toward edges | Most natural transition effect, recommended for most scenarios | -| **FLAT** | Equal weight distribution in overlap areas | Simple and direct fusion, suitable for uniform content | -| **COS** | Cosine curve-shaped weight distribution | Very smooth transition, suitable for content requiring gentle effects | +## 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 | WAN model object with applied context window processing | - -## Node Principle: Cinematic Shot Division Strategy +| `model` | MODEL | Processed WAN model, can be directly connected to sampler for use | -Imagine you need to shoot an ultra-long panoramic movie, but the camera's field of view is limited. The `WAN Context Windows (Manual)` is like a **professional shot division director**: - -### Workflow Diagram - -```mermaid -graph TD - A[WAN Model Input] --> B[Automatic Parameter Adjustment] - B --> C{Context Scheduling Strategy} - C -->|STATIC_STANDARD| D[Fixed Position Windows] - C -->|UNIFORM_STANDARD| E[Uniform Moving Windows] - C -->|UNIFORM_LOOPED| F[Loop Moving Windows] - C -->|BATCHED| G[Batch Parallel Windows] - - D --> H[Segmented Sampling] - E --> H - F --> H - G --> H - - H --> I[Window Fusion] - I --> J{Fusion Method} - J -->|PYRAMID| K[Pyramid Weight Fusion] - J -->|FLAT| L[Average Weight Fusion] - J -->|COS| M[Cosine Weight Fusion] - - K --> N[Complete Sequence Output] - L --> N - M --> N - - style A fill:#172DD7,color:#ffffff - style N fill:#F0FF41,color:#000000 - style B fill:#2E41E7,color:#ffffff -``` -### WAN Automatic Parameter Conversion +### WAN Parameter Automatic Adjustment ```mermaid graph LR - subgraph User Input - A1[context_length: 81] - A2[context_overlap: 30] + subgraph Your Input Values + A1[Window Size: 81] + A2[Overlap: 30] end - subgraph Automatic Conversion Formula - B1["((length-1) ÷ 4) + 1"] - B2["((overlap-1) ÷ 4) + 1"] - B3[dim = 2 fixed] + subgraph Automatic Adjustment + B1[Adjust to multiples of 4] + B2[Adjust to multiples of 4] + B3[Fixed at 2] end - subgraph WAN Internal Parameters - C1[Actual length: 21] - C2[Actual overlap: 8] + subgraph WAN Actual Usage + C1[Actual Size: 21] + C2[Actual Overlap: 8] C3[Dimension: 2] end @@ -131,38 +107,11 @@ graph LR style C3 fill:#F0FF41,color:#000000 ``` -### Simple Understanding - -The `WAN Context Windows (Manual)` is like using multiple small lenses to shoot a long movie: -- Each lens captures a small segment of content (window processing) -- Lenses overlap to ensure continuity (window overlap) -- Finally, all shots are intelligently stitched into a complete film (fusion output) - -## Recommended Configuration - -**Beginner Recommendation**: Keep default values (length: 81, overlap: 30) - -**For Higher Quality**: Increase overlap value to 40-50 - -**For Processing Ultra-Long Content**: Increase window length to 100-150 - -## Performance and Limitations - -### Advantages -- ✅ **Memory-Friendly**: Segmented processing avoids large memory requirements -- ✅ **WAN Optimized**: Specifically tuned for WAN models -- ✅ **Automatic Parameter Adjustment**: No need for manual calculation and conversion -- ✅ **Multiple Strategies**: Flexible scheduling and fusion options - -### Considerations -- ⚠️ Processing time will be slightly longer than standard methods -- ⚠️ Requires more memory to store window information - ## Typical Usage ```mermaid graph LR - A[WAN Model Loader] --> B[WAN Context Windows Manual] + A[Model Loader (WAN Model)] --> B[WAN Context Windows Manual] B --> C[KSampler] C --> D[Final Output] @@ -174,7 +123,5 @@ graph LR **Usage Steps**: 1. Load WAN model -2. Connect to WAN Context Windows Manual node -3. Connect to sampler to generate results - -With the `WAN Context Windows (Manual)` node, you can easily handle long sequence generation tasks without worrying about memory limitations. \ No newline at end of file +2. Connect to WAN Context Windows Manual node +3. Connect to sampler to generate results \ No newline at end of file diff --git a/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx b/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx index 5a6c3373..66c358bb 100644 --- a/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx +++ b/zh-CN/built-in-nodes/ContextWindowsManualNode.mdx @@ -2,10 +2,16 @@ title: "Context Windows (Manual) - ComfyUI 原生节点文档" description: "Context Windows (Manual) 节点提供手动上下文窗口控制,实现滑动窗口采样技术处理长序列生成任务,有效管理显存使用并提供多种调度策略。" sidebarTitle: "Context Windows (Manual)" -icon: "window-maximize" +icon: "circle" --- -`Context Windows (Manual)` 节点提供完全手动的上下文窗口控制功能。它将长序列分解为多个重叠的上下文窗口进行采样,而不是一次性处理整个序列,从而有效管理显存使用并实现高质量的长序列生成。 +`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"}}}%% @@ -34,158 +40,40 @@ gantt ## 输入参数 -| 参数名称 | 功能说明 | 详细解释 | +| 参数名称 | 功能说明 | 简单解释 | |---------|----------|----------| -| `model` | 模型输入 | 需要应用上下文窗口处理的基础模型对象 | -| `context_length` | 窗口长度控制 | 每个上下文窗口的长度,值越大处理范围越广但显存占用更高 | -| `context_overlap` | 窗口重叠设置 | 相邻窗口间的重叠区域大小,确保窗口间内容连贯性,重叠越多越平滑但处理时间更长 | -| `context_schedule` | 调度策略选择 | 控制窗口如何在序列上移动和排布,包括静态、均匀、循环、批处理四种模式 | -| `context_stride` | 移动步长 | 窗口每次移动的步长大小,仅在 UNIFORM 调度模式下生效,控制窗口移动的精细程度 | -| `closed_loop` | 循环模式开关 | 是否将最后一个窗口与第一个窗口连接形成循环,仅在 LOOPED 调度模式下生效 | -| `fuse_method` | 融合方法 | 决定重叠区域如何合并的算法,影响窗口间过渡的平滑程度和最终效果 | -| `dim` | 应用维度 | 指定在哪个数据维度上应用上下文窗口处理,通常为0(时间维度) | - -## 上下文调度策略 - -| 调度策略 | 工作方式 | 最佳使用场景 | -|---------|----------|-------------| -| **STATIC_STANDARD** | 窗口位置固定不动 | 处理固定区域内容,需要精确控制位置的任务 | -| **UNIFORM_STANDARD** | 窗口按设定步长均匀移动 | 长序列的连续处理,如长文本或长视频序列 | -| **UNIFORM_LOOPED** | 均匀移动并首尾相连 | 循环内容处理,如背景音乐、重复图案生成 | -| **BATCHED** | 多个窗口并行批处理 | 大量数据的高效处理,适合显存充足的情况 | - -## 融合方法 - -| 融合方法 | 权重分布方式 | 效果特点 | -|---------|-------------|----------| -| **PYRAMID** | 中心区域权重最高,向边缘递减 | 最自然的过渡效果,推荐大多数场景使用 | -| **FLAT** | 重叠区域平均分配权重 | 简单直接的融合,适合均匀内容 | -| **COS** | 余弦曲线形状的权重分布 | 非常平滑的过渡,适合需要柔和效果的内容 | +| `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` | 应用了上下文窗口处理的模型对象,可直接连接到采样器进行生成 | - -## 节点原理 - -`Context Windows (Manual)` 将长序列分解为多个重叠的窗口进行处理: - -### 工作流程图 - -```mermaid -graph TD - A[模型输入] --> B[参数配置] - B --> C{选择调度策略} - C -->|STATIC_STANDARD| D[静态窗口] - C -->|UNIFORM_STANDARD| E[均匀移动] - C -->|UNIFORM_LOOPED| F[循环移动] - C -->|BATCHED| G[批量处理] - - D --> H[窗口采样] - E --> H - F --> H - G --> H - - H --> I{融合策略} - I -->|PYRAMID| J[金字塔融合
中心权重高] - I -->|FLAT| K[平均融合
等权重分配] - I -->|COS| L[余弦融合
平滑过渡] - - J --> M[完整序列输出] - K --> M - L --> M - - style A fill:#1976d2,color:#ffffff - style M fill:#2e7d32,color:#ffffff - style B fill:#ef6c00,color:#ffffff - style H fill:#c2185b,color:#ffffff -``` - -### 调度策略对比 - -```mermaid -graph LR - subgraph STATIC["STATIC_STANDARD - 静态窗口"] - S1[窗口1: 位置固定] - S2[窗口2: 位置固定] - S3[窗口3: 位置固定] - S1 -.-> S2 - S2 -.-> S3 - end - - subgraph UNIFORM["UNIFORM_STANDARD - 均匀移动"] - U1[窗口1] --> U2[窗口2] --> U3[窗口3] --> U4[窗口4] - end - - subgraph LOOPED["UNIFORM_LOOPED - 循环移动"] - L1[窗口1] --> L2[窗口2] --> L3[窗口3] --> L1 - end - - subgraph BATCH["BATCHED - 批量处理"] - B1[窗口1] - B2[窗口2] - B3[窗口3] - B1 -.并行.-> B2 - B2 -.并行.-> B3 - end - - style STATIC fill:#d32f2f,color:#ffffff - style UNIFORM fill:#388e3c,color:#ffffff - style LOOPED fill:#1976d2,color:#ffffff - style BATCH fill:#f57c00,color:#ffffff -``` - -### 融合方法对比 - -```mermaid -graph TB - subgraph 重叠区域融合 - A[重叠区域] --> B{融合方法选择} - - B -->|PYRAMID| C[金字塔权重] - B -->|FLAT| D[平均权重] - B -->|COS| E[余弦权重] - - C --> F[权重分布:
1.0→0.8→0.6→0.4→0.2→0.0] - D --> G[权重分布:
0.5→0.5→0.5→0.5→0.5→0.5] - E --> H[权重分布:
1.0→0.9→0.7→0.3→0.1→0.0] - - F --> I[最自然过渡] - G --> J[简单直接] - H --> K[最平滑过渡] - end - - style C fill:#388e3c,color:#ffffff - style D fill:#1976d2,color:#ffffff - style E fill:#f57c00,color:#ffffff -``` - -### 简单理解 - -就像用多个小窗口看一幅大画: -- 每个窗口看一部分(窗口处理) -- 窗口之间有重叠确保连贯(重叠区域) -- 最后将所有部分拼接成完整的图像(结果融合) - -## 推荐设置 - -**新手推荐**:保持默认值即可(length: 16, overlap: 4) - -**需要更高质量**:增加重叠值到 6-8 - -**处理超长内容**:增加窗口长度到 32-64 - -## 优劣势 - -**优势**: -- ✅ 节约显存使用 -- ✅ 支持超长序列处理 - -**注意**: -- ⚠️ 处理时间会稍长 -- ⚠️ 需要更多系统内存 +| `model` | 处理好的模型,可以直接连接到采样器使用 | ## 典型用法 @@ -203,7 +91,5 @@ graph LR **使用步骤**: 1. 加载模型 -2. 连接到 Context Windows Manual 节点 -3. 连接到采样器生成结果 - -通过 `Context Windows (Manual)` 节点,您可以轻松处理超长序列,无需担心显存限制。 \ No newline at end of file +2. 连到 Context Windows Manual 节点 +3. 连到采样器生成结果 diff --git a/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx b/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx index 49f299d8..6b782e9e 100644 --- a/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx +++ b/zh-CN/built-in-nodes/WanContextWindowsManualNode.mdx @@ -2,122 +2,97 @@ title: "WAN Context Windows (Manual) - ComfyUI 原生节点文档" description: "WAN Context Windows (Manual) 节点专门为 WAN (Wide Attention Network) 模型优化的上下文窗口手动控制节点。它将普通的上下文参数自动转换为 WAN 兼容格式,实现滑动窗口采样以处理超长序列生成。" sidebarTitle: "WAN Context Windows (Manual)" -icon: "window-maximize" +icon: "circle" --- -`WAN Context Windows (Manual)` 节点是专门为 WAN (Wide Attention Network) 模型设计的上下文窗口控制器。它自动将用户友好的上下文参数转换为 WAN 模型所需的内部格式,实现高效的滑动窗口采样,特别适用于长序列生成任务。 +`WAN Context Windows (Manual)` 节点专门为 WAN 模型设计。它会自动调整参数,让 WAN 模型能更好地处理长内容。 +**作用方式:** +就像用多个分段的采样分别生成不同分段的视频,最后合成一个完整视频** +- 每个窗口看一部分(窗口处理) +- 窗口之间有重叠确保连贯(重叠区域) +- 最后将所有部分拼接成完整的图像(结果融合) ```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 WAN 上下文窗口处理示例 (length=21, overlap=8) + title 上下文窗口处理示例 (length=21, overlap=5) dateFormat X axisFormat %s section 原始序列 - 完整内容 (长度100) : 0, 81 + 完整内容 (长度81) : 0, 81 - section 窗口划分 - 窗口1 (0-20) : active, window1, 0, 21 - 窗口2 (13-33) : active, window2, 13, 34 - 窗口3 (26-46) : active, window3, 26, 47 - 窗口4 (39-59) : active, window4, 39, 60 + 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, overlap1, 13, 21 - 重叠2-3 : crit, overlap2, 26, 34 - 重叠3-4 : crit, overlap3, 39, 47 + 重叠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` | WAN 模型输入 | 需要应用上下文窗口处理的 WAN 模型对象 | -| `context_length` | 窗口长度控制 | 每个上下文窗口的长度,WAN 模型会自动按 4 的倍数调整。值越大处理范围越广但显存占用更高 | -| `context_overlap` | 窗口重叠设置 | 相邻窗口间的重叠区域大小,确保窗口间内容连贯性。重叠越多越平滑但处理时间更长 | -| `context_schedule` | 调度策略选择 | 控制窗口如何在序列上移动和排布,包括静态、均匀、循环、批处理四种模式 | -| `context_stride` | 移动步长 | 窗口每次移动的步长大小,仅在 UNIFORM 调度模式下生效,控制窗口移动的精细程度 | -| `closed_loop` | 循环模式开关 | 是否将最后一个窗口与第一个窗口连接形成循环,仅在 LOOPED 调度模式下生效 | -| `fuse_method` | 融合方法 | 决定重叠区域如何合并的算法,影响窗口间过渡的平滑程度和最终效果 | - -### 上下文调度策略详解 - -| 调度策略 | 工作方式 | 最佳使用场景 | -|---------|----------|-------------| -| **STATIC_STANDARD** | 窗口位置固定不动 | 处理固定区域内容,需要精确控制位置的任务 | -| **UNIFORM_STANDARD** | 窗口按设定步长均匀移动 | 长序列的连续处理,如长文本或长视频序列 | -| **UNIFORM_LOOPED** | 均匀移动并首尾相连 | 循环内容处理,如背景音乐、重复图案生成 | -| **BATCHED** | 多个窗口并行批处理 | 大量数据的高效处理,适合显存充足的情况 | - -### 融合方法详解 - -| 融合方法 | 权重分布方式 | 效果特点 | -|---------|-------------|----------| -| **PYRAMID** | 中心区域权重最高,向边缘递减 | 最自然的过渡效果,推荐大多数场景使用 | -| **FLAT** | 重叠区域平均分配权重 | 简单直接的融合,适合均匀内容 | -| **COS** | 余弦曲线形状的权重分布 | 非常平滑的过渡,适合需要柔和效果的内容 | +| `model` | WAN 模型输入 | 你要处理的 WAN 模型 | +| `context_length` | 窗口大小 | 每个小窗口的长度,WAN 会自动按 4 的倍数调整。越大处理范围越广但占用内存更多 | +| `context_overlap` | 重叠大小 | 窗口之间重叠的部分,重叠越多效果越平滑但处理越慢 | +| `context_schedule` | 处理方式 | 选择窗口如何移动,有四种模式可选 | +| `context_stride` | 移动步长 | 窗口每次移动多少,只在均匀模式下有用 | +| `closed_loop` | 循环模式 | 是否让最后一个窗口连回第一个,只在循环模式下有用 | +| `fuse_method` | 合并方法 | 选择重叠部分如何合并,影响最终效果 | +| `dim` | 处理维度 | 固定为 2,专门为 WAN 模型优化 | + +### 调度策略选择 + +| 调度策略 | 工作方式 | +|---------|----------| +| **STATIC_STANDARD** | 窗口位置固定 | +| **UNIFORM_STANDARD** | 窗口均匀移动 | +| **UNIFORM_LOOPED** | 窗口循环移动 | +| **BATCHED** | 多个窗口同时处理 | + +### 合并方法 + +| 合并方法 | 权重分布方式 | 特点 | +|---------|----------|----------| +| **PYRAMID** | 中间部分最重要,向两边递减 | 最自然的效果,推荐使用 | +| **RELATIVE** | 智能调整权重 | 根据位置自动调整,效果自然 | +| **FLAT** | 平均分配权重 | 简单直接,适合均匀内容 | +| **OVERLAP_LINEAR** | 线性渐变 | 过渡更平滑 | ## 输出结果 | 参数名称 | 数据类型 | 说明 | |---------|---------|------| -| `model` | MODEL | 应用了上下文窗口处理的 WAN 模型对象 | - -## 节点原理:电影制作的分镜头策略 - -想象你要拍摄一部超长的全景电影,但摄像机的视野有限。`WAN Context Windows (Manual)` 就像是**专业的分镜头导演**: +| `model` | MODEL | 处理好的 WAN 模型,可以直接连接到采样器使用 | -### 工作流程图 - -```mermaid -graph TD - A[WAN 模型输入] --> B[参数自动调整] - B --> C{上下文调度策略} - C -->|STATIC_STANDARD| D[固定位置窗口] - C -->|UNIFORM_STANDARD| E[均匀移动窗口] - C -->|UNIFORM_LOOPED| F[循环移动窗口] - C -->|BATCHED| G[批量并行窗口] - - D --> H[分段采样] - E --> H - F --> H - G --> H - - H --> I[窗口融合] - I --> J{融合方法} - J -->|PYRAMID| K[金字塔权重融合] - J -->|FLAT| L[平均权重融合] - J -->|COS| M[余弦权重融合] - - K --> N[输出完整序列] - L --> N - M --> N - - style A fill:#172DD7,color:#ffffff - style N fill:#F0FF41,color:#000000 - style B fill:#2E41E7,color:#ffffff -``` -### WAN 参数自动转换 +### WAN 参数自动调整 ```mermaid graph LR - subgraph 用户输入 - A1[context_length: 81] - A2[context_overlap: 30] + subgraph 你输入的值 + A1[窗口大小: 81] + A2[重叠: 30] end - subgraph 自动转换公式 - B1["((length-1) ÷ 4) + 1"] - B2["((overlap-1) ÷ 4) + 1"] - B3[dim = 2 固定] + subgraph 自动调整 + B1[按4的倍数调整] + B2[按4的倍数调整] + B3[固定为2] end - subgraph WAN内部参数 - C1[实际length: 21] - C2[实际overlap: 8] + subgraph WAN实际使用 + C1[实际大小: 21] + C2[实际重叠: 8] C3[维度: 2] end @@ -132,38 +107,11 @@ graph LR style C3 fill:#F0FF41,color:#000000 ``` -### 简单理解 - -`WAN Context Windows (Manual)` 就像用多个小镜头拍摄一部长电影: -- 每个镜头拍摄一小段内容(窗口处理) -- 镜头之间有重叠确保连贯性(窗口重叠) -- 最后将所有镜头智能拼接成完整影片(融合输出) - -## 推荐配置 - -**新手推荐**:保持默认值即可(length: 81, overlap: 30) - -**需要更高质量**:增加重叠值到 40-50 - -**处理超长内容**:增加窗口长度到 100-150 - -## 性能与限制 - -### 优势 -- ✅ **显存友好**:分段处理避免大显存需求 -- ✅ **WAN 优化**:专门为 WAN 模型调优 -- ✅ **参数自动调整**:无需手动计算转换 -- ✅ **多种策略**:灵活的调度和融合选项 - -### 注意事项 -- ⚠️ 处理时间会比普通方式稍长 -- ⚠️ 需要更多显存来存储窗口信息 - ## 典型用法 ```mermaid graph LR - A[WAN Model Loader] --> B[WAN Context Windows Manual] + A[Model Loader(WAN模型)] --> B[WAN Context Windows Manual] B --> C[KSampler] C --> D[最终输出] @@ -175,7 +123,5 @@ graph LR **使用步骤**: 1. 加载 WAN 模型 -2. 连接到 WAN Context Windows Manual 节点 -3. 连接到采样器生成结果 - -通过 `WAN Context Windows (Manual)` 节点,您可以轻松处理长序列生成任务,无需担心显存限制。 \ No newline at end of file +2. 连到 WAN Context Windows Manual 节点 +3. 连到采样器生成结果 \ No newline at end of file