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
b68c4c07
Unverified
Commit
b68c4c07
authored
Aug 10, 2024
by
Ying Sheng
Committed by
GitHub
Aug 10, 2024
Browse files
fix: force max new tokens to be 1 for embedding request (#1019)
parent
e712837d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
python/sglang/srt/managers/io_struct.py
python/sglang/srt/managers/io_struct.py
+5
-4
test/srt/models/test_embedding_models.py
test/srt/models/test_embedding_models.py
+3
-1
No files found.
python/sglang/srt/managers/io_struct.py
View file @
b68c4c07
...
...
@@ -195,7 +195,8 @@ class EmbeddingReqInput:
if
self
.
rid
is
None
:
self
.
rid
=
uuid
.
uuid4
().
hex
if
self
.
sampling_params
is
None
:
self
.
sampling_params
=
{
"max_new_tokens"
:
1
}
self
.
sampling_params
=
{}
self
.
sampling_params
[
"max_new_tokens"
]
=
1
else
:
# support select operation
self
.
batch_size
=
(
...
...
@@ -207,9 +208,9 @@ class EmbeddingReqInput:
if
not
isinstance
(
self
.
rid
,
list
):
raise
ValueError
(
"The rid should be a list."
)
if
self
.
sampling_params
is
None
:
self
.
sampling_params
=
[
{
"max_new_tokens"
:
1
}
for
_
in
range
(
self
.
batch_size
)
]
self
.
sampling_params
=
[
{}]
*
self
.
batch_size
for
i
in
range
(
self
.
batch_size
)
:
self
.
sampling_params
[
i
][
"max_new_tokens"
]
=
1
@
dataclass
...
...
test/srt/models/test_embedding_models.py
View file @
b68c4c07
...
...
@@ -44,7 +44,9 @@ class TestEmbeddingModels(unittest.TestCase):
torch_dtype
=
torch_dtype
,
is_generation_model
=
False
,
)
as
srt_runner
:
srt_outputs
=
srt_runner
.
forward
(
prompts
)
srt_outputs
=
srt_runner
.
forward
(
prompts
,
)
for
i
in
range
(
len
(
prompts
)):
hf_logits
=
torch
.
Tensor
(
hf_outputs
.
embed_logits
[
i
])
...
...
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