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)
| 25 | |
| 26 | |
| 27 | def 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 | |
| 43 | def gdn_gates(a, b, a_log, dt_bias): |
no outgoing calls
no test coverage detected