MCPcopy Index your code
hub / github.com/pytorch/pytorch / _Broadcast

Function _Broadcast

caffe2/python/data_parallel_model.py:1009–1037  ·  view source on GitHub ↗
(devices, model, net, param, use_nccl=False)

Source from the content-addressed store, hash-verified

1007
1008
1009def _Broadcast(devices, model, net, param, use_nccl=False):
1010 # Copy params from gpu_0 to other
1011 master_dev = devices[0]
1012
1013 if use_nccl:
1014 if _IsGPUBlob(model, param):
1015 master_device_opt = core.DeviceOption(model._device_type, master_dev)
1016 with core.DeviceScope(master_device_opt):
1017 # Note that the root is the root _rank_ and not the root
1018 # _device_. Thus we always use root=0, regardless of the
1019 # devices used.
1020 net.NCCLBroadcast(
1021 list(model._device_grouped_blobs[param].values()),
1022 list(model._device_grouped_blobs[param].values()),
1023 root=0,
1024 )
1025 return
1026
1027 for dev_idx in devices[1:]:
1028 if _IsGPUBlob(model, param):
1029 device_opt = core.DeviceOption(workspace.GpuDeviceType, dev_idx)
1030 else:
1031 device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0) if _IsIDEEPBlob(model, param) else \
1032 core.DeviceOption(caffe2_pb2.CPU, 0)
1033 with core.DeviceScope(device_opt):
1034 net.Copy(
1035 model._device_grouped_blobs[param][master_dev],
1036 model._device_grouped_blobs[param][dev_idx]
1037 )
1038
1039
1040def _AllReduce(devices, model, net, param, use_nccl=False, control_input=None):

Callers 6

_AllReduceFunction · 0.70
_SyncAllParamsSingleHostFunction · 0.70

Calls 4

_IsGPUBlobFunction · 0.85
listFunction · 0.85
_IsIDEEPBlobFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…