Repository navigation
feat(inkling): Inkling 2 Mini runs in basalt — P1 looped text stack, oQ + mlx-lm layouts (#650) - #660
Merged
Merged
Conversation
…, oQ/mlx-lm weight layouts, TinyModel (#650) - Inkling2Model (inkling2_loop / inkling2): prelude, core x num_passes and coda over 48 layer visits; passes 2-3 restart from the prelude output and read cross-pass messages (depth attention over the previous pass's blocks) through rank-r gates on q, k, v and the MoE input. - Attention without RoPE: learned relative logits (r_proj x rel_logits_proj), per-token sinks, sigmoid output gate, q/k/rel L2 clips, value norm without gamma, log-scaled query temperature on global layers; static short convs on local K/V, dynamic ones on global K/V, short convs after attention and MLP. - Depth-attention residuals over 6-layer blocks; sigmoid + bias router with route_scale; softcapped SwiGLU over interleaved gate/up expert rows. - Caches: a flat [attention, ArraysCache(4)] per visit; local layers use Inkling2WindowKVCache (temporal order, compacted to the window, exact key positions), treated as snapshot-only so hybrid prompt-cache reuse works. - Weights: mlx-lm layout as is; oMLX oQ layout (fused in_proj / q_proj / k_proj / v_proj rows, packed loop controllers, loop_message queries) mapped to it; modules quantized from the packed weights' shapes. - TinyModel.inkling2Loop (6 layers, core 2..<4 x 3, window 8) with tests: decode in chunks of 1/4/7 equals the full forward, loop changes output, oQ layout round-trips, window cache positions and trim; joins the all-family suites (prompt-cache reuse passes; Quest and batched decode refused). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
…jump-forward for inkling2 Every known family must verify the base capabilities GenerationPlanTests checks; prompt-cache reuse is covered by the fixture suites, lookup is still refused at runtime by PromptLookupTokenIterator.supports for these caches, and KV quantization stays off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
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.
What (#650 P1 — text stack in plain MLX ops, no kernels)
Inkling2Modelrunsinkling2_loop(Inkling 2 Mini) andinkling2in basalt, inSources/BasaltInference/Models/Inkling2/(7 files, each under the size limits). It was ported from the reference implementation in ml-explore/mlx-lm#2086 and checked against oMLX's oQ layout (omlx/patches/inkling2/oq_layout.py,loader.py); the fork is not touched.(1 − tanh f)·x + tanh g·msg).r_proj×rel_logits_proj, distances below 1,024), per-token sinks fromsink_proj, a sigmoid output gate, q/k/relative L2 clips, a value norm without gamma, and a log-scaled query temperature on the global layers (5, 11, 17, 23). Static depthwise short convs on local K/V, dynamic ones (static_weight+weight_proj) on global K/V, short convs after attention and after the MLP.route_scale8; SwiGLU with tanh softcaps over interleaved gate/up expert rows; final logit softcap 30, vocab sliced to 200,058.[attention, ArraysCache(4)]per visit (96 entries for the real model). Local layers useInkling2WindowKVCache, which keeps keys in time order, compacts to the window and knows each key's position; relative attention needs exact distances, and the fork'sRotatingKVCachekeeps its write index private. The window cache counts as a snapshot-only layer, so hybrid prompt-cache reuse works.mlx-community/Inkling-2-Mini-4bitnaming) loads as is. The oMLX oQ layout (Inkling-2-Mini-oQ3e/oQ4e/oQ2.5e) is mapped to it: fusedin_proj(q, k, v, r, gate, sink) and globalq_proj/k_proj/v_projrows are split, quantized matrices included, andloop_down/loop_gain_forget/loop_message.queryare unpacked into the message gates and queries. Modules are quantized from the packed weights' shapes (Flint's helper), so oQ's per-path overrides need no renaming.inkling2_loopandinkling2;ModelCapabilitiesrow with nothing verified yet.Not in P1: native NVFP4/MXFP8 experts with
global_scale(the 4-bit pack and the original checkpoint), the ModelOpt source layout, kernels (P2), the<|message_model|>frame stream adapter and tool calls (P3), vision and DSpark.Measured
mlx-community/Inkling-2-Mini-oQ3e-mtp(13.7 GB, 3-bit experts), M4 Pro 24 GB, release build, CI idle:Issue targets are ≥ 35 tok/s decode and ≥ 450 tok/s prefill at 4K: P2's kernels (relative attention K1, depth attention K2, fused router K3). Until P3, replies carry the raw frame tokens.
Tests
Inkling2ModelTestsonTinyModel.inkling2Loop(6 layers, core 2..<4 × 3 passes, window 8, 8 experts):Verified
swift build -Xswiftc -warnings-as-errorsand-c releaseclean; no new comments; no size limit exceeded; feature matrix, causality, fixture, hybrid-prefix and prompt-cache suites pass (128 tests) plus the Inkling suites.🤖 Generated with Claude Code
https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh