Repository navigation
feat(cuda): the Inkling model's matrix products on the GPU - #25
Merged
Merged
Conversation
…e Products trait; golden checks on the tiny and the real model
…gram that reports where a token's time goes
…anted bugs for the GPU products
…he device from input to weighted sum; the GPU-against-CPU check uses the measured bar
… the GPU products and the expert-step kernels
…on per product on the GPU side; a refusal for aliased buffers; note states each model's bar; 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. The real Inkling 2 Mini now runs with its matrix products on the GPU and matches the reference.
What is in it
dluth-model(built and tested by CI)Products::expertsbecomesProducts::expert_layer: one request for a layer's chosen experts, covering both matrix products of each, the capped activation between them and the weighted sum. The CPU implementation keeps the same arithmetic in the same order, so CPU results are unchanged.dluth-cuda(needs a GPU; not built by CI)inkling::CudaProductsimplementsProductson a CUDA device. A BF16 product is a round trip (copy the vector in, launch, wait, copy the result out). A layer's experts stay on the device from input to weighted sum: one copy in, four launches, one copy out. Weights are copied to the device the first time a matrix is used.kernels/expert_ops.cu:capped_gate_pairs(the activation) andweighted_sum, with a wrapper that refuses anything outside its buffers.examples/generate.rs: generates text and reports where a token's time goes.Result on a GB10
Speed, greedy, 90 generated tokens: 19.7 tokens per second (the CPU model: 2.6 on an Apple M5 Max).
The products alone would take about 22 ms at the rate the kernels read weights. The rest is the round trips and the CPU; removing them is the next work.
How it was checked
tools/mutants.sh cpu52 killed, 0 not killed (two forward-pass patches regenerated after the expert code moved).cargo test --release -p dluth-cudawith the real checkpoint, 33 tests; format check and lint clean across the workspace.# needs: gpu), each applied in turn on the GB10: its test fails.Review
The qwen reviewer asked for changes. Made:
weighted_sumrefuses one buffer used for two arguments; a test's sanity check now looks at the device's results.Checked and unchanged: the new kernel file is built (the build script compiles every file in
kernels/); a job's vector position is in floats, which is what the code passes; no other implementation of the trait exists.Declined: counting a refused expert stage in the timing counters. A refusal ends the run with an error; the counters are for runs that finish.