Repository navigation
feat(cuda): several positions per sweep of the weights on the device - #30
Merged
Merged
Conversation
…tive positions in one launch
…eft stale regenerated; docs: note 22
…the ring are refused; each position's expert count is checked; 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, second step of the batch dimension. Every kernel of the device model takes a batch of up to 16 consecutive positions in one launch, so a sweep through the model over 16 positions starts about as many kernels, and waits for the device as often, as a sweep over one.
What is in it
kernels/attention.cu,small_ops.cu,expert_ops.cu: every kernel gains the position within the batch. New:store_rows(a batch's keys or values into their rows of a history, wrapping),ring_store(a batch's last tokens into a convolution's memory),vec_copy.window + 15rows, so that the last position of a batch does not take a row the first can still see.ring_storeruns afterwards. A batch of one behaves as before.ops.rs:DeviceVecis a batch; the stacked products are one product for one position and one per matrix for a batch.examples/generate.rsreads the text again in batches of 1 to 16 after generating, and prints what a batch costs.Measured (Inkling 2 Mini on the GB10)
Reading 160 tokens without scoring them:
Generation one token at a time: 24.5 tokens per second, against 24.6 to 24.7 for the code before on the same prompt (three runs each).
How it was checked
dluth-cudatests with the real checkpoint. Mac: format check, clippy, 216 tests.Review
The qwen reviewer asked for changes. It traced the views, the scratch stride, the sink's place, row wrapping, the convolution memories, the expert grouping, the launch order and the argument lists of all 13 changed kernels, and found them correct. Its must-fix was a doc line:
attendgave the sizes of the relative vectors and sinks per head where they are per query and head.Made: that line; taps that overlap a convolution's memory are refused (with a test); each position's number of chosen experts is compared with the configured number.
Declined: "the number of vectors may not be a multiple of the heads" in
head_scale_clip. The check that the floats are a multiple ofheads * dimalready makes it one.