processor#
Module Contents#
Provide more flexible distributed tensor communication functions based on |
- class PackageProcessor#
Bases:
object
Provide more flexible distributed tensor communication functions based on
torch.distributed.send()
andtorch.distributed.recv()
.PackageProcessor
defines the details of point-to-point package communication.EVERYTHING is
torch.Tensor
in FedLab.- static send_package(package, dst)#
Three-segment tensor communication pattern based on
torch.distributed
- Pattern is shown as follows:
1.1 sender: send a header tensor containing
slice_size
to receiver1.2 receiver: receive the header, and get the value of
slice_size
and create a buffer for incoming slices of content2.1 sender: send a list of slices indicating the size of every content size.
2.2 receiver: receive the slices list.
3.1 sender: send a content tensor composed of a list of tensors.
3.2 receiver: receive the content tensor, and parse it to obtain slices list using parser function
- static recv_package(src=None)#
Three-segment tensor communication pattern based on
torch.distributed
- Pattern is shown as follows:
1.1 sender: send a header tensor containing
slice_size
to receiver1.2 receiver: receive the header, and get the value of
slice_size
and create a buffer for incoming slices of content2.1 sender: send a list of slices indicating the size of every content size.
2.2 receiver: receive the slices list.
3.1 sender: send a content tensor composed of a list of tensors.
3.2 receiver: receive the content tensor, and parse it to obtain slices list using parser function