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
c4447dab
Commit
c4447dab
authored
May 08, 2023
by
Benjamin Fattori
Browse files
clean up cumul batches for rolling + remove unused print
parent
e6492441
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+4
-6
No files found.
lm_eval/models/gpt2.py
View file @
c4447dab
...
...
@@ -159,9 +159,9 @@ class HFLM(LM):
extra_pad
=
[]
numpad_batches
=
0
# balance token batches among iterators
if
self
.
world_size
>
1
:
cumulative_batches
=
0
cumulative_batches
=
0
# balance token batches among iterators
# compute cumlative batches once -> could also just cache this can then use it later
for
(
string
,)
in
tqdm
([
req
.
args
for
req
in
requests
],
disable
=
(
self
.
rank
!=
0
)):
rolling_token_windows
=
list
(
...
...
@@ -179,15 +179,13 @@ class HFLM(LM):
rolling_token_windows
=
[(
None
,)
+
x
for
x
in
rolling_token_windows
]
cumulative_batches
+=
len
(
rolling_token_windows
)
cum_batches_ranks
=
torch
.
tensor
(
cumulative_batches
,
device
=
self
.
device
)
gathered_item
=
self
.
accelerator
.
gather
(
cum_batches_ranks
).
cpu
().
detach
().
numpy
().
tolist
()
cum
ul
_batches_ranks
=
torch
.
tensor
(
cumulative_batches
,
device
=
self
.
device
)
gathered_item
=
self
.
accelerator
.
gather
(
cum
ul
_batches_ranks
).
cpu
().
detach
().
numpy
().
tolist
()
# compute number of pseudobatches to pad with (FSDP/DDP require even batches among ranks)
numpad_batches
=
max
(
gathered_item
)
-
gathered_item
[
self
.
rank
]
extra_pad
=
[(
'pad'
,)]
if
numpad_batches
>
0
else
[]
print
(
self
.
rank
,
numpad_batches
)
loglikelihoods
=
[]
for
(
string
,)
in
tqdm
(
extra_pad
+
[
req
.
args
for
req
in
requests
],
disable
=
(
self
.
rank
!=
0
)):
if
numpad_batches
>
0
:
...
...
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