INNER CODE UNIT · Python
d
FareedKhan-dev/kimi-k3-in-c · tools/cmp_logits.py:85
d = np.abs(c.astype(np.float64) - r.astype(np.float64))
scale = max(float(np.abs(r).max()), 1e-30)
rel = float(d.max()) / scale
budget = 1.2e-7 * np.sqrt(hidden) * 50
ca, ra = int(np.argmax(c)), int(np.argmax(r))
# Rank correlation on the top of the distribution is the property that actually
# decides generated text, so report it separately from the raw elementwise diff.
ctop = set(np.argsort(-c)[:10].tolist())
rtop = set(np.argsort(-r)[:10].tolist())
print("vocab : %d" % c.size)
print("C argmax : %d (logit %.6f)" % (ca, c[ca]))
print("reference argmax : %d (logit %.6f)" % (ra, r[ra]))
print("top-10 overlap : %d/10" % len(ctop & rtop))
print("max |diff| : %.6e" % float(d.max()))
print("relative to max|ref| : %.6e (budget %.1e)" % (rel, budget))
print("mean |diff| : %.6e" % float(d.mean()))