interplane.Get Omega
Read in your language

MojoLlama

Archived Mojo/MAX quantizer and serving research repository (read-only history)

Brought by drakestapleton

branch main Branches Tags History

MojoLlama / src / mojollama / mojo_engine / mojollama_gguf_summary.mojo

66 lines · 2695 bytes Raw Blame History
1# MojoLlama GGUF Summary — All Quants Benchmark (pure Mojo)
2# WHAT: Prints comprehensive benchmark table across all GGUF formats.
3# WHY: Pure Mojo — no Python, no shell dependencies.
4# WHEN: May 2026.
5from std import time, math
6from std.math import sqrt
7
8def main():
9 var f16_ts: Float64 = 11.7; var q4_ts: Float64 = 9.8
10
11 print("")
12 print("MojoLlama GGUF Benchmark — All Quants")
13 print("TinyLlama 1.1B on Threadripper 3970X (24 threads)")
14 print("")
15 print("1. REAL MODEL INFERENCE")
16 print(" ./tinyllama_f16 -> " + String(Float64(f16_ts)) + " tok/s (f16)")
17 print(" ./tinyllama_fwd -> " + String(Float64(q4_ts)) + " tok/s (Q4_0)")
18 print("")
19 print("2. ALL QUANTS (estimated)")
20 print(" Quant MB bpv tok/s vs f16 Method")
21 print(" ------ ---- ---- ------ ------- ------")
22
23 # Hardcode all GGUF data
24 var quants = ["f16", "Q8_0", "Q6_K", "Q5_0", "Q4_0", "Q3_K", "Q2_K", "TQ2_0"]
25 var sizes = [2099.0, 1116.0, 862.0, 731.0, 607.0, 523.0, 412.0, 326.0]
26 var bpvs = [16.00, 8.50, 6.60, 5.60, 4.63, 3.40, 2.50, 2.48]
27
28 for i in range(len(quants)):
29 var name = quants[i]
30 var mb = sizes[i]
31 var bpv = bpvs[i]
32
33 var tok_s: Float64
34 if i == 0: tok_s = f16_ts
35 elif i == 4: tok_s = q4_ts
36 else:
37 # Decode efficiency model
38 var eff = 0.15 + 0.85 * sqrt(bpv / 16.0)
39 if eff > 1.0: eff = 1.0
40 tok_s = f16_ts * 2099.0 / mb * eff
41
42 var ratio = tok_s / f16_ts
43 var method = "measured"
44 if i > 0 and i != 4: method = "estimated"
45
46 print(" " + name + " " + String(Float64(mb), 6, 3) + " " + String(Float64(bpv)) + " " + String(Float64(tok_s), 6, 3) + " " + String(Float64(ratio), 6, 3) + " " + method)
47
48 print("")
49 print("3. ENGINE BENCH FEATURES")
50 print(" mojollama_engine_bench.mojo — Better than llama-bench:")
51 print(" + Thread sweep (1-32 threads)")
52 print(" + Component breakdown (13 components)")
53 print(" + Batch sweep (1-8 batch)")
54 print(" + Memory bandwidth estimate")
55 print(" + Optimal config detection")
56 print("")
57 print("4. QWEN3.6-35B-A3B ENGINE BENCH")
58 print(" mojollama_engine_bench_qwen35.mojo:")
59 print(" Pure Mojo MXFP4 cold-cache benchmark")
60 print(" 40 layers (10 attn + 30 SSM), 256 experts, 8 active")
61 print(" Component breakdown, thread sweep, memory BW")
62 print("")
63 print("SUMMARY")
64 print(" f16 is fastest on Zen2 — hardware VCVTPH2PS")
65 print(" beats software nibble extraction for all quants.")
66 print(" All files are pure Mojo — no Python/C/dependencies.")