ComfyUI > Nodes > ComfyUI-HunyuanVideoWrapper > HunyuanVideo BlockSwap

ComfyUI Node: HunyuanVideo BlockSwap

Class Name

HyVideoBlockSwap

Category
HunyuanVideoWrapper
Author
kijai (Account age: 2506days)
Extension
ComfyUI-HunyuanVideoWrapper
Latest Updated
2025-05-12
Github Stars
2.4K

How to Install ComfyUI-HunyuanVideoWrapper

Install this extension via the ComfyUI Manager by searching for ComfyUI-HunyuanVideoWrapper
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-HunyuanVideoWrapper in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

HunyuanVideo BlockSwap Description

Optimizes memory usage by swapping computational blocks between GPU and CPU for efficient video processing.

HunyuanVideo BlockSwap:

The HyVideoBlockSwap node is designed to optimize memory usage during video processing by strategically swapping computational blocks between the GPU and CPU. This node is particularly beneficial for managing VRAM (Video Random Access Memory) consumption, which is crucial when working with high-resolution video data or when the available GPU memory is limited. By offloading certain blocks to the CPU, the node helps in balancing the load and ensuring smoother processing without overwhelming the GPU. This approach is especially useful in scenarios where multiple video processing tasks are running concurrently, as it allows for more efficient resource allocation and can prevent potential bottlenecks caused by memory constraints.

HunyuanVideo BlockSwap Input Parameters:

double_blocks_to_swap

This parameter specifies the number of double blocks to be swapped from the GPU to the CPU. Double blocks typically involve more complex operations and thus consume more memory. By default, this value is set to 20, with a minimum of 0 and a maximum of 20. Adjusting this parameter allows you to control how many of these resource-intensive blocks are offloaded, which can significantly impact the node's performance and memory usage.

single_blocks_to_swap

This parameter determines the number of single blocks to be swapped. Single blocks are generally less memory-intensive compared to double blocks. The default value is 0, with a range from 0 to 40. Increasing this value can help further reduce VRAM usage by offloading less critical operations to the CPU, thus freeing up GPU resources for more demanding tasks.

offload_txt_in

A boolean parameter that, when set to true, offloads the text input layer to the CPU. This can be useful if the text processing component of your video workflow is consuming a significant amount of GPU memory. The default setting is false, meaning the text input layer remains on the GPU unless specified otherwise.

offload_img_in

Similar to offload_txt_in, this boolean parameter controls whether the image input layer is offloaded to the CPU. Offloading the image input layer can be beneficial in scenarios where image processing is a major component of the workflow and is consuming substantial GPU resources. By default, this parameter is set to false.

HunyuanVideo BlockSwap Output Parameters:

block_swap_args

The output parameter block_swap_args provides a dictionary containing the arguments used for block swapping. This includes the number of double and single blocks swapped, as well as the offloading status of the text and image input layers. This output is crucial for understanding the current configuration of the node and can be used for debugging or further optimization of the video processing pipeline.

HunyuanVideo BlockSwap Usage Tips:

  • To optimize performance, start by adjusting the double_blocks_to_swap parameter, as double blocks typically consume more resources. Gradually increase the number of blocks swapped until you achieve a balance between performance and memory usage.
  • Use the offload_txt_in and offload_img_in parameters to offload less critical components of your workflow to the CPU, freeing up GPU resources for more demanding tasks.
  • Monitor the VRAM usage while adjusting these parameters to ensure that the GPU is not being overburdened, which can lead to performance degradation.

HunyuanVideo BlockSwap Common Errors and Solutions:

"CUDA out of memory"

  • Explanation: This error occurs when the GPU runs out of available memory to process the video data.
  • Solution: Increase the number of blocks swapped to the CPU by adjusting the double_blocks_to_swap and single_blocks_to_swap parameters. Additionally, consider enabling offload_txt_in and offload_img_in to further reduce GPU memory usage.

"Block index out of range"

  • Explanation: This error may occur if the number of blocks specified for swapping exceeds the available blocks in the model.
  • Solution: Ensure that the values for double_blocks_to_swap and single_blocks_to_swap do not exceed the total number of double and single blocks in your model. Adjust these parameters accordingly.

HunyuanVideo BlockSwap Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-HunyuanVideoWrapper
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.