Resume answer screening with verified paired batching
This commit is contained in:
@@ -155,6 +155,8 @@ def main():
|
||||
parser.add_argument('--out', required=True, type=Path)
|
||||
parser.add_argument('--seconds', default=21600, type=int)
|
||||
parser.add_argument('--batch-prompts', default=2, type=int, choices=(1, 2))
|
||||
parser.add_argument('--execution-batch-prompts', type=int, choices=(1, 2),
|
||||
help='Use a different execution batch on resume after replaying completed rows')
|
||||
parser.add_argument('--preflight', action='store_true')
|
||||
args = parser.parse_args()
|
||||
torch.set_num_threads(1)
|
||||
@@ -193,8 +195,19 @@ def main():
|
||||
rows = json.loads(path.read_text()) if path.exists() else []
|
||||
if [r['id'] for r in rows] != [x['id'] for x in examples[:len(rows)]]:
|
||||
raise ValueError('Existing screen results do not match frozen prompts')
|
||||
for start in range(len(rows), len(examples), args.batch_prompts):
|
||||
rows.extend(evaluate(model, tokenizer, examples[start:start+args.batch_prompts], SCHEDULES))
|
||||
batch = args.execution_batch_prompts or args.batch_prompts
|
||||
if batch != args.batch_prompts:
|
||||
if len(rows) < batch:
|
||||
raise ValueError('The alternate batch requires enough already evaluated prompts for replay')
|
||||
replay = evaluate(model, tokenizer, examples[:batch], SCHEDULES)
|
||||
if replay != rows[:batch]:
|
||||
raise ValueError('Alternate batch changed the first completed token streams')
|
||||
write_json(args.out/'execution-batch-replay.json',
|
||||
{'frozen_sha256': fingerprint(manifest), 'batch_prompts': batch,
|
||||
'matched_rows': [row['id'] for row in replay]})
|
||||
print('validated execution batch', batch, flush=True)
|
||||
for start in range(len(rows), len(examples), batch):
|
||||
rows.extend(evaluate(model, tokenizer, examples[start:start+batch], SCHEDULES))
|
||||
write_json(path, rows)
|
||||
print('screen complete', len(rows), '/', len(examples), flush=True)
|
||||
summary = summarize(rows)
|
||||
|
||||
Reference in New Issue
Block a user