Skip to content

Commit 61d14a7

Browse files
sayakpaula-r-r-o-w
andauthored
[WIP][tests] add precomputation tests (#234)
* add precomputation tests * update * updates * changes * quality * remove do_not_run_validation. * make get_memory_stat method leaner. * reset memory utils. * sync util. * updates * typo. Co-authored-by: a-r-r-o-w <[email protected]> * resolve imports. * updates * update ltx * updates * updates * updates * updates * fixes * fixes --------- Co-authored-by: a-r-r-o-w <[email protected]>
1 parent 4bb10c6 commit 61d14a7

23 files changed

+407
-45
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
check_dirs := finetrainers tests examples
44

55
quality:
6-
ruff check $(check_dirs)
7-
ruff format --check $(check_dirs)
6+
ruff check $(check_dirs) --exclude examples/_legacy
7+
ruff format --check $(check_dirs) --exclude examples/_legacy
88

99
style:
10-
ruff check $(check_dirs) --fix
11-
ruff format $(check_dirs)
10+
ruff check $(check_dirs) --fix --exclude examples/_legacy
11+
ruff format $(check_dirs) --exclude examples/_legacy

examples/_legacy/cogvideox/cogvideox_image_to_video_sft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from diffusers.models.autoencoders.vae import DiagonalGaussianDistribution
4545
from diffusers.optimization import get_scheduler
4646
from diffusers.training_utils import cast_training_params
47-
from diffusers.utils import convert_unet_state_dict_to_peft, export_to_video, load_image
47+
from diffusers.utils import export_to_video, load_image
4848
from diffusers.utils.hub_utils import load_or_create_model_card, populate_model_card
4949
from huggingface_hub import create_repo, upload_folder
5050
from torch.utils.data import DataLoader

examples/_legacy/cogvideox/cogvideox_text_to_video_lora.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
print_memory,
6363
reset_memory,
6464
unwrap_model,
65-
) # isort:skip
65+
)
6666

6767

6868
logger = get_logger(__name__)

examples/_legacy/cogvideox/cogvideox_text_to_video_sft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
print_memory,
6262
reset_memory,
6363
unwrap_model,
64-
) # isort:skip
64+
)
6565

6666

6767
logger = get_logger(__name__)

examples/_legacy/cogvideox/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,4 @@ def __iter__(self):
425425
random.shuffle(bucket)
426426
yield bucket
427427
del self.buckets[fhw]
428-
self.buckets[fhw] = []
428+
self.buckets[fhw] = []

examples/_legacy/mochi-1/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Default values taken from
2+
Default values taken from
33
https://github.com/genmoai/mochi/blob/aba74c1b5e0755b1fa3343d9e4bd22e89de77ab1/demos/fine_tuner/configs/lora.yaml
44
when applicable.
55
"""

examples/_legacy/mochi-1/dataset_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __getitem__(self, idx):
3737
def process_videos(directory):
3838
dir_path = Path(directory)
3939
mp4_files = [str(f) for f in dir_path.glob("**/*.mp4") if not f.name.endswith(".recon.mp4")]
40-
assert mp4_files, f"No mp4 files found"
40+
assert mp4_files, "No mp4 files found"
4141

4242
dataset = LatentEmbedDataset(mp4_files)
4343
dataloader = DataLoader(dataset, batch_size=4, shuffle=True)

examples/_legacy/mochi-1/embed.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
https://github.com/genmoai/mochi/blob/main/demos/fine_tuner/embed_captions.py
55
"""
66

7+
from pathlib import Path
8+
79
import click
810
import torch
911
import torchvision
10-
from pathlib import Path
1112
from diffusers import AutoencoderKLMochi, MochiPipeline
12-
from transformers import T5EncoderModel, T5Tokenizer
1313
from tqdm.auto import tqdm
14+
from transformers import T5EncoderModel, T5Tokenizer
1415

1516

1617
def encode_videos(model: torch.nn.Module, vid_path: Path, shape: str):

examples/_legacy/mochi-1/text_to_video_lora.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
# limitations under the License.
1515

1616
import gc
17-
import random
18-
from glob import glob
1917
import math
2018
import os
21-
import torch.nn.functional as F
22-
import numpy as np
19+
import random
20+
from glob import glob
2321
from pathlib import Path
24-
from typing import Any, Dict, Tuple, List
22+
from typing import Any, Dict, List, Tuple
2523

24+
import numpy as np
2625
import torch
26+
import torch.nn.functional as F
2727
import wandb
2828
from diffusers import FlowMatchEulerDiscreteScheduler, MochiPipeline, MochiTransformer3DModel
2929
from diffusers.models.autoencoders.vae import DiagonalGaussianDistribution
@@ -37,9 +37,10 @@
3737

3838

3939
from args import get_args # isort:skip
40+
4041
from dataset_simple import LatentEmbedDataset
4142

42-
import sys
43+
4344
from utils import print_memory, reset_memory # isort:skip
4445

4546

@@ -100,7 +101,7 @@ def save_model_card(
100101
```py
101102
from diffusers import MochiPipeline
102103
from diffusers.utils import export_to_video
103-
import torch
104+
import torch
104105
105106
pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview")
106107
pipe.load_lora_weights("CHANGE_ME")
@@ -315,7 +316,7 @@ def main(args):
315316
optimizer = torch.optim.AdamW(transformer_lora_parameters, lr=args.learning_rate, weight_decay=args.weight_decay)
316317

317318
# Dataset and DataLoader
318-
train_vids = list(sorted(glob(f"{args.data_root}/*.mp4")))
319+
train_vids = sorted(glob(f"{args.data_root}/*.mp4"))
319320
train_vids = [v for v in train_vids if not v.endswith(".recon.mp4")]
320321
print(f"Found {len(train_vids)} training videos in {args.data_root}")
321322
assert len(train_vids) > 0, f"No training data found in {args.data_root}"

examples/_legacy/mochi-1/trim_and_crop_videos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
https://github.com/genmoai/mochi/blob/main/demos/fine_tuner/trim_and_crop_videos.py
44
"""
55

6-
from pathlib import Path
76
import shutil
7+
from pathlib import Path
88

99
import click
1010
from moviepy.editor import VideoFileClip

0 commit comments

Comments
 (0)