Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/94943
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b0dff0c: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
| def foo(): | ||
| small_buffers = [int8_cuda(MIN_BLOCK_SIZE) for _ in range(11)] | ||
| return small_buffers[5] | ||
| return small_buffers[5].add_(2) |
| gc.collect() | ||
| torch.cuda.empty_cache() | ||
|
|
||
| # TODO: re-enable |
There was a problem hiding this comment.
There is another comment thread that I commented on this about. To enable this we would have to leak Storages as a concept to the allocator, so i'm not sure. Explanation here: #94943 (comment).
There was a problem hiding this comment.
ok, just breadcrumb it in the comment here, so we can find it later
| freed_pointer_set.insert((ptr)); | ||
| } | ||
| // that block has already been freed, | ||
| // so even those this will error, so too will the allcoator |
There was a problem hiding this comment.
- allcoator
- correponding
- even those this
- so too will the allcoator
| // when the corresponding tensor dies because there is no | ||
| // live tensor correponding to it | ||
| TORCH_CHECK( | ||
| ptr_set.size() >= definite_freed_count, |
There was a problem hiding this comment.
Is this a >=, or is it an exact equality test? Why is this an inequality?
There was a problem hiding this comment.
It could be larger in the case that there is a Block which is removed and freed with the same pointer address.
|
|
||
| // returns the pointers freed in the pool | ||
| // and the pointers allocated. Note: a pointer | ||
| // may appear in both freed and allocated |
There was a problem hiding this comment.
So what does it mean if a pointer appears in both freed and allocated? Is it live coming out or not?
There was a problem hiding this comment.
It could be reallocated as a separate size, with a tensor stale that is dead now and a new tensor now live using that address.
There was a problem hiding this comment.
Can I have the opposite situation? A tensor is allocated and then freed internally?
There was a problem hiding this comment.
Yes that is possible. We pass in the stale storages to the api and them swap their deleters with no-ops so they are not freed twice.
| bool succeeded = stale_storage->data_ptr().compare_exchange_deleter( | ||
| t->raw_deleter(), &no_op_delete); | ||
|
|
||
| TORCH_CHECK( |
There was a problem hiding this comment.
So, when can this happen? Is this if I pass garbage tensors to the checkpoint function? If I only ever pass tensors that are allocated out of the pool, the deleter should always be as expected, right? Can we describe the preconditions for the checkpoint tensor list?
There was a problem hiding this comment.
This error means that you had a non-standard deleter fn, and so it's not safe for us to blindly remove it. As the comment in Allocator.h says:
* Compare the deleter in a DataPtr to expected_deleter.
* If it matches, replace the deleter with new_deleter
* and return true; otherwise, does nothing and returns
* false.
*
* In general, it is not safe to unconditionally set the
* deleter on a DataPtr, because you don't know what
* the deleter is, and thus will have a hard time properly
* disposing of the deleter without storing the original
* deleter
zdevito
left a comment
There was a problem hiding this comment.
Looks nice and clean now. Thanks for the changes!
| constexpr size_t kRoundLarge = 2097152; // round up large allocations to 2 MiB | ||
| constexpr size_t kRoundUpPowerOfTwoIntervals = 16; | ||
|
|
||
| void local_raw_delete(void* ptr); |
There was a problem hiding this comment.
nit: don't think this is needed anymore, though it isn't doing any harm to be pre-declared...
| "_cuda_setCheckpointPoolState", | ||
| [](int device, | ||
| std::shared_ptr<c10::cuda::CUDACachingAllocator::AllocatorState> pps) { | ||
| std::shared_ptr<c10::cuda::CUDACachingAllocator::AllocatorState> pps, |
There was a problem hiding this comment.
I think for now this is ok, and when the APIs are all in place we can ask what series of actions can lead to this state and figure out the right guards then.
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. [ghstack-poisoned]
|
@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. Differential Revision: [D43999886](https://our.internmc.facebook.com/intern/diff/D43999886) [ghstack-poisoned]
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. Differential Revision: [D43999886](https://our.internmc.facebook.com/intern/diff/D43999886) [ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. Differential Revision: [D43999886](https://our.internmc.facebook.com/intern/diff/D43999886) Pull Request resolved: pytorch/pytorch#94943 Approved by: https://github.com/zdevito
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die. Differential Revision: [D43999886](https://our.internmc.facebook.com/intern/diff/D43999886) Pull Request resolved: pytorch/pytorch#94943 Approved by: https://github.com/zdevito
|
@eellison Can you look again at the comments in Module.cpp? It has the following typos/mistakes:
|
|
Will accept a pr to fix. |
|
Should we replace |
|
sure, that works. |
Stack from ghstack (oldest at bottom):
We choose to ignore certain blocks that are currently allocated when we set the pool to its checkpoint. For those blocks, we need to swap out the deleter function of their corresponding blocks so that a deallocation is not triggered when they die.
Differential Revision: D43999886