INNER CODE UNIT · Python
main
FareedKhan-dev/kimi-k3-in-c · tools/cmp_logits.py:33
def main():
if len(sys.argv) < 3:
print(__doc__)
return 2
cbin, refp = sys.argv[1], sys.argv[2]
hidden = int(sys.argv[3]) if len(sys.argv) > 3 else 7168
# The first argument is normally k3_run's raw float32 dump, but accepting a
# ref_forward JSON too lets this same comparator score one REFERENCE variant against
# another -- for example an int8 simulation against the bf16 golden vector -- without
# a second, subtly different comparison script.
if cbin.endswith(".json"):
C = json.load(open(cbin))
c = np.array(C["logits_bits"], dtype=np.uint32).view(np.float32)
else:
C = {}
c = np.fromfile(cbin, dtype=np.float32)
R = json.load(open(refp))