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
change
sglang
Commits
dd6ec029
Unverified
Commit
dd6ec029
authored
Aug 24, 2025
by
Beichen Ma
Committed by
GitHub
Aug 24, 2025
Browse files
Add target module validation for init adapters (#9429)
parent
bf863e3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
12 deletions
+29
-12
python/sglang/srt/lora/lora_manager.py
python/sglang/srt/lora/lora_manager.py
+29
-12
No files found.
python/sglang/srt/lora/lora_manager.py
View file @
dd6ec029
...
@@ -420,20 +420,37 @@ class LoRAManager:
...
@@ -420,20 +420,37 @@ class LoRAManager:
):
):
"""Infer LoRA target modules and max_lora_rank from loaded adapters if not provided."""
"""Infer LoRA target modules and max_lora_rank from loaded adapters if not provided."""
if
target_modules
is
not
None
:
self
.
target_modules
=
(
self
.
target_modules
=
set
(
target_modules
)
get_normalized_target_modules
(
target_modules
)
if
target_modules
else
set
()
else
:
)
self
.
target_modules
=
set
()
for
config
in
self
.
configs
.
values
():
for
lora_id
,
config
in
self
.
configs
.
items
():
if
not
isinstance
(
config
.
target_modules
,
list
):
if
not
isinstance
(
config
.
target_modules
,
list
):
raise
ValueError
(
f
"SGLang currently only supports inferring LoRA target modules when a list of "
"suffixes is provided in `target_modules` field of PEFT config. Please explicitly "
"specify `--lora-target-modules` during server startup. You can specify `all` to "
"enable all support modules types. "
)
adapter_target_modules
=
get_normalized_target_modules
(
config
.
target_modules
)
if
target_modules
is
not
None
:
# When `--lora-target-modules` is provided, validate adapter target modules is a subset of the specified target modules.
if
not
adapter_target_modules
.
issubset
(
self
.
target_modules
):
unsupported_modules
=
adapter_target_modules
-
self
.
target_modules
lora_name
=
self
.
lora_refs
[
lora_id
].
lora_name
raise
ValueError
(
raise
ValueError
(
f
"
SGLang currently only supports inferring LoRA target modules when a list of
"
f
"
LoRA adapter '
{
lora_name
}
' contains target modules
{
sorted
(
unsupported_modules
)
}
"
"suffixes is provided in `
target
_
modules
` field of PEFT config. Please explicitly
"
f
"that are not included in the specified --lora-
target
-
modules
{
sorted
(
self
.
target_modules
)
}
.
"
"specify `
--lora-target-modules
` during server startup. You can specify `all` to
"
f
"Please update
--lora-target-modules
to include all required modules:
"
"
enable all support modules
types.
"
f
"
{
sorted
(
self
.
target_modules
|
adapter_target_modules
)
}
, or use 'all' to
enable all support
ed
modules
.
"
)
)
self
.
target_modules
.
update
(
config
.
target_modules
)
else
:
self
.
target_modules
=
get_normalized_target_modules
(
self
.
target_modules
)
# Otherwise, infer target_modules from adapter configs.
self
.
target_modules
.
update
(
adapter_target_modules
)
if
max_lora_rank
is
not
None
:
if
max_lora_rank
is
not
None
:
self
.
max_lora_rank
=
max_lora_rank
self
.
max_lora_rank
=
max_lora_rank
...
...
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