Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVD compile node #409

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions onediff_comfy_nodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ Omitting specific details here, the following workflow can be loaded and tested.

![](workflows/vae-graph-loader.png)


### SVD Acceleration

Similar to the usage of "Model Speedup" nodes, it's used to accelerate the Stable Video Diffusion (SVD) model, completing the acceleration of the text-to-video pipeline.

Compatible with "Model Graph Loader" node and "Model Graph Saver" node.

Omitting specific details here, the following workflow can be loaded and tested.

![](workflows/text-to-video-speedup.png)


### Image Distinction Scanner

The "Image Distinction Scanner" node is used to compare the differences between two images and visualize the resulting variances.
Expand Down
3 changes: 3 additions & 0 deletions onediff_comfy_nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
VaeSpeedup,
VaeGraphLoader,
VaeGraphSaver,
SVDSpeedup,
)
from ._compare_node import CompareModel, ShowImageDiff

Expand All @@ -20,6 +21,7 @@
"VaeSpeedup": VaeSpeedup,
"VaeGraphSaver": VaeGraphSaver,
"VaeGraphLoader": VaeGraphLoader,
"SVDSpeedup": SVDSpeedup,
}

NODE_DISPLAY_NAME_MAPPINGS = {
Expand All @@ -31,6 +33,7 @@
"VaeSpeedup": "VAE Speedup",
"VaeGraphLoader": "VAE Graph Loader",
"VaeGraphSaver": "VAE Graph Saver",
"SVDSpeedup": "SVD Speedup",
}

if _USE_UNET_INT8:
Expand Down
28 changes: 28 additions & 0 deletions onediff_comfy_nodes/_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"VaeSpeedup",
"VaeGraphLoader",
"VaeGraphSaver",
"SVDSpeedup",
]

if not args.dont_upcast_attention:
Expand Down Expand Up @@ -151,6 +152,33 @@ def save_graph(self, samples, model, filename_prefix):
return {}


class SVDSpeedup:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"model": ("MODEL",),
"static_mode": (["enable", "disable"],),
},
}

RETURN_TYPES = ("MODEL",)
FUNCTION = "speedup"
CATEGORY = "OneDiff"

def speedup(self, model, static_mode):
from onediff.infer_compiler import oneflow_compile

use_graph = static_mode == "enable"

new_model = copy.deepcopy(model)
new_model.model.diffusion_model = oneflow_compile(
new_model.model.diffusion_model, use_graph=use_graph
)

return (new_model,)


class VaeSpeedup:
@classmethod
def INPUT_TYPES(s):
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading