Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/MojoLlama/blob/main/src/mojollama/bench_gpt.py # MojoLlama Archived Mojo/MAX quantizer and serving research repository (read-only history) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `MojoLlama / src / mojollama / bench_gpt.py` 34 lines · 945 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Benchmark GPT-OSS-20B Q4_K_M — find path to 65 tok/s.""" 3 import sys, gc, time, numpy as np, os 4 sys.path.insert(0, '/onedev-workspace/work/src/mojollama/kernels') 5 gc.disable() 6 os.environ['OMP_NUM_THREADS'] = '32' 7 from turbo_engine_v7_moe import TurboEngineV7MoE 8 9 engine = TurboEngineV7MoE('/tmp/models/gpt-oss-20b-Q4_K_M.gguf', n_threads=32) 10 11 for i in range(10): engine.forward(i) 12 13 ts = [] 14 for i in range(50): 15 t0 = time.perf_counter() 16 y = engine.forward(i + 30) 17 ts.append(time.perf_counter() - t0) 18 19 avg = np.mean(ts[5:]) 20 best = min(ts[5:]) 21 s = sorted(ts[5:]) 22 p50 = s[len(s)//2] 23 p95 = s[int(len(s)*0.95)] 24 25 print(f'Avg: {1/avg:.1f} tok/s ({avg*1000:.2f}ms)') 26 print(f'Best: {1/best:.1f} tok/s') 27 print(f'p50: {1/p50:.1f} p95: {1/p95:.1f}') 28 print(f'Std: {np.std(ts[5:])*1000:.2f}ms') 29 30 # Show individual times 31 for i, t in enumerate(ts): 32 if i >= 5: 33 print(f' tok {i+30}: {t*1000:.2f}ms') 34 gc.enable()