Run ComfyUI Easily with InstaSD

Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:

  • One-click deployment
  • Any model, any node
  • Powerful GPUs for rapid iteration
Get Started

Available Nodes

PatchModelPatcherOrder

Documentation for ComfyUI Node: PatchModelPatcherOrder

Overview

The PatchModelPatcherOrder node is an experimental feature within the ComfyUI-KJNodes repository. Its purpose is to alter the order in which model patching is applied within ComfyUI. This can be particularly beneficial when using advanced techniques such as torch.compile, where specific patching orders can optimize the utilization of resources like LoRAs (Low-Rank Adaptations) in conjunction with compiled models.

Functionality

This node is used to modify the order of operations during the model patching process, specifically focusing on when weight patches (like LoRAs) are applied in relation to the compilation of the model. This adjustment can be crucial for workflows that involve model compilation to ensure that all necessary patches are applied efficiently and correctly.

Inputs

The PatchModelPatcherOrder node accepts the following inputs:

  • Model: The target model that you wish to modify the patching order for.
  • Patch Order: This is a dropdown selection that determines the sequence of patch applications. The options are:
    • object_patch_first: Object patches (compilations) are applied before weight patches.
    • weight_patch_first: Weight patches (LoRAs) are applied before compiling the model.
  • Full Load: An option to control the memory management during patch application. The possible settings are:
    • enabled: Force a full load.
    • disabled: Prevent full loading, which might help in managing memory for large models.
    • auto: Automatically decide based on current conditions, potentially balancing performance and memory use.

Outputs

The node outputs the patched model. The alterations made by this node prepare the model to use patching more effectively, especially in environments where model performance and resource management are critical concerns.

Use Cases in ComfyUI Workflows

In ComfyUI workflows, this node is particularly useful for users intending to:

  • Optimize Model Performance: By adjusting the patching order, users can ensure that their model operates optimally, especially when deploying computationally efficient patches or adaptations like LoRAs alongside model compilation mechanisms.
  • Manage Resource Consumption: Offers the flexibility to adjust full load settings to manage system memory better, a significant advantage when working with large or complex models.
  • Experiment with Advanced Features: This node supports experimental use cases, encouraging users to explore newer optimization techniques like torch.compile in a more controlled environment.

Special Features and Considerations

  • Experimental Feature: The node is categorized as experimental and may not be suitable for all production environments. Users are encouraged to test its behavior in their specific use cases extensively.
  • Model Specific Adjustments: Users should note the type and structure of the model they are working with to ensure the patching order aligns with the desired performance outcomes.
  • Integration with Compilation Tools: Particularly useful in scenarios where model compilation is employed. The correct patch order can significantly affect how well the model integrates with the compilation process and the efficiency gains realized through such integrations.