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
bfbda62c
"vscode:/vscode.git/clone" did not exist on "0dfd54d11d06eb8363bc7fb3cf9a1f464368caf8"
Unverified
Commit
bfbda62c
authored
Jan 15, 2025
by
Ke Bao
Committed by
GitHub
Jan 15, 2025
Browse files
Add ut for w8a8 int8 quantization (#2897)
parent
b3e99dfb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
test/srt/run_suite.py
test/srt/run_suite.py
+1
-0
test/srt/test_w8a8_quantization.py
test/srt/test_w8a8_quantization.py
+74
-0
No files found.
test/srt/run_suite.py
View file @
bfbda62c
...
...
@@ -47,6 +47,7 @@ suites = {
"test_update_weights_from_tensor.py"
,
"test_vision_chunked_prefill.py"
,
"test_vision_openai_server.py"
,
"test_w8a8_quantization.py"
,
"test_session_control.py"
,
],
"nightly"
:
[
...
...
test/srt/test_w8a8_quantization.py
0 → 100644
View file @
bfbda62c
import
time
import
unittest
from
types
import
SimpleNamespace
import
requests
from
sglang.srt.utils
import
kill_process_tree
from
sglang.test.few_shot_gsm8k
import
run_eval
from
sglang.test.test_utils
import
(
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH
,
DEFAULT_URL_FOR_TEST
,
popen_launch_server
,
)
class
TestW8A8
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
cls
.
model
=
"neuralmagic/Meta-Llama-3-8B-Instruct-quantized.w8a8"
cls
.
base_url
=
DEFAULT_URL_FOR_TEST
cls
.
process
=
popen_launch_server
(
cls
.
model
,
cls
.
base_url
,
timeout
=
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH
,
other_args
=
[
"--quantization"
,
"w8a8_int8"
],
)
@
classmethod
def
tearDownClass
(
cls
):
kill_process_tree
(
cls
.
process
.
pid
)
def
test_gsm8k
(
self
):
args
=
SimpleNamespace
(
num_shots
=
5
,
data_path
=
None
,
num_questions
=
200
,
max_new_tokens
=
512
,
parallel
=
128
,
host
=
"http://127.0.0.1"
,
port
=
int
(
self
.
base_url
.
split
(
":"
)[
-
1
]),
)
metrics
=
run_eval
(
args
)
print
(
metrics
)
self
.
assertGreater
(
metrics
[
"accuracy"
],
0.7
)
def
run_decode
(
self
,
max_new_tokens
):
response
=
requests
.
post
(
self
.
base_url
+
"/generate"
,
json
=
{
"text"
:
"The capital of France is"
,
"sampling_params"
:
{
"temperature"
:
0
,
"max_new_tokens"
:
max_new_tokens
,
},
"ignore_eos"
:
True
,
},
)
return
response
.
json
()
def
test_throughput
(
self
):
max_tokens
=
256
tic
=
time
.
time
()
res
=
self
.
run_decode
(
max_tokens
)
tok
=
time
.
time
()
print
(
res
[
"text"
])
throughput
=
max_tokens
/
(
tok
-
tic
)
print
(
f
"Throughput:
{
throughput
}
tokens/s"
)
assert
throughput
>=
140
if
__name__
==
"__main__"
:
unittest
.
main
()
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