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/gpu-head-to-head/blob/main/bench/make_prompts.py # gpu-head-to-head aien-dev/gpu-head-to-head 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 `gpu-head-to-head / bench / make_prompts.py` 72 lines ยท 3177 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Generate prompts/decode.jsonl and prompts/prefill.jsonl deterministically. 3 4 Needs the `tokenizers` package (run inside the pinned vLLM container, see bench/README) and the 5 checkpoint's tokenizer.json. Prefill documents are calibrated so that the chat-rendered prompt 6 (Qwen3.6 template, thinking off) lands on the target token count. 7 """ 8 import json 9 import random 10 import sys 11 12 from tokenizers import Tokenizer 13 14 MODEL = sys.argv[1] 15 OUT = sys.argv[2] 16 tok = Tokenizer.from_file(MODEL + "/tokenizer.json") 17 18 TOPICS = [ 19 "the history of the printing press", "how a river delta forms", "the life cycle of a star", 20 "building a wooden boat by hand", "the first transatlantic telegraph cable", 21 "how bees choose a new hive site", "a day in a medieval market town", "the physics of a bicycle", 22 "how glaciers shape valleys", "the invention of the mechanical clock", 23 "a lighthouse keeper's winter", "how coral reefs grow", "the design of Roman aqueducts", 24 "a journey along the Silk Road", "how volcanoes create new islands", "the story of paper money", 25 ] 26 27 28 def chat_len(text): 29 # Qwen3.6 chat template, thinking off: user turn, assistant header, empty think block. 30 rendered = ("<|im_start|>user\n" + text + "<|im_end|>\n<|im_start|>assistant\n" 31 "\n\n\n\n") 32 return len(tok.encode(rendered, add_special_tokens=False).ids) 33 34 35 WORDS = ("river stone light market harbor engine winter garden letter mountain bridge village " 36 "signal window forest copper lantern season voyage archive canal meadow orchard tower " 37 "compass ledger quarry furnace beacon cellar harvest pilgrim chapel mill granary").split() 38 VERBS = "carried crossed watched built opened measured repaired followed recorded traded".split() 39 40 41 def sentence(rng): 42 return "The %s near the %s %s the %s before the %s %s again." % ( 43 rng.choice(WORDS), rng.choice(WORDS), rng.choice(VERBS), rng.choice(WORDS), 44 rng.choice(WORDS), rng.choice(VERBS)) 45 46 47 def document(target, seed): 48 rng = random.Random(seed) 49 question = "\n\nQuestion: in one sentence, what is the document above about?" 50 sents = [] 51 while True: 52 sents.append(sentence(rng)) 53 if chat_len(" ".join(sents) + question) >= target: 54 break 55 # trim back to the closest count not above the target 56 while chat_len(" ".join(sents) + question) > target and len(sents) > 1: 57 sents.pop() 58 text = " ".join(sents) + question 59 return text, chat_len(text) 60 61 62 with open(OUT + "/decode.jsonl", "w") as f: 63 for i, t in enumerate(TOPICS): 64 text = ("Write a long, detailed essay of at least 600 words about %s. " 65 "Use several paragraphs and do not stop early." % t) 66 f.write(json.dumps({"id": "d%02d" % i, "text": text, "chat_tokens": chat_len(text)}) + "\n") 67 68 with open(OUT + "/prefill.jsonl", "w") as f: 69 for name, target in (("p256", 256), ("p512", 512), ("p2k", 2048), ("p8k", 8192)): 70 text, n = document(target, seed=target) 71 f.write(json.dumps({"id": name, "text": text, "chat_tokens": n, "target": target}) + "\n") 72 print(name, target, n, file=sys.stderr)