MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / gen_slopes

Function gen_slopes

inference/models/mpt.py:22–29  ·  view source on GitHub ↗
(n_heads, alibi_bias_max=8)

Source from the content-addressed store, hash-verified

20
21
22def gen_slopes(n_heads, alibi_bias_max=8):
23 _n_heads = 2 ** math.ceil(math.log2(n_heads))
24 m = torch.arange(1, _n_heads + 1, dtype=torch.float32)
25 m = m.mul(alibi_bias_max / _n_heads)
26 slopes = 1.0 / torch.pow(2, m)
27 if _n_heads != n_heads:
28 slopes = torch.concat([slopes[1::2], slopes[::2]])[:n_heads]
29 return slopes.view(1, n_heads, 1, 1)
30
31
32def build_alibi_bias(

Callers 1

build_alibi_biasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected