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
e8613df0
Unverified
Commit
e8613df0
authored
Oct 07, 2024
by
Byron Hsu
Committed by
GitHub
Oct 08, 2024
Browse files
[Engine] Fix generate hanging issue after the first call (#1606)
parent
c5325aba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
python/sglang/srt/server.py
python/sglang/srt/server.py
+3
-2
test/srt/test_srt_engine.py
test/srt/test_srt_engine.py
+12
-0
No files found.
python/sglang/srt/server.py
View file @
e8613df0
...
@@ -691,8 +691,9 @@ class Engine:
...
@@ -691,8 +691,9 @@ class Engine:
lora_path
=
lora_path
,
lora_path
=
lora_path
,
)
)
# make it synchronous
# get the current event loop
return
asyncio
.
run
(
generate_request
(
obj
,
None
))
loop
=
asyncio
.
get_event_loop
()
return
loop
.
run_until_complete
(
generate_request
(
obj
,
None
))
def
shutdown
(
self
):
def
shutdown
(
self
):
kill_child_process
(
os
.
getpid
(),
including_parent
=
False
)
kill_child_process
(
os
.
getpid
(),
including_parent
=
False
)
...
...
test/srt/test_srt_engine.py
View file @
e8613df0
...
@@ -28,6 +28,18 @@ class TestSRTBackend(unittest.TestCase):
...
@@ -28,6 +28,18 @@ class TestSRTBackend(unittest.TestCase):
print
(
out2
)
print
(
out2
)
assert
out1
==
out2
,
f
"
{
out1
}
!=
{
out2
}
"
assert
out1
==
out2
,
f
"
{
out1
}
!=
{
out2
}
"
def
test_engine_multiple_generate
(
self
):
# just to ensure there is no issue running multiple generate calls
prompt
=
"Today is a sunny day and I like"
model_path
=
DEFAULT_MODEL_NAME_FOR_TEST
sampling_params
=
{
"temperature"
:
0
,
"max_new_tokens"
:
8
}
engine
=
sgl
.
Engine
(
model_path
=
model_path
,
random_seed
=
42
)
engine
.
generate
(
prompt
,
sampling_params
)
engine
.
generate
(
prompt
,
sampling_params
)
engine
.
shutdown
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
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