mlx-bun 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/README.md +71 -588
  2. package/docs/README.md +94 -0
  3. package/docs/{design → archive/investigations}/audio-input-plan.md +4 -4
  4. package/docs/{design → archive/investigations}/diffusion-gemma-port.md +3 -3
  5. package/docs/{design → archive/investigations}/faithful-l1-consolidation.md +4 -4
  6. package/docs/{design → archive/investigations}/minicpm5-decode-megakernel.md +11 -11
  7. package/docs/archive/investigations/openjarvis-fit.md +198 -0
  8. package/docs/{design → archive/investigations}/optimization_plan.md +1 -1
  9. package/docs/{design → archive/investigations}/pre-colibri-stabilization.md +5 -5
  10. package/docs/archive/investigations/qwen38-27b-campaign-log.md +1092 -0
  11. package/docs/{design → archive/investigations}/the-dreaming-handoff.md +2 -2
  12. package/docs/archive/planning/release-notes-v0.3.0.md +35 -0
  13. package/docs/design/batching.md +1841 -0
  14. package/docs/design/decode-speed-program.md +2346 -169
  15. package/docs/design/dreaming-nightly-pipeline.md +675 -282
  16. package/docs/design/generic-model-support.md +655 -334
  17. package/docs/design/kv-cache.md +824 -0
  18. package/docs/design/orpo-training.md +673 -1239
  19. package/docs/design/speculative-decoding.md +1990 -0
  20. package/docs/design/turboquant.md +2212 -0
  21. package/docs/design/unified-engine-frontier-plan.md +1833 -727
  22. package/docs/design/web-chat-redesign.md +666 -1083
  23. package/docs/planning/PRODUCT_ROADMAP.md +50 -1
  24. package/docs/planning/release-notes-v0.4.0.md +45 -0
  25. package/docs/planning/video-series.md +2 -2
  26. package/docs/reference/benchmarks.md +3613 -0
  27. package/docs/reference/cli.md +434 -160
  28. package/docs/reference/distribution.md +328 -182
  29. package/docs/reference/environment.md +398 -0
  30. package/docs/reference/glossary.md +39 -0
  31. package/docs/reference/library-api.md +566 -168
  32. package/docs/reference/memory.md +227 -64
  33. package/docs/reference/models.md +113 -6
  34. package/docs/reference/server-api.md +944 -429
  35. package/docs/reference/server-config.md +740 -338
  36. package/docs/reference/training.md +393 -254
  37. package/docs/reference/troubleshooting.md +158 -0
  38. package/package.json +9 -4
  39. package/src/audio/decode.ts +2 -2
  40. package/src/audio/features.ts +2 -2
  41. package/src/backends/mlx/assistant-target.ts +46 -0
  42. package/src/backends/mlx/autoregressive-draft-rows.ts +120 -0
  43. package/src/backends/mlx/autoregressive.ts +108 -0
  44. package/src/backends/mlx/batch-group.ts +1790 -0
  45. package/src/backends/mlx/cache-attachment.ts +67 -0
  46. package/src/backends/mlx/cache-layout.ts +31 -0
  47. package/src/backends/mlx/checkpoint-state.ts +53 -0
  48. package/src/backends/mlx/continuation-persistence.ts +106 -0
  49. package/src/backends/mlx/continuation-request.ts +43 -0
  50. package/src/backends/mlx/continuation.ts +77 -0
  51. package/src/backends/mlx/diffusion.ts +39 -0
  52. package/src/backends/mlx/draft-target.ts +32 -0
  53. package/src/backends/mlx/evaluation.ts +105 -0
  54. package/src/backends/mlx/fill-append.ts +45 -0
  55. package/src/backends/mlx/full-kv-row-append.ts +32 -0
  56. package/src/backends/mlx/full-kv-row-donor.ts +54 -0
  57. package/src/backends/mlx/full-transitioning-kv-rows.ts +65 -0
  58. package/src/backends/mlx/gateway-binding.ts +130 -0
  59. package/src/backends/mlx/graph.ts +38 -0
  60. package/src/backends/mlx/kv-codec.ts +9 -0
  61. package/src/backends/mlx/kv-maintenance.ts +133 -0
  62. package/src/backends/mlx/kv-tensor-rows.ts +212 -0
  63. package/src/backends/mlx/memory-client.ts +189 -0
  64. package/src/backends/mlx/methods.ts +90 -0
  65. package/src/backends/mlx/model-prompt.ts +164 -0
  66. package/src/backends/mlx/model-serving.ts +79 -0
  67. package/src/backends/mlx/prefill-cohort.ts +89 -0
  68. package/src/backends/mlx/prefill-rows.ts +200 -0
  69. package/src/backends/mlx/prefill.ts +33 -0
  70. package/src/backends/mlx/projected-context-rows.ts +72 -0
  71. package/src/backends/mlx/request-policy.ts +20 -0
  72. package/src/backends/mlx/request-state-policy.ts +41 -0
  73. package/src/backends/mlx/rollback.ts +89 -0
  74. package/src/backends/mlx/row-sampling.ts +49 -0
  75. package/src/backends/mlx/serial-executor.ts +242 -0
  76. package/src/backends/mlx/speculative-group.ts +359 -0
  77. package/src/backends/mlx/speculative-round.ts +161 -0
  78. package/src/backends/mlx/speculative.ts +114 -0
  79. package/src/backends/mlx/state-rows.ts +104 -0
  80. package/src/backends/mlx/state-views.ts +46 -0
  81. package/src/backends/mlx/target-layout-capability.ts +35 -0
  82. package/src/backends/mlx/text-engine.ts +73 -0
  83. package/src/backends/mlx/transitioning-kv-rows.ts +165 -0
  84. package/src/cli.ts +66 -58
  85. package/src/client.ts +66 -0
  86. package/src/config.ts +21 -4
  87. package/src/contracts/completion.ts +16 -0
  88. package/src/contracts/execution.ts +60 -0
  89. package/src/contracts/generation.ts +103 -0
  90. package/src/contracts/host.ts +7 -0
  91. package/src/contracts/jobs.ts +66 -0
  92. package/src/contracts/pi-provider.ts +30 -0
  93. package/src/contracts/pi.ts +259 -0
  94. package/src/contracts/prefix-cache.ts +23 -0
  95. package/src/contracts/resources.ts +25 -0
  96. package/src/contracts/sampling.ts +23 -0
  97. package/src/contracts/scheduling.ts +45 -0
  98. package/src/contracts/tsconfig.json +14 -0
  99. package/src/diffusion/diffusion-generate.ts +218 -153
  100. package/src/embed.ts +1 -1
  101. package/src/engine/admission.ts +59 -0
  102. package/src/engine/cancellation.ts +38 -0
  103. package/src/engine/engine.ts +56 -0
  104. package/src/engine/execution-coordinator.ts +70 -0
  105. package/src/engine/execution-plan.ts +53 -0
  106. package/src/engine/resources.ts +53 -0
  107. package/src/engine/scheduler.ts +72 -0
  108. package/src/engine/session.ts +247 -0
  109. package/src/eval/README.md +44 -1
  110. package/src/eval/kl.ts +236 -3
  111. package/src/eval/reference-logits.ts +207 -0
  112. package/src/eval/runner.ts +8 -96
  113. package/src/fill/echo-index.ts +188 -0
  114. package/src/fill/fill-session.ts +452 -0
  115. package/src/fill/proposal.ts +68 -0
  116. package/src/fill/schema-rows.ts +506 -0
  117. package/src/fill/tool-boundary.ts +103 -0
  118. package/src/fit.ts +30 -16
  119. package/src/generate.ts +709 -417
  120. package/src/grammar.ts +12 -7
  121. package/src/harness-pi.ts +14 -33
  122. package/src/hub-rest.ts +4 -4
  123. package/src/index.ts +7 -0
  124. package/src/inference/denoising.ts +17 -0
  125. package/src/inference/draft-acceptance.ts +41 -0
  126. package/src/inference/draft-output.ts +49 -0
  127. package/src/inference/graph.ts +33 -0
  128. package/src/inference/prefill.ts +39 -0
  129. package/src/inference/rollback.ts +7 -0
  130. package/src/jobs/db.ts +4 -0
  131. package/src/jobs/index.ts +2 -0
  132. package/src/jobs/job-entry.ts +12 -12
  133. package/src/jobs/runner.ts +98 -13
  134. package/src/jobs/task-client.ts +19 -0
  135. package/src/jobs/types.ts +2 -58
  136. package/src/kv-scheme.ts +70 -12
  137. package/src/kv-store.ts +177 -63
  138. package/src/lab/README.md +18 -0
  139. package/src/{assets → lab/curve}/curve-designer.html +2 -2
  140. package/src/{curve-sampler.ts → lab/curve/curve-sampler.ts} +2 -2
  141. package/src/{expert-trace.ts → lab/expert-trace/expert-trace.ts} +5 -5
  142. package/src/lab/paged-kv/paged-kv-rows.ts +83 -0
  143. package/src/{model → lab/paged-kv}/paged-kv.ts +32 -15
  144. package/src/library.ts +40 -0
  145. package/src/lora.ts +18 -0
  146. package/src/media-fetch.ts +1 -1
  147. package/src/memory/article.ts +1 -1
  148. package/src/memory/chunk.ts +1 -1
  149. package/src/memory/model.ts +30 -169
  150. package/src/memory/prompts.ts +1 -1
  151. package/src/memory/rest.ts +1 -1
  152. package/src/memory/schedule.ts +1 -1
  153. package/src/memory/stages.ts +4 -1
  154. package/src/memory/vault.ts +1 -3
  155. package/src/mlx/array.ts +11 -11
  156. package/src/mlx/compile.ts +12 -2
  157. package/src/mlx/ffi.ts +58 -11
  158. package/src/mlx/materialize.ts +23 -0
  159. package/src/mlx/metal-kernel.ts +10 -11
  160. package/src/mlx/ops.ts +33 -13
  161. package/src/mlx/quantized-rows.ts +36 -0
  162. package/src/mlx/token-bitmask.ts +52 -0
  163. package/src/mlx/turboquant-kv-decode.ts +82 -0
  164. package/src/mlx/turboquant-kv-inverse.ts +122 -0
  165. package/src/mlx/turboquant-ops.ts +33 -3
  166. package/src/mlx/turboquant-tables.ts +2 -2
  167. package/src/model/artifact-identity.ts +73 -0
  168. package/src/model/batched-kv.ts +235 -0
  169. package/src/model/batched-mask.ts +20 -6
  170. package/src/model/batched-quant.ts +9 -3
  171. package/src/model/batched-quantized-kv.ts +144 -0
  172. package/src/model/batched-rotating-quant.ts +78 -17
  173. package/src/model/batched-rotating-state.ts +76 -0
  174. package/src/model/batched-rotating.ts +65 -23
  175. package/src/model/batched-row-storage.ts +52 -0
  176. package/src/model/batched-ssm.ts +52 -0
  177. package/src/model/batched-turboquant-kv.ts +93 -0
  178. package/src/model/compiled-decode.ts +8 -2
  179. package/src/model/decoded-kv-donor.ts +12 -0
  180. package/src/model/delayed-quantized-kv.ts +72 -0
  181. package/src/model/delayed-rotating-quantized-kv.ts +93 -0
  182. package/src/model/delayed-turboquant-kv.ts +55 -0
  183. package/src/model/diffusion-gemma.ts +8 -8
  184. package/src/model/factory.ts +76 -33
  185. package/src/model/fingerprint.ts +1 -1
  186. package/src/model/flash-attention.ts +3 -3
  187. package/src/model/full-prefill-padding.ts +56 -0
  188. package/src/model/full-prefill-row.ts +105 -0
  189. package/src/model/gemma4-base.ts +179 -80
  190. package/src/model/gemma4.ts +40 -32
  191. package/src/model/generated/gemma4-12b.ts +6 -3
  192. package/src/model/generated/gemma4-26b.ts +6 -3
  193. package/src/model/generated/gemma4-e4b.ts +6 -3
  194. package/src/model/glm52-cache.ts +80 -4
  195. package/src/model/glm52-dsa.ts +13 -9
  196. package/src/model/glm52-memory.ts +1 -1
  197. package/src/model/glm52-mla.ts +12 -6
  198. package/src/model/glm52.ts +19 -40
  199. package/src/model/implementation.ts +69 -0
  200. package/src/model/kv-attention-view.ts +67 -0
  201. package/src/model/minicpm5.ts +17 -15
  202. package/src/model/profile.ts +12 -2
  203. package/src/model/qwen-append.ts +12 -0
  204. package/src/model/qwen-conv.ts +52 -0
  205. package/src/model/qwen3-delta-state.ts +74 -0
  206. package/src/model/qwen3-delta.ts +59 -36
  207. package/src/model/qwen3_5-checkpoint.ts +164 -0
  208. package/src/model/qwen3_5.ts +202 -78
  209. package/src/model/rotating-kv-donor.ts +35 -0
  210. package/src/model/rotating-kv-layout.ts +262 -0
  211. package/src/model/rotating-row-transaction.ts +35 -0
  212. package/src/model/speculative-rotating-kv.ts +101 -0
  213. package/src/model/ssm-prefill-padding.ts +39 -0
  214. package/src/model/support.ts +1 -1
  215. package/src/model/trellis-balanced-scatter.ts +51 -0
  216. package/src/model/trellis-linear.ts +672 -0
  217. package/src/model/trellis-shared-m.ts +151 -0
  218. package/src/model/trellis-shared-scatter.ts +144 -0
  219. package/src/model/trellis-splitk-prefill.ts +158 -0
  220. package/src/model/trellis-tiled-prefill.ts +136 -0
  221. package/src/model/trellis-vector-expand.ts +62 -0
  222. package/src/model/trellis-wide-prefill.ts +94 -0
  223. package/src/model/turboquant-codec.ts +83 -0
  224. package/src/model/universal/dense.ts +15 -14
  225. package/src/model/universal/modules.ts +8 -1
  226. package/src/native-pack.ts +6 -5
  227. package/src/pi-provider.ts +6 -64
  228. package/src/pi-web.ts +8 -315
  229. package/src/preflight.ts +31 -15
  230. package/src/prompt-cache.ts +110 -69
  231. package/src/quantize/allocator.ts +1 -1
  232. package/src/quantize/config-writer.ts +10 -3
  233. package/src/quantize/rotate.ts +4 -4
  234. package/src/quantize/trellis.ts +586 -0
  235. package/src/responses.ts +28 -1
  236. package/src/runtime-config.ts +18 -4
  237. package/src/sampler.ts +40 -29
  238. package/src/serve/batch-scheduler.ts +8 -1671
  239. package/src/serve/chat-request.ts +391 -0
  240. package/src/serve/chat-stage.ts +195 -0
  241. package/src/serve/checkpoint-identity.ts +64 -0
  242. package/src/serve/completion-executor.ts +15 -7
  243. package/src/serve/discovery-routes.ts +12 -13
  244. package/src/serve/generation-gateway.ts +183 -213
  245. package/src/serve/http.ts +159 -0
  246. package/src/serve/inference-request.ts +79 -0
  247. package/src/serve/isolate.ts +297 -105
  248. package/src/serve/lab-routes.ts +3 -0
  249. package/src/serve/lane-registry.ts +2 -1
  250. package/src/serve/model-admin-routes.ts +7 -5
  251. package/src/serve/model-binding.ts +43 -0
  252. package/src/serve/model-host.ts +511 -0
  253. package/src/serve/openai-wire.ts +103 -0
  254. package/src/serve/parent-application.ts +56 -0
  255. package/src/serve/pipeline.ts +33 -0
  256. package/src/serve/preparation.ts +33 -0
  257. package/src/serve/request-plan.ts +23 -18
  258. package/src/serve/request-prep.ts +344 -0
  259. package/src/serve/response-lease.ts +24 -0
  260. package/src/serve/responses-client.ts +69 -0
  261. package/src/serve/session-completion-engine.ts +110 -0
  262. package/src/serve/session-search.ts +1 -1
  263. package/src/serve/static-routes.ts +5 -5
  264. package/src/serve/text-completion-stage.ts +104 -0
  265. package/src/serve/token-streams.ts +519 -0
  266. package/src/server.ts +335 -2711
  267. package/src/spec/assistant-rows.ts +92 -0
  268. package/src/spec/assistant-source.ts +31 -55
  269. package/src/spec/cache-identity.ts +22 -0
  270. package/src/spec/deepspec-rows.ts +29 -0
  271. package/src/spec/deepspec-source.ts +16 -14
  272. package/src/spec/dflash-source.ts +36 -12
  273. package/src/spec/drafter.ts +153 -142
  274. package/src/spec/dspark/ab-stats.ts +3 -3
  275. package/src/spec/dspark/calibration.ts +2 -2
  276. package/src/spec/dspark/deepspec-module.ts +97 -122
  277. package/src/spec/dspark/generate-dflash.ts +2 -2
  278. package/src/spec/dspark/generate.ts +2 -2
  279. package/src/spec/dspark/loader.ts +1 -1
  280. package/src/spec/dspark/module-dflash.ts +129 -172
  281. package/src/spec/dspark/module.ts +3 -3
  282. package/src/spec/dspark/quantize-drafter.ts +1 -1
  283. package/src/spec/generate.ts +1 -1
  284. package/src/spec/glm52-mtp-graph.ts +29 -0
  285. package/src/spec/glm52-mtp-rows.ts +132 -0
  286. package/src/spec/glm52-mtp-source.ts +54 -137
  287. package/src/spec/glm52-mtp-state.ts +33 -0
  288. package/src/spec/ngram-source.ts +93 -21
  289. package/src/spec/projected-draft-rows.ts +73 -0
  290. package/src/spec/qwen-mtp-module.ts +171 -0
  291. package/src/spec/qwen-mtp-rows.ts +219 -0
  292. package/src/spec/qwen-mtp-source.ts +147 -195
  293. package/src/spec/qwen-mtp-state.ts +30 -0
  294. package/src/spec/serve-loop.ts +201 -201
  295. package/src/spec/source.ts +110 -13
  296. package/src/spec/two-model-rows.ts +61 -0
  297. package/src/spec/two-model.ts +44 -102
  298. package/src/ssd-cache.ts +99 -19
  299. package/src/ssd-durability.ts +36 -20
  300. package/src/tool-call.ts +51 -14
  301. package/src/train/flash-cce.ts +2 -2
  302. package/src/train/forward.ts +6 -0
  303. package/src/train/loss.ts +1 -1
  304. package/src/train/prefix-shared.ts +5 -1
  305. package/src/train/segmented.ts +5 -3
  306. package/src/train/trainer.ts +6 -6
  307. package/src/vision/prompt.ts +1 -1
  308. package/src/vision/qwen3vl-tower.ts +52 -10
  309. package/src/web/app.html +1 -1
  310. package/src/web/app.js +62 -60
  311. package/src/web/src/adapters-panel.ts +3 -3
  312. package/src/web/src/assistant.ts +2 -36
  313. package/src/web/src/chat.ts +4 -4
  314. package/src/web/src/composer.ts +4 -4
  315. package/src/web/src/hub.ts +1 -1
  316. package/src/web/src/markdown.ts +0 -0
  317. package/src/web/src/memory-panel.ts +1 -1
  318. package/src/web/src/model-picker.ts +1 -1
  319. package/src/web/src/palette.ts +1 -1
  320. package/src/web/src/protocol.ts +3 -39
  321. package/src/web/src/sessions.ts +1 -1
  322. package/src/web/src/ui-catalog.ts +4 -18
  323. package/src/web-assets.ts +47 -0
  324. package/src/weights.ts +55 -9
  325. package/docs/archive/investigations/curve-runs/bisector-route.json +0 -98
  326. package/docs/archive/investigations/curve-runs/bisector-trace.json +0 -1393
  327. package/docs/archive/investigations/curve-runs/curve-terrain.json +0 -1179
  328. package/docs/archive/investigations/curve-runs/curve-terrain.svg +0 -42
  329. package/docs/archive/investigations/hlg-ab.html +0 -34
  330. package/docs/archive/investigations/hlg-explorer.html +0 -238
  331. package/docs/archive/investigations/hlg-figs/cliff.svg +0 -1
  332. package/docs/archive/investigations/hlg-figs/cross.svg +0 -1
  333. package/docs/archive/investigations/hlg-figs/edges.svg +0 -1
  334. package/docs/archive/investigations/hlg-figs/k20-grids.svg +0 -1
  335. package/docs/archive/investigations/hlg-figs/k20-peaks.svg +0 -1
  336. package/docs/archive/investigations/hlg-figs/lw-curve.svg +0 -1
  337. package/docs/archive/investigations/hlg-figs/terrain.svg +0 -1
  338. package/docs/archive/investigations/hlg-report.html +0 -262
  339. package/docs/archive/investigations/hlg-runs/hlg-ab.json +0 -149
  340. package/docs/archive/investigations/hlg-runs/hlg-blind-prompts.md +0 -87
  341. package/docs/archive/investigations/hlg-runs/hlg-blind.json +0 -107
  342. package/docs/archive/investigations/hlg-runs/hlg-cliff.json +0 -197
  343. package/docs/archive/investigations/hlg-runs/hlg-cross.json +0 -505
  344. package/docs/archive/investigations/hlg-runs/hlg-edge.json +0 -388
  345. package/docs/archive/investigations/hlg-runs/hlg-eval1.json +0 -25
  346. package/docs/archive/investigations/hlg-runs/hlg-frontier.json +0 -86
  347. package/docs/archive/investigations/hlg-runs/hlg-grid.json +0 -242
  348. package/docs/archive/investigations/hlg-runs/hlg-grid2.json +0 -343
  349. package/docs/archive/investigations/hlg-runs/hlg-lw-coarse.json +0 -110
  350. package/docs/archive/investigations/hlg-runs/hlg-map.json +0 -383
  351. package/docs/archive/investigations/hlg-runs/run0-original.log +0 -159
  352. package/docs/archive/investigations/hlg-runs/runA-recommended.log +0 -131
  353. package/docs/archive/investigations/hlg-runs/runAA-cliff-cpm5.log +0 -26
  354. package/docs/archive/investigations/hlg-runs/runAB-grid2-e4b.log +0 -18
  355. package/docs/archive/investigations/hlg-runs/runAC-peak-e4b-partial.log +0 -25
  356. package/docs/archive/investigations/hlg-runs/runAD-ab-samples.log +0 -8
  357. package/docs/archive/investigations/hlg-runs/runAE-edge-e4b.log +0 -51
  358. package/docs/archive/investigations/hlg-runs/runAF-logit-calibration.log +0 -10
  359. package/docs/archive/investigations/hlg-runs/runAG-eval-config2.log +0 -16
  360. package/docs/archive/investigations/hlg-runs/runB-gain-variants.log +0 -192
  361. package/docs/archive/investigations/hlg-runs/runC-pivots.log +0 -162
  362. package/docs/archive/investigations/hlg-runs/runD-oetf.log +0 -132
  363. package/docs/archive/investigations/hlg-runs/runE-eotf.log +0 -162
  364. package/docs/archive/investigations/hlg-runs/runF-shaper-working.log +0 -86
  365. package/docs/archive/investigations/hlg-runs/runG-shaper-sweep.log +0 -101
  366. package/docs/archive/investigations/hlg-runs/runH-wsweep.log +0 -176
  367. package/docs/archive/investigations/hlg-runs/runI-asweep.log +0 -176
  368. package/docs/archive/investigations/hlg-runs/runJ-knobmap.log +0 -49
  369. package/docs/archive/investigations/hlg-runs/runK-frontier.log +0 -19
  370. package/docs/archive/investigations/hlg-runs/runL-widemap.log +0 -65
  371. package/docs/archive/investigations/hlg-runs/runM-frontier-emb.log +0 -15
  372. package/docs/archive/investigations/hlg-runs/runN-verify.log +0 -116
  373. package/docs/archive/investigations/hlg-runs/runO-frontier-seed5000.log +0 -15
  374. package/docs/archive/investigations/hlg-runs/runP-grid-AxSm.log +0 -15
  375. package/docs/archive/investigations/hlg-runs/runQ-grid-tgW.log +0 -15
  376. package/docs/archive/investigations/hlg-runs/runR-blind-transcript.log +0 -79
  377. package/docs/archive/investigations/hlg-runs/runS-cross-coherence.log +0 -33
  378. package/docs/archive/investigations/hlg-runs/runT-cross-cpm5.log +0 -33
  379. package/docs/archive/investigations/hlg-runs/runU-cross-12b.log +0 -33
  380. package/docs/archive/investigations/hlg-runs/runV-lw-e4b.log +0 -22
  381. package/docs/archive/investigations/hlg-runs/runW-lw-12b.log +0 -22
  382. package/docs/archive/investigations/hlg-runs/runX-lw-cpm5.log +0 -22
  383. package/docs/archive/investigations/hlg-runs/runY-cliff-e4b.log +0 -26
  384. package/docs/archive/investigations/hlg-runs/runZ-cliff-12b.log +0 -26
  385. package/docs/archive/mlx-bun-lab-report.html +0 -275
  386. package/docs/archive/wwdc-mlx-bun.html +0 -848
  387. package/docs/design/adapters-end-to-end.md +0 -205
  388. package/docs/design/batching-perf-path.md +0 -255
  389. package/docs/design/batching-v2-plan.md +0 -529
  390. package/docs/design/bucketing-stage.md +0 -197
  391. package/docs/design/compat-cli-surface-design.md +0 -230
  392. package/docs/design/docs-reorg-plan.md +0 -165
  393. package/docs/design/dspark-serving-program.md +0 -371
  394. package/docs/design/dspark-speculative-decoding.md +0 -318
  395. package/docs/design/grammar-spec-batching-integration.md +0 -301
  396. package/docs/design/memory-inference-path.md +0 -422
  397. package/docs/design/memory-synthesis.md +0 -287
  398. package/docs/design/memory-system.md +0 -237
  399. package/docs/design/mlx-lm-serving-execution-seam.md +0 -81
  400. package/docs/design/mlx-lm-tool-parity-plan.md +0 -545
  401. package/docs/design/omlx-adoption-map.md +0 -98
  402. package/docs/design/orpo-dynamic-lambda.md +0 -220
  403. package/docs/design/orpo-future-enhancements.md +0 -340
  404. package/docs/design/paged-kv-cache.md +0 -214
  405. package/docs/design/parallel-slots.md +0 -567
  406. package/docs/design/parity-tier-dag.md +0 -161
  407. package/docs/design/repo-cleanup-plan.md +0 -231
  408. package/docs/design/runtime-isolation.md +0 -263
  409. package/docs/design/segmented-backward-training.md +0 -543
  410. package/docs/design/spec-decode-larger-targets.md +0 -229
  411. package/docs/design/ssd-kv-cold-tier.md +0 -415
  412. package/docs/design/structured-output.md +0 -484
  413. package/docs/design/tauri-desktop-app.md +0 -127
  414. package/docs/design/the-dreaming-master-plan.md +0 -445
  415. package/docs/design/turboquant-kv.md +0 -235
  416. package/docs/design/turboquant-weights.md +0 -467
  417. package/docs/design/w4a16-compute-precision-spike.md +0 -232
  418. package/docs/design/web-chat-beat-matrix.md +0 -315
  419. package/docs/design/write-pipeline-entity.md +0 -468
  420. package/docs/planning/IDEAS.md +0 -69
  421. package/docs/reference/embedding.md +0 -197
  422. package/docs/reference/features-matrix.md +0 -101
  423. package/docs/reference/orpo-quickstart.md +0 -135
  424. package/src/flags.ts +0 -11
  425. /package/docs/{design → archive/investigations}/colibri-glm52-port.md +0 -0
  426. /package/docs/{planning → archive/planning}/chunk-task-roadmap.md +0 -0
  427. /package/docs/{planning → archive/planning}/curve-sampler-research-plan.md +0 -0
  428. /package/docs/{planning → archive/planning}/memory-docs-and-dag-plan.md +0 -0
  429. /package/docs/{planning → archive/planning}/pi-integration-review.md +0 -0
  430. /package/docs/{planning → archive/planning}/release-notes-v0.2.0.md +0 -0
  431. /package/src/{memory-plan.ts → admission-plan.ts} +0 -0
  432. /package/{docs/archive/investigations → src/serve/assets}/curve-terrain.html +0 -0
  433. /package/{docs/dag → src/serve/assets}/training-inference-map.html +0 -0
@@ -0,0 +1,1092 @@
1
+ # Qwen3.8-27B optimization campaign — execution log (2026-09-04 → 2026-09-08)
2
+
3
+ Verbatim move of `docs/design/decode-speed-program.md` §7.8 ("Execution progress and next measurements"); the per-row outcomes, retained flags and open gates it fed are in that doc's §7.13. Evidence filenames resolve to `reports/qwen38-rd/` on the measuring host (Apple M4 Pro, 24 GB unless stated); host names are provenance, not scope.
4
+
5
+ ## §7.8 Execution progress and next measurements (as archived)
6
+
7
+ Use the integrated memory safeguards and relevant numerical controls in
8
+ section 7.1, then measure the expensive computation. The existing benchmark
9
+ accepts an exact local artifact and can print its
10
+ commands without loading a model. The first prepared jobs are the affine
11
+ flagship on mlx-bun serial versus mlx-lm, followed by packed Q3 on mlx-bun
12
+ serial. Start at 4k context; widen only after the measured memory row.
13
+ The commands and preparation mode are documented in
14
+ [benchmarks.md](../reference/benchmarks.md#running-the-benchmark).
15
+
16
+ The harness now keeps all five decode samples, uses reproducible nonces with
17
+ `--workload-seed`, pins thinking mode across arms, and saves request bodies,
18
+ counts, finish reasons, errors and wall times in a JSON companion. It rejects
19
+ missing token usage instead of counting SSE chunks as tokens. Each block
20
+ still needs an explicit AB/BA order and a distinct output path; one harness
21
+ pass is a screening block, not the full paired-session confidence interval.
22
+ Identical decoded text and prompt counts remain a smoke check; engine logit
23
+ and token-ID gates provide the stronger correctness evidence.
24
+
25
+ The matched-prefill MTP control exposed a separate ordinary-generation
26
+ latency cost: the serial loop constructs the next decode step before yielding
27
+ token zero. A runtime-only source transform yields the first sampled token
28
+ before that construction, retaining the later pipeline and excluding fill,
29
+ grammar and resumed generation. Its initial packed-model pair preserves every
30
+ token ID, live cache state, cache key, usage count and finish reason at raw
31
+ prompt lengths 6/128/512. Native first-token latency improves while complete
32
+ generation time is approximately flat. Six lifecycle tests, the 26 existing
33
+ fill-loop tests and 15 binding tests pass with the prototype. One binding
34
+ cancellation expectation needs the new event order: token zero may arrive
35
+ before cancellation triggered inside the subsequent forward; no token arrives
36
+ after cancellation. Consumer return at that first yield leaves a correctly
37
+ described prompt-only cache. Those screens changed only the runtime-loaded module.
38
+
39
+ The first serial HTTP pair preserves all seven warm/measured responses but
40
+ does not reproduce the native TTFT improvement. Client-visible output can lag
41
+ token zero through detokenizer buffering. A separate sink observer confirms
42
+ that these raw prompts first generate bare-space token 220, which emits no
43
+ event, followed by token 17 (`2`), which emits content and yields for network
44
+ progress. Both arms preserve that sequence; earlier delivery of the hidden
45
+ space cannot improve client TTFT. Keep this negative result and test chat
46
+ fixtures before attributing a serving win or integrating the prototype.
47
+ Both screens keep sources fixed and exit cleanly. Evidence:
48
+ `first-yield-native-screen{,-review}.json`, `first-yield-http-screen.json`,
49
+ `first-yield-http-observe.json` and its per-server `*.sink.json` records,
50
+ `first-yield-smoke-candidate-v2.txt`, `first-yield-existing-loop-tests.txt` and
51
+ `first-yield-binding-order-tests.txt` in the campaign report directory.
52
+
53
+ The subsequent three-fixture chat HTTP screen preserves all seven paired
54
+ responses and improves first visible output on each measured fixture, with
55
+ approximately flat complete-request time. Evidence:
56
+ `first-yield-chat-http-screen{,-review}.json`. A simplified version captures
57
+ the current sample index before yielding and increments the normal generated
58
+ count immediately, avoiding a second stats counter. Its control passes eight
59
+ tests and the candidate passes 49 lifecycle, binding and fill-loop tests,
60
+ including two- and three-token budgets. The first budget test expected an
61
+ explicit native `length` reason, but the incumbent leaves budget completion
62
+ implicit; the corrected assertion preserves that contract. Evidence:
63
+ `first-yield-v2-{control-tests,tests,tests-corrected}.txt`. The simplified
64
+ prototype then completes six fresh-process native pairs. All 36 warm/measured
65
+ token, live-state, cache-key and usage comparisons agree; every measured pair
66
+ improves first-token latency at all three prompt lengths. Complete generation
67
+ time is approximately flat. All 12 children exit cleanly with fixed sources
68
+ and the same remaining active allocation after explicit cleanup. Evidence:
69
+ `first-yield-native-v2-repeat{,-review}.json`. Six chat server pairs then
70
+ complete all 84 requests with 42 exact response/count/finish comparisons.
71
+ Every measured pair improves first visible output, with approximately flat
72
+ complete-request time. The sampled native audit also preserves token IDs,
73
+ requested log probabilities and live cache state across two seeds and two
74
+ prompt lengths, with penalties enabled. Both runs keep sources fixed and
75
+ exit cleanly. Evidence: `first-yield-chat-http-v2-repeat{,-review}.json` and
76
+ `first-yield-sampled-native.json`. Other artifacts and cached/pressure
77
+ acceptance remain, including first-token consumer return and follow-up reuse.
78
+
79
+ The serial change is now integrated behind `MLX_BUN_EARLY_FIRST_TOKEN=1`,
80
+ default off. Its scheduling decision comes from the binding's captured
81
+ runtime; request and execution interfaces are unchanged. Eight permanent
82
+ binding tests cover both settings, captured-policy isolation, short budgets,
83
+ early return, cancellation and initial EOS. The focused tests and enabled-fill
84
+ regression pass, as do all three typechecks, hygiene and the complete
85
+ model-free suite: 1,831 pass, 10 skip, zero failures. The first cancellation
86
+ test incorrectly expected final stats after an exception; the corrected test
87
+ preserves the existing null-stats contract for aborted runs. Orderly consumer
88
+ return still reports the emitted token and exact cache key. Real-model and
89
+ HTTP flag comparisons follow the prototype measurements before this thread
90
+ can close. Evidence: `first-yield-production-unit{,-v2}.txt`,
91
+ `first-yield-production-fill-enabled.txt`, `first-yield-production-typecheck.txt`,
92
+ `first-yield-production-hygiene.txt` and `first-yield-production-model-free.txt`.
93
+ The integrated packed-model native pair preserves all six warm/measured
94
+ token/state/key/usage comparisons. Its serial HTTP pair completes 14 responses
95
+ with all seven paired text/count/finish checks exact. Both reproduce earlier
96
+ first-token delivery and keep sources fixed with clean child exits. A slow
97
+ HTTP warmup is retained; these integration screens do not replace the six
98
+ balanced prototype pairs for timing evidence. Evidence:
99
+ `first-yield-production-native-r6{,-review}.json` and
100
+ `first-yield-production-http-r6{,-review}.json`. Closed source-transform and
101
+ duplicate test helpers are removed; permanent tests and raw reports remain.
102
+ The first integrated RTN4 native pair also preserves all six token/state/key
103
+ comparisons. Its apparent large complete-time difference is not accepted as
104
+ a speed gain: step intervals change substantially within the control process,
105
+ system swap grows and final preflight records substantial Chrome CPU use.
106
+ Keep this correctness result and repeat timing before attribution. Evidence:
107
+ `first-yield-production-native-rtn4{,-review}.json` and per-token arrival times
108
+ in the same report. No unrelated application was stopped.
109
+
110
+ The continuous scheduler has its own first-output boundary: an empty group
111
+ finishes preparation and emits token zero, then advances decode before its
112
+ event-loop yield. A separate prototype adds a yield only when preparation
113
+ leaves exactly one active row and no queued arrivals. It preserves grouped
114
+ short admissions and stops immediately if the group closes during that await.
115
+ Nine scheduling tests pass for each control/candidate arm; an actual
116
+ continuous HTTP screen must verify wire placement and client arrival time.
117
+ Evidence: `first-prepare-scheduler-{control,candidate}.txt` and the frozen
118
+ `first-prepare-http-screen-plan.json` in the campaign report directory.
119
+
120
+ Six subsequent AB/BA blocks complete on the M4 Pro with 12 clean server exits,
121
+ 84 responses and 42 exact paired responses, including counts, finish reasons
122
+ and cache usage. The actual continuous lane and submitted-row increment are
123
+ checked for every request. Median paired TTFT changes are -7.66% for code,
124
+ -7.90% for explanation and -5.63% for JSON, about 74–77 ms earlier. Complete
125
+ request time changes by +0.15%, +0.04% and +0.08%, respectively. One code pair
126
+ has 2.20% worse TTFT and remains in the report. The machine begins with Chrome
127
+ CPU activity and existing swap, so these are diagnostic measurements. Chrome
128
+ is unrelated background load; a Bun HTTP client sends requests directly to
129
+ the server without the chat UI. Source hashes remain fixed. Evidence is
130
+ `first-prepare-http-repeat{,-review}.json`; scheduler lifecycle and broader
131
+ request gates remain before integration.
132
+
133
+ The continuous option is now integrated under `MLX_BUN_EARLY_FIRST_TOKEN`,
134
+ default off. The MLX backend reads its captured runtime and passes a boolean
135
+ to the generic scheduler. No request or execution-contract field is added.
136
+ After the early yield, the scheduler restarts its policy loop so new arrivals,
137
+ cancelled queued work, admission holds and shutdown are observed before the
138
+ next step. Eight added unit cases cover those transitions, short-admission
139
+ grouping, an existing active row and cleanup on a failed yield. All 1,839
140
+ model-free tests, the three typechecks and hygiene pass. Integrated real HTTP,
141
+ cache, pressure and quiet gates remain. The integrated native option also
142
+ passes four sampled cases per artifact on packed Q3 and RTN4, preserving all
143
+ 32 token IDs, requested log probabilities, cache keys, live KV/recurrent state
144
+ and usage. Each arm returns to the same measured native allocation baseline
145
+ after disposal. These are correctness checks, not repeated timing claims.
146
+ Evidence is `first-prepare-production-{unit,model-free,typecheck,hygiene}.txt`
147
+ and `first-yield-production-sampled-{r6,rtn4}.json`.
148
+
149
+ The first integrated continuous HTTP attempt is retained as a setup failure.
150
+ Its driver set the new option after MLX imports had captured the runtime, so
151
+ the candidate's execution counter remained zero and rejected the run. The
152
+ corrected driver sets the flag in the child environment before imports. Both
153
+ arms then execute the same instrumented production source, with seven early
154
+ yields in the candidate and zero in the control. All seven paired responses
155
+ and usage/finish checks pass, with fixed source and clean exits. TTFT improves
156
+ by 68–90 ms across the three measured fixtures; this one-block integration
157
+ check does not replace the six prototype timing pairs. Evidence is
158
+ `first-prepare-production-http-r6-v2{,-review}.json`; the original unsuffixed
159
+ report preserves the failed path-coverage check.
160
+
161
+ Nine packed-Q3 native cache-lifecycle pairs also pass. At prompt lengths
162
+ 6/128/512, each arm either returns after one token, returns after two, or
163
+ aborts after one, then reuses its own borrowed cache for a 16-token follow-up.
164
+ An early first-token return/abort covers the prompt alone; the incumbent has
165
+ already fed token zero. Clean-return cache keys reflect those exact positions,
166
+ and an aborted generation retains the existing null-stats contract. A
167
+ one-token follow-up suffix with ordinary tail splitting gives matched M=1
168
+ forwards for any missing emitted token. All subsequent tokens, requested log
169
+ probabilities, final live cache states and cache keys match. Both processes
170
+ return to 16,390 native active bytes after disposal, without forced GC, and
171
+ the source stays fixed. This proves the covered native reuse transitions;
172
+ HTTP cache/SSD pressure and broader suffix shapes remain. Evidence is
173
+ `first-yield-production-cache-r6.json`. The same nine pairs also pass on RTN4,
174
+ including every follow-up token, requested log probability, cache key and live
175
+ state. Both RTN4 arms return to six native active bytes after disposal. Its
176
+ separate evidence is `first-yield-production-cache-rtn4.json`.
177
+
178
+ The broader native suffix screen completes 110 follow-ups across both Qwen
179
+ quants at suffix lengths 1/2/3/4/5/8/31/127/511/512/513. It does not pass
180
+ universal identity. After returning at token one, the early arm's prompt-only
181
+ cache makes the next prefill one token longer. Seven packed and six RTN4
182
+ cases change log probabilities or live state; two packed cases and one RTN4
183
+ case also change emitted IDs. Every two-token-return case remains exact.
184
+ Feeding the missing emitted token separately at M=1 restores exact stopped
185
+ state and all 22 aligned follow-ups, including requested log probabilities
186
+ and cache keys. Both arms return to their original active-allocation baselines.
187
+ This identifies a prefill-shape effect, not a seed mismatch or a corrupted
188
+ snapshot. Keep the option experimental; reconciling the first-token cache
189
+ boundary needs an implementation and performance gate before default
190
+ promotion. Evidence is `first-yield-suffix-qwen{,-review}.json`. The preceding
191
+ Llama smoke also records a natural 512-token suffix state/logprob difference.
192
+
193
+ The integrated option also passes the saved seven-request agent-boundary/SSD
194
+ gate in serial and actual continuous serving on the M4 Pro 24 GB. The first
195
+ six one-token budgets retain their original path; each lane's counter proves
196
+ the new option runs once on the final 512-token request. All 14 paired choices
197
+ and complete usage records match. The longest prompt has 14,465 tokens and
198
+ reuses the same 12,953-token prefix in every arm. All four final flushes report
199
+ 14 durable entries, no pending/missing/failed snapshots, and a longest durable
200
+ prefix of 14,976 tokens. Sources stay fixed and all servers exit cleanly.
201
+ These non-streaming responses establish the covered memory/cache lifecycle,
202
+ not a TTFT result or an agent task success. Broader suffix shapes remain.
203
+ Evidence is
204
+ `first-token-production-long-{serial,continuous}{,-review}.json`.
205
+
206
+ Actual streaming HTTP cancellation and arrival checks now pass 120 requests
207
+ across eight Qwen servers, covering packed Q3 and RTN4, serial and continuous
208
+ serving, and both option settings. Each server aborts twice at headers and
209
+ twice at first output, then completes an independent recovery request after
210
+ each abort. The server observes all 32 cancellations and settles before
211
+ consuming the 512-token budget. Every recovery response, usage record and
212
+ finish reason matches its reference. Final active MLX allocation equals the
213
+ loaded-model baseline exactly, with no cache entries or active/pending rows.
214
+ One-token budgets also remain exact. Both overlapping-arrival fixtures
215
+ observe two active rows in continuous serving, with actual admission counts;
216
+ serial serving remains serial. All sources stay fixed and servers exit
217
+ cleanly. A preceding Llama smoke adds 60 requests and 16 cancellations.
218
+ These instrumented checks establish lifecycle behavior, not speed. Concurrent
219
+ trajectories are not compared across differing admission timing and batch
220
+ shapes. Evidence is `first-token-lifecycle-{llama,qwen}{,-review}.json`.
221
+
222
+ The first actual continuous HTTP pair then completes all 14 requests with
223
+ seven exact response/count/finish comparisons and verified batched placement.
224
+ First visible output improves on all three measured chat fixtures; complete
225
+ time varies slightly. Both servers exit cleanly with fixed sources. This
226
+ remains a prototype pending balanced repeats and broader scheduling gates.
227
+ Evidence: `first-prepare-http-screen{,-review}.json`.
228
+
229
+ The first performance work after the pull uses the packed artifact's actual
230
+ k2/k3/k4 matrices. The M=1/2/3/4/5/8 screen identifies the gate/up crossover
231
+ and the down-projection bit-width asymmetry. Shared-M reduce and fused gate/up
232
+ kernels are retained as experimental variant 7 after exact matrix/MLP checks
233
+ and six balanced diagnostic A/B blocks. Variant 8 adds a balanced and aligned
234
+ 3-bit down kernel; it improves the observed M=1/2/4 full-model forwards while
235
+ preserving logits, live state and subsequent-token checks. A device LUT for the existing f32
236
+ code values loses on this M4 and is recorded as a negative result. Kernel
237
+ implementation, commands and evidence live in turboquant.md's packed-kernel section.
238
+
239
+ The full packed 27B passes logits, live recurrent/KV state and subsequent-token
240
+ identity at M=1..5. Six paired native-forward blocks also retain the gain at
241
+ M=2/4, but they use a short synthetic prefix and project every output position.
242
+ They are not HTTP decode, verified MTP or strict-fill throughput measurements.
243
+ The existing exact-artifact graph/session/cache gate passes on the packed
244
+ model as well. Variant 6 remains the default.
245
+
246
+ The packed 27B strict-fill regression passes on variants 6 and 7: nonzero
247
+ assert injection, no verification events and exactly matching emitted tokens.
248
+ This is one tool-call fixture, not a held-out determinism or timing result.
249
+ The last-position-only native append sweep covers M=1/2/3/4/5/8/9/16 with
250
+ six paired blocks, preserving candidate/current logits and live state in every
251
+ cell. It retains the small-M gain and confirms the M=4/5 whole-model cost
252
+ discontinuity. Raw evidence: `reports/qwen38-rd/shared-m-append-lengths.json`.
253
+
254
+ Variant 10 now shares scatter decode across small M as well. It passes the
255
+ same exact full-model gates and improves M=2..4 against variant 8 in six
256
+ paired native blocks. Variant 9 separately moves expanded-projection
257
+ evaluation to the existing layer boundary. Its observed outputs agree, but
258
+ peak memory rises. Extending the packed crossover to M=8 is a distinct Lab
259
+ candidate with observed output differences. The packed-kernel section in
260
+ turboquant.md owns these implementations and evidence.
261
+
262
+ Integrated variant 11 adds direct tiled gate/up prefill for M=5..32, with
263
+ the same full-model logit/state gates and paired native improvement against
264
+ variant 10. The operation has no model-name dependency; its dispatch profile
265
+ currently covers the measured Qwen MLP geometry. It also improves the strict
266
+ fill fixture's complete generation time in six paired fill/no-fill blocks,
267
+ with identical emitted tokens and no verification forwards. This remains
268
+ fixture evidence, not a universal determinism proof. Evidence:
269
+ `variant11-full-model-review.json` and
270
+ `strict-fill-v11-cap32-served-eos.review.json`. Six paired raw-completion
271
+ HTTP blocks per method improve first-token and complete-request latency,
272
+ with identical output, through strict serial and continuous B=1 execution.
273
+ They cover one six-token prompt and eight/64 output tokens; concurrency and
274
+ broader-workload conclusions remain open. Evidence: `trellis-v11-http.json`
275
+ and `trellis-v11-http-review.json`.
276
+
277
+ Variant 12 adds tiled split-K down projection at M=5..8. The integrated
278
+ kernel passes exact full-model logits/state/continuation checks and improves
279
+ six native paired blocks without changing the paths outside that range.
280
+ Its implementation and sweep evidence live in turboquant.md. Serving and
281
+ combined-candidate measurements remain separate gates. The combined variant
282
+ 12 versus original variant 6 now passes six raw-completion HTTP pairs for
283
+ each serial/default scheduling method, with matching text and actual token
284
+ counts at eight/64 output tokens. Source hashes stay fixed throughout all
285
+ 24 bounded server processes. These one-prompt, B=1 diagnostics improve both
286
+ TTFT and complete-request latency; they do not establish concurrent load or
287
+ quiet-machine performance. Evidence: `trellis-v12-combined-http.json` and
288
+ `trellis-v12-combined-http-review.json`. The exact-input native control also
289
+ improves first-token and complete-request time in six paired blocks per
290
+ output length, with identical emitted IDs. One candidate worker escaped
291
+ through Bun with a C++ exception; its traced replay and the complete repeated
292
+ pair succeed. The original failed block is retained and excluded from timing
293
+ aggregation. This does not close the runtime reliability issue. Evidence:
294
+ `trellis-v12-combined-native-review.json`, its original/resumed reports and
295
+ `trellis-v12-native-failure-replay.json`.
296
+
297
+ The packed serving comparison now also covers four simultaneous raw
298
+ completions. Six fresh-process pairs compare variants 6 and 12, with a warm
299
+ four-request wave followed by a measured wave. Every arm observes four active
300
+ batch rows, all responses/counts/finish reasons agree, and the candidate
301
+ improves complete-wave throughput in every pair. Prompt and SSD caches are
302
+ disabled; the source snapshot stays fixed and all twelve servers exit cleanly.
303
+ These diagnostics establish that the shared small-M kernels improve actual
304
+ concurrent serving, alongside the earlier B=1 results. Mixed lengths, larger
305
+ concurrency and quiet-machine acceptance remain separate gates.
306
+ Evidence: `trellis-concurrent-http.json` and
307
+ `trellis-concurrent-http-review.json`.
308
+
309
+ The operation trace led to smaller M=5..8 matrix tiles and deferred evaluation
310
+ for direct tiles. Dense expansion retains its projection boundary. The
311
+ integrated kernels pass targeted units and an old-source/new-source comparison
312
+ at ten append lengths, including logits, live cache bytes and continuation.
313
+ Six subsequent HTTP process pairs compare the previous and updated variant 12
314
+ at B=1 and eight concurrent requests. Every wave observes the expected active
315
+ row count; all paired warmup and measured responses, token counts and finish
316
+ reasons agree. Eight-request throughput improves consistently; B=1 first-token
317
+ latency improves, with a much smaller complete-request gain. All twelve servers
318
+ exit cleanly and the source hashes remain fixed. The initial explicit-seed
319
+ pilot routed through serial and is excluded from batching evidence. These
320
+ remain loaded-machine diagnostics (measured on the M4 Pro), with variant 6 unchanged. Evidence:
321
+ `trellis-tile-integrated-forward-review.json`, `trellis-tile-http-review.json`
322
+ and `trellis-tile-seeded-serial-http-review.json` in the campaign directory.
323
+ Six old/new native process pairs also preserve all 64 emitted IDs and finish
324
+ reasons in warmup and measurement. First-token latency improves in every pair;
325
+ the complete native request improves slightly because single-row decode is
326
+ unchanged. All twelve workers complete with fixed source hashes. Evidence:
327
+ `trellis-tile-native.json` and `trellis-tile-native-review.json`.
328
+ The tile and evaluation-boundary experiments are detailed in turboquant.md.
329
+
330
+ The existing `bench-serve.ts all` suite also completes two AB/BA process pairs
331
+ for packed variants 6 and 12 with the serial arm, fixed workload seed and 192
332
+ decode tokens. Source snapshots match across all four runs. All 38 paired
333
+ recorded requests and the separate raw/chat parity probes agree; every server
334
+ exits cleanly, all SSD entries are durable, and no failed samples are dropped.
335
+ Single-request decode improves consistently at both tested contexts. Cold
336
+ prefill improves modestly; warm first-token latency varies between pairs and
337
+ sampled RSS shows no reduction. The requested context target produces 2,679
338
+ actual prompt tokens. The four-request aggregate leg is serial queue throughput,
339
+ not batching evidence. This loaded-machine diagnostic (M4 Pro 24 GB) does not promote a default or
340
+ replace quiet-machine acceptance. Evidence:
341
+ `single-request-suite-packed.json` and `single-request-suite-packed-review.json`,
342
+ with all four raw suite reports in the campaign directory.
343
+
344
+ Variant 13 adds vectorized packed-weight expansion after a larger fused-tile
345
+ screen failed to beat native matmul. The operation and packing contract are
346
+ documented in turboquant.md. Focused tests cover every codebook state, circular
347
+ windows, scale dtypes, strided inputs and fallback. The integrated 12/13
348
+ comparison preserves logits, live cache bytes and continuation at five append
349
+ lengths across seven blocks, including six measured AB/BA pairs. Actual kernel
350
+ calls confirm the eligible prefills improve while M=1/8 retain their existing
351
+ path. All three typechecks, hygiene and 1,795 model-free tests pass. Evidence:
352
+ `trellis-vector-integrated-full-model-review.json` and
353
+ `trellis-vector-integrated-{unit,typecheck,hygiene,model-free}.txt` in the
354
+ campaign report directory.
355
+
356
+ Two subsequent AB/BA pairs through the existing serving suite preserve all 38
357
+ paired requests, raw/chat parity and SSD restart durability. All four servers
358
+ exit cleanly with fixed source snapshots and no failures. Cold TTFT at the
359
+ smaller prefill improves modestly, while decode, long-context TTFT and RSS are
360
+ approximately flat. Cached TTFT varies substantially, so it is not an accepted
361
+ kernel gain. An external browser/build/test burst occurs near the first pair's
362
+ transition and is retained in the observations. This result does not establish
363
+ a broad serving improvement or promote variant 13. Quiet-machine acceptance
364
+ remains. Evidence: `vector-expand-suite-packed.json`,
365
+ `vector-expand-suite-packed-review.json` and
366
+ `vector-expand-suite-load-observations.json` in the campaign directory.
367
+
368
+ Six further serial HTTP AB/BA pairs isolate 6/16/128/512-token prompts with
369
+ 64 generated tokens and prompt/SSD caching disabled. Each shape receives a
370
+ separate warmup; all first-shape timings are retained. Every paired response,
371
+ token count and finish reason matches across all 54 warmup/measured requests,
372
+ sources remain fixed, and all twelve servers shut down cleanly. TTFT and
373
+ complete-request time improve in every 16/128-token pair. The six-token
374
+ control and decode speed are flat; the 512-token and sampled RSS results are
375
+ less consistent. Six default-scheduler pairs repeat the improvement at
376
+ 16/128 tokens, with exact responses, fixed sources and clean shutdowns.
377
+ Per-request telemetry proves scheduler admission. Existing swap usage and
378
+ background CPU activity keep both series (measured on the M4 Pro) diagnostic; the 512-token
379
+ effect remains less consistent. Evidence:
380
+ `trellis-vector-short-http-paired-{serial,default}.json` and the corresponding
381
+ `-review.json` files in the campaign directory. Quiet, second-machine and
382
+ pressure acceptance remain before any default promotion.
383
+
384
+ The updated affine controls now complete six alternating Bun/MLX-LM process
385
+ pairs for each flagship, compact and RTN4 artifact. They use the same six raw
386
+ prompt IDs, 64 output tokens, tokenizer/model EOS handling, production wiring
387
+ decisions and fresh-cache cleanup. Every pair emits identical IDs. Complete
388
+ native request time is close, with a small median Bun advantage; MLX-LM has
389
+ slightly lower first-token latency. These diagnostic controls establish no
390
+ new kernel win or HTTP conclusion. All 36 workers finish and the source
391
+ snapshot stays fixed. Evidence: `native-affine-paired.json` and
392
+ `native-affine-paired-review.json` in the campaign report directory.
393
+
394
+ The shared grammar bitmask candidate compares host expansion, direct Metal,
395
+ compiled Metal and XGrammar's compiled MLX bitmap-table approach. The compiled
396
+ Metal operation preserves the additive mask's bytes for bf16/f16/f32,
397
+ strided inputs, missing words, signed zero and nonfinite values. Its owned
398
+ host snapshot survives matcher mutation before lazy evaluation. Repeated
399
+ calls release their arrays after stream synchronization. Complete greedy,
400
+ sampled and logprob-enabled sampling retains identical selected tokens and
401
+ logprob bytes across changing masks at three vocabulary sizes, and improves
402
+ eight paired blocks against the actual host loop. An earlier probe used a
403
+ slower host callback expansion and is excluded from performance evidence.
404
+ Grammar integration is opt-in pending actual serving measurements. Evidence:
405
+ `token-mask-probe.json`, `token-bitmask-unit.txt` and
406
+ `token-bitmask-grammar-metal.txt`, plus `token-mask-sampling.json` and
407
+ `token-mask-sampling-review.json` in the report directory.
408
+
409
+ The first dense attention prototype adapts vLLM-Metal's register-resident
410
+ online softmax. It reduces temporary memory but loses the timing screen.
411
+ Instantiating pinned MLX Steel attention at head dimension 256 is faster on
412
+ some self-attention shapes, while the long-K/short-Q suffix case remains
413
+ slower. Tiling must follow both lengths and the device's workspace limit.
414
+ This changes numerics relative to the current unfused bf16 path and stays
415
+ Lab pending model and task-quality checks. Evidence:
416
+ `steel-attention-tune-manifest.json` and its per-tile reports. The initial
417
+ probe's small-head error metrics used physical output order; the corrected
418
+ contiguous readback agrees with the pinned oracle and CPU reference in
419
+ `attention-cpu-check.json` and `attention-oracle-check.json`.
420
+ The full packed-model Steel test is flat at 128/512 prompt tokens; one
421
+ 512-token cell exceeds its predeclared last-logit KL screen, despite matching
422
+ the observed argmax. It has no model-level speed or quality acceptance.
423
+ Moving Q into threadgroup storage and transposing K storage did not rescue
424
+ the separate register-based prototype's timing. Evidence:
425
+ `attention-full-model-packed-128-512-review.json` and
426
+ `dense-attention-memory-tune-review.json`. Larger-context and exact-arithmetic
427
+ attention candidates remain separate experiments.
428
+
429
+ Graph export now records the existing evaluation boundaries for variants
430
+ 6/8 at M=1/4/5. Small-M forward has one final evaluation boundary. M=5 has
431
+ 192 projection evaluations, 64 layer evaluations and a final evaluation.
432
+ The exported graphs identify the exercised operations, including affine
433
+ projections, packed custom kernels, GDN, convolution, norms, RoPE, attention
434
+ and casts. Counts are exported operation occurrences, not GPU dispatches.
435
+ Raw graphs and the manifest are in `reports/qwen38-rd/graph-captures/`.
436
+
437
+ An attached Metal System Trace captures the warmed Bun target and its GPU
438
+ encoder intervals. The installed release MLX labels only command buffers
439
+ and encoders, so individual-kernel duration attribution remains open. The
440
+ capture covers part of prefill and decode; it is not a complete TTFT trace.
441
+ The first launch-based capture contains no target GPU work and is excluded.
442
+ Evidence: `variant8-attached.trace` and `attached-trace-summary.json` in the
443
+ same report directory. A pinned MLX source checkout supports inspection of
444
+ the actual dispatch and an isolated profiling build without changing the
445
+ oracle or installed runtime.
446
+
447
+ The isolated profiling build now records the kernel name, dispatch grid,
448
+ threadgroup geometry and pipeline limits for each submitted dispatch. A second
449
+ attached trace adds operation labels to encoder scopes. Those scopes contain
450
+ multiple operations, including zero-work views, so their GPU duration cannot
451
+ be attributed to the label's final operation. The selected Xcode counter
452
+ profile is unsupported on this M4 and exports no shader or counter samples.
453
+ Use the dispatch inventory to select isolated operation experiments while
454
+ individual GPU timing remains open. Evidence: `labelled-v8-analysis.json`,
455
+ `labelled-v8-kernels.txt` and `variant8-labelled.trace` in the report directory.
456
+
457
+ A direct device capability query exposes timestamp counters only at compute
458
+ stage boundaries on this M4 Pro. Dispatch-level sampling is unsupported.
459
+ The isolated pinned runtime now samples each operation in a separate encoder,
460
+ reserving two slots in a shared counter buffer and resolving them once per
461
+ completed command buffer. A per-operation allocation first exhausted Metal's
462
+ sample-buffer resources; a larger pool exceeded its documented-in-error size
463
+ limit. Both failed attempts are retained, and the final pool fits that limit.
464
+ The installed native library and Python oracle are unchanged.
465
+
466
+ Calibration compares the release library, the isolated build without
467
+ segmentation, segmentation alone, and counters. At B=1 and append lengths
468
+ 1/4/8/128 from a 32-token prefix, every arm preserves logits, live cache bytes
469
+ and one continuation across one warmup and three measured forwards. The
470
+ instrumented full-forward overhead is small in this screen. All recorded
471
+ timestamps are valid, and sampled CPU/GPU clock pairs agree. These are
472
+ operation-encoder intervals: operations with multiple dispatches stay grouped,
473
+ intervals can overlap and include waits, and their sum is not GPU wall time
474
+ or critical-path attribution. The small-M trace directs further work toward
475
+ packed projections and affine matvecs; the eight-token trace exposes the
476
+ cost of the tiled prefill path. Evidence: `metal-counter-capabilities.json`,
477
+ `mlx-counter-source-manifest.json`, `mlx-counter-build.patch`,
478
+ `metal-counter-pooled-unit.stderr.txt` and
479
+ `metal-counter-calibration-review.json` in the report directory.
480
+
481
+ A separate schedule recorder now preserves MLX's normal encoder and command
482
+ buffer boundaries. It counts existing dispatches, barriers, fence waits and
483
+ temporary references, and reads command-buffer GPU start/end times in the
484
+ completion handler, following [Metal's timing contract](https://developer.apple.com/documentation/metal/mtlcommandbuffer/gpustarttime).
485
+ It rejects simultaneous operation segmentation. The first smoke test exposes
486
+ a unit mistake in the recorder: the pinned runtime's `buffer_sizes_` adds
487
+ `data_size()`, which counts dtype elements. Correct the recorder to report
488
+ that heuristic as elements and multiply by item size for temporary bytes.
489
+ The effective M4 Pro submission defaults are 50 dispatches and 50 shifted
490
+ element-count units. The setting's upstream name remains
491
+ `MLX_MAX_MB_PER_BUFFER`; it is not a literal byte ceiling. Temporary-reference
492
+ totals are also not peak resident memory.
493
+
494
+ The corrected recorder passes 45 complete generations across Llama 1B and
495
+ Qwen packed/RTN4, comparing the ordinary library, the isolated library without
496
+ telemetry and the recorder with native/raw/compiled sampler arms. Every
497
+ token, live state byte and usage record agrees. Warmed complete timings show
498
+ no clear systematic instrumentation shift in this screen; repeated overhead
499
+ calibration remains necessary for quantitative timing attribution. The
500
+ 64-token packed sampling trace loses four dispatches per token with fusion,
501
+ but all three sampler arms still submit 3,905 buffers containing dispatches.
502
+ Many additional buffers contain no kernel dispatches; they may still carry
503
+ event waits or signals. Audit callers before attempting to remove them.
504
+ Command-buffer spans include internal waits, so their union is not kernel
505
+ active time or device utilization. Evidence is `mlx-schedule-source-manifest.json`,
506
+ `mlx-schedule-smoke-v2.log` and `top-p-schedule-screen{,-review}.json`.
507
+
508
+ A separate caller trace attributes 24 zero-dispatch submissions during steady
509
+ packed greedy decode to the pressure branch in MLX's `eval_impl`, reached
510
+ through `async_eval`. That branch finalizes open GPU streams before waiting
511
+ for outstanding work. All three traced generations preserve emitted IDs,
512
+ live cache bytes and usage against the calibrated recorder. Startup-only
513
+ stacks had instead reached final evaluation and synchronization, so they
514
+ could not establish the steady decode cause. The trace adds CPU logging and
515
+ is not timing evidence. These observations do not establish that an empty
516
+ dispatch list has no event work. Keep the validated recorder separate from
517
+ the caller-trace build. Evidence is `empty-submit-r6-steady-trace{,-review}.json`
518
+ and `mlx-empty-submit-steady-source-manifest.json`.
519
+
520
+ The next stock-library screen varies MLX's command-buffer submission limits,
521
+ bounded breadth-first graph traversal and optional Metal synchronization
522
+ implementation. Measure complete warmed generation, with matching token IDs,
523
+ requested log probabilities and live state, before changing native code or
524
+ retaining a setting. New-shape prefill cells are correctness screens until
525
+ their shapes are warmed in both arms. Positive cells require balanced native
526
+ and actual serial/continuous HTTP repeats, plus memory and disposal checks.
527
+ The frozen screen is `graph-schedule-screen-plan.json`.
528
+
529
+ That first screen passes all 120 generations and 27 complete arm comparisons
530
+ on Llama 1B and Qwen packed/RTN4. No packed-model decode setting has a
531
+ compelling first-pass gain. The later RTN4 timings overlap with unrelated
532
+ disburse TypeScript/Vite/Playwright jobs, including higher load and swap use.
533
+ Exclude RTN4 timing from tuning decisions and repeat it after those workers
534
+ exit; retain its exactness results. Llama's smaller-buffer observation needs
535
+ balanced repeats. Evidence is `graph-schedule-screen{,-review}.json` and
536
+ `graph-schedule-screen-contamination.json`. Retained tuning belongs at the
537
+ existing model-owned execution seams; these experiments do not establish
538
+ new global defaults.
539
+
540
+ The RTN4 rescreen completes 40 generations with nine exact arm comparisons,
541
+ including a return to the default settings at the end. The apparent 0.94%
542
+ greedy gain with traversal width 64 matches the ending default's 0.92% drift;
543
+ sampled generation is flat in both. Larger submission limits also fail to
544
+ improve both decode fixtures. No Qwen setting advances from this screen.
545
+ New-shape prefill timings remain excluded. Evidence is
546
+ `graph-schedule-rtn4-rescreen-v2{,-review}.json`.
547
+
548
+ Llama's six balanced native pairs preserve all 30 paired generations, including
549
+ requested log probabilities and live state. Reducing both submission limits
550
+ to 25 lowers complete warmed generation time by 2.44% for greedy and 2.30%
551
+ for sampled output; all six pairs improve in each cell. TTFT is effectively
552
+ flat. Peak MLX allocation falls in the measured cells, which is not a claim
553
+ about physical RAM savings. Six actual HTTP pairs per lane then preserve all
554
+ 84 paired responses across 168 requests. Complete time improves by
555
+ 1.86–3.02% in serial and 2.22–3.00% in continuous serving across the three
556
+ fixtures, with every pair faster. These results (measured on the M4 Pro) remain diagnostic pending a quiet-machine repeat.
557
+ The controls are `graph-schedule-llama-repeat{,-review}.json` and
558
+ `graph-schedule-llama-http-repeat{,-review}.json`. MLX caches these settings
559
+ at device initialization; assigning environment variables from a later
560
+ model forward would not apply the measured policy. Broader contexts,
561
+ lifecycle coverage and scoped integration remain.
562
+
563
+ A separate native prototype elides `finalize` only when the command buffer
564
+ has not been touched since the preceding commit. Access to the buffer,
565
+ encoder creation, output registration and temporary registration all make it
566
+ ineligible. This preserves event-only and completion-handler work, and leaves
567
+ explicit synchronization unchanged. The isolated build and its disabled arm
568
+ each pass 84 stream/lifetime cases against the installed library, spanning
569
+ three dtypes, two sizes, two memory limits, CPU/GPU and GPU/GPU dependencies,
570
+ view-only events and disposal before asynchronous completion. All cases
571
+ return active memory to zero. The subsequent 45 complete generations also
572
+ preserve IDs, requested log probabilities, live state and usage across the
573
+ three artifacts and both library controls. Packed generation is effectively
574
+ flat. Six subsequent RTN4 AB/BA pairs preserve all 30 paired generations but
575
+ find no reliable gain: complete greedy time changes by -0.069%, sampled by
576
+ +0.108% and warmed prefill by +0.011%. Peak MLX allocation is flat. Close the
577
+ prototype without production integration. Evidence
578
+ is `mlx-untouched-finalize-source-manifest.json` and
579
+ `untouched-finalize-stream-default{,-review}.json`, plus
580
+ `untouched-finalize-native{,-review}.json` and
581
+ `untouched-finalize-rtn4-repeat{,-review}.json`.
582
+
583
+ The separate exact traces confirm that the prototype removes the intended
584
+ submissions. For 64 packed sampled tokens, zero-dispatch buffers fall from
585
+ 3,311 to 194, while all 116,164 dispatches and 3,905 buffers containing
586
+ dispatches remain. RTN4's corresponding zero-dispatch count falls from 4,083
587
+ to two; its 115,947 dispatches remain. The sampled skip counters record
588
+ 3,113/4,072 omitted calls. Counts need not subtract exactly between runs
589
+ because pressure callbacks and completion timing vary. This is mechanism
590
+ evidence, not an end-to-end speed claim. Evidence is
591
+ `untouched-finalize-trace{,-review}.json`.
592
+
593
+ The optional upstream `MLX_METAL_FAST_SYNCH=1` mode stalls in the installed
594
+ library's large bf16 three-stream case under the probe's small submission
595
+ limits. A stack sample finds the host in `scheduler::wait_for_one` and a
596
+ worker in `Fence::wait`. Stop only that probe after more than 100 seconds
597
+ without progress, retain its partial results, and rerun all default-mode
598
+ cases successfully. Do not attribute this stock-library failure to the new
599
+ prototype or treat the unrun experimental-mode arms as passes. Evidence is
600
+ `untouched-finalize-stream.json`, `untouched-finalize-stream-fast1-interruption.json`
601
+ and `untouched-finalize-stream-fast1-default.sample.txt`.
602
+ The initial interruption annotation mislabeled that case as f32; the partial
603
+ report's dtype 12 identifies bf16. The corrected attribution is recorded in
604
+ `untouched-finalize-stream-fast1-failure-review.json`.
605
+
606
+ The existing GDN stage profiler has also been run at M=1/4/128/512 against
607
+ unprofiled forwards from the same prefix. Observed logits agree. Its added
608
+ stage/layer evaluations substantially inflate small-M time, so those stage
609
+ durations cannot substitute for GPU kernel attribution. Evidence:
610
+ `reports/qwen38-rd/gdn-stage-probe.json`. A fused convolution/SiLU/copied-tail
611
+ prototype matches the tested bf16/f32 outputs and live tail at B=1/2. It
612
+ requires MLX's typed sigmoid expression; a float32 rewrite changes bf16
613
+ results. The opt-in operation now passes full packed-model logits, live
614
+ state, continuation and speculative rollback checks. Its initial memory
615
+ benefit exposed an aliasing baseline: `mlx_copy` retains the source buffer.
616
+ The default path now uses a shared compact materialization operation backed
617
+ by stock MLX DynamicSlice, with gradient and compiled-execution gates.
618
+ Replacing the alias preserves all tested packed-model logits, live state,
619
+ continuation and rollback bytes. Explicit disposal still owns handle cleanup;
620
+ the copy change allows the large backing allocation to be released.
621
+ Against an independently materialized baseline, convolution fusion has
622
+ approximately flat full-model timing and similar peak memory. It remains an
623
+ unpromoted R8 experiment. Evidence: `qwen-conv-materialized-packed.json`,
624
+ `materialize-final-packed-comparison.json`, and `conv-probe-typed-sigmoid.json`.
625
+ The final stock-copy rerun is a correctness gate; concurrent CPU trace exports
626
+ exclude its diagnostic timings from performance comparisons.
627
+
628
+ GDN specialization now covers threadgroup layouts, fixed sequence lengths,
629
+ loop unrolling, compiled wrappers and typed sigmoid fusion. Correcting the
630
+ initial float32 sigmoid rewrite restores exact bf16 recurrence and state.
631
+ The subsequent shape sweep passes all 114 cells. A compiled fixed-length
632
+ candidate preserves full-model logits, live state and continuation, but its
633
+ isolated gains mostly disappear in full forwards. A separate fused recurrence,
634
+ output RMS normalization and gate kernel passes 60 isolated shape/dtype cells
635
+ and the small-M full-model checks. Its full-forward improvement is too small
636
+ to justify integration at this point. Neither candidate changes production
637
+ dispatch. Evidence: `gdn-specialization-typed.json`,
638
+ `gdn-static-full-model-review.json`, `gdn-fused-norm-probe.json` and
639
+ `gdn-fused-norm-full-model-review.json`.
640
+
641
+ The affine matvec layout screen preserves pinned MLX's reduction arithmetic
642
+ while varying output rows per SIMD group and groups per threadgroup. Actual
643
+ packed-artifact head and GDN projection weights pass exact checks with both
644
+ direct and compiled wrappers. The best isolated head cells improve only
645
+ slightly, and the small-M projection results are mixed. There is no accepted
646
+ whole-model gain. Combined projection dispatch remains a separate candidate.
647
+ Evidence: `affine-qmv-screen.json` and `affine-qmv-compiled.json`.
648
+
649
+ A second affine prototype shares packed weights and quantization metadata
650
+ across four or eight input rows, preserving MLX's dot-product and SIMD
651
+ reduction order. The corrected real-matrix screen passes all 50 cases; larger
652
+ GDN projections improve in isolation, while vocabulary-head gains are smaller.
653
+ An initial bf16 failure was large, not rounding noise: some shared-row layouts
654
+ read incorrect scale/bias values. Explicit bf16 bit expansion avoids the
655
+ observed failure without resident float32 metadata copies. Direct and compiled
656
+ bf16/f32 debug cells then agree exactly. The underlying compiler cause is not
657
+ established. Six full-model pairs preserve logits, live cache bytes and
658
+ continuation on both packed and plain RTN4 artifacts. RTN4 improves consistently
659
+ at M=4/8 with unchanged peak allocation and flat unused-shape controls. Packed
660
+ improves little; its unused M=128 control also shifts, so the smaller packed
661
+ timing difference needs an independent check. Six RTN4 HTTP process pairs
662
+ then preserve all 108 paired warmup/measured responses, token counts and
663
+ finish reasons. Every measured eight-request wave reaches eight active rows
664
+ and improves throughput; the single-request control is approximately flat.
665
+ All twelve servers exit cleanly with fixed source hashes. Evidence:
666
+ `affine-shared-m-http-rtn4-review.json`, `affine-shared-m-probe.json`,
667
+ `affine-shared-m-probe-initial.json` and
668
+ `affine-shared-m-debug-scale-bits.json`, plus
669
+ `affine-shared-m-full-model-{packed,rtn4}-review.json`.
670
+
671
+ The retained shared operation is `src/mlx/affine-shared-m.ts`, opt-in via
672
+ `MLX_BUN_AFFINE_SHARED_M=1` [both later removed with the MLX 0.32.2 runtime
673
+ consolidation, §7.12 of the design doc; frozen source controls retain them]. Eligibility follows dtype, quantization, shape
674
+ and stream rather than a model name. It retains native MLX for unsupported
675
+ cells and during shapeless compile traces: the native CustomKernel primitive
676
+ cannot infer output shapes there. The trace context is restored on return or
677
+ exception. Shape-specific compiled calls remain eligible. Focused tests cover
678
+ strided activations and metadata, leading dimensions, shape changes and
679
+ fallbacks. A cleaned-up kernel passes another six RTN4 full-model pairs and
680
+ retains the gain. Six final production-flag HTTP pairs preserve all 156 paired
681
+ warmup/measured responses with fixed source hashes and clean server exits.
682
+ Both four- and eight-request throughput improve in every pair; the
683
+ single-request control is flat. Dispatch counters confirm M4 and M8 use the
684
+ shared operation. Broader artifacts and quiet-machine gates remain. Evidence:
685
+ `affine-shared-m-production-full-model-rtn4-review.json`,
686
+ `affine-shared-m-shapeless.json`, `affine-shared-m-integrated-unit.txt` and
687
+ `affine-shared-m-integrated-http-rtn4-review.json`.
688
+
689
+ The next row-width screen passes all 112 real RTN4 matrix cases at
690
+ M=2/3/5/6/7. Six full-model pairs per width also preserve logits, live state
691
+ and continuation. M2 loses and retains native dispatch. M3 improves slightly;
692
+ M5/6/7 improve consistently without a material peak-memory increase. The large
693
+ head needs separate geometry: its M6/7 shared-row cells lose even when smaller
694
+ projections win. Wider integration therefore keeps those head cells native.
695
+ Evidence: `affine-shared-m-width-rtn4-review.json` and
696
+ `affine-shared-m-width-full-model-rtn4-review.json`.
697
+
698
+ A broader-format prototype initially fails nine of 216 arithmetic cells,
699
+ all bf16 M8 layouts with 3- or 5-bit weights. The errors are large and survive
700
+ float32 output storage. Float32 activations remove the large error but also
701
+ change the reference's typed arithmetic. Explicit bf16 input expansion plus
702
+ rounding after each typed addition preserves that arithmetic and passes all
703
+ 216 dtype/bit/group-size cells. Evidence:
704
+ `affine-shared-m-all-bits-correctness-review.json`,
705
+ `affine-shared-m-all-bits-debug.json` and
706
+ `affine-shared-m-all-bits-explicit-input-correctness-review.json`.
707
+
708
+ The compact artifact supplies actual 3-bit head/MLP and 8-bit attention/GDN
709
+ matrices. All 80 real-matrix cells agree exactly, including compiled calls.
710
+ Reusing each packed load for two input rows at 3-bit and four at 8-bit wins
711
+ the retained M4/8 cells. Both compute four output rows per SIMD group, with
712
+ two SIMD groups per threadgroup. Six full-model pairs
713
+ with the prototype and another six with the cleaned production operation
714
+ preserve logits, live cache bytes and continuation; both row counts improve,
715
+ unused-shape controls stay approximately flat and peak allocation is unchanged.
716
+ The 3/8-bit implementation now lives in `src/mlx/affine-shared-quant.ts`, under
717
+ the same opt-in flag and native fallback rules [also removed in the §7.12
718
+ consolidation]. Other bit widths and group
719
+ sizes remain research-only. Evidence:
720
+ `affine-shared-m-all-bits-explicit-compact-review.json`,
721
+ `affine-shared-m-all-bits-full-model-compact-review.json` and
722
+ `affine-shared-m-broader-full-model-compact-review.json`.
723
+
724
+ The final 4-bit operation includes M3/5/6/7, retaining native M2 and the large
725
+ head at M5/6/7. Six complete-model pairs per width preserve logits, state and
726
+ continuation. Six production-flag HTTP pairs at B1/3/5/6/7 preserve all 264
727
+ paired warmup/measured responses. Each measured wave reaches the requested
728
+ active width; candidate dispatch is observed and all twelve servers exit
729
+ cleanly. Concurrent throughput improves in every pair. Single-request decode
730
+ is approximately flat. All pairs are retained, including noisier final runs:
731
+ the machine has residual swap, XProtect is active at the initial preflight,
732
+ and unrelated build/browser activity is observed after the run. This remains
733
+ a diagnostic result. Wider model coverage remains open.
734
+ Evidence: `affine-shared-m-broader-full-model-rtn4-review.json` and
735
+ `shared-affine-frontier-http-rtn4-review.json`. Current focused tests, all
736
+ three typechecks, hygiene and the complete model-free tier pass; the latter
737
+ has 1,785 passes, ten skips and no failures. Evidence:
738
+ `affine-shared-m-broader-{unit,typecheck,hygiene,model-free}.txt`.
739
+
740
+ Six final compact production-flag HTTP pairs preserve all 156 paired warmup
741
+ and measured responses, usage counts and stop reasons. Both B4 and B8 improve
742
+ in every measured pair; the median B1 control is flat, with individual noisy
743
+ outliers retained. Actual active widths and both 3/8-bit dispatches are
744
+ observed, all twelve servers exit cleanly and source hashes remain fixed.
745
+ Residual swap keeps this diagnostic. Evidence:
746
+ `shared-affine-frontier-http-compact-review.json`.
747
+
748
+ A subsequent host-overhead prototype caches shape-specific compiled calls
749
+ around these shared-affine kernels. Every weight/scale/bias/activation remains
750
+ a dynamic input, so one compiled function can serve distinct model layers.
751
+ Six compact full-model pairs retain exact logits, state and continuation;
752
+ 24 compiled configurations serve all eligible projections without new traces
753
+ in measured rows. The eligible M4/8 cells improve modestly. Six subsequent
754
+ HTTP process pairs preserve all 156 paired warm/measured responses with clean
755
+ server exits and fixed source hashes. Serving gains shrink to approximately
756
+ flat at B1/4 and a small B8 difference. This does not justify integrating the
757
+ extra compiled-function cache at present. Evidence:
758
+ `affine-compiled-call-cache-full-model-compact-review.json` and
759
+ `affine-compiled-call-cache-http-compact-review.json`.
760
+
761
+ The grammar-mask operation now completes six compact HTTP process pairs at
762
+ B1/4 with shared-affine enabled in both arms and grammar jumping disabled.
763
+ All 60 paired warm/measured responses match and satisfy the frozen JSON
764
+ schema; both arms apply the mask the same number of times. Every concurrent
765
+ wave reaches four active rows, source hashes remain fixed and all servers
766
+ exit cleanly. The timing is inconclusive for promotion: residual swap and
767
+ overlapping unrelated build/browser work are recorded, the B1 median is
768
+ approximately flat and the B4 median regresses. Preserve all samples and
769
+ revisit on a controlled session. Host masking remains default. Evidence:
770
+ `grammar-mask-http-compact-review.json`.
771
+
772
+ A fused affine gate/up/SwiGLU prototype shares activation loads and replaces
773
+ the two projections plus activation dispatch. Its first version preserves
774
+ both projection outputs but fails the activation check: a float32 sigmoid
775
+ expression differs from MLX's dtype-specific expression. The corrected
776
+ kernel passes all 48 real RTN4 small-M cells, including complete MLP output.
777
+ Only M=1 benefits in that isolated screen. Restricting the full-model prototype
778
+ to M=1 preserves logits, live state and continuation across six paired blocks,
779
+ but its full-forward gain is too small to justify integration. Longer-M
780
+ forwards retain the original path. Evidence: `affine-gateup-debug.json`,
781
+ `affine-gateup-debug-typed.json`, `affine-gateup-typed.json` and
782
+ `affine-gateup-full-model-review.json`. The existing packed activation's
783
+ separate arithmetic contract needs its own audit before reusing that code
784
+ in an affine operation.
785
+
786
+ A residual-add/RMSNorm kernel preserves the native reduction topology and
787
+ the rounded residual before normalization. All 90 synthetic bf16/f16/f32
788
+ cases preserve both outputs. Six packed-model pairs at M1/4/8/128 then
789
+ preserve logits, live cache bytes and continuation, with 64 fused calls per
790
+ forward. M1 is slightly slower, M4/8 are approximately flat and M128 varies.
791
+ The complete path does not establish a compelling benefit, so this version
792
+ is not integrated. Operation samples include wrapper/evaluation costs and are
793
+ not GPU-only timestamps. Evidence: `residual-rms-screen-scalar-review.json`
794
+ and `residual-rms-full-model-packed-review.json`. Earlier driver/binding
795
+ failures occurred before timing and remain separate. Closed helpers are
796
+ removed after recording the finding.
797
+
798
+ The first real HTTP screen uses the compact artifact through bounded CLI
799
+ servers. It retains request hashes, actual usage, arrival times, cache hits,
800
+ restart durability, concurrent request completion and failures. Its cold
801
+ context leg required a Bun restart; the retried nonce changed the prompt, so
802
+ that context comparison is unmatched. The chat probe also diverged despite
803
+ equal prompt counts. Frozen chat IDs produce identical direct Bun/Python
804
+ tokens. A cold HTTP control reproduces the Python difference only in its
805
+ seedless BatchGenerator path; `seed=0` selects its serial method and matches
806
+ the direct text. Compare those execution methods separately. The Bun HTTP
807
+ sample also omits a final space, so it has no byte-identical wire-output claim.
808
+ The benchmark records failed-attempt
809
+ stderr and process status, including failures recovered by retry. This screen
810
+ is diagnostic and establishes no serving win. Evidence and exclusions:
811
+ `serving-compact-screen-0.review.json` and
812
+ `serving-primes-native-comparison.json` in the report directory.
813
+
814
+ Repeated native-throw traces identify the continuous serving crash as Metal
815
+ command-buffer out-of-memory. Bun 1.4.2 avoids it in one screen but misses
816
+ one pending SSD snapshot at its first restart boundary; neither issue is
817
+ closed. Continuous preparation and decode now share the serial memory
818
+ guard, entered after cache acquisition under the execution lease. Ownership,
819
+ refusal and guard restoration tests pass. The same context failure still
820
+ reproduces: the affine graph's transient allocations occur at evaluation,
821
+ after the per-layer construction checks. Investigate allocator residency
822
+ and snapshot retention before declaring this fixed. Evidence:
823
+ `serving-compact-bun140-throw.review.json`,
824
+ `serving-compact-bun142-throw.review.json` and
825
+ `serving-compact-shared-guard.review.json`. Source snapshots now include
826
+ untracked kernels as well as tracked changes.
827
+
828
+ The frozen compact request isolates a cache-consumption cause: after one
829
+ warm repeat transfers the exact recurrent boundary out of RAM, a third
830
+ identical prompt loses that prefix and prefills again. Stopping after two
831
+ requests also reproduces a missing SSD snapshot followed by a false-success
832
+ flush; restart cannot reuse the longer untrimmable descendant. Persisting the
833
+ boundary before transfer preserves the third request's prefix. Durability
834
+ records now remain dirty until actually covered, and already-durable records
835
+ avoid another clone. Ownership/failure and coordinator regression gates pass.
836
+ The three-request HTTP replay preserves output and cached tokens through
837
+ repeat and restart, with no missing flush. The two-request replay also writes
838
+ the consumed boundary before restart. This requires a synchronous SSD write
839
+ on the first transfer when that boundary is not already durable. The complete
840
+ compact serving diagnostic now finishes context repeats, SSD flush/restart
841
+ and four concurrent streams without a recorded failure. One diagnostic pass
842
+ does not close long-agent or repeated reliability acceptance. Evidence:
843
+ `ssd-boundary-before.json`, `ssd-boundary-two-before.json`,
844
+ `ssd-boundary-after.json`, `ssd-boundary-two-after.json`,
845
+ `ssd-boundary-tests.txt` and `serving-compact-boundary-fixed.review.json`
846
+ in the campaign report directory.
847
+
848
+ The merged packed path now passes the seven saved Pi tool-result boundaries
849
+ in separate serial and continuous server processes. Both arms use variant 12
850
+ and the same frozen requests. Each completes the longest prompt, emits the
851
+ requested 512 tokens, demotes old cache entries under pressure, and finishes
852
+ with a durable SSD flush and no pending, missing or failed snapshots. Responses
853
+ match across the two methods and the source snapshot stays fixed. The system
854
+ prompt was reconstructed once with the installed Pi package and frozen;
855
+ historical system-prompt byte identity is not established. This is a bounded
856
+ memory/integration check, not a long-running agent success claim. No returned
857
+ tools execute. Evidence: `agent-boundary-fixture.json`,
858
+ `agent-boundary-current.json` and `agent-boundary-current-review.json`.
859
+
860
+ The M4 DeltaNet fixture discrepancy is now traced to the cached reference,
861
+ not a Bun/oracle disagreement. Both implementations match gate values, output
862
+ bytes and complete recurrent state on the frozen inputs. The explicit
863
+ replay changes one older expected output and adds oracle provenance/state
864
+ hashes. The platform evidence and regeneration procedure live in
865
+ [environment.md](../reference/environment.md).
866
+
867
+ R22 now tests immutable file-backed weights through page-aligned Metal roots
868
+ and ordinary MLX tensor views. The existing external-buffer entry point is
869
+ sufficient for element-aligned tensors; each root includes the leading page
870
+ padding and the tensor view carries the offset. This resembles
871
+ [llama.cpp's mapped Metal buffer views](https://github.com/ggml-org/llama.cpp/blob/427291b5b34cd914a31b3fd3b61a68f6184f4b9f/ggml/src/ggml-metal/ggml-metal-device.m#L1999),
872
+ which align the root pointer and split oversized mappings into overlapping
873
+ views. The prototype uses no new artifact and no new production loader.
874
+ Small metadata and unsupported element alignment retain native loading.
875
+ All 32 operation cases match payload bytes and GPU add/matmul results;
876
+ pointer equality proves that the candidate aliases the file, and file hashes
877
+ stay unchanged. The Llama 1B artifact is ineligible because its large payloads
878
+ start at odd byte offsets, so that initial native/native control establishes
879
+ no candidate performance result.
880
+
881
+ The first packed 27B native pair maps 758 tensors, 11,895,111,680 payload
882
+ bytes, through 11,907,530,752 bytes of page windows. Prefix state, ten
883
+ full-forward logit/live-state/continuation cases and both generation token
884
+ sequences match. The subsequent six-pair repeat preserves all 60 full-forward
885
+ logit/state/continuation cases, every prefix state and all 12 generation
886
+ comparisons. Sources stay fixed and all 12 child processes exit cleanly.
887
+ The measured 64-token generation is 0.25% slower by median paired wall-time
888
+ ratio, with no faster pair; TTFT is approximately flat. M1 is about 0.6%
889
+ faster, while M4/8/128/512 give no consistent useful improvement. Evidence:
890
+ `mmap-weights-native-packed-paired{,-review}.json`. Readiness varies strongly
891
+ with order and file-cache state, so it has no cold-start improvement claim. Process RSS and macOS
892
+ physical-footprint accounting fall sharply because most private copied weights
893
+ become file-backed mappings. That does not shrink model bytes or establish a
894
+ corresponding reduction in total physical RAM: clean file pages and GPU
895
+ residency require separate accounting. Preserve MLX active/peak bytes, RSS,
896
+ `vmmap` output and system pressure together. Evidence:
897
+ `reports/qwen38-rd/mmap-page-window{,-pointer}-screen.json` and
898
+ `mmap-weights-native-{llama1,packed}-screen.json`.
899
+
900
+ The serial HTTP follow-up completes six fresh-server pairs with all 42
901
+ warm/measured response texts, usage counts and finish reasons exact. Sources
902
+ remain fixed and all servers exit cleanly. Warm complete-response time is
903
+ 0.04% to 0.14% slower by median paired ratio; decode is 0.14% to 0.21% slower.
904
+ Median per-server peak RSS changes from 12,182,749,184 to 482,508,800 bytes.
905
+ The recorded physical-footprint summaries show the same private/file-backed
906
+ accounting change, not a smaller tensor working set. Evidence:
907
+ `mmap-weights-http-serial{,-review}.json`. Default scheduling, system-memory
908
+ pressure and cold file-cache behavior remain separate gates.
909
+
910
+ The initial prototype retains immutable roots and mapping owners for the
911
+ process, matching the existing external-array lifetime requirement. A retained
912
+ loader must also prove unload, outstanding GPU-reference ownership, repeated
913
+ model replacement, pressure behavior and HTTP performance. No default or
914
+ production lifetime change follows from this screen. A subsequent ownership
915
+ prototype stores array/root handles with each `Weights` instance and releases
916
+ them on disposal. Existing shard mappings remain mapped for the process. Three
917
+ full-artifact cycles each load 2,019 tensors and release all 13,056,265,696
918
+ active bytes. An outstanding GPU consumer survives weight disposal, produces
919
+ the exact expected output and releases the remaining 2,048 bytes on disposal;
920
+ active memory is zero before GC. Evidence:
921
+ `mmap-weights-ownership-packed{,-mapping}.json`. Three additional cycles
922
+ retain a single-input lazy negation, dispose the weights before submitting it,
923
+ and then evaluate it. Outputs remain exact; the pending view retains
924
+ 39,747,584 bytes until its disposal, after which active memory returns to zero
925
+ before GC. Evidence: `mmap-weights-single-consumer-lazy{,-mapping}.json`.
926
+ The whole-tensor follow-up fails output identity on the first cycle after
927
+ owner disposal, although active memory returns to zero and the source tensor
928
+ still matches the untouched original artifact. The earlier small view did
929
+ not qualify for unary buffer donation: MLX also bounds excess backing-buffer
930
+ bytes. Thus those passing cases did not establish donation safety. Keep this
931
+ read-only loader out of production; reduce the failure on scratch data and
932
+ test writable private mappings with native lifetime ownership. Evidence:
933
+ `mmap-weights-whole-consumer-lazy.json`, its log and
934
+ `mmap-whole-consumer-source-integrity.json`. Full serving, default-scheduler
935
+ and pressure gates remain for any corrected loader.
936
+
937
+ Scratch files isolate the failure across float32/bfloat16 and aligned/offset
938
+ views. With a retained root, all read-only cases are exact and output uses a
939
+ separate buffer. After root release, all four donated read-only cases return
940
+ the original input bytes instead of the negation. Private writable mappings
941
+ preserve every output, including donation, and leave each file unchanged.
942
+ Evidence: `mmap-donation-{ro,cow}-screen.json`. The corrected prototype gives
943
+ each private page window a native payload destructor that unmaps it on the
944
+ last MLX buffer release. It uses no JavaScript destructor or new production
945
+ API. All eight scratch ownership cases preserve output and file bytes, retain
946
+ the mapping through the live consumer, and release every mapping afterward.
947
+ Three full-artifact cycles then preserve the whole-tensor lazy negation after
948
+ weight disposal. Only its 1,654,784-byte mapping survives until the pending
949
+ consumer is disposed; native mapping counts and MLX active bytes return to
950
+ zero before GC. Evidence: `mmap-managed-donation-screen.json` and
951
+ `mmap-weights-managed-whole-consumer-lazy{,-mapping}.json`. A further 64-cycle
952
+ scratch gate submits chained operations asynchronously and disposes the
953
+ input handles. Half the cycles check every output value; the others dispose
954
+ the final output before synchronization. All release every native mapping and
955
+ return MLX active memory to zero. Evidence: `mmap-managed-submitted.json`.
956
+ Six subsequent private-mapping native blocks on the M4 Pro 24 GB preserve 60 full-forward
957
+ logit/state/continuation cases and 12 8/64-token generation comparisons, with
958
+ fixed sources, clean exits and zero remaining native mapping windows. The
959
+ 64-token warm generation median paired wall-time change is +0.02%; TTFT is
960
+ +0.13%. Warm full forwards at M1/4/8/128/512 have no useful consistent speed
961
+ gain. The opening-plus-first-hidden-forward phase is about 7.38 seconds slower
962
+ by median paired difference, but that observation materializes different
963
+ amounts of the model. After the hidden-only forward, native head tensors are
964
+ still lazy while mapped roots already account for their full extent. The
965
+ 727,580,672-byte active-allocation difference is exactly the 715,161,600-byte
966
+ head plus 12,419,072 bytes of page padding, in all six pairs. Large changes in
967
+ RSS and `vmmap` physical-footprint accounting still do not establish how much
968
+ system RAM is saved. Child wall time includes `vmmap` inspection and is not a
969
+ performance metric. Evidence is
970
+ `mmap-weights-managed-native-repeat{,-review}.json` and
971
+ `mmap-initial-residency-attribution.json`.
972
+
973
+ A separate lazy-view control removes per-tensor evaluation and pointer checks
974
+ from loading. All 64 unsubmitted consumers and 64 submitted consumers remain
975
+ valid after releasing their weight owners, then release every mapping and
976
+ return active allocation to zero without forced GC. Its model screen preserves
977
+ ten full-forward cases and both generations, but warm 64-token generation is
978
+ +0.22% slower and the first hidden-forward phase does not improve. This rules
979
+ out retaining the lazy change on that screen; it does not isolate the cause
980
+ of the first-use cost. Evidence is
981
+ `mmap-lazy-view-ownership.json` and
982
+ `mmap-weights-lazy-managed-native-screen{,-review}.json`. Neither prototype is
983
+ integrated.
984
+
985
+ A subsequent four-arm screen measures opening the model through the first
986
+ generated token, completing all 64 tokens, then a warm 64-token generation.
987
+ Native loading, lazy private mappings, mapped pages with an OS read-ahead
988
+ hint, and mapped pages read once per page preserve all token IDs, live state
989
+ and usage, then release every mapping. On the M4 Pro 24 GB, native first-token
990
+ time from opening is 14.09 seconds; lazy mapping is 13.62 seconds, read-ahead
991
+ 19.97 seconds and explicit reads 30.50 seconds. These timings include the
992
+ preparation itself. Warm generation is approximately flat. The two CPU
993
+ preparation methods lose this screen. Lazy mapping's small first-generation
994
+ gain needs balanced repeats: this is one fixed-order block with unpurged
995
+ filesystem cache. Neither a cold-storage result nor a physical-memory saving
996
+ is established. Evidence is `mmap-prefault-native-screen.json`.
997
+
998
+ The balanced follow-up rejects that apparent cold-generation gain. All six
999
+ fresh-process pairs preserve both 64-token generations, live state and usage,
1000
+ with fixed sources, clean exits and all 758 mappings released. First-token
1001
+ time from opening is worse in five pairs: the median paired change is +18.42%
1002
+ or +2.24 seconds. Completing the first generation is +12.93% or +2.29 seconds;
1003
+ warm generation is approximately flat at +0.24%. One large native outlier
1004
+ remains in the report. The filesystem cache is unpurged and the machine is
1005
+ not quiet, so these are diagnostic results. RSS accounting falls sharply for
1006
+ file-backed pages but physical-memory savings are still unproven. Close this
1007
+ loader as a performance candidate on the measured workload; no integration
1008
+ or HTTP speed claim follows. Closed loader, page-preparation and ownership
1009
+ helpers are removed; raw plans and evidence remain in
1010
+ `mmap-cold-native-repeat{,-review}.json`.
1011
+
1012
+ The first full-model pair with native private mappings preserves prefix state,
1013
+ all ten checked logit/live-state/continuation cases and both 8/64-token
1014
+ generation sequences. Sources remain fixed; both children exit cleanly and
1015
+ the mapped child releases all 758 native windows before exit. Its 64-token
1016
+ wall time is approximately flat. This single pair is a correctness screen,
1017
+ not a performance acceptance. Evidence:
1018
+ `mmap-weights-managed-native-screen{,-review}.json`. Repeated native/HTTP,
1019
+ and pressure gates still apply. A subsequent API ownership gate preserves
1020
+ pending-consumer output and rematerialized source bytes after `release`,
1021
+ `releaseShard` and `dispose`. It rejects a late view change and releases the
1022
+ mapping after an intentional tensor-fixup failure. All native mapping counts
1023
+ and MLX active bytes return to zero. Evidence:
1024
+ `mmap-managed-shard-release{,-mapping}.json`.
1025
+
1026
+ Plan at this point (the MTP and strict-fill measurements were later
1027
+ completed; see speculative-decoding.md §4.7/§7.4 and the design doc §7.13):
1028
+ finish MTP and strict-fill request measurements after the kernel
1029
+ changes, broaden their correctness and state audits, and obtain individual
1030
+ kernel attribution. Continue shared GDN/convolution/affine/prefill work and
1031
+ the exact-artifact controls across quants. Quiet application A/Bs, pressure
1032
+ replay and quiet-machine gates remain. Recheck process ownership and preflight
1033
+ before each GPU run; diagnostic measurements cannot promote a default.
1034
+
1035
+ The native-owned managed mapping is visible to MLX allocation accounting.
1036
+ Across all ten full-model rows in its paired screen, mapped peak allocation
1037
+ exceeds the incumbent by exactly 12,419,072 bytes, the difference between
1038
+ page-aligned root and payload bytes. The low process RSS is not evidence of
1039
+ an unaccounted model in the async-scheduling threshold. Combining these
1040
+ experiments still needs a separate pressure gate. Evidence:
1041
+ `mmap-managed-active-accounting-review.json`.
1042
+
1043
+ A dedicated KV append dispatch probe covers 18 bf16 cases with four KV heads
1044
+ and dimension 256, at depths 65/256/2049/2048/8193/8192. Every active prefix,
1045
+ new row and retained snapshot remains exact; explicit cleanup returns MLX
1046
+ active allocation to zero. With spare capacity and no retained view, each
1047
+ SliceUpdate dispatches only the new-row copy. Holding an evaluated temporal
1048
+ view adds a full-buffer copy; releasing it restores donation. At a 256-step
1049
+ growth boundary, the pair allocates padding, concatenates old/new storage
1050
+ and appends, totaling eight dispatches regardless of retained views. This
1051
+ rejects the assumption that ordinary cache append always copies the full
1052
+ buffer. The next gate is a real-generation census of retained views and
1053
+ growth; instrumented one-shot timings do not establish a speed win. Evidence:
1054
+ `kv-append-donation-probe{,-review}.json` and its native dispatch log.
1055
+
1056
+ A real native-generation census on the interleaved v13 artifact uses a
1057
+ 2,049-token synthetic prompt and 32 generated tokens. Without a prompt
1058
+ snapshot, all 1,024 observed one-row K/V appends dispatch only the new-row
1059
+ copy. Retaining a real `cloneKvCaches` snapshot produces 32 full-buffer copies,
1060
+ one per K/V buffer, then 992 new-row-only appends. Both runs emit identical
1061
+ IDs with fixed sources. This rejects a repeated whole-cache copy in the
1062
+ tested native path; serving, deeper contexts and other cache types remain
1063
+ separate coverage. The counter build is for attribution, not timing claims.
1064
+ Explicit cleanup leaves 16,390 active bytes, so this is not a zero-allocation
1065
+ claim. Evidence: `kv-append-model-trace-2049{,-review}.json` and its dispatch
1066
+ log under campaign reports.
1067
+
1068
+ The actual HTTP census confirms the same append behavior at a verified
1069
+ 2,049-token text prompt. Serial and continuous servers each complete two
1070
+ 16-token warmups and a 32-token measured response. All three paired outputs,
1071
+ counts and finish reasons match, the continuous lane is verified, and both
1072
+ servers exit cleanly with fixed source. Each measured request has 1,024
1073
+ one-row K/V update encoders, all writing only the new row; neither performs
1074
+ a full-buffer copy for those appends. No matching update records fall outside
1075
+ the request phase markers. This rejects a repeated whole-cache-copy hypothesis
1076
+ for both tested HTTP lanes with prefix caching disabled. Deeper context,
1077
+ retained snapshots, growth boundaries and compressed caches remain separate
1078
+ regimes. The original token-array HTTP fixture was correctly rejected by the
1079
+ endpoint; the corrected text fixture is encoded and hashed by the Bun
1080
+ tokenizer before tracing. Evidence is
1081
+ `kv-append-http-text-census{,-review}.json` and its per-server dispatch logs.
1082
+
1083
+ The native census also passes at an 8,193-token prompt with 32 generated
1084
+ tokens. Ordinary ownership again gives 1,024 new-row-only K/V writes. A held
1085
+ snapshot gives 32 whole-buffer copies followed by 992 new-row-only writes.
1086
+ The two runs emit identical IDs, cover the same 8,224 cached tokens, keep
1087
+ sources fixed and return to 16,390 active bytes after explicit cleanup.
1088
+ Each phase also contains 480 larger prefill updates. These counts classify
1089
+ `SliceUpdate` encoders only; allocation/growth and copy traffic in other
1090
+ operations remain separate measurements. Evidence is
1091
+ `kv-append-native-8193{,-review}.json` and its dispatch log. There is no timing
1092
+ claim or new append kernel from this attribution result.