-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwan_energon_datamodule.py
More file actions
49 lines (41 loc) · 1.87 KB
/
wan_energon_datamodule.py
File metadata and controls
49 lines (41 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=C0115,C0116,C0301
from dataclasses import dataclass
from megatron.bridge.data.utils import DatasetBuildContext
from torch import int_repr
from dfm.src.megatron.data.common.diffusion_energon_datamodule import DiffusionDataModule, DiffusionDataModuleConfig
from dfm.src.megatron.data.wan.wan_taskencoder import WanTaskEncoder
@dataclass(kw_only=True)
class WanDataModuleConfig(DiffusionDataModuleConfig):
path: str
seq_length: int
packing_buffer_size: int
micro_batch_size: int
global_batch_size: int
num_workers: int_repr
dataloader_type: str = "external"
def __post_init__(self):
self.dataset = DiffusionDataModule(
path=self.path,
seq_length=self.seq_length,
packing_buffer_size=self.packing_buffer_size,
task_encoder=WanTaskEncoder(seq_length=self.seq_length, packing_buffer_size=self.packing_buffer_size),
micro_batch_size=self.micro_batch_size,
global_batch_size=self.global_batch_size,
num_workers=self.num_workers,
)
self.sequence_length = self.dataset.seq_length
def build_datasets(self, context: DatasetBuildContext):
return self.dataset.train_dataloader(), self.dataset.train_dataloader(), self.dataset.train_dataloader()