Repository navigation
Conversation
…half the kernels, bit for bit mlx-lm's (a value cast twice is cast once, constants are cast at load, runs of elementwise ops are one compiled kernel each, what a token's visits share is computed once a token; applied only after each compiled group matches its ops run one by one and a visit of each layer kind matches mlx-lm's, every output and cache entry; needs mlx-lm #2086's layer, stays off on the CPU; STREAMLX_FUSED=0 turns it off). Inkling 2 Mini oQ4e: 7,097 -> 3,955 kernels a token, plain decoding +2.8% synchronous and +3.5% with run-ahead; tests
… checked by kind and by their parameters' dtypes, since a projection kept in float32 gave another token, and a kind that differs keeps mlx-lm's visit; a stream in another dtype than the check's, as float16 input embeddings, runs mlx-lm's code); what it makes of parameters is made again when they are replaced; fuse() checks a fused model anew; the test module imports without an mlx-lm that has inkling2; tests
…cords each layer visit once where some layers keep mlx-lm's visit (a fused layer falling back reached its class's parent, which the recorders also wrapped: a 17-token prompt raised, and the looped head's rows were wrong); what the fused visit makes of parameters takes them from its caller, so no reference cycle holds a model's modules; an update in place needs fuse() again (documented); tests
…x-lm's own _conv_input (mlx-lm #2086's head keeps the convolution state in the stream's dtype since 11-22 where the fused visit cast it to float32, so fuse() found the values differ and kept mlx-lm's visit in every layer; now either is followed); round32, unused, removed
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.
A decode step of mlx-lm's inkling2 queues about 150 GPU kernels a layer visit, most of them a cast, an add or a mask over one vector: Inkling 2 Mini queues 7,097 a token. The fused visit computes the same values in 3,955. It applies to visits of up to 16 rows, a decode step or a step's drafts checked together; prompt chunks still run mlx-lm's code.
What changes
inkling2_step(new):fuse(model)gives mlx-lm's inkling2 layers (Inkling 2 Mini's looped stack and Inkling-2-Small's) a visit that keeps every operation and its order, element by element:mx.compile, as mlx-lm's own clips are);model.load_weightsdoes.fuse()on a fused model checks it anew and makes them again, which loading weights of other dtypes, or updating a parameter in place (an indexed assignment keeps its identity), needs.integrate:load_streaming_modelandinstall_streamingapply it;STREAMLX_FUSED=0turns it off.validate: it says how many layers take the fused visit.Checks
streamlx validatepasses through it on the Mini, held (128 slots) and streamed (16 slots, 40% misses): all 24 layers fused, 64 of 64 tokens, prefill logits bitwise.validatecannot run; instead mlx-lm's visit and the fused one ran on two copies of one cache, step by step.streamlx servewith its defaults (writefib.py, run it):main, every request the same.main: the head's drafted steps are bound by their expert rows.streamlx servewith its defaults, with the fused visit (#2086) and without it (#2061): the same conversation, request for request, at the same speed (the drive bounds it).test_inkling2_stepcovers toy checkpoints of both layer kinds, looped and not:fuse(), and a parameter updated in place thenfuse()again, bit for bit;