Upstream's bench/results/ (23 MB, one directory per community machine) and the fork's bench/unbiased/ run directories (57 MB: step 6 to 9, 13, the 4090 run, the correctness record) are removed. A result from one machine is a record, not source; the numbers that matter are in README.md "Measured", and the directories stay in history at7551f138(git checkout7551f138-- bench/unbiased bench/results). bench/ keeps bench_vs_llama.py with its corpus, the kernel probes, and bench/correctness/, the step-12 teacher-forced harness moved from bench/unbiased/correctness/scripts/ without its per-campaign chain-*.sh glue (it writes under ~/us2-results/, not in the tree). README, UPSTREAM.md, PLAN.md, docs/MODEL-FILES.md and docs/CORRECTNESS-PLAN.md point at the history commit where they cited the directories. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
46 lines
2.7 KiB
Python
46 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Step 12 inputs (CORRECTNESS-PLAN.md 3.2). Writes inputs/<set>/<seq>.prompt.ids (comma-separated token ids) and, for
|
|
the real-text set, .answer.ids. Tokenizer: llama-tokenize from the reference build on the Qwen3.6 file (Flash-Next's
|
|
tokenizer gives the same ids: checked on prompt 1, 2026-10-18). Chat prompts use Qwen's ChatML; thinking off = empty
|
|
<think> block, as tools/qwen35/parity_prompts.ids."""
|
|
import json, os, pathlib, subprocess, sys
|
|
ROOT = pathlib.Path.home() / 'us2-results/correctness'
|
|
TOK = pathlib.Path.home() / 'llamacpp-ref/build/bin/llama-tokenize'
|
|
MODEL = '/mnt/ds4/unbiased-strata/qwen36/Qwen3.6-35B-A3B-UD-Q3_K_M.gguf'
|
|
SRC = ROOT / 'inputs-src'; OUT = ROOT / 'inputs'
|
|
|
|
def tokenize(text):
|
|
p = SRC / '_tmp.txt'; p.write_text(text)
|
|
r = subprocess.run([str(TOK), '-m', MODEL, '--ids', '--no-bos', '-f', str(p)], capture_output=True, text=True)
|
|
line = [l for l in r.stdout.splitlines() if l.startswith('[')][-1]
|
|
return json.loads(line)
|
|
|
|
def chat(q, think):
|
|
return ('<|im_start|>user\n' + q + '<|im_end|>\n<|im_start|>assistant\n' +
|
|
('<think>\n' if think else '<think>\n\n</think>\n\n'))
|
|
|
|
def write(setname, seq, prompt, answer=None, n_answer=None):
|
|
d = OUT / setname; d.mkdir(parents=True, exist_ok=True)
|
|
(d / f'{seq}.prompt.ids').write_text(','.join(map(str, prompt)) + '\n')
|
|
if answer is not None:
|
|
(d / f'{seq}.answer.ids').write_text(','.join(map(str, answer)) + '\n')
|
|
meta = {'prompt_tokens': len(prompt), 'n_answer': len(answer) if answer else n_answer}
|
|
(d / f'{seq}.json').write_text(json.dumps(meta) + '\n')
|
|
print(setname, seq, meta)
|
|
|
|
# short chat: upstream's 10 prompts, 128 answer tokens
|
|
ref_ids = [list(map(int, l.split(','))) for l in open(pathlib.Path.home() / 'us2-build/tools/qwen35/parity_prompts.ids') if l.strip()]
|
|
for i, q in enumerate(json.load(open(SRC / 'short.json'))):
|
|
ids = tokenize(chat(q, False))
|
|
assert ids == ref_ids[i], (i, ids, ref_ids[i]) # the retokenized prompt must equal upstream's file
|
|
write('short', f'p{i:02d}', ids, n_answer=128)
|
|
# code (thinking off, 400) and reasoning (thinking on, 324)
|
|
write('code', 'lru', tokenize(chat((SRC / 'code.txt').read_text().strip(), False)), n_answer=400)
|
|
write('code', 'puzzle', tokenize(chat((SRC / 'reasoning.txt').read_text().strip(), True)), n_answer=324)
|
|
# long prompts from the repository's docs, 256-token continuation each; real text = last 510 of the 16K document
|
|
doc = tokenize((SRC / 'longdoc.txt').read_text())
|
|
print('longdoc tokens', len(doc)); assert len(doc) >= 31744
|
|
for name, n in (('d4k', 4096), ('d16k', 16384), ('d31k', 31744)):
|
|
write('long', name, doc[:n], n_answer=256)
|
|
write('realtext', 'r16k', doc[:16384 - 510], answer=doc[16384 - 510:16384])
|