Batch eval generation across turns via --eval_batch_size#62
Open
TonyChen06 wants to merge 1 commit into
Open
Conversation
The evaluator generated one turn at a time: for every sample it looped over response ranges and called generate() per turn with batch size 1. Restructure into two phases: flatten_eval_turns expands every (sample, turn) pair into a flat work item (prefix ids, masked signal indices, per-sample encoder outputs, ground truth), then generation runs over chunks of --eval_batch_size turns, left-padded to the chunk max with signal indices shifted per item. Results are reassembled in the original order before the (unchanged) metric computation. --eval_batch_size defaults to 1, which preserves today's behavior exactly: same generate() calls in the same order, verified on a real eval (277 turn pairs, sampling on): 277/277 generations and all metrics identical to main. With batching, greedy decoding at eval_batch_size=4 reproduces 75-77% of eval_batch_size=1 generations exactly (signal and rgb configs, untrained connector); the remainder differ through bfloat16 batched kernels reaching different logit argmaxes on near-ties. Aggregate metrics agree to the third decimal. index_nested now returns the squeezed per-sample entry; its only caller is the new flatten step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third piece of splitting up #12 into simpler PRs — the batched-generation core, rewritten against current main (the original predates the thinking-split metrics, pretrain breakdown,
max_new_tokensplumbing, and the current ELM names, so a rebase would have resurrected stale behavior).What
The evaluator generated one turn at a time: per sample, per response range, one
generate()call at batch size 1. This restructuresevaluate()into two phases:flatten_eval_turns— expands every (sample, turn) pair into a flat work item: prefix ids/mask, per-turn maskedsignal_id_indices, per-sample encoder outputs, ground truth. Same logic as the previous inner loop, run once up front.--eval_batch_sizeturns, left-padded to the chunk max (collate_turns), signal indices shifted per item, onegenerate()per chunk. Results are re-assembled in original order before the unchanged metric tail.--eval_batch_sizedefaults to 1, which preserves current behavior exactly — samegenerate()calls, same RNG consumption order.Verification (real eval: qwen2.5-0.5b + patch_elf, ECG-QA PTB-XL subset, 277 turn pairs from 55 multi-turn samples)
--eval_batch_size 8for the 277-turn eval, including model load.Full determinism across batch sizes (the fp64 variant of #12) is intentionally out of scope, per review feedback there.