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

Function grouped_linear

deepspeed/module_inject/kernel_reference.py:27–40  ·  view source on GitHub ↗

Unified projection: matmul against each weight, optional GLU epilogue. The portable interface's single entry point for all GEMV/GEMM paths (flat single-row, small-batch grouped, large-batch composite). Returns a list of per-weight outputs; the GLU variant folds silu(gate)*up into th

(x, weights, glu_epilogue=False)

Source from the content-addressed store, hash-verified

25
26
27def grouped_linear(x, weights, glu_epilogue=False):
28 """Unified projection: matmul against each weight, optional GLU epilogue.
29
30 The portable interface's single entry point for all GEMV/GEMM paths
31 (flat single-row, small-batch grouped, large-batch composite). Returns
32 a list of per-weight outputs; the GLU variant folds silu(gate)*up into
33 the first output.
34 """
35 outs = [F.linear(x, w) for w in weights]
36 if glu_epilogue:
37 # bf16-native silu: bitwise-equal to HF's activation (the fp32
38 # decomposition rounds differently) and skips its extra casts
39 outs = [F.silu(outs[0]) * outs[1]]
40 return outs
41
42
43def gdn_gates(a, b, a_log, dt_bias):

Callers 3

forwardMethod · 0.90
forwardMethod · 0.90
_dual_weight_glu_forwardFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected