Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
da0e81c
sdk: a last-row head is the slice of the head over every row of the call
davidtai Nov 26, 2026
16799f6
chat: thinking-off on Inkling commits the text message in the prompt
davidtai Nov 26, 2026
7c9218a
engine: a repeatable request rounds alone; a drafter's round ladder i…
davidtai Nov 26, 2026
783863f
moe: the row-mapped NAX gather takes an interleaved soft-capped SwiGL…
davidtai Nov 26, 2026
4858297
inkling2: speed levers beside main's kernels, the 8-bit trunk and pip…
davidtai Nov 26, 2026
e2873d2
inkling2: the bundled drafter's 8-bit Markov fold a vocab row (MARKOV…
CerebralCoding Nov 26, 2026
3cc27ce
inkling2: kernel-contract cases for the speculative rounds, the verif…
davidtai Nov 26, 2026
f350e55
inkling2: the tensor-unit prompt read is on by default
davidtai Nov 26, 2026
13eb742
engine: a greedy request rounds alone only when asked
davidtai Nov 26, 2026
40c5e10
inkling2: the load says which drafter serves
davidtai Nov 27, 2026
9996b48
inkling2: a prompt the tensor-unit read cannot take gets main's read;…
davidtai Nov 27, 2026
68b3b5b
inkling2: the prompt levers ask the forward's load, so verifies and b…
davidtai Nov 27, 2026
8ee19ec
inkling2: the row map asks the mapped kernel's own layout check and n…
davidtai Nov 27, 2026
ffaaad4
inkling2: a launch does no pipeline-record work with PIPELINES_AT_LOA…
davidtai Nov 27, 2026
e58451d
inkling2: the 8-bit trunk, async prompt evals and the pipeline record…
davidtai Nov 27, 2026
98aab12
inkling2: the norm kernel's one-row path keeps main's register, and n…
davidtai Nov 27, 2026
0782867
inkling2: the tensor-unit prompt read and GATE_MM are held no farther…
davidtai Nov 27, 2026
218cb70
inkling2: a prompt's tensor-unit reads are tested through the cache's…
davidtai Nov 27, 2026
3c1a2eb
inkling2: BIAS_IN_ATTN=0 reads a prompt with main's relattn_nax; the …
davidtai Nov 27, 2026
9941167
inkling2: GATE_MM's parity test holds each metric within 5% of the ol…
davidtai Nov 27, 2026
0a43682
inkling2: the prep_strided and relsplit_lanes contract records state …
davidtai Nov 27, 2026
f996d88
inkling2: GATE_MM's parity test holds both arms to one float64 precis…
davidtai Nov 27, 2026
b596b9a
inkling2: the relsplit and relslots contract records state what M1 an…
davidtai Nov 27, 2026
4433762
inkling2: the 8-bit trunk made at load is opt-in; the release serves …
davidtai Nov 27, 2026
ed6b76c
inkling2: a prompt's bytes are held to one value whatever the buffer …
davidtai Nov 28, 2026
5c9c414
inkling2: the tensor-unit prompt read orders its bias tiles with the …
davidtai Nov 28, 2026
368ae96
engine: a repeatable prompt keeps its model's chunk, pinned from the …
davidtai Nov 28, 2026
f82ff39
engine: every prompt logs what its bytes are a function of
davidtai Nov 28, 2026
1bfa84f
inkling2: the tensor-unit prompt read's far blocks keep the loop they…
davidtai Nov 28, 2026
73fcdc4
inkling2: comments say what holds, not how they came to be
davidtai Nov 28, 2026
fa020ad
inkling2: a launch an open pipeline record has seen costs one compare
davidtai Nov 28, 2026
d688c55
engine: a load that read a stored round ladder serves one prompt befo…
davidtai Nov 28, 2026
fa09677
inkling2: a step's norm and prep launch main's kernels; the prompt ar…
davidtai Nov 28, 2026
c16e602
inkling2: a drafter's round is a decode's forward to the pipeline record
davidtai Nov 29, 2026
a3a9483
inkling2: import verifyQmmNaxAvailable by name, apart from main's loc…
davidtai Nov 29, 2026
4f14dcd
inkling2: the pipeline record is written before ready and closes at r…
davidtai Nov 29, 2026
1905d99
inkling2: a served build reads each lever once a process; no dead dec…
davidtai Nov 29, 2026
b6b5b6a
Merge main into inkling2/mini-speed
davidtai Nov 29, 2026
b194d93
inkling2: the prompt paths have no env switches; their code gates decide
davidtai Nov 29, 2026
48f90fb
patches: mlx-metal-alloc-fill retires with an upstream allocator fill…
davidtai Nov 29, 2026
8aed098
inkling2: EXPERTS_I8, a prompt chunk's expert GEMMs on int8 (opt-in, …
davidtai Nov 29, 2026
6f46ffe
inkling2: EXPERTS_I8 keeps main's stream threads when a producer twin…
davidtai Nov 30, 2026
ab2f08e
engine: a plugin's optional accelerators are billed, and declined by …
davidtai Nov 30, 2026
3fb0d5c
sdk: w8a8's grouped int8 expert GEMM, moved out of the Inkling 2 plugin
davidtai Nov 30, 2026
90c2ba7
inkling2: PF_INT8, the int8 accelerator for prompt chunks (levels 1 a…
davidtai Nov 30, 2026
c151a97
kit: export blocks.dit.w8a8_grouped
davidtai Nov 30, 2026
4acae7f
w8a8 grouped: the copy test's half-step bound allows the f32 rounding…
davidtai Nov 30, 2026
382bab1
inkling2: drop two release-pack tests that faster tests cover
davidtai Nov 30, 2026
555f91b
Merge main into inkling2/mini-speed
davidtai Nov 30, 2026
60c30cf
Merge inkling2/mini-speed into inkling2/int8-accel
davidtai Nov 30, 2026
d1b2023
inkling2: the release-pack tests share one load per configuration
davidtai Nov 30, 2026
632838a
Merge inkling2/mini-speed into inkling2/int8-accel
davidtai Nov 30, 2026
70e8a5a
inkling2: the PF_INT8 test keeps its own loads, after the shared ones
davidtai Nov 30, 2026
97dbf80
inkling2 tests: the shared loads' openers and close methods are pub; …
davidtai Dec 1, 2026
a53f96a
Merge remote-tracking branch 'fork/inkling2/mini-speed' into inkling2…
davidtai Dec 1, 2026
46252be
inkling2 tests: the shared load's key walks env.vars with std.meta.de…
davidtai Dec 1, 2026
07098bf
Merge remote-tracking branch 'fork/inkling2/mini-speed' into inkling2…
davidtai Dec 1, 2026
359bbc0
inkling2 PF_INT8: the trunk's GEMM inputs leave their producers quant…
davidtai Dec 1, 2026
a2e2422
inkling2: the MLX allocator fill hook and its pool-fill test move to …
davidtai Dec 1, 2026
0e9d31a
Merge remote-tracking branch 'fork/inkling2/mini-speed' into inkling2…
davidtai Dec 1, 2026
8ddf82f
inkling2: PF_INT8 and EXPERTS_I8 leave core; the engine keeps the acc…
davidtai Dec 1, 2026
405e80a
inkling2: the prompt paths run only on NAX; M1-M4 take main's path
davidtai Dec 1, 2026
5daed2d
Merge branch 'inkling2/mini-speed' into inkling2/int8-accel
davidtai Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,9 @@ Used in mlx-serve:
* `src/plugins/inkling2/kernels/relattn.metal` ports the `relative_attention`
kernel of the Inkling 2 model (`mlx_lm/models/inkling2/kernels.py`,
https://github.com/ml-explore/mlx-lm/pull/2086); `relsplit.metal` and
`relslots.metal` split that kernel's read over the keys and over slots.
`relslots.metal` split that kernel's read over the keys and over slots;
`relative_attention_nax.metal` (Stéphane Busso's, from his inkling2-final
branch of PR 1261) runs MLX's NAX attention loop with that kernel's score.

Modifications by mlx-serve: reimplemented in Zig against mlx-c, and the GDN
kernel is extended by a sequence variant (`GDN_KERNEL_SEQ_SOURCE`) that records
Expand Down
18 changes: 15 additions & 3 deletions docs/gotchas/engine-mlx.md
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,13 @@ before the drafter's state carried over), and a seeded sampled one never repeate
finished one adopted its drafter state (context rows, calibration) and copied its answer as drafts, so its rounds
lined up differently; a verify row's logits differ from another alignment's in the low bits (bf16), and a near-tie
token flips. Fix: a greedy or seeded request (`SamplingParams.repeats`) adopts nothing and copies no earlier answer;
an unseeded sampled one keeps both. Rule: state carried between requests may speed a request up, never change what
a request that asks to repeat reads. Beside other requests a group still follows arrival order. Guard: `plugin native
drafter: only an unseeded sampled request continues an earlier one`.
an unseeded sampled one keeps both. Beside other requests the group rounds then made its text follow arrivals: a
group's forward carries every slot's rows, and the kernels (MLX's matmul by row count, the router and expert paths past
32 and 63 rows, the split-K by the launch's longest lane, the draft head and tree width by lanes) follow the group. Fix:
such a request can round alone (`native_group.roundsAlone`, opt-in `MLX_SERVE_GREEDY_SOLO_ROUNDS=1`: on by default it held
multi-user greedy decode flat). Rule: a request that must repeat under load reads nothing another request chose. Guards: `plugin native drafter: only an unseeded sampled request continues an earlier
one`, `roundsAlone: with the switch on, a request that must answer the same twice never shares a forward`, `inkling2 release: a greedy lane's
rounds beside a sampled group are its rounds alone`.

### A kernel template argument that carried a launch's rows filled the proof table, and every launch then paid an evaluation
Defect: Inkling 2's decode ran 10 ms a round slower for the life of a process, from the first boot of a build (its warm
Expand Down Expand Up @@ -1747,3 +1751,11 @@ media model held the room until something unloaded it. Fix: a prefill whose cach
first unloads the least recently used idle media model, one per cut, then re-clamps grow-only (`reclaimSqueezedCache`,
`squeezed_from`); a media job that grew active memory re-checks the budgets, since the weights land at the first job.
Guard: `a squeezed hot cache takes its room back from an idle media model, never a held one or a chat model`.

### Inkling 2's prompt paths also ran in grouped verifies and batched decode
Defect: paths built for prompt chunks (the strided prep past 8 rows, the row norm past 32, the tiled gates, the experts'
row map and its gate_up epilogue past 64) keyed on the forward's rows, so batched decode at 9-32 slots and grouped
verifies of 2+ lanes (past 64 rows at 11 DFlash2 lanes on NAX) took arms never tested or timed there; the row map's
prompt call also dropped the condition that keeps MLX's verify bits. Fix: each asks `kernels.Load` (a prompt chunk or
not, from the forward's mode). Rule: a path built for a load asks the load. Guards: `inkling2 proof: batched slots and a
grouped verify take main's path`, `inkling2 kernels: a verify's rows past 64 keep MLX's gather`.
7 changes: 7 additions & 0 deletions docs/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ Declared today:
- **Concurrent**: archs that batch decode (B > 1) are not row-exact across batch widths; serial archs (`qwen3_next`,
`laguna`, `kolibri1`, `bailing_hybrid`, `hy_v3`, `inkling`, `gpt_oss`, `nemotron_h`, `lfm2`) and the single-flight
`deepseek_v4`/`deepseek_v41` are equal to solo by construction but no guard checks it.
- **Concurrent, a served drafter's groups** (`inkling2`): a greedy or seeded request groups with the others by default, so
a near-tie token can follow who else is served and in what order. With `MLX_SERVE_GREEDY_SOLO_ROUNDS=1` it rounds
alone (`native_group.roundsAlone`, at a multi-user throughput cost), so its text is the one it gets alone, except: past 16
requests drafting on the model its drafter ring can be parked out and restart (`max_open`); a prompt prefilled while
others decode runs 2048-row chunks (1024 under a decode share; `companyPrefillChunk`); with speculation off it decodes
in the batched group; and a prompt restored from another request's prefix-cache entry is outside `exact_resumed`
(above). An unseeded sampled request groups, and its tokens follow who else is served and in what order.
- **Embedded engines** (`ds4`, `llama`, `ane`): every contract unverified. The adapters ignore `Request.no_drafts` and
`CacheHint.cold`, and ds4 reports `Stats.drafted = 0`, so a drafted check could not see a draft.
- Embedding, decision and media plugins have no token decode loop; their bar is seeded outputs identical.
Expand Down
6 changes: 4 additions & 2 deletions docs/plugin-abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ Model facts the host keeps once at load. Defaults are the generic model's.
| `merged_state` | `bool` | `false` | A batch's recurrent state is read and written only through `CacheOps.state_rows` / `set_state_rows`, so the engine may keep it merged across batched ticks instead of re-stacking every layer each tick. |
| `slot_state` | `bool` | `false` | Module-owned state (`owns_decode_state`) kept per slot (`Forward.slots`, `release_slot`, `activate_slot`): requests interleave and batch instead of running single-flight. |
| `ablation` | `bool` | `false` | The forward honours `Forward.ablation` on every pass that writes the residual stream (a native drafter's rounds included). A plugin that resumes its own state across requests (`CacheHooks.resume_prompt`) resumes only under the same `Ablation.keys` entry. |
| `prompt_last_row` | `bool` | `false` | A prompt forward asked for `Logits.last_row` returns its last row's logits alone, bit-identical to that row of its `.all_rows` result, and still every hidden and captured row it is asked for. The host asks for it on the prefill's prompt forwards unless the request echoes prompt logprobs. |
| `prompt_last_row` | `bool` | `false` | A prompt forward asked for `Logits.last_row` returns its last row's logits alone, bit-identical to that row of its `.all_rows` result, and still every hidden and captured row it is asked for. The host asks for it on the prefill's prompt forwards unless the request echoes prompt logprobs. The SDK's bases slice the head's call over every row of the forward, so the bytes do not depend on the mode; a plugin that runs its own head owns the same contract. |
| `experts_stream` | `bool` | `false` | The load streams an MLX pack's routed experts on the `stream_experts` setting (`sdk/weights/streamed.zig`): the preflight bills their slot rows, not the experts. Without it the setting is refused by name. |
| `served_context` | `bool` | `false` | The load reports the context it serves (`LoadCtx.reportGrant`), and the host holds it to that. A model that streams its weights should: one that does not serves the context it was asked for, and the host warns. |
| `_` | `u30` | `0` | |
| `repeatable_prefill` | `bool` | `false` | A repeatable (greedy or seeded) request's bytes depend on nothing a boot measures: the prompt chunk is pinned from the machine and the pack, never live memory, and a prompt that does not fit waits for room, then is refused by name, instead of running at another width. |
| `_` | `u29` | `0` | |

### `ThinkingDefault` (enum(u8))

Expand Down Expand Up @@ -1054,6 +1055,7 @@ A model plugin's table, exported as `exportName(name, version)`. `claims` and `p
| `weights` | `*const WeightHooks` | | |
| `meters` | `?*const fn (m: *anyopaque, slot: u32, out: *Str) callconv(.c) void` | `null` | `slot`'s arm counters for its request's summary lines (each a full log line), in memory the plugin owns until the next call on `m`; the counters reset. |
| `speech` | `?*const SpeechHooks` | `null` | |
| `ready` | `?*const fn (m: *anyopaque) callconv(.c) void` | `null` | The load's own warm-up has run and the model serves requests from now on: work the plugin does only while it warms stops here. Once per load, on the inference thread. Read it through `readyOf`. |

### `declaresMode(caps: Caps, mode: Mode) bool`

Expand Down
9 changes: 8 additions & 1 deletion src/abi/dylib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub fn negotiate(m: *const Manifest, host_mlx: []const u8) Verdict {
switch (m.kind) {
.model => {
if (head.version == 0 or head.version > model_abi.version) return Verdict.refuse(.unsupported, "model table is newer than this host's: a newer mlx-serve serves it");
if (head.size < @sizeOf(model_abi.ModelTable)) return Verdict.refuse(.unsupported, "model table is older than this host's");
if (head.size < model_abi.ModelTable.min_size) return Verdict.refuse(.unsupported, "model table is older than this host's");
const t: *const model_abi.ModelTable = @ptrCast(@alignCast(m.table));
if (nullWord(t, "cache") or nullWord(t, "weights"))
return Verdict.refuse(.failed, "model table has no cache or weight hook table: both are required, even empty");
Expand Down Expand Up @@ -318,6 +318,13 @@ test "abi dylib: a model table with a hook table older than the host's is refuse
// never writes a grown `Parsed` or `Bill` past this host's.
t.version = model_abi.version - 1;
try testing.expect(negotiate(&m, pin).isOk());
// A table built before `ready` loads, the hook read as absent; one shorter still is refused.
t.size = model_abi.ModelTable.min_size;
try testing.expect(negotiate(&m, pin).isOk());
try testing.expect(t.readyOf() == null);
t.size = model_abi.ModelTable.min_size - 8;
try testing.expectEqualStrings("model table is older than this host's", negotiate(&m, pin).why.slice());
t.size = @sizeOf(model_abi.ModelTable);
t.version = model_abi.version + 1;
try testing.expectEqualStrings("model table is newer than this host's: a newer mlx-serve serves it", negotiate(&m, pin).why.slice());
t.version = model_abi.version;
Expand Down
32 changes: 30 additions & 2 deletions src/abi/plugin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ pub const Caps = packed struct(u64) {
ablation: bool = false,
/// A prompt forward asked for `Logits.last_row` returns its last row's logits alone, bit-identical to that row of
/// its `.all_rows` result, and still every hidden and captured row it is asked for. The host asks for it on the
/// prefill's prompt forwards unless the request echoes prompt logprobs.
/// prefill's prompt forwards unless the request echoes prompt logprobs. The SDK's bases slice the head's call over
/// every row of the forward, so the bytes do not depend on the mode; a plugin that runs its own head owns the same
/// contract.
prompt_last_row: bool = false,
/// The load streams an MLX pack's routed experts on the `stream_experts` setting (`sdk/weights/streamed.zig`):
/// the preflight bills their slot rows, not the experts. Without it the setting is refused by name.
experts_stream: bool = false,
/// The load reports the context it serves (`LoadCtx.reportGrant`), and the host holds it to that. A model that
/// streams its weights should: one that does not serves the context it was asked for, and the host warns.
served_context: bool = false,
_: u30 = 0,
/// A repeatable (greedy or seeded) request's bytes depend on nothing a boot measures: the prompt chunk is pinned
/// from the machine and the pack, never live memory, and a prompt that does not fit waits for room, then is
/// refused by name, instead of running at another width.
repeatable_prefill: bool = false,
_: u29 = 0,
};

pub const ThinkingDefault = enum(u8) { unset, off, on, on_with_tools };
Expand Down Expand Up @@ -1200,6 +1206,18 @@ pub const ModelTable = extern struct {
/// the next call on `m`; the counters reset.
meters: ?*const fn (m: *anyopaque, slot: u32, out: *Str) callconv(.c) void = null,
speech: ?*const SpeechHooks = null,
/// The load's own warm-up has run and the model serves requests from now on: work the plugin does only while it
/// warms stops here. Once per load, on the inference thread. Read it through `readyOf`.
ready: ?*const fn (m: *anyopaque) callconv(.c) void = null,

/// `ready`, null on a table whose `size` ends before it.
pub fn readyOf(t: *const ModelTable) ?*const fn (m: *anyopaque) callconv(.c) void {
if (t.size < @offsetOf(ModelTable, "ready") + @sizeOf(@FieldType(ModelTable, "ready"))) return null;
return t.ready;
}

/// The smallest table the loader admits: one built before `ready`, which reads as absent.
pub const min_size: u32 = @offsetOf(ModelTable, "ready");
};

/// The modes a model serves: prefill, decode and verify always; the rest as its caps declare. An encoder (`embed`)
Expand Down Expand Up @@ -1266,6 +1284,16 @@ test "abi plugin: auxiliary callbacks are required function pointers" {
}
}

test "abi plugin: a model table built before `ready` reads it as absent" {
// Bar: a table whose size ends at `min_size` has no ready hook; a full one has the hook it set.
var t: ModelTable = .{ .name = .of("toy"), .claims = undefined, .parse = undefined, .free_parsed = undefined, .bill = undefined, .load = undefined, .unload = undefined, .forward = undefined, .cache = undefined, .weights = undefined, .ready = &struct {
fn f(_: *anyopaque) callconv(.c) void {}
}.f };
try testing.expect(t.readyOf() != null);
t.size = ModelTable.min_size;
try testing.expect(t.readyOf() == null);
}

test "abi plugin: unset generation defaults read as unset" {
const g: GenDefaults = .{};
try testing.expect(std.math.isNan(g.temperature) and std.math.isNan(g.top_p) and g.top_k == -1);
Expand Down
Loading
Loading