Skip to content

Get rid of Storage View, IPC will not preserve storage structure #9447

@ezyang

Description

@ezyang

Storage views are currently used to implement CUDA IPC with the caching allocator. The basic problem is that you can only do IPC with a chunk of memory returned by cudaMalloc, but when you are using the caching CUDA allocator, lots of logically distinct allocations are together on the same cudaMalloc block, and you have no choice but to IPC the whole thing. A storage view was used to implement this situation, since you gave the entire CUDA caching allocator block a storage, and then you had the actual storages be views on this storage.

This is not a good reason to add something as complicated as storage views to PyTorch. So the new plan is this:

  1. When you transfer a CUDA tensor across IPC, its storage/offsets change: instead of being the same storages they were before, you get the entire CUDA allocation storage.
  2. The transferred tensors are non-resizable (this is true in practice today, since resizing would break sharing, but it is even more important after IPC, because a resize could cause you to clobber other allocations)

CC @apaszke, who I flew this plan by previously.

This should fix #5311

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions