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
2725f8da
Unverified
Commit
2725f8da
authored
Oct 13, 2024
by
Ying Sheng
Committed by
GitHub
Oct 13, 2024
Browse files
[Minor] Rename no_eos_trim to no_stop_trim (#1661)
parent
da1ffed6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
python/sglang/srt/managers/detokenizer_manager.py
python/sglang/srt/managers/detokenizer_manager.py
+4
-4
python/sglang/srt/managers/io_struct.py
python/sglang/srt/managers/io_struct.py
+1
-1
python/sglang/srt/managers/scheduler.py
python/sglang/srt/managers/scheduler.py
+3
-3
python/sglang/srt/openai_api/adapter.py
python/sglang/srt/openai_api/adapter.py
+5
-5
python/sglang/srt/openai_api/protocol.py
python/sglang/srt/openai_api/protocol.py
+1
-1
python/sglang/srt/sampling/sampling_params.py
python/sglang/srt/sampling/sampling_params.py
+2
-2
No files found.
python/sglang/srt/managers/detokenizer_manager.py
View file @
2725f8da
...
...
@@ -75,8 +75,8 @@ class DetokenizerManager:
self
.
decode_status
=
LimitedCapacityDict
()
def
trim_eos
(
self
,
output
:
Union
[
str
,
List
[
int
]],
finished_reason
,
no_
eos
_trim
):
if
no_
eos
_trim
:
def
trim_eos
(
self
,
output
:
Union
[
str
,
List
[
int
]],
finished_reason
,
no_
stop
_trim
):
if
no_
stop
_trim
:
return
output
# Trim stop str. TODO(lmzheng): handle the case where multiple stop strs are hit
...
...
@@ -141,7 +141,7 @@ class DetokenizerManager:
self
.
trim_eos
(
s
.
decode_ids
[
s
.
surr_offset
:],
recv_obj
.
finished_reason
[
i
],
recv_obj
.
no_
eos
_trim
[
i
],
recv_obj
.
no_
stop
_trim
[
i
],
)
)
surr_ids
.
append
(
s
.
decode_ids
[
s
.
surr_offset
:
s
.
read_offset
])
...
...
@@ -177,7 +177,7 @@ class DetokenizerManager:
self
.
trim_eos
(
s
.
decoded_text
+
new_text
,
recv_obj
.
finished_reason
[
i
],
recv_obj
.
no_
eos
_trim
[
i
],
recv_obj
.
no_
stop
_trim
[
i
],
)
)
...
...
python/sglang/srt/managers/io_struct.py
View file @
2725f8da
...
...
@@ -295,7 +295,7 @@ class BatchTokenIDOut:
spaces_between_special_tokens
:
List
[
bool
]
meta_info
:
List
[
Dict
]
finished_reason
:
List
[
BaseFinishReason
]
no_
eos
_trim
:
List
[
bool
]
no_
stop
_trim
:
List
[
bool
]
@
dataclass
...
...
python/sglang/srt/managers/scheduler.py
View file @
2725f8da
...
...
@@ -885,7 +885,7 @@ class Scheduler:
output_read_offsets
=
[]
output_skip_special_tokens
=
[]
output_spaces_between_special_tokens
=
[]
output_no_
eos
_trim
=
[]
output_no_
stop
_trim
=
[]
else
:
# embedding or reward model
output_embeddings
=
[]
unfinished_indices
=
[]
...
...
@@ -917,7 +917,7 @@ class Scheduler:
output_spaces_between_special_tokens
.
append
(
req
.
sampling_params
.
spaces_between_special_tokens
)
output_no_
eos
_trim
.
append
(
req
.
sampling_params
.
no_
eos
_trim
)
output_no_
stop
_trim
.
append
(
req
.
sampling_params
.
no_
stop
_trim
)
meta_info
=
{
"prompt_tokens"
:
len
(
req
.
origin_input_ids
),
...
...
@@ -968,7 +968,7 @@ class Scheduler:
output_spaces_between_special_tokens
,
output_meta_info
,
output_finished_reason
,
output_no_
eos
_trim
,
output_no_
stop
_trim
,
)
)
else
:
# embedding or reward model
...
...
python/sglang/srt/openai_api/adapter.py
View file @
2725f8da
...
...
@@ -494,7 +494,7 @@ def v1_generate_request(
request
.
logprobs
if
request
.
logprobs
is
not
None
else
0
)
sampling_params
=
[]
if
isinstance
(
request
.
no_
eos
_trim
,
list
):
if
isinstance
(
request
.
no_
stop
_trim
,
list
):
num_reqs
=
len
(
request
.
prompt
)
else
:
num_reqs
=
1
...
...
@@ -514,10 +514,10 @@ def v1_generate_request(
"json_schema"
:
request
.
json_schema
,
"n"
:
request
.
n
,
"ignore_eos"
:
request
.
ignore_eos
,
"no_
eos
_trim"
:
(
request
.
no_
eos
_trim
if
not
isinstance
(
request
.
no_
eos
_trim
,
list
)
else
request
.
no_
eos
_trim
[
i
]
"no_
stop
_trim"
:
(
request
.
no_
stop
_trim
if
not
isinstance
(
request
.
no_
stop
_trim
,
list
)
else
request
.
no_
stop
_trim
[
i
]
),
}
)
...
...
python/sglang/srt/openai_api/protocol.py
View file @
2725f8da
...
...
@@ -174,7 +174,7 @@ class CompletionRequest(BaseModel):
min_tokens
:
int
=
0
repetition_penalty
:
Optional
[
float
]
=
1.0
stop_token_ids
:
Optional
[
List
[
int
]]
=
Field
(
default_factory
=
list
)
no_
eos
_trim
:
Union
[
bool
,
List
[
bool
]]
=
False
no_
stop
_trim
:
Union
[
bool
,
List
[
bool
]]
=
False
class
CompletionResponseChoice
(
BaseModel
):
...
...
python/sglang/srt/sampling/sampling_params.py
View file @
2725f8da
...
...
@@ -40,7 +40,7 @@ class SamplingParams:
regex
:
Optional
[
str
]
=
None
,
n
:
int
=
1
,
json_schema
:
Optional
[
str
]
=
None
,
no_
eos
_trim
:
bool
=
False
,
no_
stop
_trim
:
bool
=
False
,
)
->
None
:
self
.
temperature
=
temperature
self
.
top_p
=
top_p
...
...
@@ -61,7 +61,7 @@ class SamplingParams:
self
.
regex
=
regex
self
.
n
=
n
self
.
json_schema
=
json_schema
self
.
no_
eos
_trim
=
no_
eos
_trim
self
.
no_
stop
_trim
=
no_
stop
_trim
# Process some special cases
if
self
.
temperature
<
_SAMPLING_EPS
:
...
...
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