Repository navigation
feat(model): the operations take a batch of consecutive positions - #29
Merged
Merged
Conversation
…eding a sequence in batches gives bit for bit what token by token gives
…e batches; a split that covers every token and a refusal at position 0 in the tests; review fixes
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.
Milestone I2, first step of several positions per sweep of the weights. The CPU model's results for one token at a time are unchanged.
A value of the
Opstrait is now a batch: one vector for each of a few consecutive positions, in order. A token at a time is a batch of one. The operations that remember (attentionand the two convolutions) take the positions in order, so a later position of a batch sees the earlier ones exactly as it would if they had been fed before it.What is in it
inkling::Ops:countandrow;embedtakes several tokens;attention's position is that of the batch's first token;scoresreturns one run of scores per position.inkling::CpuOpsloops over the positions. Its value type isCpuVecs, one vector per position.Inkling:forward_tokens(feed a batch, scores for every position),feed(no scores),next_scores(scores after the last token only),set_prompt_batch(how many prompt tokensgenerate_greedyfeeds at once; 1 by default, so nothing changes unless asked).dluth-cuda: the device operations are kept compiling and refuse a batch of more than one token, before anything is computed. Batched kernels come next.Scoring only the last position matters: the output table is the largest matrix of the model, and a prompt's other positions are scored for nobody.
How it was checked
On the CPU a batch is the same arithmetic in the same order as token by token, so the test is equality bit for bit:
DLUTH_INKLING2_MINIset): a recorded prompt of 22 tokens fed at once, and in two uneven batches, scores identically to token by token.tools/mutants.sh cpu: 56 killed, 0 not killed. Planted bugs 94 to 97 are new (every token of a batch given the first token's position; the first position scored where the last was asked for; a batch counted as one token; only a batch's first position checked against the room). Patch 51 regenerated.dluth-cudabuilds and its 51 tests pass with the real checkpoint, including the refusal of a batch.Review
The qwen reviewer asked for changes. It traced the claim (any split, state between tokens, the loop over passes, messages between passes, a refusal leaving state alone) and found nothing wrong with it. Its must-fix was a sentence: the prompt batch setting was documented as giving the same result for any value, which the device operations' refusal in this same change disproves. The doc now says an implementation may refuse batches.
Also made: one split covered 39 of 40 tokens behind a loose assertion; refusals are now also tested at position 0, where an accepted batch would restart the sequence; two doc clauses.