Skip to content

Commit 89ed946

Browse files
pradeepfnamathewc
authored andcommitted
Supporting non-tensor-data write_size in planner write items. (pytorch#149434)
Summary: 1\ The current write item structure does not contain the amount of data that needs to be written. 2\ the planner.item already has a size primitive 'tensor_storage_size'. https://fburl.com/code/7a0gsmw7 But only for tensors. 3\ Right now, the only way the writer layer get hold of this property (fro non tensor data) - first do a lookup in to the actual tensor/bytes - then calculate the nbytes. This change introduce a way to capture non-tensor data size within a write-plan item. Reviewed By: daulet-askarov Differential Revision: D70497442 Pull Request resolved: pytorch#149434 Approved by: https://github.com/MeetVadakkanchery
1 parent 52bb658 commit 89ed946

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

torch/distributed/checkpoint/planner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
__all__ = [
2121
"WriteItemType",
2222
"LoadItemType",
23+
"BytesIOWriteData",
2324
"TensorWriteData",
2425
"WriteItem",
2526
"ReadItem",
@@ -41,6 +42,11 @@ class LoadItemType(Enum):
4142
BYTE_IO = auto()
4243

4344

45+
@dataclass(frozen=True)
46+
class BytesIOWriteData:
47+
nbytes: int
48+
49+
4450
@dataclass(frozen=True)
4551
class TensorWriteData:
4652
chunk: ChunkStorageMetadata
@@ -55,6 +61,9 @@ class WriteItem:
5561
index: MetadataIndex
5662
type: WriteItemType
5763

64+
# Size of bytesIO data to be written.
65+
bytes_io_data: Optional[BytesIOWriteData] = None
66+
5867
# Value present if it's a tensor write
5968
tensor_data: Optional[TensorWriteData] = None
6069

0 commit comments

Comments
 (0)