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
a38c1497
Unverified
Commit
a38c1497
authored
Aug 29, 2025
by
wangyu
Committed by
GitHub
Aug 28, 2025
Browse files
feat(draft_model): support draft_model for RemoteModelLoader (#6407)
Signed-off-by:
wangyu
<
wangyu.steph@bytedance.com
>
parent
74dd4249
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
examples/runtime/engine/save_remote_state.py
examples/runtime/engine/save_remote_state.py
+10
-1
python/sglang/srt/hf_transformers_utils.py
python/sglang/srt/hf_transformers_utils.py
+8
-0
python/sglang/srt/managers/scheduler_update_weights_mixin.py
python/sglang/srt/managers/scheduler_update_weights_mixin.py
+8
-1
No files found.
examples/runtime/engine/save_remote_state.py
View file @
a38c1497
...
@@ -34,6 +34,12 @@ parser.add_argument(
...
@@ -34,6 +34,12 @@ parser.add_argument(
type
=
str
,
type
=
str
,
help
=
"remote address to store model weights"
,
help
=
"remote address to store model weights"
,
)
)
parser
.
add_argument
(
"--remote-draft-model-save-url"
,
default
=
None
,
type
=
str
,
help
=
"remote address to store draft model weights"
,
)
def
main
(
args
):
def
main
(
args
):
...
@@ -43,7 +49,10 @@ def main(args):
...
@@ -43,7 +49,10 @@ def main(args):
raise
ValueError
(
"model path must be a local directory"
)
raise
ValueError
(
"model path must be a local directory"
)
# Create LLM instance from arguments
# Create LLM instance from arguments
llm
=
Engine
(
**
dataclasses
.
asdict
(
engine_args
))
llm
=
Engine
(
**
dataclasses
.
asdict
(
engine_args
))
llm
.
save_remote_model
(
url
=
args
.
remote_model_save_url
)
llm
.
save_remote_model
(
url
=
args
.
remote_model_save_url
,
draft_url
=
args
.
remote_draft_model_save_url
)
print
(
"save remote (draft) model successfully"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
python/sglang/srt/hf_transformers_utils.py
View file @
a38c1497
...
@@ -126,6 +126,14 @@ def get_config(
...
@@ -126,6 +126,14 @@ def get_config(
kwargs
[
"gguf_file"
]
=
model
kwargs
[
"gguf_file"
]
=
model
model
=
Path
(
model
).
parent
model
=
Path
(
model
).
parent
if
is_remote_url
(
model
):
# BaseConnector implements __del__() to clean up the local dir.
# Since config files need to exist all the time, so we DO NOT use
# with statement to avoid closing the client.
client
=
create_remote_connector
(
model
)
client
.
pull_files
(
ignore_pattern
=
[
"*.pt"
,
"*.safetensors"
,
"*.bin"
])
model
=
client
.
get_local_dir
()
config
=
AutoConfig
.
from_pretrained
(
config
=
AutoConfig
.
from_pretrained
(
model
,
trust_remote_code
=
trust_remote_code
,
revision
=
revision
,
**
kwargs
model
,
trust_remote_code
=
trust_remote_code
,
revision
=
revision
,
**
kwargs
)
)
...
...
python/sglang/srt/managers/scheduler_update_weights_mixin.py
View file @
a38c1497
...
@@ -121,9 +121,16 @@ class SchedulerUpdateWeightsMixin:
...
@@ -121,9 +121,16 @@ class SchedulerUpdateWeightsMixin:
url
=
params
[
"url"
]
url
=
params
[
"url"
]
worker
=
self
.
tp_worker
.
worker
worker
=
self
.
tp_worker
.
worker
worker
.
model_runner
.
save_remote_model
(
url
)
worker
.
model_runner
.
save_remote_model
(
url
)
if
self
.
draft_worker
is
not
None
:
draft_url
=
params
.
get
(
"draft_url"
,
None
)
assert
(
draft_url
is
not
None
),
"draft_url must be provided when draft model is enabled"
draft_worker
=
self
.
draft_worker
.
worker
draft_worker
.
model_runner
.
save_remote_model
(
draft_url
)
def
save_sharded_model
(
self
,
params
):
def
save_sharded_model
(
self
,
params
):
worker
=
self
.
tp_worker
.
worker
worker
=
self
.
tp_worker
.
worker
...
...
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