Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xuwx1
LightX2V
Commits
f6d4fc85
Commit
f6d4fc85
authored
Aug 05, 2025
by
PengGao
Committed by
GitHub
Aug 05, 2025
Browse files
style: add ruff isort (#183)
parent
878f5a48
Changes
133
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
73 additions
and
49 deletions
+73
-49
lightx2v/common/ops/attn/sage_attn.py
lightx2v/common/ops/attn/sage_attn.py
+4
-2
lightx2v/common/ops/attn/sparge_attn.py
lightx2v/common/ops/attn/sparge_attn.py
+5
-3
lightx2v/common/ops/attn/torch_sdpa.py
lightx2v/common/ops/attn/torch_sdpa.py
+3
-1
lightx2v/common/ops/attn/ulysses_attn.py
lightx2v/common/ops/attn/ulysses_attn.py
+5
-3
lightx2v/common/ops/attn/utils/ring_comm.py
lightx2v/common/ops/attn/utils/ring_comm.py
+2
-1
lightx2v/common/ops/conv/conv2d.py
lightx2v/common/ops/conv/conv2d.py
+3
-1
lightx2v/common/ops/conv/conv3d.py
lightx2v/common/ops/conv/conv3d.py
+3
-1
lightx2v/common/ops/mm/mm_weight.py
lightx2v/common/ops/mm/mm_weight.py
+6
-4
lightx2v/common/ops/mm/mm_weight_calib.py
lightx2v/common/ops/mm/mm_weight_calib.py
+4
-2
lightx2v/common/ops/norm/__init__.py
lightx2v/common/ops/norm/__init__.py
+1
-1
lightx2v/common/ops/norm/layer_norm_weight.py
lightx2v/common/ops/norm/layer_norm_weight.py
+4
-2
lightx2v/common/ops/norm/rms_norm_weight.py
lightx2v/common/ops/norm/rms_norm_weight.py
+4
-2
lightx2v/common/ops/tensor/tensor.py
lightx2v/common/ops/tensor/tensor.py
+2
-1
lightx2v/common/transformer_infer/transformer_infer.py
lightx2v/common/transformer_infer/transformer_infer.py
+2
-1
lightx2v/infer.py
lightx2v/infer.py
+14
-15
lightx2v/models/input_encoders/hf/clip/model.py
lightx2v/models/input_encoders/hf/clip/model.py
+1
-1
lightx2v/models/input_encoders/hf/llama/model.py
lightx2v/models/input_encoders/hf/llama/model.py
+1
-1
lightx2v/models/input_encoders/hf/llava/model.py
lightx2v/models/input_encoders/hf/llava/model.py
+3
-3
lightx2v/models/input_encoders/hf/t5/model.py
lightx2v/models/input_encoders/hf/t5/model.py
+4
-3
lightx2v/models/input_encoders/hf/t5_v1_1_xxl/model.py
lightx2v/models/input_encoders/hf/t5_v1_1_xxl/model.py
+2
-1
No files found.
lightx2v/common/ops/attn/sage_attn.py
View file @
f6d4fc85
import
torch
from
.template
import
AttnWeightTemplate
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
loguru
import
logger
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
.template
import
AttnWeightTemplate
if
torch
.
cuda
.
get_device_capability
(
0
)
==
(
8
,
9
):
try
:
from
sageattention
import
sageattn_qk_int8_pv_fp16_triton
as
sageattn
...
...
lightx2v/common/ops/attn/sparge_attn.py
View file @
f6d4fc85
import
torch
from
.template
import
AttnWeightTemplate
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
loguru
import
logger
import
torch.nn
as
nn
from
loguru
import
logger
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
.template
import
AttnWeightTemplate
try
:
from
spas_sage_attn.autotune
import
SparseAttentionMeansim
...
...
lightx2v/common/ops/attn/torch_sdpa.py
View file @
f6d4fc85
import
torch
import
torch.nn.functional
as
F
from
.template
import
AttnWeightTemplate
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
.template
import
AttnWeightTemplate
@
ATTN_WEIGHT_REGISTER
(
"torch_sdpa"
)
class
TorchSDPAWeight
(
AttnWeightTemplate
):
...
...
lightx2v/common/ops/attn/ulysses_attn.py
View file @
f6d4fc85
import
torch
from
.template
import
AttnWeightTemplate
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
import
torch.distributed
as
dist
from
.utils.all2all
import
all2all_seq2head
,
all2all_head2seq
from
lightx2v.utils.registry_factory
import
ATTN_WEIGHT_REGISTER
from
.template
import
AttnWeightTemplate
from
.utils.all2all
import
all2all_head2seq
,
all2all_seq2head
@
ATTN_WEIGHT_REGISTER
(
"ulysses"
)
...
...
lightx2v/common/ops/attn/utils/ring_comm.py
View file @
f6d4fc85
from
typing
import
Optional
from
loguru
import
logger
import
torch
import
torch.distributed
as
dist
from
loguru
import
logger
class
RingComm
:
...
...
lightx2v/common/ops/conv/conv2d.py
View file @
f6d4fc85
import
torch
from
abc
import
ABCMeta
,
abstractmethod
import
torch
from
lightx2v.utils.registry_factory
import
CONV2D_WEIGHT_REGISTER
...
...
lightx2v/common/ops/conv/conv3d.py
View file @
f6d4fc85
import
torch
from
abc
import
ABCMeta
,
abstractmethod
import
torch
from
lightx2v.utils.registry_factory
import
CONV3D_WEIGHT_REGISTER
...
...
lightx2v/common/ops/mm/mm_weight.py
View file @
f6d4fc85
import
torch
from
abc
import
ABCMeta
,
abstractmethod
from
lightx2v.utils.registry_factory
import
MM_WEIGHT_REGISTER
from
lightx2v.utils.quant_utils
import
IntegerQuantizer
,
FloatQuantizer
from
lightx2v.utils.envs
import
*
import
torch
from
loguru
import
logger
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.quant_utils
import
FloatQuantizer
,
IntegerQuantizer
from
lightx2v.utils.registry_factory
import
MM_WEIGHT_REGISTER
try
:
from
vllm
import
_custom_ops
as
ops
except
ImportError
:
...
...
lightx2v/common/ops/mm/mm_weight_calib.py
View file @
f6d4fc85
import
torch
from
.mm_weight
import
MMWeight
from
lightx2v.utils.quant_utils
import
FloatQuantizer
,
IntegerQuantizer
from
lightx2v.utils.registry_factory
import
MM_WEIGHT_REGISTER
from
lightx2v.utils.quant_utils
import
IntegerQuantizer
,
FloatQuantizer
from
.mm_weight
import
MMWeight
@
MM_WEIGHT_REGISTER
(
"Calib"
)
...
...
lightx2v/common/ops/norm/__init__.py
View file @
f6d4fc85
from
.rms_norm_weight
import
*
from
.layer_norm_weight
import
*
from
.rms_norm_weight
import
*
lightx2v/common/ops/norm/layer_norm_weight.py
View file @
f6d4fc85
import
torch
from
abc
import
ABCMeta
,
abstractmethod
from
lightx2v.utils.registry_factory
import
LN_WEIGHT_REGISTER
import
torch
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.registry_factory
import
LN_WEIGHT_REGISTER
class
LNWeightTemplate
(
metaclass
=
ABCMeta
):
...
...
lightx2v/common/ops/norm/rms_norm_weight.py
View file @
f6d4fc85
import
torch
from
abc
import
ABCMeta
,
abstractmethod
from
lightx2v.utils.registry_factory
import
RMS_WEIGHT_REGISTER
import
torch
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.registry_factory
import
RMS_WEIGHT_REGISTER
try
:
import
sgl_kernel
...
...
lightx2v/common/ops/tensor/tensor.py
View file @
f6d4fc85
import
torch
from
lightx2v.utils.registry_factory
import
TENSOR_REGISTER
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.registry_factory
import
TENSOR_REGISTER
@
TENSOR_REGISTER
(
"Default"
)
...
...
lightx2v/common/transformer_infer/transformer_infer.py
View file @
f6d4fc85
import
math
from
abc
import
ABC
,
abstractmethod
import
torch
import
math
class
BaseTransformerInfer
(
ABC
):
...
...
lightx2v/infer.py
View file @
f6d4fc85
import
argparse
import
torch
import
torch.distributed
as
dist
import
json
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.utils
import
seed_all
from
lightx2v.utils.profiler
import
ProfilingContext
from
lightx2v.utils.set_config
import
set_config
,
print_config
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
import
torch
import
torch.distributed
as
dist
from
loguru
import
logger
from
lightx2v.common.ops
import
*
from
lightx2v.models.runners.cogvideox.cogvidex_runner
import
CogvideoxRunner
from
lightx2v.models.runners.graph_runner
import
GraphRunner
from
lightx2v.models.runners.hunyuan.hunyuan_runner
import
HunyuanRunner
from
lightx2v.models.runners.wan.wan_runner
import
WanRunner
,
Wan22MoeRunner
from
lightx2v.models.runners.wan.wan_distill_runner
import
WanDistillRunner
from
lightx2v.models.runners.wan.wan_audio_runner
import
Wan22MoeAudioRunner
,
WanAudioRunner
from
lightx2v.models.runners.wan.wan_causvid_runner
import
WanCausVidRunner
from
lightx2v.models.runners.wan.wan_audio_runner
import
WanAudioRunner
,
Wan22MoeAudioRunner
from
lightx2v.models.runners.wan.wan_distill_runner
import
WanDistillRunner
from
lightx2v.models.runners.wan.wan_runner
import
Wan22MoeRunner
,
WanRunner
from
lightx2v.models.runners.wan.wan_skyreels_v2_df_runner
import
WanSkyreelsV2DFRunner
from
lightx2v.
models.runners.graph_runner
import
GraphRunner
from
lightx2v.
models.runners.cogvideox.cogvidex_runner
import
CogvideoxRunner
from
lightx2v.
common.ops
import
*
from
l
oguru
import
logger
from
lightx2v.
utils.envs
import
*
from
lightx2v.
utils.profiler
import
ProfilingContext
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
from
lightx2v.
utils.set_config
import
print_config
,
set_config
from
l
ightx2v.utils.utils
import
seed_all
def
init_runner
(
config
):
...
...
lightx2v/models/input_encoders/hf/clip/model.py
View file @
f6d4fc85
import
torch
from
transformers
import
CLIPTextModel
,
AutoTokenizer
from
loguru
import
logger
from
transformers
import
AutoTokenizer
,
CLIPTextModel
class
TextEncoderHFClipModel
:
...
...
lightx2v/models/input_encoders/hf/llama/model.py
View file @
f6d4fc85
import
torch
from
transformers
import
AutoModel
,
AutoTokenizer
from
loguru
import
logger
from
transformers
import
AutoModel
,
AutoTokenizer
class
TextEncoderHFLlamaModel
:
...
...
lightx2v/models/input_encoders/hf/llava/model.py
View file @
f6d4fc85
import
torch
from
PIL
import
Image
import
numpy
as
np
import
torch
import
torchvision.transforms
as
transforms
from
transformers
import
LlavaForConditionalGeneration
,
CLIPImageProcessor
,
AutoTokenizer
from
PIL
import
Image
from
loguru
import
logger
from
transformers
import
AutoTokenizer
,
CLIPImageProcessor
,
LlavaForConditionalGeneration
def
generate_crop_size_list
(
base_size
=
256
,
patch_size
=
32
,
max_ratio
=
4.0
):
...
...
lightx2v/models/input_encoders/hf/t5/model.py
View file @
f6d4fc85
...
...
@@ -3,14 +3,15 @@
import
logging
import
math
import
os
import
torch
import
torch.nn
as
nn
import
torch.nn.functional
as
F
from
.tokenizer
import
HuggingfaceTokenizer
from
loguru
import
logger
from
lightx2v.models.input_encoders.hf.q_linear
import
VllmQuantLinearInt8
,
VllmQuantLinearFp8
,
TorchaoQuantLinearInt8
,
Q8FQuantLinearInt8
,
Q8FQuantLinearFp8
from
lightx2v.models.input_encoders.hf.q_linear
import
Q8FQuantLinearFp8
,
Q8FQuantLinearInt8
,
TorchaoQuantLinearInt8
,
VllmQuantLinearFp8
,
VllmQuantLinearInt8
from
.tokenizer
import
HuggingfaceTokenizer
__all__
=
[
"T5Model"
,
...
...
lightx2v/models/input_encoders/hf/t5_v1_1_xxl/model.py
View file @
f6d4fc85
import
torch
import
os
import
torch
from
transformers
import
T5EncoderModel
,
T5Tokenizer
...
...
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment