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
a14288d5
Unverified
Commit
a14288d5
authored
Oct 10, 2025
by
yihuiwen
Committed by
GitHub
Oct 10, 2025
Browse files
fix error code (#356)
Co-authored-by:
yihuiwen
<
yihuiwen@sensetime.com
>
parent
891f3bf1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
48 deletions
+23
-48
lightx2v/models/runners/default_runner.py
lightx2v/models/runners/default_runner.py
+9
-17
lightx2v/models/runners/qwen_image/qwen_image_runner.py
lightx2v/models/runners/qwen_image/qwen_image_runner.py
+3
-13
lightx2v/models/runners/wan/wan_animate_runner.py
lightx2v/models/runners/wan/wan_animate_runner.py
+1
-1
lightx2v/models/runners/wan/wan_runner.py
lightx2v/models/runners/wan/wan_runner.py
+1
-1
lightx2v/models/runners/wan/wan_vace_runner.py
lightx2v/models/runners/wan/wan_vace_runner.py
+1
-1
lightx2v/server/metrics/__init__.py
lightx2v/server/metrics/__init__.py
+0
-1
lightx2v/server/metrics/metrics.py
lightx2v/server/metrics/metrics.py
+6
-12
lightx2v/server/metrics/monitor.py
lightx2v/server/metrics/monitor.py
+1
-0
lightx2v/utils/envs.py
lightx2v/utils/envs.py
+1
-2
No files found.
lightx2v/models/runners/default_runner.py
View file @
a14288d5
...
...
@@ -170,7 +170,7 @@ class DefaultRunner(BaseRunner):
img_ori
=
Image
.
open
(
img_path
).
convert
(
"RGB"
)
if
GET_RECORDER_MODE
():
width
,
height
=
img_ori
.
size
monitor_cli
.
lightx2v_input_image_len
.
observe
(
width
*
height
)
monitor_cli
.
lightx2v_input_image_len
.
observe
(
width
*
height
)
img
=
TF
.
to_tensor
(
img_ori
).
sub_
(
0.5
).
div_
(
0.5
).
unsqueeze
(
0
).
cuda
()
self
.
input_info
.
original_size
=
img_ori
.
size
return
img
,
img_ori
...
...
@@ -256,10 +256,12 @@ class DefaultRunner(BaseRunner):
self
.
model
.
select_graph_for_compile
(
self
.
input_info
)
for
segment_idx
in
range
(
self
.
video_segment_num
):
logger
.
info
(
f
"🔄 start segment
{
segment_idx
+
1
}
/
{
self
.
video_segment_num
}
"
)
with
ProfilingContext4DebugL1
(
f
"segment end2end
{
segment_idx
+
1
}
/
{
self
.
video_segment_num
}
"
,
\
recorder_mode
=
GET_RECORDER_MODE
(),
\
metrics_func
=
monitor_cli
.
lightx2v_run_pre_step_dit_duration
,
\
metrics_labels
=
[
segment_idx
+
1
,
self
.
video_segment_num
]):
with
ProfilingContext4DebugL1
(
f
"segment end2end
{
segment_idx
+
1
}
/
{
self
.
video_segment_num
}
"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_pre_step_dit_duration
,
metrics_labels
=
[
segment_idx
+
1
,
self
.
video_segment_num
],
):
self
.
check_stop
()
# 1. default do nothing
self
.
init_run_segment
(
segment_idx
)
...
...
@@ -273,12 +275,7 @@ class DefaultRunner(BaseRunner):
self
.
end_run
()
return
{
"video"
:
gen_video_final
}
@
ProfilingContext4DebugL1
(
"Run VAE Decoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_vae_decode_duration
,
metrics_labels
=
labels
=
[
"DefaultRunner"
]
)
@
ProfilingContext4DebugL1
(
"Run VAE Decoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_vae_decode_duration
,
metrics_labels
=
[
"DefaultRunner"
])
def
run_vae_decoder
(
self
,
latents
):
if
self
.
config
.
get
(
"lazy_load"
,
False
)
or
self
.
config
.
get
(
"unload_modules"
,
False
):
self
.
vae_decoder
=
self
.
load_vae_decoder
()
...
...
@@ -333,12 +330,7 @@ class DefaultRunner(BaseRunner):
logger
.
info
(
f
"✅ Video saved successfully to:
{
self
.
input_info
.
save_result_path
}
✅"
)
return
{
"video"
:
None
}
@
ProfilingContext4DebugL1
(
"RUN pipeline"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_worker_request_duration
,
metrics_labels
=
[
"DefaultRunner"
]
)
@
ProfilingContext4DebugL1
(
"RUN pipeline"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_worker_request_duration
,
metrics_labels
=
[
"DefaultRunner"
])
def
run_pipeline
(
self
,
input_info
):
if
GET_RECORDER_MODE
():
monitor_cli
.
lightx2v_worker_request_count
.
inc
()
...
...
lightx2v/models/runners/qwen_image/qwen_image_runner.py
View file @
a14288d5
...
...
@@ -10,10 +10,10 @@ from lightx2v.models.networks.qwen_image.model import QwenImageTransformerModel
from
lightx2v.models.runners.default_runner
import
DefaultRunner
from
lightx2v.models.schedulers.qwen_image.scheduler
import
QwenImageScheduler
from
lightx2v.models.video_encoders.hf.qwen_image.vae
import
AutoencoderKLQwenImageVAE
from
lightx2v.server.metrics
import
monitor_cli
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.profiler
import
*
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
from
lightx2v.server.metrics
import
monitor_cli
def
calculate_dimensions
(
target_area
,
ratio
):
...
...
@@ -108,12 +108,7 @@ class QwenImageRunner(DefaultRunner):
"image_encoder_output"
:
image_encoder_output
,
}
@
ProfilingContext4DebugL1
(
"Run Text Encoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_text_encode_duration
,
metrics_labels
=
[
"QwenImageRunner"
]
)
@
ProfilingContext4DebugL1
(
"Run Text Encoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_text_encode_duration
,
metrics_labels
=
[
"QwenImageRunner"
])
def
run_text_encoder
(
self
,
text
,
image
=
None
):
if
GET_RECORDER_MODE
():
monitor_cli
.
lightx2v_input_prompt_len
.
observe
(
len
(
text
))
...
...
@@ -130,12 +125,7 @@ class QwenImageRunner(DefaultRunner):
text_encoder_output
[
"image_info"
]
=
image_info
return
text_encoder_output
@
ProfilingContext4DebugL1
(
"Run VAE Encoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_vae_encode_duration
,
metrics_labels
=
[
"QwenImageRunner"
]
)
@
ProfilingContext4DebugL1
(
"Run VAE Encoder"
,
recorder_mode
=
GET_RECORDER_MODE
(),
metrics_func
=
monitor_cli
.
lightx2v_run_vae_encode_duration
,
metrics_labels
=
[
"QwenImageRunner"
])
def
run_vae_encoder
(
self
,
image
):
image_latents
=
self
.
vae
.
encode_vae_image
(
image
)
return
{
"image_latents"
:
image_latents
}
...
...
lightx2v/models/runners/wan/wan_animate_runner.py
View file @
a14288d5
...
...
@@ -18,11 +18,11 @@ from lightx2v.models.input_encoders.hf.animate.face_encoder import FaceEncoder
from
lightx2v.models.input_encoders.hf.animate.motion_encoder
import
Generator
from
lightx2v.models.networks.wan.animate_model
import
WanAnimateModel
from
lightx2v.models.runners.wan.wan_runner
import
WanRunner
from
lightx2v.server.metrics
import
monitor_cli
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.profiler
import
*
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
from
lightx2v.utils.utils
import
load_weights
,
remove_substrings_from_keys
from
lightx2v.server.metrics
import
monitor_cli
@
RUNNER_REGISTER
(
"wan2.2_animate"
)
...
...
lightx2v/models/runners/wan/wan_runner.py
View file @
a14288d5
...
...
@@ -24,12 +24,12 @@ from lightx2v.models.schedulers.wan.scheduler import WanScheduler
from
lightx2v.models.video_encoders.hf.wan.vae
import
WanVAE
from
lightx2v.models.video_encoders.hf.wan.vae_2_2
import
Wan2_2_VAE
from
lightx2v.models.video_encoders.hf.wan.vae_tiny
import
Wan2_2_VAE_tiny
,
WanVAE_tiny
from
lightx2v.server.metrics
import
monitor_cli
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.profiler
import
*
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
from
lightx2v.utils.utils
import
*
from
lightx2v.utils.utils
import
best_output_size
from
lightx2v.server.metrics
import
monitor_cli
@
RUNNER_REGISTER
(
"wan2.1"
)
...
...
lightx2v/models/runners/wan/wan_vace_runner.py
View file @
a14288d5
...
...
@@ -8,10 +8,10 @@ from PIL import Image
from
lightx2v.models.input_encoders.hf.vace.vace_processor
import
VaceVideoProcessor
from
lightx2v.models.networks.wan.vace_model
import
WanVaceModel
from
lightx2v.models.runners.wan.wan_runner
import
WanRunner
from
lightx2v.server.metrics
import
monitor_cli
from
lightx2v.utils.envs
import
*
from
lightx2v.utils.profiler
import
*
from
lightx2v.utils.registry_factory
import
RUNNER_REGISTER
from
lightx2v.server.metrics
import
monitor_cli
@
RUNNER_REGISTER
(
"wan2.1_vace"
)
...
...
lightx2v/server/metrics/__init__.py
View file @
a14288d5
# -*-coding=utf-8-*-
from
.metrics
import
server_process
from
.monitor
import
Monitor
monitor_cli
=
Monitor
()
lightx2v/server/metrics/metrics.py
View file @
a14288d5
# -*-coding=utf-8-*-
from
prometheus_client
import
start_http_server
,
Counter
,
Gauge
,
Histogram
from
prometheus_client.metrics
import
MetricWrapperBase
import
time
from
loguru
import
logger
import
threading
from
typing
import
List
,
Tuple
from
loguru
import
logger
from
prometheus_client
import
Counter
,
Gauge
,
Histogram
,
start_http_server
from
pydantic
import
BaseModel
from
typing
import
Optional
,
List
,
Dict
,
Any
,
Tuple
from
functools
import
wraps
class
MetricsConfig
(
BaseModel
):
...
...
@@ -129,15 +127,11 @@ class MetricsClient:
if
config
.
type_
==
"counter"
:
self
.
register_counter
(
config
.
name
,
config
.
desc
,
config
.
labels
)
elif
config
.
type_
==
"histogram"
:
self
.
register_histogram
(
config
.
name
,
config
.
desc
,
config
.
labels
,
buckets
=
config
.
buckets
)
self
.
register_histogram
(
config
.
name
,
config
.
desc
,
config
.
labels
,
buckets
=
config
.
buckets
)
elif
config
.
type_
==
"gauge"
:
self
.
register_gauge
(
config
.
name
,
config
.
desc
,
config
.
labels
)
else
:
logger
.
warning
(
f
"Unsupported metric type:
{
config
.
type_
}
for
{
metric_name
}
"
)
logger
.
warning
(
f
"Unsupported metric type:
{
config
.
type_
}
for
{
metric_name
}
"
)
def
register_counter
(
self
,
name
,
desc
,
labels
):
metric_instance
=
Counter
(
name
,
desc
,
labels
)
...
...
lightx2v/server/metrics/monitor.py
View file @
a14288d5
# -*-coding=utf-8-*-
import
threading
from
.metrics
import
MetricsClient
...
...
lightx2v/utils/envs.py
View file @
a14288d5
...
...
@@ -42,9 +42,8 @@ def GET_SENSITIVE_DTYPE():
return
GET_DTYPE
()
return
DTYPE_MAP
[
RUNNING_FLAG
]
@
lru_cache
(
maxsize
=
None
)
def
GET_RECORDER_MODE
():
RECORDER_MODE
=
int
(
os
.
getenv
(
"RECORDER_MODE"
,
"0"
))
return
RECORDER_MODE
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