MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / check_using_norm

Method check_using_norm

deepspeed/runtime/utils.py:259–276  ·  view source on GitHub ↗
(self, norm_group, reduce_overflow=True)

Source from the content-addressed store, hash-verified

257 self.has_moe_params = True
258
259 def check_using_norm(self, norm_group, reduce_overflow=True):
260 # TODO: I don't think reduce_overflow is needed if mpu is None
261 overflow = any(is_invalid_grad_norm(norm) for norm in norm_group)
262 overflow_gpu = get_accelerator().FloatTensor([overflow])
263 if self.has_moe_params:
264 # In this case, we need to do an all_reduce across
265 # the expert_parallel_group, so that if there was
266 # an overflow due to expert weights, we detect it
267
268 # Only need to check groups.get_largest_expert_parallel_group()
269 dist.all_reduce(overflow_gpu, op=dist.ReduceOp.MAX, group=groups._get_max_expert_parallel_group())
270 if self.mpu is not None:
271 dist.all_reduce(overflow_gpu, op=dist.ReduceOp.MAX, group=self.mpu.get_model_parallel_group())
272 elif reduce_overflow:
273 dist.all_reduce(overflow_gpu, op=dist.ReduceOp.MAX)
274 dist.barrier()
275 overflow = overflow_gpu[0].item()
276 return bool(overflow)
277
278 def check(self, param_groups=None):
279 params = []

Callers 4

testMethod · 0.95
step_fused_adamMethod · 0.80
step_fused_lambMethod · 0.80

Calls 6

get_acceleratorFunction · 0.90
is_invalid_grad_normFunction · 0.85
FloatTensorMethod · 0.45
all_reduceMethod · 0.45
barrierMethod · 0.45