MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / detect_nan_hook

Function detect_nan_hook

training/run.py:84–88  ·  view source on GitHub ↗
(grad, name)

Source from the content-addressed store, hash-verified

82 )
83
84 def detect_nan_hook(grad, name):
85 if torch.isnan(grad).any():
86 print(f"NaN detected in gradients of {name}!")
87 print(f"Gradient values: {grad}")
88 exit()
89
90 # 注册钩子到每个参数
91 for name, param in model.named_parameters():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected