NakliTechie commited on
Commit
47563a3
·
1 Parent(s): de40005

Sync from GitHub 2026-10-31T08:12:54Z

Browse files
Files changed (1) hide show
  1. index.html +164 -14
index.html CHANGED
@@ -2694,7 +2694,7 @@
2694
  <li><strong>Ling 3.0 Flash 124B-A5B &middot; via anyformer (experimental)</strong> (~81 GB) &mdash; text, reasoning. inclusionAI's Ling 3.0 Flash (released 2026-08-02, MIT): a 124B mixture-of-experts (512 experts, 8 active per token, about 5.1B parameters per token) whose layers mix linear attention (KDA) and latent attention (MLA), from inclusionAI's own 4-bit Q4_K_M GGUF (77 GB in two parts). anyformer loads it on diskformer's engine for it, which keeps the attention, routers and caches on the GPU (about 2.5 GB plus a 4 GB expert cache; it needs about 7 GB of GPU memory) and streams the 20,480 routed experts from on-device storage (OPFS). The first load copies the model into this browser's storage once (~81 GB of disk). About 5.5 tokens/s on an M4 Pro with 24 GB, and prompts are read at about 5 tokens/s. Flip <strong>Show reasoning</strong> for its thinking. Tools are off for now.</li>
2695
  <li><strong>DeepSeek V4.1 Flash 763B &middot; tech demo, very slow, chat untested</strong> (~231 GB) &mdash; text. DeepSeek's 763B mixture-of-experts model, 6 of its 384 experts per token, from ISTA-DASLab's IQ1_M files plus a separate Engram file. anyformer runs it on diskformer's llama.cpp path: an 8 GB GPU budget, with the experts read from this browser's storage as each token needs them. It needs 231 GB of free browser storage and runs at under one token a second, so treat it as a demonstration, not a chat model. One plain prompt was checked in Chrome; chat through its template has not been run, so replies may come out wrong. Reasoning and tools are off.</li>
2696
  <li><strong>Nemotron-Labs-Diffusion 3B &middot; experimental &middot; diffusion</strong> (~2.7 GB) &mdash; text. NVIDIA's Nemotron-Labs-Diffusion-3B writes by diffusion: it fills in whole blocks of words at once instead of one word at a time. It runs on kohra.js through anyformer, at about 12-16 tokens a second on an M4 Pro. Opt-in and experimental: only single-turn chats have been checked. Reasoning and tools are off.</li>
2697
- <li><strong>LFM2.5 24B-A2B + Pi coding adapter &middot; experimental</strong> (~13.6 GB) &mdash; text. The LFM2.5 24B-A2B model above with harness-hub's Pi coding-agent adapter (37 MB) applied when it loads. The adapter was trained inside the Pi coding agent, so outside it expect behaviour like the base model or worse. It runs on llama.cpp in the tab with experts read from on-device storage, about 4 GB of GPU memory, and is slower than the base entry (about 3 tokens a second on an M4 Pro). Tools are off. Licence lfm1.0: royalty-free commercial use only below US$10M annual revenue.</li>
2698
  <li><strong>Clover 35B-A3B &middot; SSD-streamed, experimental &middot; diffusion</strong> (~19.6 GB) &mdash; text. Diffuspace's Clover-35B-A3B-Preview is Qwen3.6 35B-A3B retrained to write by diffusion: each block of 32 words is filled in over several passes, so replies appear a block at a time. It streams its experts from on-device storage through anyformer and diskformer, using about 4 GB of GPU memory. The first load copies a 19.6 GB file into browser storage. Opt-in and experimental: its speed has not been measured yet. Tools are off.</li>
2699
  <li><strong>Nemotron 3.5 Bolt E4B &middot; via anyformer (experimental)</strong> (~4.9 GB) &mdash; text. NVIDIA's Nemotron 3.5 Bolt E4B, a dense model with about 4B effective parameters, post-trained from Google's Gemma 4 E4B. It runs on Transformers.js through anyformer, from a community 4-bit ONNX conversion (text only), at about 35 tokens a second on an M4 Pro. Reasoning and tools are off for now.</li>
2700
  <li><strong>GLM-4.7-Flash 30B-A3B &middot; via anyformer (experimental)</strong> (~18 GB) &mdash; text, reasoning. Z.ai's GLM-4.7-Flash, a 30B mixture-of-experts with about 3B parameters per token, from unsloth's 4-bit GGUF (18.3 GB). LocalMind has no engine of its own for it: anyformer picks diskformer's llama.cpp path, which runs llama.cpp's WebGPU build in a worker and pages the experts in from on-device storage (OPFS). The first load copies the file into this browser's storage once. Flip <strong>Show reasoning</strong> for its thinking. Tools are off for now.</li>
@@ -8080,7 +8080,7 @@ const engineFetch = async (url, init = {}) => {
8080
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy
8081
  // of the engine (Gemma4Mobile) and, with ple, builds the OPFS per-layer-embedding table itself. The worker then drives
8082
  // session.engine exactly as it drove its own engine. Pinned to the same anyformer as anyformer_models.js.
8083
- const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.19/index.js';
8084
 
8085
  let anyformerLoad = null;
8086
  let session = null;
@@ -8225,7 +8225,7 @@ self.onmessage = async (e) => {
8225
  // rolled-in module URLs (moduleUrl()).
8226
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
8227
  // the engine (TernaryBonsai2); the worker drives session.engine as before and attaches DFlash / MTP itself.
8228
- const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.19/index.js';
8229
  const DFLASH_URL = '__TERNARY_BONSAI2_DFLASH_URL__';
8230
  const MTP_URL = '__TERNARY_BONSAI2_MTP_URL__';
8231
  // MTP speculative decoding (Settings → Models, default OFF; posted as `mtp` + `mtpDepth` on the
@@ -9521,10 +9521,10 @@ self.addEventListener('message', async (e) => {
9521
  contextSize: 4096,
9522
  genConfig: { max_new_tokens: 2048 },
9523
  },
9524
- // backend:'anyformer-lfm25-24b-pi' → anyformer's MODELS.chat.LFM2_5_24B_PI (0.4.18+): the same QAD-Q4_0 GGUF with
9525
- // harness-hub's Pi coding-agent LoRA (37.4 MB, applied at load, not merged) on diskformer's llama.cpp path with paged
9526
- // experts, a 4 GB GPU budget. anyformer 0.4.19 (diskformer 0.6.18) closes the template's always-open <think> when
9527
- // thinking is off. anyformer's check: 4/4 turns on topic, 2.6-3.1 tok/s, Chrome 156 on an M4 Pro. Shares the base
9528
  // entry's id, so resolveModelKey('LiquidAI/LFM2.5-24B-A2B-GGUF') still picks the base; this one is reached by key.
9529
  // Tools off until LocalMind's tool battery runs on it (the adapter was trained inside the Pi agent's own harness).
9530
  // Licence lfm1.0 (model and adapter).
@@ -17769,7 +17769,7 @@ self.addEventListener('message', async (e) => {
17769
  'anyformer-gemma26b': { engine: 'anyformer_models.js', exportName: 'Gemma4_26B', label: 'Gemma 4 26B-A4B (Q4_0, via anyformer)' },
17770
  'anyformer-flint': { engine: 'anyformer_models.js', exportName: 'Flint40B', label: 'Flint 40B-A2.5B (Q4_1, via anyformer)' },
17771
  'anyformer-lfm25-24b': { engine: 'anyformer_models.js', exportName: 'Lfm25_24B', label: 'LFM2.5 24B-A2B (Q4_0, via anyformer)' },
17772
- 'anyformer-lfm25-24b-pi': { engine: 'anyformer_models.js', exportName: 'Lfm25_24bPi', label: 'LFM2.5 24B-A2B + Pi LoRA (Q4_0, via anyformer and diskformer llama.cpp)' },
17773
  'anyformer-qwen36': { engine: 'anyformer_models.js', exportName: 'Qwen36', label: 'Qwen3.6 35B-A3B (Q8_0, via anyformer)' },
17774
  'anyformer-ling3flash': { engine: 'anyformer_models.js', exportName: 'Ling3Flash', label: 'Ling 3.0 Flash (Q4_K_M, via anyformer)' },
17775
  'anyformer-glm47flash': { engine: 'anyformer_models.js', exportName: 'Glm47Flash', label: 'GLM-4.7-Flash (Q4_K_M, via anyformer)' },
@@ -24242,7 +24242,7 @@ self.addEventListener('message', async (e) => {
24242
  */
24243
  const THINK_CLOSE = -2;
24244
 
24245
- export const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.19/index.js';
24246
 
24247
  // anyformer's progress events → the engine events the SSD worker posts. The llama.cpp path reports 'download' (bytes
24248
  // into OPFS) and 'load' / 'plan'; a hand engine (diskformer back end) reports its own engine events, 'weights' with
@@ -24396,9 +24396,9 @@ export class Clover35B extends AnyformerModel {
24396
  static entry = 'CLOVER_35B_A3B';
24397
  }
24398
 
24399
- // LFM2.5 24B-A2B with harness-hub's Pi coding-agent LoRA by anyformer's catalog entry (0.4.18+; 0.4.19 closes the
24400
- // always-open <think> when thinking is off): the QAD-Q4_0 GGUF plus a 37.4 MB adapter applied at load, on diskformer's
24401
- // llama.cpp path with paged experts, a 4 GB budget. Opt-in and experimental; licence lfm1.0.
24402
  export class Lfm25_24bPi extends AnyformerModel {
24403
  static entry = 'LFM2_5_24B_PI';
24404
  }
@@ -32667,7 +32667,7 @@ const GGUF_FILE = 'LFM2.5-230M-Q4_0.gguf';
32667
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
32668
  // the LFM2.5 engine (Lfm2Mobile) and returns a session with the same generate / reset / dispose. Pinned to an exact
32669
  // version; LocalMind's anyformer_models.js pins the same one.
32670
- const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.19/index.js';
32671
 
32672
  let anyformerLoad = null;
32673
  let model = null;
@@ -39759,7 +39759,7 @@ ${d}`}var Mm=e=>Bo(e,{wrapInTimeLoop:!0,useLayerOffsets:!0,indent:4}),Bm=e=>Bo(e
39759
 
39760
  import { Qwen3MoeSsd, BpeTokenizer, GGML, Q4_BLOCK, tensorBytes, TOK, STORAGE, COPY_SRC, COPY_DST, MAP_READ } from './qwen3_moe_ssd.js';
39761
  import { Gemma4MoeSsd } from './gemma4_moe_ssd.js';
39762
- import { Q8_BLOCK } from './gguf.js';
39763
  import { QWEN35_BATCH_KERNELS } from './qwen35_moe_ssd.js';
39764
 
39765
  export function configFromGgufLfm2Moe(kv) {
@@ -39961,6 +39961,34 @@ struct P { H: u32 }
39961
  let conv = w[3u * i] * s0 + w[3u * i + 1u] * s1 + w[3u * i + 2u] * bx;
39962
  y[i] = bcx[p.H + i] * conv;
39963
  st[2u * i] = s1; st[2u * i + 1u] = bx;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39964
  }`,
39965
  // Debug capture: y[off + i] = x[i].
39966
  copyAt: `
@@ -39999,6 +40027,39 @@ ${QB}
39999
  s0 = s1; s1 = bx;
40000
  }
40001
  st[2u * i] = s0; st[2u * i + 1u] = s1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40002
  }`,
40003
  // act = SiLU(g) · u over T × n (the dense FFN's separate gate and up).
40004
  siluSplitB: `
@@ -40069,6 +40130,7 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40069
  constructor(device, manifest, gguf, opts) {
40070
  super(device, manifest, gguf, opts);
40071
  this.lookahead = Math.max(1, Math.floor(opts.lookahead ?? 1));
 
40072
  }
40073
 
40074
  // Kernel names for the matrix and expert weights: Q4_0 here; an engine reading a Q8_0 file (hy_v3_moe_ssd.js) swaps
@@ -40305,6 +40367,7 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40305
  d('rmsnorm', g.rmsA, 1);
40306
  if (g.attn) {
40307
  d(this.kq.mm, g.q, Math.ceil(QN / 4)); d(this.kq.mm, g.k, Math.ceil(KVN / 4)); d(this.kq.mm, g.v, Math.ceil(KVN / 4));
 
40308
  d('qkNormRope', g.ropeQ, c.heads); d('qkNormRope', g.ropeK, c.kvHeadsAttn);
40309
  d('kvStore', g.kv, Math.ceil(KVN / 256));
40310
  const ak = this.attnK;
@@ -40312,17 +40375,22 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40312
  d(ak.soft, g.soft, c.heads);
40313
  d(ak.out, g.attOut, Math.ceil(QN / 256));
40314
  d(this.kq.mm, g.o, Math.ceil(H / 4));
 
40315
  } else {
40316
  d(this.kq.mm, g.inProj, Math.ceil(3 * H / 4));
 
40317
  d('shortConv', g.conv, Math.ceil(H / 256));
40318
  d(this.kq.mm, g.o, Math.ceil(H / 4));
 
40319
  }
40320
  d('addInPlace', g.addO, Math.ceil(H / 256));
40321
  d('rmsnorm', g.rmsF, 1);
40322
  if (L < c.lead) {
40323
  d(this.kq.mm, g.mg, Math.ceil(c.denseFf / 4)); d(this.kq.mm, g.mu, Math.ceil(c.denseFf / 4));
 
40324
  d('siluMulMoe', g.mact, Math.ceil(c.denseFf / 256));
40325
  d(this.kq.mm, g.md, Math.ceil(H / 4));
 
40326
  d('addInPlace', g.addO, Math.ceil(H / 256));
40327
  if (g.cap) d('copyAt', g.cap, Math.ceil(H / 256));
40328
  }
@@ -40366,6 +40434,7 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40366
  d('rmsnormB', g.rmsA, T);
40367
  if (this.mlayers[L].attn) {
40368
  d(this.kq.mmT, g.q, mm(QN), tt); d(this.kq.mmT, g.k, mm(KVN), tt); d(this.kq.mmT, g.v, mm(KVN), tt);
 
40369
  d('qkNormRopeB', g.ropeQ, c.heads, T); d('qkNormRopeB', g.ropeK, c.kvHeadsAttn, T);
40370
  d('kvStoreB', g.kv, Math.ceil(KVN / 256), T);
40371
  const ak = this.attnK;
@@ -40373,17 +40442,22 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40373
  d(ak.softB, g.soft, c.heads * T);
40374
  d(ak.outB, g.attOut, Math.ceil(QN / 256), T);
40375
  d(this.kq.mmT, g.o, mm(H), tt);
 
40376
  } else {
40377
  d(this.kq.mmT, g.inProj, mm(3 * H), tt);
 
40378
  d('shortConvB', g.conv, Math.ceil(H / 256));
40379
  d(this.kq.mmT, g.o, mm(H), tt);
 
40380
  }
40381
  d('addInPlaceB', g.addO, Math.ceil(H / 256), T);
40382
  d('rmsnormB', g.rmsF, T);
40383
  if (L < c.lead) {
40384
  d(this.kq.mmT, g.mg, mm(c.denseFf), tt); d(this.kq.mmT, g.mu, mm(c.denseFf), tt);
 
40385
  d('siluSplitB', g.mact, Math.ceil(c.denseFf / 256), T);
40386
  d(this.kq.mmT, g.md, mm(H), tt);
 
40387
  d('addInPlaceB', g.addO, Math.ceil(H / 256), T);
40388
  }
40389
  }
@@ -40409,6 +40483,82 @@ export class Lfm2MoeSsd extends Gemma4MoeSsd {
40409
  }
40410
  }
40411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40412
  // The conv state cannot rewind, so any change before the cached end restarts from token 0.
40413
  reset() {
40414
  super.reset();
 
2694
  <li><strong>Ling 3.0 Flash 124B-A5B &middot; via anyformer (experimental)</strong> (~81 GB) &mdash; text, reasoning. inclusionAI's Ling 3.0 Flash (released 2026-08-02, MIT): a 124B mixture-of-experts (512 experts, 8 active per token, about 5.1B parameters per token) whose layers mix linear attention (KDA) and latent attention (MLA), from inclusionAI's own 4-bit Q4_K_M GGUF (77 GB in two parts). anyformer loads it on diskformer's engine for it, which keeps the attention, routers and caches on the GPU (about 2.5 GB plus a 4 GB expert cache; it needs about 7 GB of GPU memory) and streams the 20,480 routed experts from on-device storage (OPFS). The first load copies the model into this browser's storage once (~81 GB of disk). About 5.5 tokens/s on an M4 Pro with 24 GB, and prompts are read at about 5 tokens/s. Flip <strong>Show reasoning</strong> for its thinking. Tools are off for now.</li>
2695
  <li><strong>DeepSeek V4.1 Flash 763B &middot; tech demo, very slow, chat untested</strong> (~231 GB) &mdash; text. DeepSeek's 763B mixture-of-experts model, 6 of its 384 experts per token, from ISTA-DASLab's IQ1_M files plus a separate Engram file. anyformer runs it on diskformer's llama.cpp path: an 8 GB GPU budget, with the experts read from this browser's storage as each token needs them. It needs 231 GB of free browser storage and runs at under one token a second, so treat it as a demonstration, not a chat model. One plain prompt was checked in Chrome; chat through its template has not been run, so replies may come out wrong. Reasoning and tools are off.</li>
2696
  <li><strong>Nemotron-Labs-Diffusion 3B &middot; experimental &middot; diffusion</strong> (~2.7 GB) &mdash; text. NVIDIA's Nemotron-Labs-Diffusion-3B writes by diffusion: it fills in whole blocks of words at once instead of one word at a time. It runs on kohra.js through anyformer, at about 12-16 tokens a second on an M4 Pro. Opt-in and experimental: only single-turn chats have been checked. Reasoning and tools are off.</li>
2697
+ <li><strong>LFM2.5 24B-A2B + Pi coding adapter &middot; experimental</strong> (~13.6 GB) &mdash; text. The LFM2.5 24B-A2B model above with harness-hub's Pi coding-agent adapter (37 MB) applied when it loads. The adapter was trained inside the Pi coding agent, so outside it expect behaviour like the base model or worse. It runs on the same in-tab engine as the base entry with experts read from on-device storage; its speed has not been measured here yet. Tools are off. Licence lfm1.0: royalty-free commercial use only below US$10M annual revenue.</li>
2698
  <li><strong>Clover 35B-A3B &middot; SSD-streamed, experimental &middot; diffusion</strong> (~19.6 GB) &mdash; text. Diffuspace's Clover-35B-A3B-Preview is Qwen3.6 35B-A3B retrained to write by diffusion: each block of 32 words is filled in over several passes, so replies appear a block at a time. It streams its experts from on-device storage through anyformer and diskformer, using about 4 GB of GPU memory. The first load copies a 19.6 GB file into browser storage. Opt-in and experimental: its speed has not been measured yet. Tools are off.</li>
2699
  <li><strong>Nemotron 3.5 Bolt E4B &middot; via anyformer (experimental)</strong> (~4.9 GB) &mdash; text. NVIDIA's Nemotron 3.5 Bolt E4B, a dense model with about 4B effective parameters, post-trained from Google's Gemma 4 E4B. It runs on Transformers.js through anyformer, from a community 4-bit ONNX conversion (text only), at about 35 tokens a second on an M4 Pro. Reasoning and tools are off for now.</li>
2700
  <li><strong>GLM-4.7-Flash 30B-A3B &middot; via anyformer (experimental)</strong> (~18 GB) &mdash; text, reasoning. Z.ai's GLM-4.7-Flash, a 30B mixture-of-experts with about 3B parameters per token, from unsloth's 4-bit GGUF (18.3 GB). LocalMind has no engine of its own for it: anyformer picks diskformer's llama.cpp path, which runs llama.cpp's WebGPU build in a worker and pages the experts in from on-device storage (OPFS). The first load copies the file into this browser's storage once. Flip <strong>Show reasoning</strong> for its thinking. Tools are off for now.</li>
 
8080
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy
8081
  // of the engine (Gemma4Mobile) and, with ple, builds the OPFS per-layer-embedding table itself. The worker then drives
8082
  // session.engine exactly as it drove its own engine. Pinned to the same anyformer as anyformer_models.js.
8083
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.20/index.js';
8084
 
8085
  let anyformerLoad = null;
8086
  let session = null;
 
8225
  // rolled-in module URLs (moduleUrl()).
8226
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
8227
  // the engine (TernaryBonsai2); the worker drives session.engine as before and attaches DFlash / MTP itself.
8228
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.20/index.js';
8229
  const DFLASH_URL = '__TERNARY_BONSAI2_DFLASH_URL__';
8230
  const MTP_URL = '__TERNARY_BONSAI2_MTP_URL__';
8231
  // MTP speculative decoding (Settings → Models, default OFF; posted as `mtp` + `mtpDepth` on the
 
9521
  contextSize: 4096,
9522
  genConfig: { max_new_tokens: 2048 },
9523
  },
9524
+ // backend:'anyformer-lfm25-24b-pi' → anyformer's MODELS.chat.LFM2_5_24B_PI: the same QAD-Q4_0 GGUF with harness-hub's
9525
+ // Pi coding-agent LoRA (37.4 MB, applied at run time, not merged). Since anyformer 0.4.20 (diskformer 0.6.19) it runs
9526
+ // on diskformer's own Lfm2MoeSsd engine like the base entry, not on the llama.cpp path; speed there not measured
9527
+ // here. anyformer's checks on 0.4.20: tool loop and 4-turn chat passed in Chrome. Shares the base
9528
  // entry's id, so resolveModelKey('LiquidAI/LFM2.5-24B-A2B-GGUF') still picks the base; this one is reached by key.
9529
  // Tools off until LocalMind's tool battery runs on it (the adapter was trained inside the Pi agent's own harness).
9530
  // Licence lfm1.0 (model and adapter).
 
17769
  'anyformer-gemma26b': { engine: 'anyformer_models.js', exportName: 'Gemma4_26B', label: 'Gemma 4 26B-A4B (Q4_0, via anyformer)' },
17770
  'anyformer-flint': { engine: 'anyformer_models.js', exportName: 'Flint40B', label: 'Flint 40B-A2.5B (Q4_1, via anyformer)' },
17771
  'anyformer-lfm25-24b': { engine: 'anyformer_models.js', exportName: 'Lfm25_24B', label: 'LFM2.5 24B-A2B (Q4_0, via anyformer)' },
17772
+ 'anyformer-lfm25-24b-pi': { engine: 'anyformer_models.js', exportName: 'Lfm25_24bPi', label: 'LFM2.5 24B-A2B + Pi LoRA (Q4_0, via anyformer)' },
17773
  'anyformer-qwen36': { engine: 'anyformer_models.js', exportName: 'Qwen36', label: 'Qwen3.6 35B-A3B (Q8_0, via anyformer)' },
17774
  'anyformer-ling3flash': { engine: 'anyformer_models.js', exportName: 'Ling3Flash', label: 'Ling 3.0 Flash (Q4_K_M, via anyformer)' },
17775
  'anyformer-glm47flash': { engine: 'anyformer_models.js', exportName: 'Glm47Flash', label: 'GLM-4.7-Flash (Q4_K_M, via anyformer)' },
 
24242
  */
24243
  const THINK_CLOSE = -2;
24244
 
24245
+ export const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.20/index.js';
24246
 
24247
  // anyformer's progress events → the engine events the SSD worker posts. The llama.cpp path reports 'download' (bytes
24248
  // into OPFS) and 'load' / 'plan'; a hand engine (diskformer back end) reports its own engine events, 'weights' with
 
24396
  static entry = 'CLOVER_35B_A3B';
24397
  }
24398
 
24399
+ // LFM2.5 24B-A2B with harness-hub's Pi coding-agent LoRA by anyformer's catalog entry: the QAD-Q4_0 GGUF plus a 37.4 MB
24400
+ // adapter applied at run time, on diskformer's Lfm2MoeSsd engine since anyformer 0.4.20 (diskformer 0.6.19). Opt-in and
24401
+ // experimental; licence lfm1.0.
24402
  export class Lfm25_24bPi extends AnyformerModel {
24403
  static entry = 'LFM2_5_24B_PI';
24404
  }
 
32667
  // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
32668
  // the LFM2.5 engine (Lfm2Mobile) and returns a session with the same generate / reset / dispose. Pinned to an exact
32669
  // version; LocalMind's anyformer_models.js pins the same one.
32670
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.20/index.js';
32671
 
32672
  let anyformerLoad = null;
32673
  let model = null;
 
39759
 
39760
  import { Qwen3MoeSsd, BpeTokenizer, GGML, Q4_BLOCK, tensorBytes, TOK, STORAGE, COPY_SRC, COPY_DST, MAP_READ } from './qwen3_moe_ssd.js';
39761
  import { Gemma4MoeSsd } from './gemma4_moe_ssd.js';
39762
+ import { Q8_BLOCK, parseGguf } from './gguf.js';
39763
  import { QWEN35_BATCH_KERNELS } from './qwen35_moe_ssd.js';
39764
 
39765
  export function configFromGgufLfm2Moe(kv) {
 
39961
  let conv = w[3u * i] * s0 + w[3u * i + 1u] * s1 + w[3u * i + 2u] * bx;
39962
  y[i] = bcx[p.H + i] * conv;
39963
  st[2u * i] = s1; st[2u * i + 1u] = bx;
39964
+ }`,
39965
+ // Run-time LoRA, first half: t = A·x, A [R × N] f16 (a GGUF `lora_a`), one workgroup per rank row.
39966
+ loraA: `enable f16;
39967
+ struct P { R: u32, N: u32 }
39968
+ @group(0) @binding(0) var<storage, read> x: array<f32>;
39969
+ @group(0) @binding(1) var<storage, read> a: array<f16>;
39970
+ @group(0) @binding(2) var<storage, read_write> t: array<f32>;
39971
+ @group(0) @binding(3) var<uniform> p: P;
39972
+ var<workgroup> red: array<f32, 256>;
39973
+ @compute @workgroup_size(256) fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) l: vec3<u32>) {
39974
+ let r = wg.x; let i = l.x; var acc = 0.0;
39975
+ for (var k = i; k < p.N; k += 256u) { acc += f32(a[r * p.N + k]) * x[k]; }
39976
+ red[i] = acc; workgroupBarrier();
39977
+ for (var s = 128u; s > 0u; s >>= 1u) { if (i < s) { red[i] += red[i + s]; } workgroupBarrier(); }
39978
+ if (i == 0u) { t[r] = red[0]; }
39979
+ }`,
39980
+ // Second half: y += scale · B·t, B [M × R] f16 (a GGUF `lora_b`), one thread per output row.
39981
+ loraB: `enable f16;
39982
+ struct P { M: u32, R: u32, s: f32 }
39983
+ @group(0) @binding(0) var<storage, read> t: array<f32>;
39984
+ @group(0) @binding(1) var<storage, read> b: array<f16>;
39985
+ @group(0) @binding(2) var<storage, read_write> y: array<f32>;
39986
+ @group(0) @binding(3) var<uniform> p: P;
39987
+ @compute @workgroup_size(256) fn main(@builtin(global_invocation_id) g: vec3<u32>) {
39988
+ let m = g.x; if (m >= p.M) { return; }
39989
+ var acc = 0.0;
39990
+ for (var j = 0u; j < p.R; j++) { acc += f32(b[m * p.R + j]) * t[j]; }
39991
+ y[m] = y[m] + p.s * acc;
39992
  }`,
39993
  // Debug capture: y[off + i] = x[i].
39994
  copyAt: `
 
40027
  s0 = s1; s1 = bx;
40028
  }
40029
  st[2u * i] = s0; st[2u * i + 1u] = s1;
40030
+ }`,
40031
+ // Run-time LoRA over the chunk: t[tok] = A·x[tok], one workgroup per (rank row, token).
40032
+ loraAT: `enable f16;
40033
+ struct P { R: u32, N: u32 }
40034
+ ${QB}
40035
+ @group(0) @binding(0) var<storage, read> x: array<f32>;
40036
+ @group(0) @binding(1) var<storage, read> a: array<f16>;
40037
+ @group(0) @binding(2) var<storage, read_write> t: array<f32>;
40038
+ @group(0) @binding(3) var<uniform> p: P;
40039
+ @group(0) @binding(4) var<uniform> qd: Q;
40040
+ var<workgroup> red: array<f32, 256>;
40041
+ @compute @workgroup_size(256) fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) l: vec3<u32>) {
40042
+ let r = wg.x; let tok = wg.y; let i = l.x; if (tok >= qd.T) { return; }
40043
+ let xb = tok * p.N; var acc = 0.0;
40044
+ for (var k = i; k < p.N; k += 256u) { acc += f32(a[r * p.N + k]) * x[xb + k]; }
40045
+ red[i] = acc; workgroupBarrier();
40046
+ for (var s = 128u; s > 0u; s >>= 1u) { if (i < s) { red[i] += red[i + s]; } workgroupBarrier(); }
40047
+ if (i == 0u) { t[tok * p.R + r] = red[0]; }
40048
+ }`,
40049
+ // y[tok] += scale · B·t[tok], one thread per (output row, token).
40050
+ loraBT: `enable f16;
40051
+ struct P { M: u32, R: u32, s: f32 }
40052
+ ${QB}
40053
+ @group(0) @binding(0) var<storage, read> t: array<f32>;
40054
+ @group(0) @binding(1) var<storage, read> b: array<f16>;
40055
+ @group(0) @binding(2) var<storage, read_write> y: array<f32>;
40056
+ @group(0) @binding(3) var<uniform> p: P;
40057
+ @group(0) @binding(4) var<uniform> qd: Q;
40058
+ @compute @workgroup_size(256) fn main(@builtin(global_invocation_id) g: vec3<u32>) {
40059
+ let m = g.x; let tok = g.y; if (m >= p.M || tok >= qd.T) { return; }
40060
+ var acc = 0.0;
40061
+ for (var j = 0u; j < p.R; j++) { acc += f32(b[m * p.R + j]) * t[tok * p.R + j]; }
40062
+ y[tok * p.M + m] = y[tok * p.M + m] + p.s * acc;
40063
  }`,
40064
  // act = SiLU(g) · u over T × n (the dense FFN's separate gate and up).
40065
  siluSplitB: `
 
40130
  constructor(device, manifest, gguf, opts) {
40131
  super(device, manifest, gguf, opts);
40132
  this.lookahead = Math.max(1, Math.floor(opts.lookahead ?? 1));
40133
+ this.arch = gguf.kv['general.architecture']; // a LoRA must be for the same architecture (loadAdapter)
40134
  }
40135
 
40136
  // Kernel names for the matrix and expert weights: Q4_0 here; an engine reading a Q8_0 file (hy_v3_moe_ssd.js) swaps
 
40367
  d('rmsnorm', g.rmsA, 1);
40368
  if (g.attn) {
40369
  d(this.kq.mm, g.q, Math.ceil(QN / 4)); d(this.kq.mm, g.k, Math.ceil(KVN / 4)); d(this.kq.mm, g.v, Math.ceil(KVN / 4));
40370
+ this.encodeLora(pass, L, 'q'); this.encodeLora(pass, L, 'k'); this.encodeLora(pass, L, 'v');
40371
  d('qkNormRope', g.ropeQ, c.heads); d('qkNormRope', g.ropeK, c.kvHeadsAttn);
40372
  d('kvStore', g.kv, Math.ceil(KVN / 256));
40373
  const ak = this.attnK;
 
40375
  d(ak.soft, g.soft, c.heads);
40376
  d(ak.out, g.attOut, Math.ceil(QN / 256));
40377
  d(this.kq.mm, g.o, Math.ceil(H / 4));
40378
+ this.encodeLora(pass, L, 'o');
40379
  } else {
40380
  d(this.kq.mm, g.inProj, Math.ceil(3 * H / 4));
40381
+ this.encodeLora(pass, L, 'inProj');
40382
  d('shortConv', g.conv, Math.ceil(H / 256));
40383
  d(this.kq.mm, g.o, Math.ceil(H / 4));
40384
+ this.encodeLora(pass, L, 'o');
40385
  }
40386
  d('addInPlace', g.addO, Math.ceil(H / 256));
40387
  d('rmsnorm', g.rmsF, 1);
40388
  if (L < c.lead) {
40389
  d(this.kq.mm, g.mg, Math.ceil(c.denseFf / 4)); d(this.kq.mm, g.mu, Math.ceil(c.denseFf / 4));
40390
+ this.encodeLora(pass, L, 'mg'); this.encodeLora(pass, L, 'mu');
40391
  d('siluMulMoe', g.mact, Math.ceil(c.denseFf / 256));
40392
  d(this.kq.mm, g.md, Math.ceil(H / 4));
40393
+ this.encodeLora(pass, L, 'md');
40394
  d('addInPlace', g.addO, Math.ceil(H / 256));
40395
  if (g.cap) d('copyAt', g.cap, Math.ceil(H / 256));
40396
  }
 
40434
  d('rmsnormB', g.rmsA, T);
40435
  if (this.mlayers[L].attn) {
40436
  d(this.kq.mmT, g.q, mm(QN), tt); d(this.kq.mmT, g.k, mm(KVN), tt); d(this.kq.mmT, g.v, mm(KVN), tt);
40437
+ this.encodeLoraB(pass, L, 'q', T); this.encodeLoraB(pass, L, 'k', T); this.encodeLoraB(pass, L, 'v', T);
40438
  d('qkNormRopeB', g.ropeQ, c.heads, T); d('qkNormRopeB', g.ropeK, c.kvHeadsAttn, T);
40439
  d('kvStoreB', g.kv, Math.ceil(KVN / 256), T);
40440
  const ak = this.attnK;
 
40442
  d(ak.softB, g.soft, c.heads * T);
40443
  d(ak.outB, g.attOut, Math.ceil(QN / 256), T);
40444
  d(this.kq.mmT, g.o, mm(H), tt);
40445
+ this.encodeLoraB(pass, L, 'o', T);
40446
  } else {
40447
  d(this.kq.mmT, g.inProj, mm(3 * H), tt);
40448
+ this.encodeLoraB(pass, L, 'inProj', T);
40449
  d('shortConvB', g.conv, Math.ceil(H / 256));
40450
  d(this.kq.mmT, g.o, mm(H), tt);
40451
+ this.encodeLoraB(pass, L, 'o', T);
40452
  }
40453
  d('addInPlaceB', g.addO, Math.ceil(H / 256), T);
40454
  d('rmsnormB', g.rmsF, T);
40455
  if (L < c.lead) {
40456
  d(this.kq.mmT, g.mg, mm(c.denseFf), tt); d(this.kq.mmT, g.mu, mm(c.denseFf), tt);
40457
+ this.encodeLoraB(pass, L, 'mg', T); this.encodeLoraB(pass, L, 'mu', T);
40458
  d('siluSplitB', g.mact, Math.ceil(c.denseFf / 256), T);
40459
  d(this.kq.mmT, g.md, mm(H), tt);
40460
+ this.encodeLoraB(pass, L, 'md', T);
40461
  d('addInPlaceB', g.addO, Math.ceil(H / 256), T);
40462
  }
40463
  }
 
40483
  }
40484
  }
40485
 
40486
+ // ── Run-time LoRA ──
40487
+ // A LoRA GGUF (llama.cpp's convert_lora_to_gguf.py: per adapted matrix W, `W.lora_a` [N → R] and `W.lora_b` [R → M],
40488
+ // F16), applied as y += scale · B(A·x) right after W's matmul, with scale = alpha / R (as llama.cpp's --lora) times
40489
+ // `scale`. The weights stay as loaded: setAdapter() switches between adapters, or back to none, with no reload.
40490
+ // Adapters on the experts are refused (the paged experts have no hook).
40491
+ async loadAdapter(source, { scale = 1 } = {}) {
40492
+ // a URL, a Blob (a File from OPFS or a picker), an ArrayBuffer or a Uint8Array
40493
+ const bytes = source instanceof Uint8Array ? source : new Uint8Array(typeof source === 'string'
40494
+ ? await (await fetch(source)).arrayBuffer() : source instanceof Blob ? await source.arrayBuffer() : source);
40495
+ const gguf = parseGguf(bytes), kv = gguf.kv;
40496
+ if (kv['adapter.type'] !== 'lora') throw new Error(`not a LoRA GGUF (adapter.type ${kv['adapter.type']})`);
40497
+ if (kv['general.architecture'] !== this.arch) throw new Error(`adapter for ${kv['general.architecture']}, model is ${this.arch}`);
40498
+ const SITES = { attn_q: 'q', attn_k: 'k', attn_v: 'v', attn_output: 'o', 'shortconv.in_proj': 'inProj', 'shortconv.out_proj': 'o', ffn_gate: 'mg', ffn_up: 'mu', ffn_down: 'md' };
40499
+ const byName = new Map(gguf.tensors.map((t) => [t.name, t]));
40500
+ const sites = Array.from({ length: this.cfg.modelLayers }, () => ({}));
40501
+ const STO = 0x80 | COPY_DST, a = this.a, b = this.b, qb = this.qb, gateBytes = this.cfg.denseFf * 4;
40502
+ let R = 0, bytesOnGpu = 0;
40503
+ const upload = (t) => {
40504
+ if (t.type !== GGML.F16) throw new Error(`${t.name}: type ${t.type}, LoRA tensors must be F16`);
40505
+ const n = t.dims.reduce((x, y) => x * y, 1), buf = this.buffer(n * 2, STO, 'adapter');
40506
+ this.device.queue.writeBuffer(buf, 0, bytes, gguf.dataStart + t.offset, n * 2);
40507
+ bytesOnGpu += buf.size;
40508
+ return buf;
40509
+ };
40510
+ for (const ta of gguf.tensors) {
40511
+ const m = /^blk\.(\d+)\.(.+)\.weight\.lora_a$/.exec(ta.name);
40512
+ if (!m) continue;
40513
+ const L = Number(m[1]), site = SITES[m[2]], tb = byName.get(ta.name.replace(/lora_a$/, 'lora_b')), w = this.w[`blk.${L}.${m[2]}.weight`];
40514
+ if (!site || !tb || !w) throw new Error(`${ta.name}: no matching matrix in this model (adapters on the experts are not supported)`);
40515
+ const [N, r] = ta.dims, [r2, M] = tb.dims;
40516
+ if (r !== r2 || N !== w.cols || M !== w.rows) throw new Error(`${ta.name}: shape ${N}×${r} / ${r2}×${M} does not fit ${w.cols}×${w.rows}`);
40517
+ R = Math.max(R, r);
40518
+ sites[L][site] = { r, N, M, A: upload(ta), B: upload(tb) };
40519
+ }
40520
+ if (!R) throw new Error('the adapter has no lora_a / lora_b pairs');
40521
+ const s = (kv['adapter.lora.alpha'] ?? R) / R * scale;
40522
+ // One t buffer per adapter (R floats per token); binds against the engine's activations.
40523
+ const lt = this.buffer(R * 4, 0x80 | COPY_SRC | COPY_DST, 'adapter'), ltB = b ? this.buffer(this.chunkTokens * R * 4, 0x80 | COPY_SRC | COPY_DST, 'adapter') : null;
40524
+ const io = (L, site) => {
40525
+ const attn = this.cfg.attn[L];
40526
+ const d = { q: [a.xn, a.q], k: [a.xn, a.k], v: [a.xn, a.v], o: attn ? [a.att, a.o] : [a.y, a.o], inProj: [a.xn, a.bcx],
40527
+ mg: [a.xn, { buffer: a.mgu, offset: 0, size: gateBytes }], mu: [a.xn, { buffer: a.mgu, offset: gateBytes, size: gateBytes }], md: [a.ma, a.o] }[site];
40528
+ const bt = b && { q: [b.xn, b.q], k: [b.xn, b.k], v: [b.xn, b.v], o: attn ? [b.att, b.o] : [b.y, b.o], inProj: [b.xn, b.bcx],
40529
+ mg: [b.xn, b.mg], mu: [b.xn, b.mu], md: [b.ma, b.o] }[site];
40530
+ return { d, bt };
40531
+ };
40532
+ sites.forEach((ss, L) => {
40533
+ for (const [site, e] of Object.entries(ss)) {
40534
+ const { d, bt } = io(L, site), uA = this.uniform([e.r, e.N]), uB = this.uniform([e.M, e.r, { f: s }]);
40535
+ e.a = this.bind('loraA', [d[0], e.A, lt, uA]);
40536
+ e.b = this.bindR('loraB', [lt, e.B, d[1], uB]);
40537
+ if (bt) { e.aB = this.bind('loraAT', [bt[0], e.A, ltB, uA, qb]); e.bB = this.bind('loraBT', [ltB, e.B, bt[1], uB, qb]); }
40538
+ }
40539
+ });
40540
+ const n = sites.reduce((x, ss) => x + Object.keys(ss).length, 0);
40541
+ return { name: kv['general.name'] || 'lora', rank: R, scale: s, matrices: n, bytes: bytesOnGpu, sites };
40542
+ }
40543
+ // The adapter for the next turns (null: the plain model). The cached prompt was computed with the old weights, so
40544
+ // the next turn starts from token 0.
40545
+ async setAdapter(adapter) {
40546
+ const release = await this.acquire();
40547
+ try { this.adapter = adapter || null; this.reset(); } finally { release(); }
40548
+ }
40549
+ encodeLora(pass, L, site) {
40550
+ const e = this.adapter && this.adapter.sites[L][site];
40551
+ if (!e) return;
40552
+ this.dispatch(pass, 'loraA', e.a, e.r);
40553
+ this.dispatch(pass, 'loraB', e.b, Math.ceil(e.M / 256));
40554
+ }
40555
+ encodeLoraB(pass, L, site, T) {
40556
+ const e = this.adapter && this.adapter.sites[L][site];
40557
+ if (!e) return;
40558
+ this.dispatch(pass, 'loraAT', e.aB, e.r, T);
40559
+ this.dispatch(pass, 'loraBT', e.bB, Math.ceil(e.M / 256), T);
40560
+ }
40561
+
40562
  // The conv state cannot rewind, so any change before the cached end restarts from token 0.
40563
  reset() {
40564
  super.reset();