-
Notifications
You must be signed in to change notification settings - Fork 127
Dev refactor onediff comfy nodes #796
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e2aa54c
refactor_onediff_comfy_nodes
ccssu b6b81f9
add OneDiffOnlineQuantizationOptimizer
ccssu 389fdb8
Delete redundant code
ccssu 5c45d9f
add OnlineQuantization.md
ccssu 2596ef1
refine
ccssu 9655038
Merge branch 'main' into dev_refactor_onediff_comfy_nodes
ccssu e5a116f
controlnet Compatibility compilation options changed
ccssu b6552af
fix No newline at end of file warning
ccssu ba6cc46
fix No newline at end of file warning
ccssu fa3361b
fix set comfyui root
ccssu 89f4569
renamed Optimizer through Booster
ccssu 9cadca1
fix No module named onediff_quant in onediff_comfy_nodes/modules/onef…
ccssu a8a7c5b
Merge branch 'main' into dev_refactor_onediff_comfy_nodes
ccssu 89ba5cd
fix check in nodes_oneflow_booster.py
ccssu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,84 +1,30 @@ | ||
| """OneDiff ComfyUI Speedup Module""" | ||
| from ._config import _USE_UNET_INT8 | ||
| from ._nodes import ( | ||
| ModelSpeedup, | ||
| ModelGraphLoader, | ||
| ModelGraphSaver, | ||
| VaeSpeedup, | ||
| VaeGraphLoader, | ||
| VaeGraphSaver, | ||
| SVDSpeedup, | ||
| ModuleDeepCacheSpeedup, | ||
| OneDiffCheckpointLoaderSimple, | ||
| OneDiffControlNetLoader, | ||
| OneDiffDeepCacheCheckpointLoaderSimple, | ||
| BatchSizePatcher, | ||
| ) | ||
| from ._compare_node import CompareModel, ShowImageDiff | ||
|
|
||
| from ._config import * | ||
| from ._nodes import (ModelSpeedup, OneDiffApplyModelOptimizer, | ||
| OneDiffCheckpointLoaderSimple, OneDiffControlNetLoader, | ||
| VaeSpeedup) | ||
|
|
||
| NODE_CLASS_MAPPINGS = { | ||
| "ModelSpeedup": ModelSpeedup, | ||
| "CompareModel": CompareModel, | ||
| "ShowImageDiff": ShowImageDiff, | ||
| "ModelGraphLoader": ModelGraphLoader, | ||
| "ModelGraphSaver": ModelGraphSaver, | ||
| "VaeSpeedup": VaeSpeedup, | ||
| "VaeGraphSaver": VaeGraphSaver, | ||
| "VaeGraphLoader": VaeGraphLoader, | ||
| "SVDSpeedup": SVDSpeedup, | ||
| "ModuleDeepCacheSpeedup": ModuleDeepCacheSpeedup, | ||
| "OneDiffModelOptimizer": OneDiffApplyModelOptimizer, | ||
| "OneDiffCheckpointLoaderSimple": OneDiffCheckpointLoaderSimple, | ||
| "OneDiffControlNetLoader": OneDiffControlNetLoader, | ||
| "OneDiffDeepCacheCheckpointLoaderSimple": OneDiffDeepCacheCheckpointLoaderSimple, | ||
| "BatchSizePatcher": BatchSizePatcher, | ||
|
|
||
| } | ||
|
|
||
| NODE_DISPLAY_NAME_MAPPINGS = { | ||
| "ModelSpeedup": "Model Speedup", | ||
| "CompareModel": "Model Weight Comparator", | ||
| "ShowImageDiff": "Image Distinction Scanner", | ||
| "ModelGraphLoader": "Model Graph Loader", | ||
| "ModelGraphSaver": "Model Graph Saver", | ||
| "VaeSpeedup": "VAE Speedup", | ||
| "VaeGraphLoader": "VAE Graph Loader", | ||
| "VaeGraphSaver": "VAE Graph Saver", | ||
| "SVDSpeedup": "SVD Speedup", | ||
| "ModuleDeepCacheSpeedup": "Model DeepCache Speedup", | ||
| "OneDiffModelOptimizer": "Apply Model Optimizer - OneDff", | ||
| "OneDiffCheckpointLoaderSimple": "Load Checkpoint - OneDiff", | ||
| "OneDiffControlNetLoader": "Load ControlNet Model - OneDiff", | ||
| "OneDiffDeepCacheCheckpointLoaderSimple": "Load Checkpoint - OneDiff DeepCache", | ||
| "BatchSizePatcher": "Batch Size Patcher", | ||
| } | ||
|
|
||
| from .extras_nodes import (nodes_compare, nodes_oneflow_optimizer, | ||
| nodes_torch_compile_optimizer) | ||
|
|
||
| if _USE_UNET_INT8: | ||
| from ._nodes import UNETLoaderInt8, Quant8Model | ||
| from ._nodes import ( | ||
| QuantKSampler, | ||
| OneDiffQuantCheckpointLoaderSimple, | ||
| OneDiffQuantCheckpointLoaderSimpleAdvanced, | ||
| ImageOnlyOneDiffQuantCheckpointLoaderAdvanced, | ||
| ) | ||
|
|
||
| NODE_CLASS_MAPPINGS.update( | ||
| { | ||
| "UNETLoaderInt8": UNETLoaderInt8, | ||
| "Quant8Model": Quant8Model, | ||
| "OneDiffQuantCheckpointLoaderSimple": OneDiffQuantCheckpointLoaderSimple, | ||
| "OneDiffQuantCheckpointLoaderSimpleAdvanced": OneDiffQuantCheckpointLoaderSimpleAdvanced, | ||
| "ImageOnlyOneDiffQuantCheckpointLoaderAdvanced": ImageOnlyOneDiffQuantCheckpointLoaderAdvanced, | ||
| "QuantKSampler": QuantKSampler, | ||
| } | ||
| ) | ||
| extras = [nodes_compare, nodes_oneflow_optimizer, nodes_torch_compile_optimizer] | ||
| for node in extras: | ||
| NODE_CLASS_MAPPINGS.update(node.NODE_CLASS_MAPPINGS) | ||
| NODE_DISPLAY_NAME_MAPPINGS.update(node.NODE_DISPLAY_NAME_MAPPINGS) | ||
|
|
||
| NODE_DISPLAY_NAME_MAPPINGS.update( | ||
| { | ||
| "UNETLoaderInt8": "UNET Loader Int8", | ||
| "Quant8Model": "Model Quantization(int8)", | ||
| "OneDiffQuantCheckpointLoaderSimple": "Load Checkpoint - OneDiff Quant", | ||
| "OneDiffQuantCheckpointLoaderSimpleAdvanced": "Load Checkpoint - OneDiff Quant Advanced", | ||
| "ImageOnlyOneDiffQuantCheckpointLoaderAdvanced": "Load Checkpoint - OneDiff Quant Advanced (img2vid)", | ||
| "QuantKSampler": "Quant K Sampler", | ||
| } | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,5 @@ | ||
| """Config file for comfyui-speedup, which will automatically""" | ||
| import os | ||
| import sys | ||
| from pathlib import Path | ||
| import folder_paths | ||
|
|
||
| ONEDIFF_QUANTIZED_OPTIMIZED_MODELS = "onediff_quant" | ||
| _USE_UNET_INT8 = True | ||
| COMFYUI_ROOT = Path(os.path.abspath(__file__)).parents[2] | ||
| COMFYUI_SPEEDUP_ROOT = Path(os.path.abspath(__file__)).parents[0] | ||
| INFER_COMPILER_REGISTRY = Path(COMFYUI_SPEEDUP_ROOT) / "infer_compiler_registry" | ||
| os.environ["COMFYUI_ROOT"] = str(COMFYUI_ROOT) | ||
| custom_nodes_path = os.path.join(COMFYUI_ROOT, "custom_nodes") | ||
| sys.path.insert(0, str(COMFYUI_ROOT)) | ||
| sys.path.insert(0, str(COMFYUI_SPEEDUP_ROOT)) | ||
| sys.path.insert(0, str(INFER_COMPILER_REGISTRY)) | ||
| if custom_nodes_path not in sys.path: | ||
| sys.path.append(custom_nodes_path) | ||
|
|
||
| import register_comfy # load plugins | ||
|
|
||
| from onediff.infer_compiler.utils import is_community_version | ||
|
|
||
| if is_community_version(): | ||
| _USE_UNET_INT8 = False | ||
|
|
||
| if _USE_UNET_INT8: | ||
| import register_onediff_quant # load plugins | ||
| from folder_paths import (folder_names_and_paths, models_dir, | ||
| supported_pt_extensions) | ||
|
|
||
| unet_int8_model_dir = Path(models_dir) / "unet_int8" | ||
| unet_int8_model_dir.mkdir(parents=True, exist_ok=True) | ||
| folder_names_and_paths["unet_int8"] = ( | ||
| [str(unet_int8_model_dir)], | ||
| supported_pt_extensions, | ||
| ) | ||
|
|
||
| opt_models_dir = Path(models_dir) / ONEDIFF_QUANTIZED_OPTIMIZED_MODELS | ||
| opt_models_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| folder_names_and_paths[ONEDIFF_QUANTIZED_OPTIMIZED_MODELS] = ( | ||
| [str(opt_models_dir)], | ||
| supported_pt_extensions, | ||
| ) | ||
| # https://github.com/comfyanonymous/ComfyUI/blob/master/folder_paths.py#L9 | ||
| os.environ["COMFYUI_ROOT"] = folder_paths.base_path |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.