Skip to content

Let grad ckpt apply opt-barrier to all params and buffers#7206

Merged
alanwaketan merged 5 commits intomasterfrom
alanwaketan/grad_ckpt
Jun 6, 2024
Merged

Let grad ckpt apply opt-barrier to all params and buffers#7206
alanwaketan merged 5 commits intomasterfrom
alanwaketan/grad_ckpt

Conversation

@alanwaketan
Copy link
Copy Markdown
Collaborator

Summary:
Let grad ckpt apply opt-barrier to all params and buffers.

Test Plan:
python test/test_operations.py -v -k test_opt_barrier

@alanwaketan alanwaketan requested a review from JackCaoG June 5, 2024 23:38
@alanwaketan alanwaketan self-assigned this Jun 5, 2024
Comment thread test/test_operations.py
output = torch.sum(output)
output.backward()

hlo = torch_xla._XLAC._get_xla_tensors_hlo([model.x.weight.grad])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't your change include the weight and buffer, but the test seems to try to test the HLO of the weight.grad

Copy link
Copy Markdown
Collaborator Author

@alanwaketan alanwaketan Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the way to get the full hlo. As long as the opt-barrier contains all tensors, it's fine.

@alanwaketan
Copy link
Copy Markdown
Collaborator Author

Thanks, Jack.

@alanwaketan alanwaketan force-pushed the alanwaketan/grad_ckpt branch from 1cfb469 to b287944 Compare June 6, 2024 03:24
Comment thread test/test_operations.py
self.assertEqual(opt_barrier.count("f32[128,128]"), 6)
self.assertEqual(opt_barrier.count("f32[128]"), 2)
self.assertEqual(opt_barrier.count("f32[64,64]"), 2)
# Somehow the CPU/GPU CI will not have the opt-barrier.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehh this is weird... I can look into this tmr...

@alanwaketan
Copy link
Copy Markdown
Collaborator Author

Skip the GPU CI to move fast.

@alanwaketan alanwaketan merged commit aec2730 into master Jun 6, 2024
@alanwaketan alanwaketan deleted the alanwaketan/grad_ckpt branch June 6, 2024 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants