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

Function gated_norm

deepspeed/module_inject/kernel_reference.py:93–97  ·  view source on GitHub ↗

GDN z-gated output norm: (weight * rms(x)) * silu(z), weight direct.

(x, z, weight, eps=1e-5)

Source from the content-addressed store, hash-verified

91
92
93def gated_norm(x, z, weight, eps=1e-5):
94 """GDN z-gated output norm: (weight * rms(x)) * silu(z), weight direct."""
95 xf = x.float()
96 xf = xf * torch.rsqrt(xf.pow(2).mean(-1, keepdim=True) + eps)
97 return (xf * weight.float() * torch.nn.functional.silu(z.float())).to(x.dtype)
98
99
100def fused_add_norm(hidden, residual, weight, eps=1e-5):

Callers

nothing calls this directly

Calls 2

meanMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected