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
gaoqiong
lm-evaluation-harness
Commits
0a7720e9
Commit
0a7720e9
authored
Jul 22, 2023
by
Benjamin Fattori
Browse files
multi-device: take minimum computed autobatch over all ranks
parent
f4df3e48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+12
-1
No files found.
lm_eval/models/huggingface.py
View file @
0a7720e9
...
@@ -354,8 +354,19 @@ class HFLM(LM):
...
@@ -354,8 +354,19 @@ class HFLM(LM):
return
batch_size
return
batch_size
batch_size
=
forward_batch
()
batch_size
=
forward_batch
()
utils
.
clear_torch_cache
()
if
self
.
world_size
>
1
:
# if multi-GPU, always take minimum over all selected batch sizes
max_rnk_bs
=
torch
.
tensor
([
batch_size
],
device
=
self
.
device
)
gathered
=
(
self
.
accelerator
.
gather
(
max_rnk_bs
).
cpu
().
detach
().
numpy
().
tolist
()
)
batch_size
=
min
(
gathered
)
utils
.
clear_torch_cache
()
return
batch_size
utils
.
clear_torch_cache
()
return
batch_size
return
batch_size
...
...
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