# Veda-on-ComfyUI 官方 README 要点摘录（核实留档）

- 仓库: https://github.com/veda-sparse/Veda-on-ComfyUI
- 摘录时间: 2026-10-08 ｜ 来源: raw.githubusercontent.com/veda-sparse/Veda-on-ComfyUI/main/README.md
- 论文: arXiv 2605.30325 (ICML 2026) ｜ 项目页: https://veda-sparse.github.io/
- 打分器: https://huggingface.co/Veda-Sparse/Minimax-H3-T2VA-Veda-8NFE-600Step-Preview
- 训练代码: https://github.com/veda-sparse/Miowtion
- 中文说明: README.zh-CN.md

## 机制
"Veda is a learned sparse-attention method for video diffusion models. Attention dominates the cost of a
long clip, and a small distilled predictor can say in advance which tiles of the attention map carry the
result. Veda computes roughly the top 10% of them and skips the rest."
One node, MODEL in / MODEL out. 支持 ComfyUI 原生 MiniMax-H3 的 T2VA / FL2VA / R2VA。

## 亮点
- 2.9x end to end / 7.1x on attention alone vs ComfyUI 默认注意力（RTX 5070 实测）；增益随片段长度增长。
- "An attention override rather than a weight patch" → Turbo 与风格 LoRA、微调/量化 H3 checkpoint、
  首尾帧与参考条件、其他 block patch 都继续可用。
- 每个 kernel 用前在 GPU 自检；跑不了就回退模型自带注意力并在节点上说明，不产出坏画面。
- 稀疏 kernel 随节点提供；从 Comfy Registry 安装会带上 Triton（NVIDIA SM80+）或 MLX（Apple）。

## 安装
要求 ComfyUI >= 0.38.0。ComfyUI Manager 搜 "Veda"；或
    comfy node install veda-sparse-attention
或 clone 到 ComfyUI/custom_nodes/ 后重启。

## 用法
Workflow -> Browse Templates -> Veda-on-ComfyUI -> "Veda MiniMax H3 T2VA" / "Veda MiniMax H3 R2VA"。
把 【Veda Sparse Attention (MiniMax H3)】放在 MODEL 线上：模型与所有 LoRA loader 之后、guider/sampler 之前。
Ctrl+B 旁路即可用同 seed 渲染全注意力做对照。

### ⚠️ 共存规则（原文）
"Do not combine it with ComfyUI's own "Model Sparse Attention" node on H3: that one replaces the attention
blocks outright, so Veda would never be called. The node says so when it sees both."

"Other attention nodes can stay. Veda runs on top of "Patch Sage Attention KJ" (the calls it does not take
go to sage), and KJNodes' "MiniMax H3 Low VRAM Attention" keeps working. A node that swaps out the whole
H3 attention, such as "MiniMax H3 Mem Eff Sage Attention Patch", must come *before* Veda: Veda then runs
the sparse layers and leaves that node the full-attention ones, and says so on its node. Placed after Veda
it would hide every call from Veda; the node warns about that too."

## 打分器
节点自己不下载任何东西。打分器（275 MB）进入 models/veda，两种方式：
* 用模板：打开任一 Veda 模板，ComfyUI 在缺失模型对话框里给出打分器，一键下载。
* 手动：下载 minimax_h3_t2va_veda_8nfe_600step_preview_fp8.safetensors 放进 ComfyUI/models/veda/ 并重启。
该目录下任何 .safetensors 都会出现在 predictor 列表里（自己训练的也一样）。文件不在时节点会打印下载地址，不联网。

## 节点自述文本（示例）
    Veda done · Triton INT8 (SM120)
    Video: 1344x768 · 5.2 s
    Attention computed: 10.9% of full attention (89.1% skipped)
`Veda off` 开头给出未运行的原因；`nearest trained size: ...` 表示视频超出训练集。verbose 增加分阶段计时/调用数/predictor 细节。

## 参数（除 model/predictor 外都是 advanced，默认为训练值）
| 输入 | 默认 | 说明 |
|---|---|---|
| generated_sparsity | 90% | 生成视频注意力的稀疏度；90% 即每 query tile 跳过 90% 的 key tile（训练值）。填整数如 24 表示精确保留 24 个 128-token key tile。 |
| reference_sparsity | 90% | 参考（首尾帧/guide 帧/参考图与参考视频）同理；0% 给它们全注意力。 |
| full_attention_layers | 空 | 保留全注意力的 0 基 DiT block，如 0, 1, 47-49。 |
| full_attention_steps | 空 | 保留全注意力的 0 基采样步，如 0。 |
| verbose | off | 报告各阶段注意力耗时、调用次数、predictor 细节。 |

released predictor 训练于 1344x768 / 768x1344 / 768x768 / 1024x768，5 / 10 / 14 秒，配 8-step Turbo LoRA。
其他尺寸回退到最接近的 tile plan。**其他尺寸、其他步数、R2VA/FL2VA 参考都能用，但在训练数据之外，请与全注意力对比。**

## 性能（T2VA 1344x768 / 124 帧 5.2s / 8 步 Turbo LoRA / 90% 稀疏 / RTX 5070 12GB Win11）
| Attention | Per step | 8 steps | Attention per step |
|---|---|---|---|
| ComfyUI default | 40.7 s | 342 s | 31.1 s |
| ComfyUI --use-sage-attention | 24.8 s | 231 s | 15.2 s |
| Veda sparse INT8 | 14.0 s | 130 s | 4.41 s |

单层注意力 104k tokens / 90% 稀疏 = 528 ms（全注意力 11.8 s）。
"Veda's INT8 arithmetic is the same code ComfyUI runs behind --use-sage-attention, so the quality is what
that path gives, with sparsity on top."

## 硬件支持
| Hardware | Status |
|---|---|
| RTX 30 / A100 / RTX 40 / L40 (sm80-89) | code path ready, not yet verified on this hardware |
| H100 / H200 (sm90) | code path ready, not yet verified |
| B200 / B300 (sm100 / sm103) | code path ready, not yet verified |
| RTX 50, RTX PRO 6000 Blackwell (sm120) | **verified: RTX 5070, Windows 11** |
| DGX Spark / GB10 (sm121) | code path ready, not yet verified |
| Apple silicon (M series) | verified: M3 Pro, macOS 15 |

## 许可
Code: MIT。INT8 kernel 的算术源自 SageAttention v1 (BSD-3-Clause)。打分器继承 MiniMax H3 Community License。
