未验证 提交 6b6d4090 编写于 作者: Z zhaoyingli 提交者: GitHub

update recompute tunint unittest support other devices (#55165)

上级 d6a899ff
...@@ -36,7 +36,7 @@ def generate_model(): ...@@ -36,7 +36,7 @@ def generate_model():
gpt = GPTModel( gpt = GPTModel(
vocab_size=50304, vocab_size=50304,
hidden_size=1024, hidden_size=1024,
num_hidden_layers=14, num_hidden_layers=13,
num_attention_heads=16, num_attention_heads=16,
intermediate_size=1024 * 4, intermediate_size=1024 * 4,
hidden_act="gelu", hidden_act="gelu",
...@@ -95,14 +95,25 @@ class TestRecomputePassTuning(unittest.TestCase): ...@@ -95,14 +95,25 @@ class TestRecomputePassTuning(unittest.TestCase):
engine = auto.Engine(model, loss, opt, strategy=strategy) engine = auto.Engine(model, loss, opt, strategy=strategy)
engine._tune(self.dataset, 3, batch_size=self.batch_size) engine._tune(self.dataset, 3, batch_size=self.batch_size)
assert ( gpu_memory_size = round(
len( paddle.device.cuda.get_device_properties(0).total_memory
engine._dist_contexts[ / 1024
'train' / 1024
].strategy.recompute.no_recompute_segments / 1024
)
> 0
) )
dist_strategy = engine._dist_contexts['train'].strategy
if gpu_memory_size in [16, 32]:
self.assertGreater(
len(dist_strategy.recompute.no_recompute_segments),
0,
"When GPU memory size is 16G or 32G, the length of no_recompute_segments should be greater than 0.",
)
elif gpu_memory_size >= 40:
self.assertEqual(
dist_strategy.recompute.enable,
False,
"When GPU memory size is greater than 40GB, the recompute strategy should be disable.",
)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册