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
09deb20d
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "e4c356d3f62158936d8031a74a8793d5162f7bb4"
Unverified
Commit
09deb20d
authored
May 11, 2024
by
Lianmin Zheng
Committed by
GitHub
May 11, 2024
Browse files
Optimize the memory usage of logits processor (#420)
parent
33b242df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
python/sglang/srt/layers/logits_processor.py
python/sglang/srt/layers/logits_processor.py
+3
-1
python/sglang/srt/managers/router/model_rpc.py
python/sglang/srt/managers/router/model_rpc.py
+1
-1
No files found.
python/sglang/srt/layers/logits_processor.py
View file @
09deb20d
...
@@ -98,7 +98,9 @@ class LogitsProcessor(nn.Module):
...
@@ -98,7 +98,9 @@ class LogitsProcessor(nn.Module):
all_logits
=
tensor_model_parallel_all_gather
(
all_logits
)
all_logits
=
tensor_model_parallel_all_gather
(
all_logits
)
all_logits
=
all_logits
[:,
:
self
.
config
.
vocab_size
]
all_logits
=
all_logits
[:,
:
self
.
config
.
vocab_size
]
all_logprobs
=
torch
.
log
(
torch
.
softmax
(
all_logits
.
float
(),
dim
=-
1
)
+
1e-6
)
all_logprobs
=
all_logits
.
float
()
all_logits
=
None
all_logprobs
[:]
=
torch
.
nn
.
functional
.
log_softmax
(
all_logprobs
,
dim
=-
1
)
prefill_top_logprobs
,
decode_top_logprobs
=
self
.
_get_top_logprobs
(
prefill_top_logprobs
,
decode_top_logprobs
=
self
.
_get_top_logprobs
(
all_logprobs
,
input_metadata
all_logprobs
,
input_metadata
...
...
python/sglang/srt/managers/router/model_rpc.py
View file @
09deb20d
...
@@ -589,7 +589,7 @@ class ModelRpcServer:
...
@@ -589,7 +589,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
.
finish_reason
,
"finish_reason"
:
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