# kablex/comfyui-ref2va-vsa architecture

> Architecture diagram of the GitHub repository kablex/comfyui-ref2va-vsa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kablex/comfyui-ref2va-vsa
- Repository: https://github.com/kablex/comfyui-ref2va-vsa

## Overview

ComfyUI-Ref2VA-VSA is a ComfyUI custom node that accelerates MiniMax H3 reference-to-video generation with sparse visual attention. The user loads the example workflow, supplies a reference character and prompt, and queues generation. The workflow applies a four-step Turbo LoRA and the Ref2VA gate-transplant node; that node installs the VSA patch, which keeps reference, text, and audio tokens dense while sparsifying generated-video attention. The README documents an optional gate-extraction utility. Internal call details beyond the sampled excerpts are not inferred.

Main entry points: [`nodes.py`](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py) (VSA model patch), [`workflows/ref2va_vsa_4step_rtx4090.json`](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/workflows/ref2va_vsa_4step_rtx4090.json) (RTX 4090 workflow), [`tools/extract_vsa_gate.py`](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/tools/extract_vsa_gate.py) (Gate extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Generation workflow"]
  node_workflow_file["RTX 4090 workflow"]
  node_comfyui["ComfyUI runtime"]
  node_reference["Character reference"]
  node_minimax["MiniMax H3 model"]
  node_turbo["Turbo LoRA"]
  node_video_result["Generated video"]
end

subgraph group_patch["VSA patching"]
  node_ref2va_patch["Ref2VA gate transplant<br/>[nodes.py]"]
  node_vsa_patch["VSA model patch<br/>[nodes.py]"]
end

subgraph group_attention["Sparse attention"]
  node_layout["Packed token geometry<br/>[nodes.py]"]
  node_sparse_attention["Sparse attention<br/>[nodes.py]"]
  node_cuda_backend["Sol-Attn CUDA"]
end

subgraph group_gate["Gate preparation"]
  node_gate_file["VSA gate weights"]
  node_source_checkpoint["FastH3 checkpoint"]
  node_gate_extractor["Gate extractor"]
end

node_user(("ComfyUI user"))

node_user -->|"loads"| node_workflow_file
node_workflow_file -->|"queues in"| node_comfyui
node_comfyui -.->|"conditions on"| node_reference
node_comfyui -.->|"runs model"| node_minimax
node_comfyui -->|"loads LoRA"| node_turbo
node_comfyui -->|"invokes node"| node_ref2va_patch
node_gate_file -->|"loads weights"| node_ref2va_patch
node_ref2va_patch -->|"delegates patch"| node_vsa_patch
node_vsa_patch -->|"builds geometry"| node_layout
node_vsa_patch -->|"installs attention"| node_sparse_attention
node_sparse_attention -->|"dispatches to"| node_cuda_backend
node_comfyui -.->|"generates"| node_video_result
node_source_checkpoint -->|"provides tensors"| node_gate_extractor
node_gate_extractor -->|"saves weights"| node_gate_file

click node_workflow_file "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/workflows/ref2va_vsa_4step_rtx4090.json"
click node_ref2va_patch "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py"
click node_vsa_patch "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py"
click node_layout "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py"
click node_sparse_attention "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py"
click node_gate_extractor "https://github.com/kablex/comfyui-ref2va-vsa/blob/main/tools/extract_vsa_gate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workflow_file,node_comfyui,node_reference,node_minimax,node_turbo,node_video_result,node_user toneBlue
class node_ref2va_patch,node_vsa_patch toneAmber
class node_layout,node_sparse_attention,node_cuda_backend toneMint
class node_gate_file,node_source_checkpoint,node_gate_extractor toneRose
```

## Components

### Generation workflow

- [RTX 4090 workflow](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/workflows/ref2va_vsa_4step_rtx4090.json): `workflows/ref2va_vsa_4step_rtx4090.json`
- **ComfyUI runtime**
- **Character reference**
- **MiniMax H3 model**
- **Turbo LoRA**
- **Generated video**

### VSA patching

- [Ref2VA gate transplant](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py): `nodes.py`
- [VSA model patch](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py): `nodes.py`

### Sparse attention

- [Packed token geometry](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py): `nodes.py`
- [Sparse attention](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/nodes.py): `nodes.py`
- **Sol-Attn CUDA**

### Gate preparation

- **VSA gate weights**
- **FastH3 checkpoint**
- [Gate extractor](https://github.com/kablex/comfyui-ref2va-vsa/blob/main/tools/extract_vsa_gate.py): `tools/extract_vsa_gate.py`

### Other components

- **ComfyUI user**

## Connections

- ComfyUI user → RTX 4090 workflow: loads (evidence: `README.md`)
- RTX 4090 workflow → ComfyUI runtime: queues in (evidence: `README.md`)
- ComfyUI runtime → Character reference: conditions on
- ComfyUI runtime → MiniMax H3 model: runs model
- ComfyUI runtime → Turbo LoRA: loads LoRA (evidence: `README.md`)
- ComfyUI runtime → Ref2VA gate transplant: invokes node (evidence: `README.md`)
- VSA gate weights → Ref2VA gate transplant: loads weights (evidence: `nodes.py`)
- Ref2VA gate transplant → VSA model patch: delegates patch (evidence: `nodes.py`)
- VSA model patch → Packed token geometry: builds geometry (evidence: `nodes.py`)
- VSA model patch → Sparse attention: installs attention (evidence: `nodes.py`)
- Sparse attention → Sol-Attn CUDA: dispatches to (evidence: `nodes.py`)
- ComfyUI runtime → Generated video: generates
- FastH3 checkpoint → Gate extractor: provides tensors (evidence: `tools/extract_vsa_gate.py`)
- Gate extractor → VSA gate weights: saves weights (evidence: `tools/extract_vsa_gate.py`)
