repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/scripts/diffusion/inference.py | scripts/diffusion/inference.py | import os
import time
import warnings
from pprint import pformat
warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=UserWarning)
import torch
import torch.distributed as dist
from colossalai.utils import set_seed
from tqdm import tqdm
from opensora.acceleration.paral... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/gradio/app.py | gradio/app.py | #!/usr/bin/env python
"""
This script runs a Gradio App for the Open-Sora model.
Usage:
python demo.py <config-path>
"""
import argparse
import datetime
import importlib
import os
import subprocess
import sys
from tempfile import NamedTemporaryFile
import spaces
import torch
import gradio as gr
MODEL_TYPES = [... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/vae/train/video_dc_ae_disc.py | configs/vae/train/video_dc_ae_disc.py | _base_ = ["video_dc_ae.py"]
discriminator = dict(
type="N_Layer_discriminator_3D",
from_pretrained=None,
input_nc=3,
n_layers=5,
conv_cls="conv3d"
)
disc_lr_scheduler = dict(warmup_steps=0)
gen_loss_config = dict(
gen_start=0,
disc_weight=0.05,
)
disc_loss_config = dict(
disc_start=0,... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/vae/train/video_dc_ae.py | configs/vae/train/video_dc_ae.py | # ============
# model config
# ============
model = dict(
type="dc_ae",
model_name="dc-ae-f32t4c128",
from_scratch=True,
from_pretrained=None,
)
# ============
# data config
# ============
dataset = dict(
type="video_text",
transform_name="resize_crop",
data_path="datasets/pexels_45k_nec... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/vae/inference/hunyuanvideo_vae.py | configs/vae/inference/hunyuanvideo_vae.py | dtype = "bf16"
batch_size = 1
seed = 42
save_dir = "samples/hunyuanvideo_vae"
plugin = "zero2"
dataset = dict(
type="video_text",
transform_name="resize_crop",
fps_max=16,
data_path="datasets/pexels_45k_necessary.csv",
)
bucket_config = {
"512px_ar1:1": {97: (1.0, 1)},
}
num_workers = 24
num_bucke... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/vae/inference/video_dc_ae.py | configs/vae/inference/video_dc_ae.py | dtype = "bf16"
batch_size = 1
seed = 42
dataset = dict(
type="video_text",
transform_name="resize_crop",
fps_max=16,
data_path="datasets/pexels_45k_necessary.csv",
)
bucket_config = {
"512px_ar1:1": {96: (1.0, 1)},
}
model = dict(
type="dc_ae",
model_name="dc-ae-f32t4c128",
from_pretra... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/image.py | configs/diffusion/train/image.py | # Dataset settings
dataset = dict(
type="video_text",
transform_name="resize_crop",
fps_max=24, # the desired fps for training
vmaf=True, # load vmaf scores into text
)
grad_ckpt_settings = (8, 100) # set the grad checkpoint settings
bucket_config = {
"256px": {1: (1.0, 50)},
"768px": {1: (0... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/high_compression.py | configs/diffusion/train/high_compression.py | _base_ = ["image.py"]
bucket_config = {
"_delete_": True,
"768px": {
1: (1.0, 20),
16: (1.0, 8),
20: (1.0, 8),
24: (1.0, 8),
28: (1.0, 8),
32: (1.0, 8),
36: (1.0, 4),
40: (1.0, 4),
44: (1.0, 4),
48: (1.0, 4),
52: (1.0, 4),
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/stage2_i2v.py | configs/diffusion/train/stage2_i2v.py | _base_ = ["stage2.py"]
# Define model components
model = dict(cond_embed=True)
grad_ckpt_buffer_size = 25 * 1024**3
condition_config = dict(
t2v=1,
i2v_head=5,
i2v_loop=1,
i2v_tail=1,
)
is_causal_vae = True
bucket_config = {
"_delete_": True,
"256px": {
1: (1.0, 195),
5: (1.0,... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/stage2.py | configs/diffusion/train/stage2.py | _base_ = ["image.py"]
# new config
grad_ckpt_settings = (100, 100)
plugin = "hybrid"
plugin_config = dict(
tp_size=1,
pp_size=1,
sp_size=4,
sequence_parallelism_mode="ring_attn",
enable_sequence_parallelism=True,
static_graph=True,
zero_stage=2,
)
bucket_config = {
"_delete_": True,
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/stage1.py | configs/diffusion/train/stage1.py | _base_ = ["image.py"]
dataset = dict(memory_efficient=False)
# new config
grad_ckpt_settings = (8, 100)
bucket_config = {
"_delete_": True,
"256px": {
1: (1.0, 45),
5: (1.0, 12),
9: (1.0, 12),
13: (1.0, 12),
17: (1.0, 12),
21: (1.0, 12),
25: (1.0, 12),
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/demo.py | configs/diffusion/train/demo.py | _base_ = ["stage1.py"]
bucket_config = {
"_delete_": True,
"256px": {
1: (1.0, 1),
33: (1.0, 1),
97: (1.0, 1),
129: (1.0, 1),
},
}
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/train/stage1_i2v.py | configs/diffusion/train/stage1_i2v.py | _base_ = ["stage1.py"]
# Define model components
model = dict(cond_embed=True)
condition_config = dict(
t2v=1,
i2v_head=5, # train i2v (image as first frame) with weight 5
i2v_loop=1, # train image connection with weight 1
i2v_tail=1, # train i2v (image as last frame) with weight 1
)
lr = 1e-5
opt... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/high_compression.py | configs/diffusion/inference/high_compression.py | _base_ = ["t2i2v_768px.py"]
# no need for parallelism
plugin = None
plugin_config = None
plugin_ae = None
plugin_config_ae = None
# model settings
patch_size = 1
model = dict(
from_pretrained="./ckpts/Open_Sora_v2_Video_DC_AE.safetensors",
in_channels=128,
cond_embed=True,
patch_size=1,
)
# AE settin... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/t2i2v_768px.py | configs/diffusion/inference/t2i2v_768px.py | _base_ = [ # inherit grammer from mmengine
"768px.py",
"plugins/t2i2v.py",
]
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/768px.py | configs/diffusion/inference/768px.py | _base_ = [ # inherit grammer from mmengine
"256px.py",
"plugins/sp.py", # use sequence parallel
]
sampling_option = dict(
resolution="768px",
)
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/256px_tp.py | configs/diffusion/inference/256px_tp.py | _base_ = [ # inherit grammer from mmengine
"256px.py",
"plugins/tp.py", # use tensor parallel
]
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/256px.py | configs/diffusion/inference/256px.py | save_dir = "samples" # save directory
seed = 42 # random seed (except seed for z)
batch_size = 1
dtype = "bf16"
cond_type = "t2v"
# conditional inference options:
# t2v: text-to-video
# i2v_head: image-to-video (head)
# i2v_tail: image-to-video (tail)
# i2v_loop: connect images
# v2v_head_half: video extension with ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/t2i2v_256px.py | configs/diffusion/inference/t2i2v_256px.py | _base_ = [ # inherit grammer from mmengine
"256px.py",
"plugins/t2i2v.py",
]
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/plugins/sp.py | configs/diffusion/inference/plugins/sp.py | plugin = "hybrid"
plugin_config = dict(
tp_size=1,
pp_size=1,
sp_size=8,
sequence_parallelism_mode="ring_attn",
enable_sequence_parallelism=True,
static_graph=True,
zero_stage=2,
overlap_allgather=False,
)
plugin_ae = "hybrid"
plugin_config_ae = dict(
tp_size=8,
pp_size=1,
s... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/plugins/t2i2v.py | configs/diffusion/inference/plugins/t2i2v.py | use_t2i2v = True
# flux configurations
img_flux = dict(
type="flux",
from_pretrained="./ckpts/flux1-dev.safetensors",
guidance_embed=True,
# model architecture
in_channels=64,
vec_in_dim=768,
context_in_dim=4096,
hidden_size=3072,
mlp_ratio=4.0,
num_heads=24,
depth=19,
d... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/configs/diffusion/inference/plugins/tp.py | configs/diffusion/inference/plugins/tp.py | plugin = "hybrid"
plugin_config = dict(
tp_size=8,
pp_size=1,
sp_size=1,
zero_stage=2,
overlap_allgather=False,
)
plugin_ae = "hybrid"
plugin_config_ae = dict(
tp_size=8,
pp_size=1,
sp_size=1,
zero_stage=2,
overlap_allgather=False,
)
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/registry.py | opensora/registry.py | from copy import deepcopy
import torch.nn as nn
from mmengine.registry import Registry
def build_module(module: dict | nn.Module, builder: Registry, **kwargs) -> nn.Module | None:
"""Build module from config or return the module itself.
Args:
module (dict | nn.Module): The module to build.
b... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/__init__.py | opensora/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/communications.py | opensora/acceleration/communications.py | import torch
import torch.distributed as dist
# ====================
# All-To-All
# ====================
def _all_to_all(
input_: torch.Tensor,
world_size: int,
group: dist.ProcessGroup,
scatter_dim: int,
gather_dim: int,
):
input_list = [t.contiguous() for t in torch.tensor_split(input_, worl... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/parallel_states.py | opensora/acceleration/parallel_states.py | import torch.distributed as dist
_GLOBAL_PARALLEL_GROUPS = dict()
def set_data_parallel_group(group: dist.ProcessGroup):
_GLOBAL_PARALLEL_GROUPS["data"] = group
def get_data_parallel_group(get_mixed_dp_pg : bool = False):
if get_mixed_dp_pg and "mixed_dp_group" in _GLOBAL_PARALLEL_GROUPS:
return _G... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/checkpoint.py | opensora/acceleration/checkpoint.py | import warnings
from collections.abc import Iterable
from typing import Callable, ContextManager, Optional, Tuple
import torch
import torch.nn as nn
from colossalai.utils import get_current_device
from torch.utils.checkpoint import (
_DEFAULT_DETERMINISM_MODE,
CheckpointFunction,
_checkpoint_without_reentr... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/__init__.py | opensora/acceleration/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/shardformer/__init__.py | opensora/acceleration/shardformer/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/shardformer/modeling/t5.py | opensora/acceleration/shardformer/modeling/t5.py | import torch
import torch.nn as nn
class T5LayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
Construct a layernorm module in the T5 style. No bias and no subtraction of mean.
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/shardformer/modeling/__init__.py | opensora/acceleration/shardformer/modeling/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/shardformer/policy/t5_encoder.py | opensora/acceleration/shardformer/policy/t5_encoder.py | from colossalai.shardformer.modeling.jit import get_jit_fused_dropout_add_func
from colossalai.shardformer.modeling.t5 import get_jit_fused_T5_layer_ff_forward, get_T5_layer_self_attention_forward
from colossalai.shardformer.policies.base_policy import Policy, SubModuleReplacementDescription
class T5EncoderPolicy(Pol... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/acceleration/shardformer/policy/__init__.py | opensora/acceleration/shardformer/policy/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/datasets.py | opensora/datasets/datasets.py | import os
import random
import numpy as np
import pandas as pd
import torch
from PIL import ImageFile
from torchvision.datasets.folder import pil_loader
from opensora.registry import DATASETS
from .read_video import read_video
from .utils import get_transforms_image, get_transforms_video, is_img, map_target_fps, rea... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/read_video.py | opensora/datasets/read_video.py | import gc
import math
import os
import re
import warnings
from fractions import Fraction
import av
import cv2
import numpy as np
import torch
from torchvision import get_video_backend
from torchvision.io.video import _check_av_available
MAX_NUM_FRAMES = 2500
def read_video_av(
filename: str,
start_pts: floa... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/sampler.py | opensora/datasets/sampler.py | from collections import OrderedDict, defaultdict
from typing import Iterator
import numpy as np
import torch
import torch.distributed as dist
from torch.utils.data import Dataset, DistributedSampler
from opensora.utils.logger import log_message
from opensora.utils.misc import format_numel_str
from .aspect import get... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/bucket.py | opensora/datasets/bucket.py | from collections import OrderedDict
import numpy as np
from opensora.utils.logger import log_message
from .aspect import get_closest_ratio, get_resolution_with_aspect_ratio
from .utils import map_target_fps
class Bucket:
def __init__(self, bucket_config: dict[str, dict[int, tuple[float, int] | tuple[tuple[floa... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/utils.py | opensora/datasets/utils.py | import math
import os
import random
import re
from typing import Any
import numpy as np
import pandas as pd
import requests
import torch
import torch.distributed as dist
import torchvision
import torchvision.transforms as transforms
from PIL import Image
from torchvision.datasets.folder import IMG_EXTENSIONS, pil_load... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/video_transforms.py | opensora/datasets/video_transforms.py | # Copyright 2024 Vchitect/Latte
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/__init__.py | opensora/datasets/__init__.py | from .datasets import TextDataset, VideoTextDataset
from .utils import get_transforms_image, get_transforms_video, is_img, is_vid, save_sample
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/dataloader.py | opensora/datasets/dataloader.py | import collections
import functools
import os
import queue
import random
import threading
import numpy as np
import torch
import torch.multiprocessing as multiprocessing
from torch._utils import ExceptionWrapper
from torch.distributed import ProcessGroup
from torch.utils.data import DataLoader, _utils
from torch.utils... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/aspect.py | opensora/datasets/aspect.py | import math
import os
ASPECT_RATIO_LD_LIST = [ # width:height
"2.39:1", # cinemascope, 2.39
"2:1", # rare, 2
"16:9", # rare, 1.89
"1.85:1", # american widescreen, 1.85
"9:16", # popular, 1.78
"5:8", # rare, 1.6
"3:2", # rare, 1.5
"4:3", # classic, 1.33
"1:1", # square
]
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/pin_memory_cache.py | opensora/datasets/pin_memory_cache.py | import threading
from typing import Dict, List, Optional
import torch
class PinMemoryCache:
force_dtype: Optional[torch.dtype] = None
min_cache_numel: int = 0
pre_alloc_numels: List[int] = []
def __init__(self):
self.cache: Dict[int, torch.Tensor] = {}
self.output_to_cache: Dict[int,... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/datasets/parallel.py | opensora/datasets/parallel.py | import multiprocessing
from itertools import count
from multiprocessing.managers import SyncManager
from typing import Any, Callable, Dict, Tuple, Type, cast
import dill
import pandarallel
import pandas as pd
from pandarallel.data_types import DataType
from pandarallel.progress_bars import ProgressBarsType, get_progre... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/__init__.py | opensora/models/__init__.py | from .dc_ae import *
from .hunyuan_vae import *
from .mmdit import *
from .text import *
from .vae import *
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/vae.py | opensora/models/hunyuan_vae/vae.py | # Modified from HunyuanVideo
#
# Copyright 2024 HunyuanVideo
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional, Tuple
import numpy as np
import torch
import torch.nn as nn
from diffus... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/policy.py | opensora/models/hunyuan_vae/policy.py | from functools import partial
from typing import Dict, Union
import torch.nn as nn
from colossalai.shardformer.policies.base_policy import ModulePolicyDescription, Policy, SubModuleReplacementDescription
from opensora.models.vae.tensor_parallel import Conv3dTPCol, Conv3dTPRow, GroupNormTP
from .distributed import Co... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/distributed.py | opensora/models/hunyuan_vae/distributed.py | from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
from colossalai.shardformer.layer._operation import gather_forward_split_backward, split_forward_gather_backward
from colossalai.shardformer.layer.attn import RingComm, _rescale_out_lse
from colossalai.shardformer.layer.utils import... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/unet_causal_3d_blocks.py | opensora/models/hunyuan_vae/unet_causal_3d_blocks.py | # Modified from diffusers==0.29.2 and HunyuanVideo
#
# Copyright 2024 The HuggingFace Team. 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... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/__init__.py | opensora/models/hunyuan_vae/__init__.py | from pathlib import Path
import torch
from .autoencoder_kl_causal_3d import CausalVAE3D_HUNYUAN
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/hunyuan_vae/autoencoder_kl_causal_3d.py | opensora/models/hunyuan_vae/autoencoder_kl_causal_3d.py | # Modified from diffusers==0.29.2 and HunyuanVideo
#
# Copyright 2024 The HuggingFace Team. 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/... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/discriminator.py | opensora/models/vae/discriminator.py | import os
import torch.nn as nn
from opensora.registry import MODELS
from opensora.utils.ckpt import load_checkpoint
def weights_init(m):
classname = m.__class__.__name__
if classname.find("Conv") != -1:
nn.init.normal_(m.weight.data, 0.0, 0.02)
elif classname.find("BatchNorm") != -1:
nn... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/lpips.py | opensora/models/vae/lpips.py | import hashlib
import os
from collections import namedtuple
import requests
import torch
import torch.nn as nn
from torchvision import models
from tqdm import tqdm
from opensora.acceleration.checkpoint import checkpoint
URL_MAP = {"vgg_lpips": "https://heibox.uni-heidelberg.de/f/607503859c864bc1b30b/?dl=1"}
CKPT_MA... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/utils.py | opensora/models/vae/utils.py | import math
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor, nn
NUMEL_LIMIT = 2**30
def ceil_to_divisible(n: int, dividend: int) -> int:
return math.ceil(dividend / (dividend // n))
def chunked_avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, cou... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/losses.py | opensora/models/vae/losses.py | import torch
import torch.nn.functional as F
from einops import rearrange
from torch import Tensor, nn
from opensora.models.vae.lpips import LPIPS
def hinge_d_loss(logits_real, logits_fake):
loss_real = torch.mean(F.relu(1.0 - logits_real))
loss_fake = torch.mean(F.relu(1.0 + logits_fake))
d_loss = 0.5 *... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/__init__.py | opensora/models/vae/__init__.py | from .autoencoder_2d import AutoEncoderFlux
from .discriminator import N_LAYER_DISCRIMINATOR_3D
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/autoencoder_2d.py | opensora/models/vae/autoencoder_2d.py | # Modified from Flux
#
# Copyright 2024 Black Forest Labs
# 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... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/vae/tensor_parallel.py | opensora/models/vae/tensor_parallel.py | from typing import List, Optional, Union
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from colossalai.device.device_mesh import DeviceMesh
from colossalai.shardformer.layer._operation import (
gather_forward_split_backward,
reduce_forward,
split_forwar... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/ae_model_zoo.py | opensora/models/dc_ae/ae_model_zoo.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/__init__.py | opensora/models/dc_ae/__init__.py | from .ae_model_zoo import DC_AE
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/dc_ae.py | opensora/models/dc_ae/models/dc_ae.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/__init__.py | opensora/models/dc_ae/models/__init__.py | from .dc_ae import *
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/nn/vo_ops.py | opensora/models/dc_ae/models/nn/vo_ops.py | import math
from inspect import signature
from typing import Any, Callable, Optional, Union
import torch
import torch.nn.functional as F
VERBOSE = False
def pixel_shuffle_3d(x, upscale_factor):
"""
3D pixelshuffle 操作。
"""
B, C, T, H, W = x.shape
r = upscale_factor
assert C % (r * r * r) == 0... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/nn/ops.py | opensora/models/dc_ae/models/nn/ops.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/nn/act.py | opensora/models/dc_ae/models/nn/act.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/nn/norm.py | opensora/models/dc_ae/models/nn/norm.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/models/nn/__init__.py | opensora/models/dc_ae/models/nn/__init__.py | from .act import *
from .norm import *
from .ops import *
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/utils/list.py | opensora/models/dc_ae/utils/list.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/utils/__init__.py | opensora/models/dc_ae/utils/__init__.py | from .init import *
from .list import *
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/dc_ae/utils/init.py | opensora/models/dc_ae/utils/init.py | # Copyright 2024 MIT Han Lab
#
# 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, ... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/model.py | opensora/models/mmdit/model.py | # Modified from Flux
#
# Copyright 2024 Black Forest Labs
# 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... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/policy.py | opensora/models/mmdit/policy.py | from functools import partial
from typing import Dict, Union
import torch.nn as nn
from colossalai.shardformer.policies.base_policy import ModulePolicyDescription, Policy, SubModuleReplacementDescription
from opensora.models.vae.tensor_parallel import Conv3dTPCol, Conv3dTPRow, GroupNormTP
from .distributed import Co... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/distributed.py | opensora/models/mmdit/distributed.py | from functools import partial
from typing import Dict, List, Optional, Tuple, Union
import torch
import torch.distributed as dist
import torch.nn as nn
from colossalai.shardformer.layer import (FusedLinear1D_Col, FusedLinear1D_Row,
Linear1D_Col, Linear1D_Row)
from colossalai.s... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | true |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/__init__.py | opensora/models/mmdit/__init__.py | from .model import Flux
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/math.py | opensora/models/mmdit/math.py | import torch
from einops import rearrange
from flash_attn import flash_attn_func as flash_attn_func_v2
from liger_kernel.ops.rope import LigerRopeFunction
from torch import Tensor
from typing import Tuple
try:
from flash_attn_interface import flash_attn_func as flash_attn_func_v3
SUPPORT_FA3 = True
except:
... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/mmdit/layers.py | opensora/models/mmdit/layers.py | # Modified from Flux
#
# Copyright 2024 Black Forest Labs
# 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... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/text/conditioner.py | opensora/models/text/conditioner.py | from colossalai.shardformer import ShardConfig, ShardFormer
from torch import Tensor, nn
from transformers import CLIPTextModel, CLIPTokenizer, T5EncoderModel, T5Tokenizer
from opensora.acceleration.shardformer.policy.t5_encoder import T5EncoderPolicy
from opensora.registry import MODELS
@MODELS.register_module("tex... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/models/text/__init__.py | opensora/models/text/__init__.py | from .conditioner import HFEmbedder
| python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/train.py | opensora/utils/train.py | import random
import warnings
from collections import OrderedDict
from datetime import timedelta
import torch
import torch.distributed as dist
import torch.nn.functional as F
from colossalai.booster.plugin import HybridParallelPlugin, LowLevelZeroPlugin
from colossalai.cluster import DistCoordinator
from colossalai.ut... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/prompt_refine.py | opensora/utils/prompt_refine.py | import base64
import os
from mimetypes import guess_type
from openai import OpenAI
sys_prompt_t2v = """You are part of a team of bots that creates videos. The workflow is that you first create a caption of the video, and then the assistant bot will generate the video based on the caption. You work with an assistant b... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/ckpt.py | opensora/utils/ckpt.py | import functools
import json
import operator
import os
import re
import shutil
from glob import glob
from typing import Dict, Optional
import torch
import torch.distributed as dist
import torch.nn as nn
from colossalai.booster import Booster
from colossalai.checkpoint_io import GeneralCheckpointIO
from colossalai.util... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/cai.py | opensora/utils/cai.py | import colossalai
import torch
import torch.distributed as dist
from colossalai.booster import Booster
from colossalai.cluster import DistCoordinator
from opensora.acceleration.parallel_states import (
get_sequence_parallel_group,
get_tensor_parallel_group,
set_sequence_parallel_group,
)
from opensora.mode... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/inference.py | opensora/utils/inference.py | import copy
import os
import re
from enum import Enum
import torch
from torch import nn
from opensora.datasets import save_sample
from opensora.datasets.aspect import get_image_size
from opensora.datasets.utils import read_from_path, rescale_image_by_path
from opensora.utils.logger import log_message
from opensora.ut... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/sampling.py | opensora/utils/sampling.py | import math
import os
import random
from abc import ABC, abstractmethod
from dataclasses import dataclass, replace
import torch
from einops import rearrange, repeat
from mmengine.config import Config
from peft import PeftModel
from torch import Tensor, nn
from opensora.datasets.aspect import get_image_size
from opens... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/optimizer.py | opensora/utils/optimizer.py | import torch
from colossalai.nn.lr_scheduler import CosineAnnealingWarmupLR
from colossalai.nn.optimizer import HybridAdam
from torch.optim.lr_scheduler import _LRScheduler
def create_optimizer(
model: torch.nn.Module,
optimizer_config: dict,
) -> torch.optim.Optimizer:
"""
Create an optimizer.
A... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/logger.py | opensora/utils/logger.py | import logging
import os
import torch.distributed as dist
def is_distributed() -> bool:
"""
Check if the code is running in a distributed setting.
Returns:
bool: True if running in a distributed setting, False otherwise
"""
return os.environ.get("WORLD_SIZE", None) is not None
def is_m... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/misc.py | opensora/utils/misc.py | import os
import time
from collections import OrderedDict
from collections.abc import Sequence
from contextlib import nullcontext
import numpy as np
import psutil
import torch
import torch.distributed as dist
import torch.nn as nn
from colossalai.cluster.dist_coordinator import DistCoordinator
from torch.utils.tensorb... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/config.py | opensora/utils/config.py | import argparse
import ast
import json
import os
from datetime import datetime
import torch
from mmengine.config import Config
from .logger import is_distributed, is_main_process
def parse_args() -> tuple[str, argparse.Namespace]:
"""
This function parses the command line arguments.
Returns:
tu... | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false |
hpcaitech/Open-Sora | https://github.com/hpcaitech/Open-Sora/blob/d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc/opensora/utils/__init__.py | opensora/utils/__init__.py | python | Apache-2.0 | d0cd5ac50da79e9a9d2285a952d4dcd806e6c8fc | 2026-01-04T14:43:51.030080Z | false | |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/setup.py | setup.py | #!/usr/bin/env python
from setuptools import Extension, setup, find_packages
import sys
import numpy
from setuptools.command.build_ext import build_ext
from sysconfig import get_path
from pathlib import Path
import shutil
from Cython.Build import cythonize
from Cython.Compiler import Options
import os
import subprocess... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/.github/validate_universe_json.py | .github/validate_universe_json.py | import json
import re
import sys
from pathlib import Path
def validate_json(document):
universe_file = Path(document)
with universe_file.open() as f:
universe_data = json.load(f)
for entry in universe_data["resources"]:
if "github" in entry:
assert not re.match(
... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/.github/spacy_universe_alert.py | .github/spacy_universe_alert.py | import os
import sys
import json
from datetime import datetime
from slack_sdk.web.client import WebClient
CHANNEL = "#alerts-universe"
SLACK_TOKEN = os.environ.get("SLACK_BOT_TOKEN", "ENV VAR not available!")
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
client = WebClient(SLACK_TOKEN)
github_context = json.loads(sys.argv[... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/extra/example_data/textcat_example_data/textcatjsonl_to_trainjson.py | extra/example_data/textcat_example_data/textcatjsonl_to_trainjson.py | from pathlib import Path
import plac
import spacy
from spacy.training import docs_to_json
import srsly
import sys
@plac.annotations(
model=("Model name. Defaults to 'en'.", "option", "m", str),
input_file=("Input file (jsonl)", "positional", None, Path),
output_dir=("Output directory", "positional", None,... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/schemas.py | spacy/schemas.py | import inspect
import re
from collections import defaultdict
from enum import Enum
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
try:
from pydantic.v1 import (
BaseModel,
ConstrainedStr,
... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/glossary.py | spacy/glossary.py | import warnings
from .errors import Warnings
def explain(term):
"""Get a description for a given POS tag, dependency label or entity type.
term (str): The term to explain.
RETURNS (str): The explanation, or `None` if not found in the glossary.
EXAMPLE:
>>> spacy.explain(u'NORP')
>>>... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/lookups.py | spacy/lookups.py | from collections import OrderedDict
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
import srsly
from preshed.bloom import BloomFilter
from .errors import Errors
from .strings import get_string_id
from .util import SimpleFrozenDict, ensure_path, load_language_data, registry
UNSET = objec... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/util.py | spacy/util.py | import functools
import importlib
import importlib.util
import inspect
import itertools
import logging
import os
import re
import shlex
import shutil
import socket
import stat
import subprocess
import sys
import tempfile
import warnings
from collections import defaultdict
from contextlib import contextmanager
from path... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | true |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/registrations.py | spacy/registrations.py | """Centralized registry population for spaCy config
This module centralizes registry decorations to prevent circular import issues
with Cython annotation changes from __future__ import annotations. Functions
remain in their original locations, but decoration is moved here.
Component definitions and registrations are ... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/language.py | spacy/language.py | import functools
import inspect
import itertools
import multiprocessing as mp
import random
import traceback
import warnings
from contextlib import ExitStack, contextmanager
from copy import deepcopy
from dataclasses import dataclass
from itertools import chain, cycle
from pathlib import Path
from timeit import default... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | true |
explosion/spaCy | https://github.com/explosion/spaCy/blob/c1e7cb2ebf387a833d56e3b0bee23788d54b1448/spacy/compat.py | spacy/compat.py | """Helpers for Python and platform compatibility."""
import sys
from thinc.util import copy_array
try:
import cPickle as pickle
except ImportError:
import pickle # type: ignore[no-redef]
try:
import copy_reg
except ImportError:
import copyreg as copy_reg # type: ignore[no-redef]
try:
from cup... | python | MIT | c1e7cb2ebf387a833d56e3b0bee23788d54b1448 | 2026-01-04T14:42:48.113774Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.