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
7fde7063
Commit
7fde7063
authored
Apr 21, 2025
by
helloyongyang
Browse files
support lru_cache
parent
7fc021e2
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
18 additions
and
8 deletions
+18
-8
lightx2v/__main__.py
lightx2v/__main__.py
+1
-1
lightx2v/models/networks/hunyuan/infer/transformer_infer.py
lightx2v/models/networks/hunyuan/infer/transformer_infer.py
+1
-1
lightx2v/models/networks/wan/infer/transformer_infer.py
lightx2v/models/networks/wan/infer/transformer_infer.py
+1
-1
lightx2v/utils/envs.py
lightx2v/utils/envs.py
+10
-4
lightx2v/utils/profiler.py
lightx2v/utils/profiler.py
+1
-1
scripts/run_hunyuan_i2v.sh
scripts/run_hunyuan_i2v.sh
+1
-0
scripts/run_hunyuan_t2v.sh
scripts/run_hunyuan_t2v.sh
+1
-0
scripts/run_wan_i2v.sh
scripts/run_wan_i2v.sh
+1
-0
scripts/run_wan_t2v.sh
scripts/run_wan_t2v.sh
+1
-0
No files found.
lightx2v/__main__.py
View file @
7fde7063
...
...
@@ -347,7 +347,7 @@ if __name__ == "__main__":
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
if
ENABLE_GRAPH_MODE
:
if
CHECK_
ENABLE_GRAPH_MODE
()
:
default_runner
=
DefaultRunner
(
model
,
inputs
)
runner
=
GraphRunner
(
default_runner
)
else
:
...
...
lightx2v/models/networks/hunyuan/infer/transformer_infer.py
View file @
7fde7063
...
...
@@ -26,7 +26,7 @@ class HunyuanTransformerInfer:
def
set_scheduler
(
self
,
scheduler
):
self
.
scheduler
=
scheduler
@
torch
.
compile
(
disable
=
not
ENABLE_GRAPH_MODE
)
@
torch
.
compile
(
disable
=
not
CHECK_
ENABLE_GRAPH_MODE
()
)
def
infer
(
self
,
weights
,
img
,
txt
,
vec
,
cu_seqlens_qkv
,
max_seqlen_qkv
,
freqs_cis
,
token_replace_vec
=
None
,
frist_frame_token_num
=
None
):
return
self
.
infer_func
(
weights
,
img
,
txt
,
vec
,
cu_seqlens_qkv
,
max_seqlen_qkv
,
freqs_cis
,
token_replace_vec
,
frist_frame_token_num
)
...
...
lightx2v/models/networks/wan/infer/transformer_infer.py
View file @
7fde7063
...
...
@@ -35,7 +35,7 @@ class WanTransformerInfer:
cu_seqlens_k
=
torch
.
cat
([
k_lens
.
new_zeros
([
1
]),
k_lens
]).
cumsum
(
0
,
dtype
=
torch
.
int32
)
return
cu_seqlens_q
,
cu_seqlens_k
,
lq
,
lk
@
torch
.
compile
(
disable
=
not
ENABLE_GRAPH_MODE
)
@
torch
.
compile
(
disable
=
not
CHECK_
ENABLE_GRAPH_MODE
()
)
def
infer
(
self
,
weights
,
grid_sizes
,
embed
,
x
,
embed0
,
seq_lens
,
freqs
,
context
):
return
self
.
infer_func
(
weights
,
grid_sizes
,
embed
,
x
,
embed0
,
seq_lens
,
freqs
,
context
)
...
...
lightx2v/utils/envs.py
View file @
7fde7063
import
os
from
functools
import
lru_cache
global
ENABLE_PROFILING_DEBUG
ENABLE_PROFILING_DEBUG
=
os
.
getenv
(
"ENABLE_PROFILING_DEBUG"
,
"false"
).
lower
()
==
"true"
@
lru_cache
(
maxsize
=
None
)
def
CHECK_ENABLE_PROFILING_DEBUG
():
ENABLE_PROFILING_DEBUG
=
os
.
getenv
(
"ENABLE_PROFILING_DEBUG"
,
"false"
).
lower
()
==
"true"
return
ENABLE_PROFILING_DEBUG
global
ENABLE_GRAPH_MODE
ENABLE_GRAPH_MODE
=
os
.
getenv
(
"ENABLE_GRAPH_MODE"
,
"false"
).
lower
()
==
"true"
@
lru_cache
(
maxsize
=
None
)
def
CHECK_ENABLE_GRAPH_MODE
():
ENABLE_GRAPH_MODE
=
os
.
getenv
(
"ENABLE_GRAPH_MODE"
,
"false"
).
lower
()
==
"true"
return
ENABLE_GRAPH_MODE
lightx2v/utils/profiler.py
View file @
7fde7063
...
...
@@ -33,4 +33,4 @@ class _NullContext(ContextDecorator):
ProfilingContext
=
_ProfilingContext
ProfilingContext4Debug
=
_ProfilingContext
if
ENABLE_PROFILING_DEBUG
else
_NullContext
ProfilingContext4Debug
=
_ProfilingContext
if
CHECK_
ENABLE_PROFILING_DEBUG
()
else
_NullContext
scripts/run_hunyuan_i2v.sh
View file @
7fde7063
...
...
@@ -24,6 +24,7 @@ fi
export
PYTHONPATH
=
${
lightx2v_path
}
:
$PYTHONPATH
export
ENABLE_PROFILING_DEBUG
=
true
export
ENABLE_GRAPH_MODE
=
false
python
${
lightx2v_path
}
/lightx2v/__main__.py
\
--model_cls
hunyuan
\
...
...
scripts/run_hunyuan_t2v.sh
View file @
7fde7063
...
...
@@ -24,6 +24,7 @@ fi
export
PYTHONPATH
=
${
lightx2v_path
}
:
$PYTHONPATH
export
ENABLE_PROFILING_DEBUG
=
true
export
ENABLE_GRAPH_MODE
=
false
python
${
lightx2v_path
}
/lightx2v/__main__.py
\
--model_cls
hunyuan
\
...
...
scripts/run_wan_i2v.sh
View file @
7fde7063
...
...
@@ -30,6 +30,7 @@ fi
export
PYTHONPATH
=
${
lightx2v_path
}
:
$PYTHONPATH
export
ENABLE_PROFILING_DEBUG
=
true
export
ENABLE_GRAPH_MODE
=
false
python
${
lightx2v_path
}
/lightx2v/__main__.py
\
--model_cls
wan2.1
\
...
...
scripts/run_wan_t2v.sh
View file @
7fde7063
...
...
@@ -30,6 +30,7 @@ fi
export
PYTHONPATH
=
${
lightx2v_path
}
:
$PYTHONPATH
export
ENABLE_PROFILING_DEBUG
=
true
export
ENABLE_GRAPH_MODE
=
false
python
${
lightx2v_path
}
/lightx2v/__main__.py
\
--model_cls
wan2.1
\
...
...
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