Diff Coverage

Diff: origin/master...HEAD, staged and unstaged changes

Source File Diff Coverage (%) Missing Lines
hyper_parallel/components/checkpoint/hf_storage.py 100%  
hyper_parallel/components/checkpoint/load_groups.py 100%  
hyper_parallel/components/checkpoint/weight_conversion.py 100%  
hyper_parallel/core/distributed_checkpoint/standard_planner.py 100%  
hyper_parallel/data/dit/__init__.py 100%  
hyper_parallel/data/dit/wan_video.py 96.9% 174-175,180-181,224,238-240,276,314
hyper_parallel/trainer/__init__.py 100%  
hyper_parallel/trainer/dit_trainer.py 99.0% 199-200
hyper_parallel/data/dit/wan_video.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
        if scale_factor is not None:
            h_bar = math.floor(height / beta / scale_factor) * scale_factor
            w_bar = math.floor(width / beta / scale_factor) * scale_factor
        else:
            h_bar = math.floor(height / beta)
            w_bar = math.floor(width / beta)

    if video_min_pixels is not None and h_bar * w_bar < video_min_pixels:
        beta = math.sqrt(video_min_pixels / (height * width))
        if scale_factor is not None:
            h_bar = math.ceil(height * beta / scale_factor) * scale_factor
            w_bar = math.ceil(width * beta / scale_factor) * scale_factor
        else:
            h_bar = math.ceil(height * beta)
            w_bar = math.ceil(width * beta)
220
221
222
223
224
225
226
227
228
        decoder = VideoDecoder(video_input, device="cpu", num_ffmpeg_threads=0)
        metadata = decoder.metadata
        total_frames = int(metadata.num_frames or 0)
        if total_frames <= 0:
            raise ValueError("torchcodec did not report a positive frame count")
        video_fps = float(metadata.average_fps or kwargs.get("fps", 24.0))
        indices, pad_count = _calculate_frame_indices(
            total_frames=total_frames,
            video_fps=video_fps,
234
235
236
237
238
239
240
241
242
243
        )
        frame_count = len(indices) + pad_count
        resize_kwargs = _apply_dynamic_video_max_pixels(frame_count, kwargs)
        video = _smart_resize(_normalize_video_tensor(decoder.get_frames_at(indices).data), **resize_kwargs)
        if pad_count:
            video = torch.cat([video, video[-1:].expand(pad_count, -1, -1, -1)], dim=0)
        return video, video_fps
    except Exception as error:  # pylint: disable=broad-exception-caught
        logger.debug("torchcodec video decode failed: %s", error)
        return None
272
273
274
275
276
277
278
279
280
        if "frames" in video_input:
            frames = []
            for frame in video_input["frames"]:
                if isinstance(frame, (bytes, bytearray)):
                    frame = Image.open(io.BytesIO(frame)).convert("RGB")
                frames.append(frame)
            video = _pil_frames_to_tensor(frames)
            video_fps = float(video_input.get("video_fps", kwargs.get("fps", 24.0)))
            indices, pad_count = _calculate_frame_indices(
310
311
312
313
314
315
316
317
318

                source = requests.get(source, timeout=120).content
        decoded = _load_video_with_torchcodec(source, **kwargs)
        if decoded is not None:
            return decoded[0]
        decoded = _load_video_with_imageio(source)
        video, video_fps = decoded

    indices, pad_count = _calculate_frame_indices(
hyper_parallel/trainer/dit_trainer.py
195
196
197
198
199
200
201
202
203
204
        dataset_config = self.base.config.dataset
        if dataset_config is None:
            raise ValueError("dataset must define a build target")
        if dataset_config.data_transform is None:
            self.base.data_transform = None
            return
        self.base.data_transform = dataset_config.data_transform.build()

    def _build_collate_fn(self) -> None:
        """Build the collate function and derive the micro-batch count."""