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
32de16ce
Unverified
Commit
32de16ce
authored
May 13, 2024
by
Lianmin Zheng
Committed by
GitHub
May 13, 2024
Browse files
Fix streaming (#437)
parent
0992d85f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
python/sglang/srt/managers/router/infer_batch.py
python/sglang/srt/managers/router/infer_batch.py
+6
-5
python/sglang/srt/managers/router/model_rpc.py
python/sglang/srt/managers/router/model_rpc.py
+2
-2
No files found.
python/sglang/srt/managers/router/infer_batch.py
View file @
32de16ce
...
@@ -20,15 +20,16 @@ class FinishReason(IntEnum):
...
@@ -20,15 +20,16 @@ class FinishReason(IntEnum):
LENGTH
=
auto
()
LENGTH
=
auto
()
STOP_STR
=
auto
()
STOP_STR
=
auto
()
def
to_str
(
self
):
@
staticmethod
if
self
==
FinishReason
.
EOS_TOKEN
:
def
to_str
(
reason
):
if
reason
==
FinishReason
.
EOS_TOKEN
:
return
None
return
None
elif
self
==
FinishReason
.
LENGTH
:
elif
reason
==
FinishReason
.
LENGTH
:
return
"length"
return
"length"
elif
self
==
FinishReason
.
STOP_STR
:
elif
reason
==
FinishReason
.
STOP_STR
:
return
"stop"
return
"stop"
else
:
else
:
r
aise
ValueError
(
f
"Invalid finish reason:
{
self
}
"
)
r
eturn
None
class
Req
:
class
Req
:
...
...
python/sglang/srt/managers/router/model_rpc.py
View file @
32de16ce
...
@@ -24,7 +24,7 @@ from sglang.srt.managers.io_struct import (
...
@@ -24,7 +24,7 @@ from sglang.srt.managers.io_struct import (
FlushCacheReq
,
FlushCacheReq
,
TokenizedGenerateReqInput
,
TokenizedGenerateReqInput
,
)
)
from
sglang.srt.managers.router.infer_batch
import
Batch
,
ForwardMode
,
Req
from
sglang.srt.managers.router.infer_batch
import
Batch
,
ForwardMode
,
Req
,
FinishReason
from
sglang.srt.managers.router.model_runner
import
ModelRunner
from
sglang.srt.managers.router.model_runner
import
ModelRunner
from
sglang.srt.managers.router.radix_cache
import
RadixCache
from
sglang.srt.managers.router.radix_cache
import
RadixCache
from
sglang.srt.managers.router.scheduler
import
Scheduler
from
sglang.srt.managers.router.scheduler
import
Scheduler
...
@@ -615,7 +615,7 @@ class ModelRpcServer:
...
@@ -615,7 +615,7 @@ class ModelRpcServer:
+
len
(
req
.
output_ids
)
+
len
(
req
.
output_ids
)
-
req
.
prompt_tokens
,
-
req
.
prompt_tokens
,
"completion_tokens_wo_jump_forward"
:
req
.
completion_tokens_wo_jump_forward
,
"completion_tokens_wo_jump_forward"
:
req
.
completion_tokens_wo_jump_forward
,
"finish_reason"
:
req
.
f
inish
_r
eason
.
to_str
(),
"finish_reason"
:
F
inish
R
eason
.
to_str
(
req
.
finish_reason
),
"hit_stop_str"
:
req
.
hit_stop_str
,
"hit_stop_str"
:
req
.
hit_stop_str
,
}
}
if
req
.
return_logprob
:
if
req
.
return_logprob
:
...
...
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