MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / _split

Function _split

DeepSpeedExample/megatron/mpu/mappings.py:35–51  ·  view source on GitHub ↗

Split the tensor along its last dimension and keep the corresponding slice.

(input_)

Source from the content-addressed store, hash-verified

33
34
35def _split(input_):
36 """Split the tensor along its last dimension and keep the
37 corresponding slice."""
38
39 world_size = get_model_parallel_world_size()
40 # Bypass the function if we are using only 1 GPU.
41 if world_size==1:
42 return input_
43
44 # Split along last dimension.
45 input_list = split_tensor_along_last_dim(input_, world_size)
46
47 # Note: torch.split does not create contiguous tensors by default.
48 rank = get_model_parallel_rank()
49 output = input_list[rank].contiguous()
50
51 return output
52
53
54def _gather(input_):

Callers 3

symbolicMethod · 0.70
forwardMethod · 0.70
backwardMethod · 0.70

Calls 3

get_model_parallel_rankFunction · 0.70

Tested by

no test coverage detected