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
zhaoyu6
sglang
Commits
4d303c4f
"examples/0_demos/1_thread/thread3.cpp" did not exist on "d9d23f34d08efa5def1e162fdea6d737f16b664b"
Unverified
Commit
4d303c4f
authored
Feb 09, 2024
by
Cody Yu
Committed by
GitHub
Feb 09, 2024
Browse files
Fix token usage with jump forward (#174)
parent
37b42297
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
python/sglang/srt/managers/router/infer_batch.py
python/sglang/srt/managers/router/infer_batch.py
+3
-0
python/sglang/srt/managers/router/model_rpc.py
python/sglang/srt/managers/router/model_rpc.py
+8
-2
No files found.
python/sglang/srt/managers/router/infer_batch.py
View file @
4d303c4f
...
...
@@ -27,6 +27,9 @@ class Req:
self
.
input_ids
=
input_ids
self
.
output_ids
=
[]
# for accumulated prompt tokens from jump forward
self
.
orig_prompt_tokens
=
len
(
input_ids
)
# For vision input
self
.
pixel_values
=
None
self
.
image_size
=
None
...
...
python/sglang/srt/managers/router/model_rpc.py
View file @
4d303c4f
...
...
@@ -534,10 +534,16 @@ class ModelRpcServer(rpyc.Service):
output_skip_special_tokens
.
append
(
req
.
sampling_params
.
skip_special_tokens
)
# For the length of input_ids, which will be accumulated during jump-forward.
# Use the original length of input_ids to calculate the token usage info.
meta_info
=
{
"prompt_tokens"
:
len
(
req
.
input_ids
),
"completion_tokens"
:
len
(
req
.
output_ids
),
"prompt_tokens"
:
req
.
orig_prompt_tokens
,
"completion_tokens"
:
len
(
req
.
input_ids
)
+
len
(
req
.
output_ids
)
-
req
.
orig_prompt_tokens
,
}
if
req
.
return_logprob
:
meta_info
[
"prompt_logprob"
]
=
req
.
logprob
meta_info
[
"token_logprob"
]
=
req
.
token_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