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
OpenDAS
AutoAWQ
Commits
5297eccc
Commit
5297eccc
authored
Sep 08, 2023
by
Casper Hansen
Browse files
More detailed benchmark
parent
341c8868
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
examples/benchmark.py
examples/benchmark.py
+7
-3
No files found.
examples/benchmark.py
View file @
5297eccc
...
...
@@ -47,18 +47,22 @@ def run_round(model_path, quant_file, n_generate, input_ids):
print
(
f
" -- Generating
{
n_generate
}
tokens,
{
len
(
input_ids
)
}
token prompt..."
)
context_time
,
generate_time
=
generate
(
model
,
input_ids
,
n_generate
)
device
=
next
(
model
.
parameters
()).
device
prefill_tokens_per_second
=
n_generate
/
context_time
decode_tokens_per_second
=
n_generate
/
generate_time
memory_used
=
torch
.
cuda
.
max_memory_allocated
(
next
(
model
.
parameters
()).
device
)
/
(
1024
**
2
)
memory_used
=
torch
.
cuda
.
max_memory_allocated
(
device
)
/
(
1024
**
3
)
memory_pct
=
memory_used
/
(
torch
.
cuda
.
get_device_properties
(
device
).
total_memory
/
(
1024
**
3
))
*
100
print
(
f
" ** Speed (Prefill):
{
prefill_tokens_per_second
:.
2
f
}
tokens/second"
)
print
(
f
" ** Speed (Decode):
{
decode_tokens_per_second
:.
2
f
}
tokens/second"
)
print
(
f
" ** Max Memory ():
{
memory_used
:.
2
f
}
GB"
)
print
(
f
" ** Max Memory (
VRAM
):
{
memory_used
:.
2
f
}
GB
(
{
memory_pct
:.
2
f
}
%)
"
)
return
{
"Prefill length"
:
len
(
input_ids
),
"Decode length"
:
n_generate
,
"Prefill tokens/s"
:
prefill_tokens_per_second
,
"Decode tokens/s"
:
decode_tokens_per_second
,
"Memory (VRAM)"
:
memory_used
,
"Memory (VRAM)"
:
f
"
{
memory_used
:.
2
f
}
GB (
{
memory_pct
:.
2
f
}
%)"
,
"GPU"
:
torch
.
cuda
.
get_device_name
()
}
...
...
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