Repository navigation
perf(cuda): one host copy per expert step; the query-input products as one - #28
Merged
Merged
Conversation
…he device in one copy
…uct over stacked weights
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. Two small fusions in the on-device forward pass. Results are unchanged.
What is in it
blockmat.rs:BlockMat::runis split intoencode(checks a job list against its buffers and returns the bytes the kernels read) and an unsafestart(launches from a list already on the device).runisencode, copy,start, as before.ops.rs: the expert step hands the chosen experts' weights and both job lists to the device in one copy into one buffer, where it made three.ops.rs: the four BF16 products that read the query input (queries, output gate, relative-position vectors, sinks) are one product over weights stacked in one device buffer; its result is cut into four runs.Measured on a GB10, real Inkling 2 Mini, greedy, 90 tokens
About a millisecond between them. The single-position path has small returns from here; the larger step is several positions per sweep, which comes next.
How it was checked
cargo test --release -p dluth-cudawith the real checkpoint, 50 tests; the golden figures are the same as before the change (real model 96 of 96 tokens, largest difference 0.00005). Format check and lint clean across the workspace.# needs: gpu), each applied in turn on the GB10 and seen to fail: 89 regenerated after the code moved; 92 (the output gate cut from the wrong part of the stacked product) and 93 (the experts' second matrices started with the first matrices' job list) are new.Review
The qwen reviewer approved with nits and no must-fix: it traced the list offsets and their 8-byte alignment, the cut offsets of the stacked product, and that the results are the same as before. Made:
startchecks the list's address, the job count and the grid size itself, so the unsafe seam does not rely on its two callers for those.Its open questions hold: a job is 88 bytes, a multiple of 8;
stackedhas two call sites, both in this diff; every expert step follows the fetch of the router's scores, which waits for the device.