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

Function split_half_float_double_sparse

deepspeed/runtime/engine.py:115–131  ·  view source on GitHub ↗
(tensors)

Source from the content-addressed store, hash-verified

113
114
115def split_half_float_double_sparse(tensors):
116 device_type = get_accelerator().device_name()
117 supported_types = [
118 "torch.{}.HalfTensor".format(device_type), "torch.{}.FloatTensor".format(device_type),
119 "torch.{}.DoubleTensor".format(device_type), "torch.{}.BFloat16Tensor".format(device_type),
120 SparseTensor.type()
121 ]
122
123 for t in tensors:
124 assert t.type() in supported_types, f"attempting to reduce an unsupported grad type: {t.type()}"
125
126 buckets = []
127 for i, dtype in enumerate(supported_types):
128 bucket = [t for t in tensors if t.type() == dtype]
129 if bucket:
130 buckets.append((dtype, bucket))
131 return buckets
132
133
134FORWARD_MICRO_TIMER = 'forward_microstep'

Callers 2

Calls 4

get_acceleratorFunction · 0.90
typeMethod · 0.80
device_nameMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected