Skip to content

Commit c3be5d3

Browse files
Combine Specs (#304)
* Add support for weighted train * Combine attn_mask dropping & data fromat specs Co-authored-by: thomasw21 <[email protected]>
1 parent 43ab0e0 commit c3be5d3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

megatron/model/gpt_model.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,12 @@ def _to_float16(inputs):
254254
# TODO: Change naming of class from GPT to something that encapsulate prefix lm.
255255
self_attn_mask_type=attn_mask_type))
256256

257-
258-
if not hasattr(args, 'attn_mask'):
259-
# We drop attention mask from the pipeline
260-
self.specs.append(lambda x: x[0])
261-
262257
# Undo data format change
263-
self.specs.append(lambda x: x.transpose(0, 1).contiguous())
258+
def undo(x):
259+
if not hasattr(args, 'attn_mask'):
260+
x = x[0]
261+
return x.transpose(0, 1).contiguous()
262+
self.specs.append(undo)
264263

265264
# Final layernorm after transformer layers
266265
self.specs.append(

0 commit comments

Comments
 (0)