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
4929cd02
Unverified
Commit
4929cd02
authored
Sep 25, 2025
by
gushiqiao
Committed by
GitHub
Sep 25, 2025
Browse files
[Update] Update lora adapter (#336)
parent
e51914a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
lightx2v/models/networks/wan/lora_adapter.py
lightx2v/models/networks/wan/lora_adapter.py
+2
-2
lightx2v/models/networks/wan/model.py
lightx2v/models/networks/wan/model.py
+12
-0
No files found.
lightx2v/models/networks/wan/lora_adapter.py
View file @
4929cd02
...
...
@@ -43,7 +43,7 @@ class WanLoraWrapper:
lora_weights
=
self
.
_load_lora_file
(
self
.
lora_metadata
[
lora_name
][
"path"
])
weight_dict
=
self
.
model
.
original_weight_dict
self
.
_apply_lora_weights
(
weight_dict
,
lora_weights
,
alpha
)
self
.
model
.
_
init
_weights
(
weight_dict
)
self
.
model
.
_
apply
_weights
(
weight_dict
)
logger
.
info
(
f
"Applied LoRA:
{
lora_name
}
with alpha=
{
alpha
}
"
)
del
lora_weights
...
...
@@ -119,7 +119,7 @@ class WanLoraWrapper:
logger
.
info
(
f
"LoRA removed, restored
{
restored_count
}
weights"
)
self
.
model
.
_
init
_weights
(
self
.
model
.
original_weight_dict
)
self
.
model
.
_
apply
_weights
(
self
.
model
.
original_weight_dict
)
torch
.
cuda
.
empty_cache
()
gc
.
collect
()
...
...
lightx2v/models/networks/wan/model.py
View file @
4929cd02
...
...
@@ -56,6 +56,11 @@ class WanModel(CompiledMethodsMixin):
else
:
self
.
seq_p_group
=
None
if
self
.
config
.
get
(
"lora_configs"
)
and
self
.
config
.
lora_configs
:
self
.
init_empty_model
=
True
else
:
self
.
init_empty_model
=
False
self
.
clean_cuda_cache
=
self
.
config
.
get
(
"clean_cuda_cache"
,
False
)
self
.
dit_quantized
=
self
.
config
.
mm_config
.
get
(
"mm_type"
,
"Default"
)
!=
"Default"
...
...
@@ -254,7 +259,14 @@ class WanModel(CompiledMethodsMixin):
# Initialize weight containers
self
.
pre_weight
=
self
.
pre_weight_class
(
self
.
config
)
self
.
transformer_weights
=
self
.
transformer_weight_class
(
self
.
config
)
if
not
self
.
init_empty_model
:
self
.
_apply_weights
()
def
_apply_weights
(
self
,
weight_dict
=
None
):
if
weight_dict
is
not
None
:
self
.
original_weight_dict
=
weight_dict
del
weight_dict
gc
.
collect
()
# Load weights into containers
self
.
pre_weight
.
load
(
self
.
original_weight_dict
)
self
.
transformer_weights
.
load
(
self
.
original_weight_dict
)
...
...
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