Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update recompute tuning unittest support other devices #55165

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions test/auto_parallel/test_tuning_recompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_model():
gpt = GPTModel(
vocab_size=50304,
hidden_size=1024,
num_hidden_layers=14,
num_hidden_layers=13,
num_attention_heads=16,
intermediate_size=1024 * 4,
hidden_act="gelu",
Expand Down Expand Up @@ -95,14 +95,25 @@ def test_recompute_pass(self):
engine = auto.Engine(model, loss, opt, strategy=strategy)
engine._tune(self.dataset, 3, batch_size=self.batch_size)

assert (
len(
engine._dist_contexts[
'train'
].strategy.recompute.no_recompute_segments
)
> 0
gpu_memory_size = round(
paddle.device.cuda.get_device_properties(0).total_memory
/ 1024
/ 1024
/ 1024
)
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__":
Expand Down