-
Notifications
You must be signed in to change notification settings - Fork 88
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
[WIP][tests] add precomputation tests #234
Open
sayakpaul
wants to merge
23
commits into
main
Choose a base branch
from
add-precompute-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
72d3000
add precomputation tests
sayakpaul d91476d
update
sayakpaul 9ba2aff
updates
sayakpaul 348fe81
changes
sayakpaul 3dda221
quality
sayakpaul 8841dbd
remove do_not_run_validation.
sayakpaul ee368a1
make get_memory_stat method leaner.
sayakpaul d63fbcf
reset memory utils.
sayakpaul 5529264
sync util.
sayakpaul fdab36b
Merge branch 'main' into add-precompute-tests
sayakpaul 1f61911
updates
sayakpaul 4422071
Merge branch 'main' into add-precompute-tests
sayakpaul c432f39
typo.
sayakpaul 3609fdf
resolve imports.
sayakpaul 8faac47
updates
sayakpaul 19356bb
update ltx
sayakpaul 5909c21
updates
sayakpaul 778d077
updates
sayakpaul 0f8b4bb
updates
sayakpaul 9595803
updates
sayakpaul 2c7f758
fixes
sayakpaul a91368d
Merge branch 'main' into add-precompute-tests
sayakpaul 846a0fb
Merge branch 'main' into add-precompute-tests
sayakpaul 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 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 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 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 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
Empty file.
Empty file.
This file contains 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,44 @@ | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
|
||
|
||
current_file = Path(__file__).resolve() | ||
root_dir = current_file.parents[3] | ||
sys.path.append(str(root_dir)) | ||
|
||
from finetrainers import Args # noqa | ||
from ..test_trainers_common import TrainerTestMixin, parse_resolution_bucket # noqa | ||
|
||
|
||
class CogVideoXTester(unittest.TestCase, TrainerTestMixin): | ||
MODEL_NAME = "cogvideox" | ||
EXPECTED_PRECOMPUTATION_LATENT_KEYS = {"latents"} | ||
EXPECTED_PRECOMPUTATION_CONDITION_KEYS = {"prompt_embeds"} | ||
|
||
def get_training_args(self): | ||
args = Args() | ||
args.model_name = self.MODEL_NAME | ||
args.training_type = "lora" | ||
args.pretrained_model_name_or_path = "finetrainers/dummy-cogvideox" | ||
args.data_root = "" # will be set from the tester method. | ||
args.video_resolution_buckets = [parse_resolution_bucket("9x16x16")] | ||
args.precompute_conditions = True | ||
args.validation_prompts = [] | ||
args.validation_heights = [] | ||
args.validation_widths = [] | ||
return args | ||
|
||
@property | ||
def latent_output_shape(self): | ||
return (8, 3, 2, 2) | ||
|
||
@property | ||
def condition_output_shape(self): | ||
return (226, 32) | ||
|
||
def populate_shapes(self): | ||
for k in self.EXPECTED_PRECOMPUTATION_LATENT_KEYS: | ||
self.EXPECTED_LATENT_SHAPES[k] = self.latent_output_shape | ||
for k in self.EXPECTED_PRECOMPUTATION_CONDITION_KEYS: | ||
self.EXPECTED_CONDITION_SHAPES[k] = self.condition_output_shape |
Empty file.
This file contains 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,51 @@ | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
|
||
|
||
current_file = Path(__file__).resolve() | ||
root_dir = current_file.parents[3] | ||
sys.path.append(str(root_dir)) | ||
|
||
from finetrainers import Args # noqa | ||
from ..test_trainers_common import TrainerTestMixin, parse_resolution_bucket # noqa | ||
|
||
|
||
class HunyuanVideoTester(unittest.TestCase, TrainerTestMixin): | ||
MODEL_NAME = "hunyuan_video" | ||
EXPECTED_PRECOMPUTATION_LATENT_KEYS = {"latents"} | ||
EXPECTED_PRECOMPUTATION_CONDITION_KEYS = { | ||
"guidance", | ||
"pooled_prompt_embeds", | ||
"prompt_attention_mask", | ||
"prompt_embeds", | ||
} | ||
|
||
def get_training_args(self): | ||
args = Args() | ||
args.model_name = self.MODEL_NAME | ||
args.training_type = "lora" | ||
args.pretrained_model_name_or_path = "finetrainers/dummy-hunyaunvideo" | ||
args.data_root = "" # will be set from the tester method. | ||
args.video_resolution_buckets = [parse_resolution_bucket("9x16x16")] | ||
args.precompute_conditions = True | ||
args.validation_prompts = [] | ||
args.validation_heights = [] | ||
args.validation_widths = [] | ||
return args | ||
|
||
@property | ||
def latent_output_shape(self): | ||
# only tensor object shapes | ||
return (8, 3, 2, 2) | ||
|
||
@property | ||
def condition_output_shape(self): | ||
# only tensor object shapes | ||
return (), (8,), (256,), (256, 16) | ||
|
||
def populate_shapes(self): | ||
for i, k in enumerate(sorted(self.EXPECTED_PRECOMPUTATION_LATENT_KEYS)): | ||
self.EXPECTED_LATENT_SHAPES[k] = self.latent_output_shape | ||
for i, k in enumerate(sorted(self.EXPECTED_PRECOMPUTATION_CONDITION_KEYS)): | ||
self.EXPECTED_CONDITION_SHAPES[k] = self.condition_output_shape[i] |
Empty file.
This file contains 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,50 @@ | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
|
||
|
||
current_file = Path(__file__).resolve() | ||
root_dir = current_file.parents[3] | ||
sys.path.append(str(root_dir)) | ||
|
||
from finetrainers import Args # noqa | ||
from ..test_trainers_common import TrainerTestMixin, parse_resolution_bucket # noqa | ||
|
||
|
||
class LTXVideoTester(unittest.TestCase, TrainerTestMixin): | ||
MODEL_NAME = "ltx_video" | ||
EXPECTED_PRECOMPUTATION_LATENT_KEYS = {"height", "latents", "latents_mean", "latents_std", "num_frames", "width"} | ||
EXPECTED_PRECOMPUTATION_CONDITION_KEYS = {"prompt_attention_mask", "prompt_embeds"} | ||
|
||
def get_training_args(self): | ||
args = Args() | ||
args.model_name = self.MODEL_NAME | ||
args.training_type = "lora" | ||
args.pretrained_model_name_or_path = "finetrainers/dummy-ltxvideo" | ||
args.data_root = "" # will be set from the tester method. | ||
args.video_resolution_buckets = [parse_resolution_bucket("9x16x16")] | ||
args.precompute_conditions = True | ||
args.validation_prompts = [] | ||
args.validation_heights = [] | ||
args.validation_widths = [] | ||
return args | ||
|
||
@property | ||
def latent_output_shape(self): | ||
# only tensor object shapes | ||
return (16, 3, 4, 4), (), () | ||
|
||
@property | ||
def condition_output_shape(self): | ||
# only tensor object shapes | ||
return (128,), (128, 32) | ||
|
||
def populate_shapes(self): | ||
i = 0 | ||
for k in sorted(self.EXPECTED_PRECOMPUTATION_LATENT_KEYS): | ||
if k in ["height", "num_frames", "width"]: | ||
continue | ||
self.EXPECTED_LATENT_SHAPES[k] = self.latent_output_shape[i] | ||
i += 1 | ||
for i, k in enumerate(sorted(self.EXPECTED_PRECOMPUTATION_CONDITION_KEYS)): | ||
self.EXPECTED_CONDITION_SHAPES[k] = self.condition_output_shape[i] |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not proud of the change but
T5Tokenizer
cannot be used on a dummy T5 tokenizer ckpt.