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/test_gen.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 / test_gen.py` 35 lines ยท 910 bytes Raw Blame History 1 """Test generation pipeline.""" 2 import sys, time, gc 3 sys.path.insert(0, 'src') 4 import numpy as np 5 from mojollama.model.inference import load_model 6 7 model = load_model('test_model.gguf') 8 ids = model.encode('Hello') 9 10 t0 = time.time() 11 logits = model.forward(ids) 12 print(f'Forward 1: {time.time()-t0:.1f}s') 13 top = int(np.argmax(logits[-1])) 14 print(f'Top token: {top}={model.decode([top])!r}') 15 16 ids.append(top) 17 gc.collect() 18 t0 = time.time() 19 logits2 = model.forward(ids) 20 print(f'Forward 2: {time.time()-t0:.1f}s') 21 top2 = int(np.argmax(logits2[-1])) 22 print(f'Top token: {top2}={model.decode([top2])!r}') 23 24 ids.append(top2) 25 gc.collect() 26 t0 = time.time() 27 logits3 = model.forward(ids) 28 print(f'Forward 3: {time.time()-t0:.1f}s') 29 30 gc.collect() 31 print('Full generation:') 32 t0 = time.time() 33 result = model.generate('The capital of France is', max_tokens=5) 34 print(f'Generate: {time.time()-t0:.1f}s') 35 print('Result:', repr(result))