"...text-generation-inference.git" did not exist on "09674e6df99918dad5169b5cc81241c884c543d0"
Commit 7a219aa9 authored by Deyu Fu's avatar Deyu Fu
Browse files

fix novograd init overflow

parent c8f9cceb
......@@ -131,10 +131,10 @@ class FusedNovoGrad(torch.optim.Optimizer):
group['exp_avg_sq'][1] = torch.cuda.FloatTensor(len(g_32)).contiguous().fill_(0)
else: # init with first step norm, so first blend have no effect
if group['norm_type'] == 0:
v_16 = [torch.max(torch.abs(g)).item() for g in g_16]
v_16 = [torch.max(torch.abs(g.to(torch.float32))).item() for g in g_16]
v_32 = [torch.max(torch.abs(g)).item() for g in g_32]
elif group['norm_type'] == 2:
v_16 = [torch.sum(torch.pow(g, 2)).sqrt().item() for g in g_16]
v_16 = [torch.sum(torch.pow(g.to(torch.float32), 2)).sqrt().item() for g in g_16]
v_32 = [torch.sum(torch.pow(g, 2)).sqrt().item() for g in g_32]
else:
raise RuntimeError('FusedNovoGrad only support l2/inf norm now.')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment