INNER CODE UNIT · Python

gap

FareedKhan-dev/kimi-k3-in-c · tools/cmp_logits.py:113

        gap = abs(float(r[ra]) - float(r[ca])) / max(abs(float(r[ra])), 1e-30)
        print("argmax differs; reference gap between the two candidates: %.3e relative"
              % gap)
    print()
    if ok_tok and ok_num:
        print("VERIFIED: the C engine's logits match the torch reference over the FULL "
              "93-layer stack on the real checkpoint, elementwise, and the argmax token "
              "agrees. Composition, the AttnRes aggregator, the final norm and the "
              "lm_head are all correct.")
        return 0
    if not ok_tok:
        print("TOKEN MISMATCH: C would emit %d, the reference would emit %d" % (ca, ra))
    if not ok_num:
        print("NUMERIC MISMATCH: relative error %.3e exceeds the %.1e budget" % (rel, budget))
        i = int(np.argmax(d))
        print("  worst at index %d: C=%.9g reference=%.9g" % (i, c[i], r[i]))
    return 1

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…