interplane.Get Omega
Read in your language

gpu-head-to-head

aien-dev/gpu-head-to-head

Brought by drakestapleton

branch main Branches Tags History

gpu-head-to-head / bench / make_ttft_prompts.py

51 lines · 2351 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Generate prompts/ttft.jsonl (PROTOCOL.md A10 TTFT rows) from pinned source texts; stdlib only.
3
4usage: bench/make_ttft_prompts.py LONG2048 LONG8192 LONG32768 LONG256 OUT
5
6The sources are the PrefillGate long prompts (sovereign evidence/merge-train/l369/long-{2048,8192,256}.txt
7@ b129e1ea) and the DRA-85 32k prompt (long-8192 x3 + long-2048 x3 + long-256 x2). Every source is
8checked against the sha256 below before anything is written; a mismatch exits 2 and writes nothing.
9Token counts depend on each server's tokenizer and chat template, so none is claimed here: the run
10records usage.prompt_tokens for every request.
11"""
12import hashlib
13import json
14import sys
15
16SOURCES = { # id -> (argv index, sha256 of the source file)
17 "t2k": (1, "26a44c508412e213de876eb54bb90390426b086c887a68b90fa78f7470425ee3"),
18 "t8k": (2, "2bcc84b25c418cba83df9546344fd4ae28962c314e03defe2aab62a8e6c8abb9"),
19 "t32k": (3, "791ef12bc33c74cb23f3318e1543def0a07e6008aa38e8d815381687dd5098b2"),
20 "turn2-new": (4, "153a5f88932393b2be56fd81f8914d44218169c614ebc5b2753069c9a09bc3a1"),
21}
22# The assistant turn between the primed 32k user turn and the new 1k user turn. It is a fixed text,
23# not the model's own reply, so the second request is byte-identical across arms.
24TURN2_ASSISTANT = "I have read the whole document above and I am ready for your question about it."
25TURN2_NEW_REPEAT = 4 # four copies of the 256-token PrefillGate text: about 1k new tokens
26
27
28def main(argv):
29 if len(argv) != 6:
30 print(__doc__.strip().splitlines()[2], file=sys.stderr)
31 return 2
32 rows = []
33 for pid, (i, want) in SOURCES.items():
34 data = open(argv[i], "rb").read()
35 got = hashlib.sha256(data).hexdigest()
36 if got != want:
37 print("%s: %s sha256 %s is not %s" % (pid, argv[i], got, want), file=sys.stderr)
38 return 2
39 text = data.decode("utf-8")
40 if pid == "turn2-new":
41 text = "\n".join([text.rstrip("\n")] * TURN2_NEW_REPEAT) + "\n"
42 rows.append({"id": pid, "text": text, "source_sha256": want})
43 rows.append({"id": "turn2-assistant", "text": TURN2_ASSISTANT, "source_sha256": None})
44 with open(argv[5], "w") as f:
45 for r in rows:
46 f.write(json.dumps(r) + "\n")
47 return 0
48
49
50if __name__ == "__main__":
51 sys.exit(main(sys.argv))