Repository navigation
refactor(model): the Inkling forward pass is written against an Ops trait - #26
Merged
Merged
Conversation
…Ops trait; CpuOps is the reference implementation
…o, and the order the convolutions rely on; 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 step that lets the whole forward pass run on a device without a second copy of it. Nothing about the CPU model's results changes.
The forward pass called CPU functions on
Vec<f32>values. It now calls a set of operations on values of a type it does not know:embed,normalize,mix,merge,rmsnorm,attention,attn_conv,expert_conv,add,experts,scores. That is the traitOps. What stays written once is the part that is easiest to get wrong: which layers run how often, what a block is, where a pass starts again, which blend feeds which sublayer, where messages come from.What is in it
inkling::Ops, with associated types for a value, for candidates normalized for a blend, and for what one layer pass remembers between tokens.inkling::CpuOps: the reference. Its operations are the functions that were there before, and it holds theProductsfrom the earlier step.inkling::Inkling<O: Ops>;InklingCpuisInkling<CpuOps>, withnewandwith_productsas before, andwith_opsfor another implementation.Layer,GateandKvConvare public descriptions, so that another implementation can read a layer's weights.How it was checked
tools/mutants.sh allwith both real models: 70 killed, 0 not killed, 23 skipped (GPU). Seven forward-pass patches no longer applied after the code moved and were regenerated.Two things that changed place
CpuOps. Those two rules are properties of an implementation, so each implementation needs its own; the device one has them on its branch.Review
The qwen reviewer approved with nits. It could not see outside the diff and asked for three things to be verified; all hold: the old single blend call was "normalize, then mix" in the kernels crate, the inline tests build, and nothing is left unused.
Made: the trait's docs now say what a second implementation must do (not that one exists), state the order the two convolutions rely on (read the earlier tokens, then add this one), and say that
LayerandGateare built by the model from checked weights.Declined:
&selffor five operations. A device implementation keeps a cache of uploaded weights and a pool of buffers, and needs&mut.CpuOps::add. Two vectors of 2,304 floats per layer pass on the reference path.