-
Notifications
You must be signed in to change notification settings - Fork 127
test_quantize_custom_model #756
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 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b97a31b
test_quantize_custom_model
ccssu b1834b7
refine
ccssu 95312a4
refine
ccssu 47bcf1b
Merge branch 'main' into add_test_quantize_custom_model
ccssu b9e8819
refine
ccssu 1bfd4b9
refine
ccssu b42b602
Optimize ComfyUI for Quantified Utilization
ccssu bca183c
add quantization/README.md
ccssu e8287ab
Update text_to_image_online_quant.py
ccssu b814daa
Merge branch 'main' into add_test_quantize_custom_model
ccssu e2d853e
refine
ccssu 6533c42
update
ccssu a5014cd
Merge branch 'main' into add_test_quantize_custom_model
ccssu a33c309
merge main
ccssu f347f5f
refine
ccssu b0db1bb
Delete redundant changes
ccssu 261383a
Merge branch 'main' into add_test_quantize_custom_model
ccssu c48b777
Update deep_cache_speedup.py
ccssu bd240dc
merge main
ccssu 67c5fb4
Update text_to_image_online_quant.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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from .deepcache_optimizer import DeepcacheOptimizerExecutor | ||
| from .quantization_optimizer import OnelineQuantizationOptimizerExecutor | ||
| from .optimizer_strategy import OptimizerStrategy |
40 changes: 40 additions & 0 deletions
40
onediff_comfy_nodes/modules/optimizer_strategy/deepcache_optimizer.py
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from dataclasses import dataclass | ||
| from functools import singledispatchmethod | ||
|
|
||
| from comfy.model_patcher import ModelPatcher | ||
|
|
||
| from ...utils.deep_cache_speedup import deep_cache_speedup | ||
| from .optimizer_strategy import OptimizerStrategy | ||
|
|
||
|
|
||
| @dataclass | ||
| class DeepcacheOptimizerExecutor(OptimizerStrategy): | ||
| cache_interval: int = 3 | ||
| cache_layer_id: int = 0 | ||
| cache_block_id: int = 1 | ||
| start_step: int = 0 | ||
| end_step: int = 1000 | ||
|
|
||
| @singledispatchmethod | ||
| def apply(self, model): | ||
| print( | ||
| "DeepcacheOptimizerExecutor.apply: not implemented for model type:", | ||
| type(model), | ||
| ) | ||
| return model | ||
|
|
||
| @apply.register(ModelPatcher) | ||
| def _(self, model): | ||
| return deep_cache_speedup( | ||
| model=model, | ||
| use_graph=True, | ||
| cache_interval=self.cache_interval, | ||
| cache_layer_id=self.cache_layer_id, | ||
| cache_block_id=self.cache_block_id, | ||
| start_step=self.start_step, | ||
| end_step=self.end_step, | ||
| use_oneflow_deepcache_speedup_modelpatcher=False, | ||
| )[0] | ||
|
|
||
|
|
||
|
|
13 changes: 13 additions & 0 deletions
13
onediff_comfy_nodes/modules/optimizer_strategy/optimizer_strategy.py
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from abc import ABC, abstractmethod | ||
|
|
||
| from comfy.model_patcher import ModelPatcher | ||
|
|
||
|
|
||
| class OptimizerStrategy(ABC): | ||
| """Interface for optimization strategies.""" | ||
|
|
||
| @abstractmethod | ||
| def apply(self, model: ModelPatcher): | ||
| """Apply the optimization strategy to the model.""" | ||
| pass | ||
|
|
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.