diff --git a/.github/issue-evidence/gemma4-assistant-mtp/completion-timings.json b/.github/issue-evidence/gemma4-assistant-mtp/completion-timings.json new file mode 100644 index 0000000000000..f8843a73a4be6 --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/completion-timings.json @@ -0,0 +1 @@ +{"index":0,"content":" four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty.","tokens":[],"id_slot":1,"stop":true,"model":"eliza-1-2b-128k.gguf","tokens_predicted":35,"tokens_evaluated":16,"generation_settings":{"seed":4294967295,"temperature":0.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"top_k":64,"top_p":0.949999988079071,"min_p":0.05000000074505806,"top_n_sigma":-1.0,"xtc_probability":0.0,"xtc_threshold":0.10000000149011612,"typical_p":1.0,"repeat_last_n":64,"repeat_penalty":1.0,"presence_penalty":0.0,"frequency_penalty":0.0,"dry_multiplier":0.0,"dry_base":1.75,"dry_allowed_length":2,"dry_penalty_last_n":8192,"dry_sequence_breakers":["\n",":","\"","*"],"repeat_line_window":0,"repeat_line_min_length":20,"repeat_line_delimiters":"\n.!?:","repeat_line_temp_boost":0.5,"mirostat":0,"mirostat_tau":5.0,"mirostat_eta":0.10000000149011612,"stop":[],"max_tokens":96,"n_predict":96,"n_keep":0,"n_discard":0,"ignore_eos":false,"stream":false,"logit_bias":[],"n_probs":0,"min_keep":0,"grammar":"","grammar_lazy":false,"grammar_triggers":[],"preserved_tokens":[],"chat_format":"Content-only","reasoning_format":"deepseek","reasoning_in_content":false,"generation_prompt":"","samplers":["penalties","dry","top_n_sigma","top_k","typ_p","top_p","min_p","xtc","temperature"],"speculative.types":"none,draft-mtp","timings_per_token":false,"post_sampling_probs":false,"backend_sampling":false,"lora":[]},"prompt":"Count from one to twenty in English words: one, two, three,","has_new_line":false,"truncated":false,"stop_type":"eos","stopping_word":"","tokens_cached":50,"timings":{"cache_n":15,"prompt_n":1,"prompt_ms":21.344,"prompt_per_token_ms":21.344,"prompt_per_second":46.85157421289355,"predicted_n":35,"predicted_ms":416.185,"predicted_per_token_ms":11.891,"predicted_per_second":84.09721638213774,"draft_n":72,"draft_n_accepted":16}} \ No newline at end of file diff --git a/.github/issue-evidence/gemma4-assistant-mtp/draft-acceptance-bench.txt b/.github/issue-evidence/gemma4-assistant-mtp/draft-acceptance-bench.txt new file mode 100644 index 0000000000000..813fed6eacb05 --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/draft-acceptance-bench.txt @@ -0,0 +1,17 @@ +gemma4-assistant E2B drafter (f16, converted from google/gemma-4-E2B-it-assistant) +target: /tmp/vision/gemma4/bundles/2b/text/eliza-1-2b-128k.gguf (eliza-1-2b, gemma4, n_embd 1536, Q8) +host: Apple M4 Max, Metal, llama-server (fork build-desktop-metal), greedy (temperature 0), n_predict 96, --cache-ram 0 + +baseline (no drafter): + counting-to-twenty : predicted_n=35 tok/s= 96.00 + quick-brown-fox : predicted_n= 3 tok/s=143.44 + weekdays : predicted_n=11 tok/s=103.99 + +-md drafter --spec-type draft-mtp --spec-draft-n-max 1 (catalog shipped window): + counting-to-twenty : predicted_n=35 tok/s=167.16 draft_n=18 accepted=16 (1.74x, 89%) + quick-brown-fox : predicted_n= 3 tok/s=200.51 draft_n= 1 accepted= 1 (1.40x, 100%) + weekdays : predicted_n=11 tok/s=150.11 draft_n= 6 accepted= 4 (1.44x, 67%) + +aggregate acceptance: 21/25 = 0.84 ; mean speedup ~1.53x +(--spec-draft-n-max 4 run: draft_n=80 accepted=14 on counting; per-step server log lines + "accepted 1/4 draft tokens" in speculative-decode-server.log) diff --git a/.github/issue-evidence/gemma4-assistant-mtp/drafter-gguf-metadata.txt b/.github/issue-evidence/gemma4-assistant-mtp/drafter-gguf-metadata.txt new file mode 100644 index 0000000000000..32f0d0e082bc5 --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/drafter-gguf-metadata.txt @@ -0,0 +1,89 @@ +GGUF.version = 3 +GGUF.tensor_count = 49 +GGUF.kv_count = 42 +general.architecture = gemma4-assistant +general.type = model +general.sampling.top_k = 64 +general.sampling.top_p = 0.949999988079071 +general.sampling.temp = 1.0 +general.name = Model +general.size_label = 77M +gemma4-assistant.block_count = 4 +gemma4-assistant.context_length = 131072 +gemma4-assistant.embedding_length = 256 +gemma4-assistant.feed_forward_length = 2048 +gemma4-assistant.attention.head_count = 4 +gemma4-assistant.attention.head_count_kv = 1 +gemma4-assistant.rope.freq_base = 1000000.0 +gemma4-assistant.rope.freq_base_swa = 10000.0 +gemma4-assistant.attention.layer_norm_rms_epsilon = 9.999999974752427e-07 +gemma4-assistant.attention.key_length = 512 +gemma4-assistant.attention.value_length = 512 +general.file_type = 1 +gemma4-assistant.attention.sliding_window = 512 +gemma4-assistant.attention.shared_kv_layers = 4 +gemma4-assistant.embedding_length_per_layer_input = 0 +gemma4-assistant.attention.sliding_window_pattern = [True, True, True, False] +gemma4-assistant.attention.key_length_swa = 256 +gemma4-assistant.attention.value_length_swa = 256 +gemma4-assistant.rope.dimension_count = 512 +gemma4-assistant.rope.dimension_count_swa = 256 +gemma4-assistant.embedding_length_out = 1536 +gemma4-assistant.nextn_predict_layers = 1 +general.quantization_version = 2 +tokenizer.ggml.model = gemma4 +tokenizer.ggml.bos_token_id = 2 +tokenizer.ggml.eos_token_id = 1 +tokenizer.ggml.unknown_token_id = 3 +tokenizer.ggml.padding_token_id = 0 +tokenizer.ggml.mask_token_id = 4 +--- tensors --- +rope_freqs.weight [np.uint64(256)] F32 +token_embd.weight [np.uint64(256), np.uint64(262144)] F16 +blk.0.attn_norm.weight [np.uint64(256)] F32 +blk.0.layer_output_scale.weight [np.uint64(1)] F32 +blk.0.ffn_down.weight [np.uint64(2048), np.uint64(256)] F16 +blk.0.ffn_gate.weight [np.uint64(256), np.uint64(2048)] F16 +blk.0.ffn_up.weight [np.uint64(256), np.uint64(2048)] F16 +blk.0.post_attention_norm.weight [np.uint64(256)] F32 +blk.0.post_ffw_norm.weight [np.uint64(256)] F32 +blk.0.ffn_norm.weight [np.uint64(256)] F32 +blk.0.attn_output.weight [np.uint64(1024), np.uint64(256)] F16 +blk.0.attn_q_norm.weight [np.uint64(256)] F32 +blk.0.attn_q.weight [np.uint64(256), np.uint64(1024)] F16 +blk.1.attn_norm.weight [np.uint64(256)] F32 +blk.1.layer_output_scale.weight [np.uint64(1)] F32 +blk.1.ffn_down.weight [np.uint64(2048), np.uint64(256)] F16 +blk.1.ffn_gate.weight [np.uint64(256), np.uint64(2048)] F16 +blk.1.ffn_up.weight [np.uint64(256), np.uint64(2048)] F16 +blk.1.post_attention_norm.weight [np.uint64(256)] F32 +blk.1.post_ffw_norm.weight [np.uint64(256)] F32 +blk.1.ffn_norm.weight [np.uint64(256)] F32 +blk.1.attn_output.weight [np.uint64(1024), np.uint64(256)] F16 +blk.1.attn_q_norm.weight [np.uint64(256)] F32 +blk.1.attn_q.weight [np.uint64(256), np.uint64(1024)] F16 +blk.2.attn_norm.weight [np.uint64(256)] F32 +blk.2.layer_output_scale.weight [np.uint64(1)] F32 +blk.2.ffn_down.weight [np.uint64(2048), np.uint64(256)] F16 +blk.2.ffn_gate.weight [np.uint64(256), np.uint64(2048)] F16 +blk.2.ffn_up.weight [np.uint64(256), np.uint64(2048)] F16 +blk.2.post_attention_norm.weight [np.uint64(256)] F32 +blk.2.post_ffw_norm.weight [np.uint64(256)] F32 +blk.2.ffn_norm.weight [np.uint64(256)] F32 +blk.2.attn_output.weight [np.uint64(1024), np.uint64(256)] F16 +blk.2.attn_q_norm.weight [np.uint64(256)] F32 +blk.2.attn_q.weight [np.uint64(256), np.uint64(1024)] F16 +blk.3.attn_norm.weight [np.uint64(256)] F32 +blk.3.layer_output_scale.weight [np.uint64(1)] F32 +blk.3.ffn_down.weight [np.uint64(2048), np.uint64(256)] F16 +blk.3.ffn_gate.weight [np.uint64(256), np.uint64(2048)] F16 +blk.3.ffn_up.weight [np.uint64(256), np.uint64(2048)] F16 +blk.3.post_attention_norm.weight [np.uint64(256)] F32 +blk.3.post_ffw_norm.weight [np.uint64(256)] F32 +blk.3.ffn_norm.weight [np.uint64(256)] F32 +blk.3.attn_output.weight [np.uint64(2048), np.uint64(256)] F16 +blk.3.attn_q_norm.weight [np.uint64(512)] F32 +blk.3.attn_q.weight [np.uint64(256), np.uint64(2048)] F16 +output_norm.weight [np.uint64(256)] F32 +nextn.post_projection.weight [np.uint64(256), np.uint64(1536)] F16 +nextn.pre_projection.weight [np.uint64(3072), np.uint64(256)] F16 diff --git a/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-bench.txt b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-bench.txt new file mode 100644 index 0000000000000..8dc42fb2449bc --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-bench.txt @@ -0,0 +1,46 @@ +gemma4-assistant E2B drafter — FUSED PRODUCT-PATH proof (libelizainference.dylib, ABI v9) +========================================================================================== +This is the desktop product path — NOT llama-server. The harness +(fused-ffi-harness.ts) drives the plugin's own bun:ffi binding +(src/services/voice/ffi-bindings.ts loadElizaInferenceFfi) against the +freshly rebuilt build-desktop-metal/bin/libelizainference.dylib: +eliza_inference_llm_stream_open with mtp_drafter_path set -> the fused +separate-drafter DRAFT_MTP engine (LLAMA_CONTEXT_TYPE_MTP draft context, +ctx_other = target context, shared KV / target tok_embd). + +host : Apple M4 Max, Metal, bun, greedy (temperature 0), maxTokens 96, ctx 4096 +target : /tmp/vision/gemma4/bundles/2b/text/eliza-1-2b-128k.gguf (gemma4, n_embd 1536) +drafter : /tmp/mtp/bundles/2b/mtp/drafter-2b.gguf (gemma4-assistant, 49 tensors, + block_count 4, embedding_length 256 -> out 1536) +window : draftMin=1 draftMax=1 (the shipped catalog window) + +capability probes: llmStreamSupported=true llmMtpSupported=true tokenizeSupported=true +drafter load : clean — no tensor/KV mismatch; "common_speculative_init: adding + speculative implementation 'draft-mtp'"; set_embeddings_pre_norm=1 + +prompt baseline MTP drafted accepted acceptance +counting-to-twenty 78-88 tok/s 96-106 tok/s 27 22 0.815 +weekdays 75-77 tok/s 86-93 tok/s 11 10 0.909 + ------ ------ ----- +TOTAL 38 32 0.842 +speedup ~1.15-1.23x wall (prefill+decode) at draftMax=1; matches the +llama-server measurement (0.84 acceptance) in draft-acceptance-bench.txt. + +output coherence: both MTP outputs coherent. weekdays output is byte-identical +to the greedy baseline across repeated runs. + +HONEST FLAG — deterministic one-token tie-flip on counting-to-twenty: +the MTP run emits "... Fifteen, Sixteen,, Eighteen ..." (skips "Seventeen", +n=48 vs 49). Reproduced identically across 2 runs. All tokens after the flip +match the baseline exactly, so draft-rollback/KV retraction is correct; this +is the target's own batched-verify logits (n_tokens=2 Metal kernels) flipping +a near-tie argmax vs single-token decode — a known speculative-decode numerics +artifact, not a drafter tensor/KV mapping defect (a mapping defect produces +garbage + near-zero acceptance, not 84% acceptance with clean continuation). + +teardown: streams + ctx close cleanly ("[harness] clean shutdown"); a known +GGML Metal residency-set assert fires later in __cxa_finalize at process exit +(ggml-metal-device.m:637), after all inference work completed — exit-time +only, upstream teardown-order issue, unrelated to MTP. + +Full log: fused-ffi-run.txt. Harness: fused-ffi-harness.ts. diff --git a/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-harness.ts b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-harness.ts new file mode 100644 index 0000000000000..9bb0cc8858e8f --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-harness.ts @@ -0,0 +1,114 @@ +/** + * Fused-lib product-path proof harness for the gemma4-assistant MTP drafter. + * + * Drives the EXACT desktop text path: libelizainference.dylib ABI-v9 + * `eliza_inference_llm_stream_open` with `mtp_drafter_path` set (the + * separate-drafter MTP engine, ctx_other shared-KV), via the plugin's own + * `loadElizaInferenceFfi` binding — no mocks, no llama-server. + * + * Target : /tmp/vision/gemma4/bundles/2b/text/eliza-1-2b-128k.gguf (gemma4) + * Drafter: /tmp/mtp/bundles/2b/mtp/drafter-2b.gguf (gemma4-assistant) + */ +import { loadElizaInferenceFfi } from "/Users/shawwalters/eliza-workspace/milady/eliza/plugins/plugin-local-inference/src/services/voice/ffi-bindings"; + +const LIB = + "/Users/shawwalters/eliza-workspace/milady/eliza/plugins/plugin-local-inference/native/llama.cpp/build-desktop-metal/bin/libelizainference.dylib"; +const BUNDLE_ROOT = "/tmp/vision/gemma4/bundles/2b"; +const DRAFTER = "/tmp/mtp/bundles/2b/mtp/drafter-2b.gguf"; +const MAX_TOKENS = 96; + +const PROMPTS = [ + "Count from one to twenty, writing each number as a word separated by commas.", + "List the seven days of the week in order, one per line.", +]; + +function gemmaPrompt(user: string): string { + return `user\n${user}\nmodel\n`; +} + +const ffi = loadElizaInferenceFfi(LIB); +console.log(`[harness] lib=${LIB}`); +console.log( + `[harness] abi=${ffi.abiVersion?.() ?? "?"} llmStreamSupported=${ffi.llmStreamSupported?.()} llmMtpSupported=${ffi.llmMtpSupported?.()} tokenizeSupported=${ffi.tokenizeSupported?.()}`, +); + +const ctx = ffi.create(BUNDLE_ROOT); +console.log(`[harness] fused ctx created over bundle root ${BUNDLE_ROOT}`); + +interface RunResult { + text: string; + nGenerated: number; + ms: number; + drafted: number; + accepted: number; +} + +function run(user: string, mtp: boolean): RunResult { + const tokens = ffi.tokenize({ ctx, text: gemmaPrompt(user) }); + const stream = ffi.llmStreamOpen({ + ctx, + config: { + maxTokens: MAX_TOKENS, + temperature: 0, // greedy so baseline and MTP outputs must match + topP: 1, + topK: 0, + repeatPenalty: 1, + slotId: -1, + promptCacheKey: null, + draftMin: mtp ? 1 : 0, + draftMax: mtp ? 1 : 0, + draftModelPath: mtp ? DRAFTER : null, + gpuLayers: -1, + contextSize: 4096, + }, + }); + let text = ""; + let nGenerated = 0; + let drafted = 0; + let accepted = 0; + const t0 = performance.now(); + try { + ffi.llmStreamPrefill({ stream, tokens }); + for (;;) { + const step = ffi.llmStreamNext({ stream, maxTokensPerStep: 32 }); + text += step.text; + nGenerated += step.tokens.length; + drafted += step.drafterDrafted; + accepted += step.drafterAccepted; + if (step.done || nGenerated >= MAX_TOKENS) break; + } + } finally { + ffi.llmStreamClose({ stream }); + } + const ms = performance.now() - t0; + return { text, nGenerated, ms, drafted, accepted }; +} + +let totDrafted = 0; +let totAccepted = 0; +for (const p of PROMPTS) { + console.log(`\n=== prompt: ${JSON.stringify(p)}`); + const base = run(p, false); + console.log( + `[baseline] n=${base.nGenerated} ${(base.nGenerated / (base.ms / 1000)).toFixed(1)} tok/s (prefill+decode ${base.ms.toFixed(0)}ms)`, + ); + console.log(`[baseline] text: ${JSON.stringify(base.text)}`); + const mtp = run(p, true); + totDrafted += mtp.drafted; + totAccepted += mtp.accepted; + console.log( + `[mtp] n=${mtp.nGenerated} ${(mtp.nGenerated / (mtp.ms / 1000)).toFixed(1)} tok/s (prefill+decode ${mtp.ms.toFixed(0)}ms) drafted=${mtp.drafted} accepted=${mtp.accepted} acceptance=${mtp.drafted > 0 ? (mtp.accepted / mtp.drafted).toFixed(3) : "n/a"}`, + ); + console.log(`[mtp] text: ${JSON.stringify(mtp.text)}`); + console.log( + `[check] greedy outputs identical: ${mtp.text === base.text}`, + ); +} + +console.log( + `\n[TOTAL] drafted=${totDrafted} accepted=${totAccepted} acceptance=${totDrafted > 0 ? (totAccepted / totDrafted).toFixed(3) : "n/a"}`, +); + +ffi.destroy(ctx); +ffi.close(); +console.log("[harness] clean shutdown"); diff --git a/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-run.txt b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-run.txt new file mode 100644 index 0000000000000..b35b8a4b1b65e --- /dev/null +++ b/.github/issue-evidence/gemma4-assistant-mtp/fused-ffi-run.txt @@ -0,0 +1,2268 @@ +[harness] lib=/Users/shawwalters/eliza-workspace/milady/eliza/plugins/plugin-local-inference/native/llama.cpp/build-desktop-metal/bin/libelizainference.dylib +[harness] abi=? llmStreamSupported=true llmMtpSupported=true tokenizeSupported=true +[harness] fused ctx created over bundle root /tmp/vision/gemma4/bundles/2b + +=== prompt: "Count from one to twenty, writing each number as a word separated by commas." +ggml_metal_device_init: tensor API disabled for pre-M5 and pre-A19 devices +ggml_metal_library_init: using embedded compiled metal library +ggml_metal_library_init: loaded in 0.008 sec +ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s) +ggml_metal_device_init: GPU name: MTL0 (Apple M4 Max) +ggml_metal_device_init: GPU family: MTLGPUFamilyApple9 (1009) +ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003) +ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4 (5002) +ggml_metal_device_init: simdgroup reduction = true +ggml_metal_device_init: simdgroup matrix mul. = true +ggml_metal_device_init: has unified memory = true +ggml_metal_device_init: has bfloat = true +ggml_metal_device_init: has tensor = false +ggml_metal_device_init: use residency sets = true +ggml_metal_device_init: use shared buffers = true +ggml_metal_device_init: use managed buffers = false +ggml_metal_device_init: recommendedMaxWorkingSetSize = 115448.73 MB +llama_model_loader: loaded meta data with 44 key-value pairs and 601 tensors from /tmp/vision/gemma4/bundles/2b/text/eliza-1-2b-128k.gguf (version GGUF V3 (latest)) +llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output. +llama_model_loader: - kv 0: general.architecture str = gemma4 +llama_model_loader: - kv 1: general.type str = model +llama_model_loader: - kv 2: general.sampling.top_k i32 = 64 +llama_model_loader: - kv 3: general.sampling.top_p f32 = 0.950000 +llama_model_loader: - kv 4: general.sampling.temp f32 = 1.000000 +llama_model_loader: - kv 5: general.size_label str = 4.6B +llama_model_loader: - kv 6: general.license str = apache-2.0 +llama_model_loader: - kv 7: general.license.link str = https://ai.google.dev/gemma/docs/gemm... +llama_model_loader: - kv 8: general.tags arr[str,1] = ["any-to-any"] +llama_model_loader: - kv 9: gemma4.block_count u32 = 35 +llama_model_loader: - kv 10: gemma4.context_length u32 = 131072 +llama_model_loader: - kv 11: gemma4.embedding_length u32 = 1536 +llama_model_loader: - kv 12: gemma4.feed_forward_length arr[i32,35] = [6144, 6144, 6144, 6144, 6144, 6144, ... +llama_model_loader: - kv 13: gemma4.attention.head_count u32 = 8 +llama_model_loader: - kv 14: gemma4.attention.head_count_kv u32 = 1 +llama_model_loader: - kv 15: gemma4.rope.freq_base f32 = 1000000.000000 +llama_model_loader: - kv 16: gemma4.rope.freq_base_swa f32 = 10000.000000 +llama_model_loader: - kv 17: gemma4.attention.layer_norm_rms_epsilon f32 = 0.000001 +llama_model_loader: - kv 18: gemma4.attention.key_length u32 = 512 +llama_model_loader: - kv 19: gemma4.attention.value_length u32 = 512 +llama_model_loader: - kv 20: gemma4.final_logit_softcapping f32 = 30.000000 +llama_model_loader: - kv 21: gemma4.attention.sliding_window u32 = 512 +llama_model_loader: - kv 22: gemma4.attention.shared_kv_layers u32 = 20 +llama_model_loader: - kv 23: gemma4.embedding_length_per_layer_input u32 = 256 +llama_model_loader: - kv 24: gemma4.attention.sliding_window_pattern arr[bool,35] = [true, true, true, true, false, true,... +llama_model_loader: - kv 25: gemma4.attention.key_length_swa u32 = 256 +llama_model_loader: - kv 26: gemma4.attention.value_length_swa u32 = 256 +llama_model_loader: - kv 27: gemma4.rope.dimension_count u32 = 512 +llama_model_loader: - kv 28: gemma4.rope.dimension_count_swa u32 = 256 +llama_model_loader: - kv 29: tokenizer.ggml.model str = gemma4 +llama_model_loader: - kv 30: tokenizer.ggml.tokens arr[str,262144] = ["", "", "", "", ... +llama_model_loader: - kv 31: tokenizer.ggml.scores arr[f32,262144] = [-1000.000000, -1000.000000, -1000.00... +llama_model_loader: - kv 32: tokenizer.ggml.token_type arr[i32,262144] = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, ... +llama_model_loader: - kv 33: tokenizer.ggml.merges arr[str,514906] = ["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n", ... +llama_model_loader: - kv 34: tokenizer.ggml.bos_token_id u32 = 2 +llama_model_loader: - kv 35: tokenizer.ggml.eos_token_id u32 = 1 +llama_model_loader: - kv 36: tokenizer.ggml.unknown_token_id u32 = 3 +llama_model_loader: - kv 37: tokenizer.ggml.padding_token_id u32 = 0 +llama_model_loader: - kv 38: tokenizer.ggml.mask_token_id u32 = 4 +llama_model_loader: - kv 39: tokenizer.chat_template str = {%- macro format_parameters(propertie... +llama_model_loader: - kv 40: tokenizer.ggml.add_space_prefix bool = false +llama_model_loader: - kv 41: tokenizer.ggml.add_bos_token bool = true +llama_model_loader: - kv 42: general.quantization_version u32 = 2 +llama_model_loader: - kv 43: general.file_type u32 = 7 +llama_model_loader: - type f32: 283 tensors +llama_model_loader: - type q8_0: 317 tensors +llama_model_loader: - type bf16: 1 tensors +print_info: file format = GGUF V3 (latest) +print_info: file type = Q8_0 +print_info: file size = 4.61 GiB (8.52 BPW) +llama_prepare_model_devices: using device MTL0 (Apple M4 Max) (unknown id) - 110100 MiB free +init_tokenizer: initializing tokenizer for type 2 +load: 0 unused tokens +load: control token: 258883 '' is not marked as EOG +load: control token: 258881 '<|audio|>' is not marked as EOG +load: control token: 258880 '<|image|>' is not marked as EOG +load: control token: 256000 '<|audio>' is not marked as EOG +load: control token: 255999 '<|image>' is not marked as EOG +load: control token: 105 '<|turn>' is not marked as EOG +load: control token: 258882 '' is not marked as EOG +load: control-looking token: 50 '<|tool_response>' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 46 '<|tool>' is not marked as EOG +load: control token: 3 '' is not marked as EOG +load: control-looking token: 212 '' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 258884 '<|video|>' is not marked as EOG +load: control token: 47 '' is not marked as EOG +load: control token: 4 '' is not marked as EOG +load: control token: 2 '' is not marked as EOG +load: control token: 98 '<|think|>' is not marked as EOG +load: control token: 0 '' is not marked as EOG +load: printing all EOG tokens: +load: - 1 ('') +load: - 50 ('<|tool_response>') +load: - 106 ('') +load: - 212 ('') +load: special_eog_ids contains '<|tool_response>', removing '' token from EOG list +load: special tokens cache size = 24 +load: token to piece cache size = 1.9445 MB +print_info: arch = gemma4 +print_info: vocab_only = 0 +print_info: no_alloc = 0 +print_info: n_ctx_train = 131072 +print_info: n_embd = 1536 +print_info: n_embd_inp = 1536 +print_info: n_layer = 35 +print_info: n_head = 8 +print_info: n_head_kv = 1 +print_info: n_rot = 512 +print_info: n_swa = 512 +print_info: is_swa_any = 1 +print_info: n_embd_head_k = 512 +print_info: n_embd_head_v = 512 +print_info: n_gqa = 8 +print_info: n_embd_k_gqa = [256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512] +print_info: n_embd_v_gqa = [256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512, 256, 256, 256, 256, 512] +print_info: f_norm_eps = 0.0e+00 +print_info: f_norm_rms_eps = 1.0e-06 +print_info: f_clamp_kqv = 0.0e+00 +print_info: f_max_alibi_bias = 0.0e+00 +print_info: f_logit_scale = 0.0e+00 +print_info: f_attn_scale = 1.0e+00 +print_info: f_attn_value_scale = 0.0000 +print_info: n_ff = [6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 6144, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288] +print_info: n_expert = 0 +print_info: n_expert_used = 0 +print_info: n_expert_groups = 0 +print_info: n_group_used = 0 +print_info: causal attn = 1 +print_info: pooling type = -1 +print_info: rope type = 2 +print_info: rope scaling = linear +print_info: freq_base_train = 1000000.0 +print_info: freq_scale_train = 1 +print_info: freq_base_swa = 10000.0 +print_info: freq_scale_swa = 1 +print_info: n_embd_head_k_swa = 256 +print_info: n_embd_head_v_swa = 256 +print_info: n_rot_swa = 256 +print_info: n_ctx_orig_yarn = 131072 +print_info: rope_yarn_log_mul = 0.0000 +print_info: rope_finetuned = unknown +print_info: model type = E2B +print_info: model params = 4.65 B +print_info: general.name = n/a +print_info: vocab type = BPE +print_info: n_vocab = 262144 +print_info: n_merges = 514906 +print_info: BOS token = 2 '' +print_info: EOS token = 1 '' +print_info: UNK token = 3 '' +print_info: PAD token = 0 '' +print_info: MASK token = 4 '' +print_info: LF token = 107 ' +' +print_info: EOG token = 1 '' +print_info: EOG token = 50 '<|tool_response>' +print_info: EOG token = 106 '' +print_info: max token length = 93 +load_tensors: loading model tensors, this can take a while... (mmap = true, direct_io = false) +load_tensors: layer 0 assigned to device MTL0, is_swa = 1 +load_tensors: layer 1 assigned to device MTL0, is_swa = 1 +load_tensors: layer 2 assigned to device MTL0, is_swa = 1 +load_tensors: layer 3 assigned to device MTL0, is_swa = 1 +load_tensors: layer 4 assigned to device MTL0, is_swa = 0 +load_tensors: layer 5 assigned to device MTL0, is_swa = 1 +load_tensors: layer 6 assigned to device MTL0, is_swa = 1 +load_tensors: layer 7 assigned to device MTL0, is_swa = 1 +load_tensors: layer 8 assigned to device MTL0, is_swa = 1 +load_tensors: layer 9 assigned to device MTL0, is_swa = 0 +load_tensors: layer 10 assigned to device MTL0, is_swa = 1 +load_tensors: layer 11 assigned to device MTL0, is_swa = 1 +load_tensors: layer 12 assigned to device MTL0, is_swa = 1 +load_tensors: layer 13 assigned to device MTL0, is_swa = 1 +load_tensors: layer 14 assigned to device MTL0, is_swa = 0 +load_tensors: layer 15 assigned to device MTL0, is_swa = 1 +load_tensors: layer 16 assigned to device MTL0, is_swa = 1 +load_tensors: layer 17 assigned to device MTL0, is_swa = 1 +load_tensors: layer 18 assigned to device MTL0, is_swa = 1 +load_tensors: layer 19 assigned to device MTL0, is_swa = 0 +load_tensors: layer 20 assigned to device MTL0, is_swa = 1 +load_tensors: layer 21 assigned to device MTL0, is_swa = 1 +load_tensors: layer 22 assigned to device MTL0, is_swa = 1 +load_tensors: layer 23 assigned to device MTL0, is_swa = 1 +load_tensors: layer 24 assigned to device MTL0, is_swa = 0 +load_tensors: layer 25 assigned to device MTL0, is_swa = 1 +load_tensors: layer 26 assigned to device MTL0, is_swa = 1 +load_tensors: layer 27 assigned to device MTL0, is_swa = 1 +load_tensors: layer 28 assigned to device MTL0, is_swa = 1 +load_tensors: layer 29 assigned to device MTL0, is_swa = 0 +load_tensors: layer 30 assigned to device MTL0, is_swa = 1 +load_tensors: layer 31 assigned to device MTL0, is_swa = 1 +load_tensors: layer 32 assigned to device MTL0, is_swa = 1 +load_tensors: layer 33 assigned to device MTL0, is_swa = 1 +load_tensors: layer 34 assigned to device MTL0, is_swa = 0 +load_tensors: layer 35 assigned to device MTL0, is_swa = 0 +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor per_layer_token_embd.weight +create_tensor: loading tensor per_layer_model_proj.weight +create_tensor: loading tensor per_layer_proj_norm.weight +create_tensor: loading tensor output_norm.weight +create_tensor: loading tensor blk.0.attn_norm.weight +create_tensor: loading tensor blk.0.attn_q.weight +create_tensor: loading tensor blk.0.attn_k.weight +create_tensor: loading tensor blk.0.attn_v.weight +create_tensor: loading tensor blk.0.attn_output.weight +create_tensor: loading tensor blk.0.attn_q_norm.weight +create_tensor: loading tensor blk.0.attn_k_norm.weight +create_tensor: loading tensor blk.0.post_attention_norm.weight +create_tensor: loading tensor blk.0.layer_output_scale.weight +create_tensor: loading tensor blk.0.ffn_norm.weight +create_tensor: loading tensor blk.0.ffn_gate.weight +create_tensor: loading tensor blk.0.ffn_up.weight +create_tensor: loading tensor blk.0.ffn_down.weight +create_tensor: loading tensor blk.0.post_ffw_norm.weight +create_tensor: loading tensor blk.0.inp_gate.weight +create_tensor: loading tensor blk.0.proj.weight +create_tensor: loading tensor blk.0.post_norm.weight +create_tensor: loading tensor blk.1.attn_norm.weight +create_tensor: loading tensor blk.1.attn_q.weight +create_tensor: loading tensor blk.1.attn_k.weight +create_tensor: loading tensor blk.1.attn_v.weight +create_tensor: loading tensor blk.1.attn_output.weight +create_tensor: loading tensor blk.1.attn_q_norm.weight +create_tensor: loading tensor blk.1.attn_k_norm.weight +create_tensor: loading tensor blk.1.post_attention_norm.weight +create_tensor: loading tensor blk.1.layer_output_scale.weight +create_tensor: loading tensor blk.1.ffn_norm.weight +create_tensor: loading tensor blk.1.ffn_gate.weight +create_tensor: loading tensor blk.1.ffn_up.weight +create_tensor: loading tensor blk.1.ffn_down.weight +create_tensor: loading tensor blk.1.post_ffw_norm.weight +create_tensor: loading tensor blk.1.inp_gate.weight +create_tensor: loading tensor blk.1.proj.weight +create_tensor: loading tensor blk.1.post_norm.weight +create_tensor: loading tensor blk.2.attn_norm.weight +create_tensor: loading tensor blk.2.attn_q.weight +create_tensor: loading tensor blk.2.attn_k.weight +create_tensor: loading tensor blk.2.attn_v.weight +create_tensor: loading tensor blk.2.attn_output.weight +create_tensor: loading tensor blk.2.attn_q_norm.weight +create_tensor: loading tensor blk.2.attn_k_norm.weight +create_tensor: loading tensor blk.2.post_attention_norm.weight +create_tensor: loading tensor blk.2.layer_output_scale.weight +create_tensor: loading tensor blk.2.ffn_norm.weight +create_tensor: loading tensor blk.2.ffn_gate.weight +create_tensor: loading tensor blk.2.ffn_up.weight +create_tensor: loading tensor blk.2.ffn_down.weight +create_tensor: loading tensor blk.2.post_ffw_norm.weight +create_tensor: loading tensor blk.2.inp_gate.weight +create_tensor: loading tensor blk.2.proj.weight +create_tensor: loading tensor blk.2.post_norm.weight +create_tensor: loading tensor blk.3.attn_norm.weight +create_tensor: loading tensor blk.3.attn_q.weight +create_tensor: loading tensor blk.3.attn_k.weight +create_tensor: loading tensor blk.3.attn_v.weight +create_tensor: loading tensor blk.3.attn_output.weight +create_tensor: loading tensor blk.3.attn_q_norm.weight +create_tensor: loading tensor blk.3.attn_k_norm.weight +create_tensor: loading tensor blk.3.post_attention_norm.weight +create_tensor: loading tensor blk.3.layer_output_scale.weight +create_tensor: loading tensor blk.3.ffn_norm.weight +create_tensor: loading tensor blk.3.ffn_gate.weight +create_tensor: loading tensor blk.3.ffn_up.weight +create_tensor: loading tensor blk.3.ffn_down.weight +create_tensor: loading tensor blk.3.post_ffw_norm.weight +create_tensor: loading tensor blk.3.inp_gate.weight +create_tensor: loading tensor blk.3.proj.weight +create_tensor: loading tensor blk.3.post_norm.weight +create_tensor: loading tensor blk.4.attn_norm.weight +create_tensor: loading tensor blk.4.attn_q.weight +create_tensor: loading tensor blk.4.attn_k.weight +create_tensor: loading tensor blk.4.attn_v.weight +create_tensor: loading tensor blk.4.attn_output.weight +create_tensor: loading tensor blk.4.attn_q_norm.weight +create_tensor: loading tensor blk.4.attn_k_norm.weight +create_tensor: loading tensor blk.4.post_attention_norm.weight +create_tensor: loading tensor blk.4.layer_output_scale.weight +create_tensor: loading tensor rope_freqs.weight +create_tensor: loading tensor blk.4.ffn_norm.weight +create_tensor: loading tensor blk.4.ffn_gate.weight +create_tensor: loading tensor blk.4.ffn_up.weight +create_tensor: loading tensor blk.4.ffn_down.weight +create_tensor: loading tensor blk.4.post_ffw_norm.weight +create_tensor: loading tensor blk.4.inp_gate.weight +create_tensor: loading tensor blk.4.proj.weight +create_tensor: loading tensor blk.4.post_norm.weight +create_tensor: loading tensor blk.5.attn_norm.weight +create_tensor: loading tensor blk.5.attn_q.weight +create_tensor: loading tensor blk.5.attn_k.weight +create_tensor: loading tensor blk.5.attn_v.weight +create_tensor: loading tensor blk.5.attn_output.weight +create_tensor: loading tensor blk.5.attn_q_norm.weight +create_tensor: loading tensor blk.5.attn_k_norm.weight +create_tensor: loading tensor blk.5.post_attention_norm.weight +create_tensor: loading tensor blk.5.layer_output_scale.weight +create_tensor: loading tensor blk.5.ffn_norm.weight +create_tensor: loading tensor blk.5.ffn_gate.weight +create_tensor: loading tensor blk.5.ffn_up.weight +create_tensor: loading tensor blk.5.ffn_down.weight +create_tensor: loading tensor blk.5.post_ffw_norm.weight +create_tensor: loading tensor blk.5.inp_gate.weight +create_tensor: loading tensor blk.5.proj.weight +create_tensor: loading tensor blk.5.post_norm.weight +create_tensor: loading tensor blk.6.attn_norm.weight +create_tensor: loading tensor blk.6.attn_q.weight +create_tensor: loading tensor blk.6.attn_k.weight +create_tensor: loading tensor blk.6.attn_v.weight +create_tensor: loading tensor blk.6.attn_output.weight +create_tensor: loading tensor blk.6.attn_q_norm.weight +create_tensor: loading tensor blk.6.attn_k_norm.weight +create_tensor: loading tensor blk.6.post_attention_norm.weight +create_tensor: loading tensor blk.6.layer_output_scale.weight +create_tensor: loading tensor blk.6.ffn_norm.weight +create_tensor: loading tensor blk.6.ffn_gate.weight +create_tensor: loading tensor blk.6.ffn_up.weight +create_tensor: loading tensor blk.6.ffn_down.weight +create_tensor: loading tensor blk.6.post_ffw_norm.weight +create_tensor: loading tensor blk.6.inp_gate.weight +create_tensor: loading tensor blk.6.proj.weight +create_tensor: loading tensor blk.6.post_norm.weight +create_tensor: loading tensor blk.7.attn_norm.weight +create_tensor: loading tensor blk.7.attn_q.weight +create_tensor: loading tensor blk.7.attn_k.weight +create_tensor: loading tensor blk.7.attn_v.weight +create_tensor: loading tensor blk.7.attn_output.weight +create_tensor: loading tensor blk.7.attn_q_norm.weight +create_tensor: loading tensor blk.7.attn_k_norm.weight +create_tensor: loading tensor blk.7.post_attention_norm.weight +create_tensor: loading tensor blk.7.layer_output_scale.weight +create_tensor: loading tensor blk.7.ffn_norm.weight +create_tensor: loading tensor blk.7.ffn_gate.weight +create_tensor: loading tensor blk.7.ffn_up.weight +create_tensor: loading tensor blk.7.ffn_down.weight +create_tensor: loading tensor blk.7.post_ffw_norm.weight +create_tensor: loading tensor blk.7.inp_gate.weight +create_tensor: loading tensor blk.7.proj.weight +create_tensor: loading tensor blk.7.post_norm.weight +create_tensor: loading tensor blk.8.attn_norm.weight +create_tensor: loading tensor blk.8.attn_q.weight +create_tensor: loading tensor blk.8.attn_k.weight +create_tensor: loading tensor blk.8.attn_v.weight +create_tensor: loading tensor blk.8.attn_output.weight +create_tensor: loading tensor blk.8.attn_q_norm.weight +create_tensor: loading tensor blk.8.attn_k_norm.weight +create_tensor: loading tensor blk.8.post_attention_norm.weight +create_tensor: loading tensor blk.8.layer_output_scale.weight +create_tensor: loading tensor blk.8.ffn_norm.weight +create_tensor: loading tensor blk.8.ffn_gate.weight +create_tensor: loading tensor blk.8.ffn_up.weight +create_tensor: loading tensor blk.8.ffn_down.weight +create_tensor: loading tensor blk.8.post_ffw_norm.weight +create_tensor: loading tensor blk.8.inp_gate.weight +create_tensor: loading tensor blk.8.proj.weight +create_tensor: loading tensor blk.8.post_norm.weight +create_tensor: loading tensor blk.9.attn_norm.weight +create_tensor: loading tensor blk.9.attn_q.weight +create_tensor: loading tensor blk.9.attn_k.weight +create_tensor: loading tensor blk.9.attn_v.weight +create_tensor: loading tensor blk.9.attn_output.weight +create_tensor: loading tensor blk.9.attn_q_norm.weight +create_tensor: loading tensor blk.9.attn_k_norm.weight +create_tensor: loading tensor blk.9.post_attention_norm.weight +create_tensor: loading tensor blk.9.layer_output_scale.weight +create_tensor: loading tensor blk.9.ffn_norm.weight +create_tensor: loading tensor blk.9.ffn_gate.weight +create_tensor: loading tensor blk.9.ffn_up.weight +create_tensor: loading tensor blk.9.ffn_down.weight +create_tensor: loading tensor blk.9.post_ffw_norm.weight +create_tensor: loading tensor blk.9.inp_gate.weight +create_tensor: loading tensor blk.9.proj.weight +create_tensor: loading tensor blk.9.post_norm.weight +create_tensor: loading tensor blk.10.attn_norm.weight +create_tensor: loading tensor blk.10.attn_q.weight +create_tensor: loading tensor blk.10.attn_k.weight +create_tensor: loading tensor blk.10.attn_v.weight +create_tensor: loading tensor blk.10.attn_output.weight +create_tensor: loading tensor blk.10.attn_q_norm.weight +create_tensor: loading tensor blk.10.attn_k_norm.weight +create_tensor: loading tensor blk.10.post_attention_norm.weight +create_tensor: loading tensor blk.10.layer_output_scale.weight +create_tensor: loading tensor blk.10.ffn_norm.weight +create_tensor: loading tensor blk.10.ffn_gate.weight +create_tensor: loading tensor blk.10.ffn_up.weight +create_tensor: loading tensor blk.10.ffn_down.weight +create_tensor: loading tensor blk.10.post_ffw_norm.weight +create_tensor: loading tensor blk.10.inp_gate.weight +create_tensor: loading tensor blk.10.proj.weight +create_tensor: loading tensor blk.10.post_norm.weight +create_tensor: loading tensor blk.11.attn_norm.weight +create_tensor: loading tensor blk.11.attn_q.weight +create_tensor: loading tensor blk.11.attn_k.weight +create_tensor: loading tensor blk.11.attn_v.weight +create_tensor: loading tensor blk.11.attn_output.weight +create_tensor: loading tensor blk.11.attn_q_norm.weight +create_tensor: loading tensor blk.11.attn_k_norm.weight +create_tensor: loading tensor blk.11.post_attention_norm.weight +create_tensor: loading tensor blk.11.layer_output_scale.weight +create_tensor: loading tensor blk.11.ffn_norm.weight +create_tensor: loading tensor blk.11.ffn_gate.weight +create_tensor: loading tensor blk.11.ffn_up.weight +create_tensor: loading tensor blk.11.ffn_down.weight +create_tensor: loading tensor blk.11.post_ffw_norm.weight +create_tensor: loading tensor blk.11.inp_gate.weight +create_tensor: loading tensor blk.11.proj.weight +create_tensor: loading tensor blk.11.post_norm.weight +create_tensor: loading tensor blk.12.attn_norm.weight +create_tensor: loading tensor blk.12.attn_q.weight +create_tensor: loading tensor blk.12.attn_k.weight +create_tensor: loading tensor blk.12.attn_v.weight +create_tensor: loading tensor blk.12.attn_output.weight +create_tensor: loading tensor blk.12.attn_q_norm.weight +create_tensor: loading tensor blk.12.attn_k_norm.weight +create_tensor: loading tensor blk.12.post_attention_norm.weight +create_tensor: loading tensor blk.12.layer_output_scale.weight +create_tensor: loading tensor blk.12.ffn_norm.weight +create_tensor: loading tensor blk.12.ffn_gate.weight +create_tensor: loading tensor blk.12.ffn_up.weight +create_tensor: loading tensor blk.12.ffn_down.weight +create_tensor: loading tensor blk.12.post_ffw_norm.weight +create_tensor: loading tensor blk.12.inp_gate.weight +create_tensor: loading tensor blk.12.proj.weight +create_tensor: loading tensor blk.12.post_norm.weight +create_tensor: loading tensor blk.13.attn_norm.weight +create_tensor: loading tensor blk.13.attn_q.weight +create_tensor: loading tensor blk.13.attn_k.weight +create_tensor: loading tensor blk.13.attn_v.weight +create_tensor: loading tensor blk.13.attn_output.weight +create_tensor: loading tensor blk.13.attn_q_norm.weight +create_tensor: loading tensor blk.13.attn_k_norm.weight +create_tensor: loading tensor blk.13.post_attention_norm.weight +create_tensor: loading tensor blk.13.layer_output_scale.weight +create_tensor: loading tensor blk.13.ffn_norm.weight +create_tensor: loading tensor blk.13.ffn_gate.weight +create_tensor: loading tensor blk.13.ffn_up.weight +create_tensor: loading tensor blk.13.ffn_down.weight +create_tensor: loading tensor blk.13.post_ffw_norm.weight +create_tensor: loading tensor blk.13.inp_gate.weight +create_tensor: loading tensor blk.13.proj.weight +create_tensor: loading tensor blk.13.post_norm.weight +create_tensor: loading tensor blk.14.attn_norm.weight +create_tensor: loading tensor blk.14.attn_q.weight +create_tensor: loading tensor blk.14.attn_k.weight +create_tensor: loading tensor blk.14.attn_v.weight +create_tensor: loading tensor blk.14.attn_output.weight +create_tensor: loading tensor blk.14.attn_q_norm.weight +create_tensor: loading tensor blk.14.attn_k_norm.weight +create_tensor: loading tensor blk.14.post_attention_norm.weight +create_tensor: loading tensor blk.14.layer_output_scale.weight +create_tensor: loading tensor blk.14.ffn_norm.weight +create_tensor: loading tensor blk.14.ffn_gate.weight +create_tensor: loading tensor blk.14.ffn_up.weight +create_tensor: loading tensor blk.14.ffn_down.weight +create_tensor: loading tensor blk.14.post_ffw_norm.weight +create_tensor: loading tensor blk.14.inp_gate.weight +create_tensor: loading tensor blk.14.proj.weight +create_tensor: loading tensor blk.14.post_norm.weight +create_tensor: loading tensor blk.15.attn_norm.weight +create_tensor: loading tensor blk.15.attn_q.weight +create_tensor: loading tensor blk.15.attn_k.weight +create_tensor: loading tensor blk.15.attn_v.weight +create_tensor: loading tensor blk.15.attn_output.weight +create_tensor: loading tensor blk.15.attn_q_norm.weight +create_tensor: loading tensor blk.15.attn_k_norm.weight +create_tensor: loading tensor blk.15.post_attention_norm.weight +create_tensor: loading tensor blk.15.layer_output_scale.weight +create_tensor: loading tensor blk.15.ffn_norm.weight +create_tensor: loading tensor blk.15.ffn_gate.weight +create_tensor: loading tensor blk.15.ffn_up.weight +create_tensor: loading tensor blk.15.ffn_down.weight +create_tensor: loading tensor blk.15.post_ffw_norm.weight +create_tensor: loading tensor blk.15.inp_gate.weight +create_tensor: loading tensor blk.15.proj.weight +create_tensor: loading tensor blk.15.post_norm.weight +create_tensor: loading tensor blk.16.attn_norm.weight +create_tensor: loading tensor blk.16.attn_q.weight +create_tensor: loading tensor blk.16.attn_k.weight +create_tensor: loading tensor blk.16.attn_v.weight +create_tensor: loading tensor blk.16.attn_output.weight +create_tensor: loading tensor blk.16.attn_q_norm.weight +create_tensor: loading tensor blk.16.attn_k_norm.weight +create_tensor: loading tensor blk.16.post_attention_norm.weight +create_tensor: loading tensor blk.16.layer_output_scale.weight +create_tensor: loading tensor blk.16.ffn_norm.weight +create_tensor: loading tensor blk.16.ffn_gate.weight +create_tensor: loading tensor blk.16.ffn_up.weight +create_tensor: loading tensor blk.16.ffn_down.weight +create_tensor: loading tensor blk.16.post_ffw_norm.weight +create_tensor: loading tensor blk.16.inp_gate.weight +create_tensor: loading tensor blk.16.proj.weight +create_tensor: loading tensor blk.16.post_norm.weight +create_tensor: loading tensor blk.17.attn_norm.weight +create_tensor: loading tensor blk.17.attn_q.weight +create_tensor: loading tensor blk.17.attn_k.weight +create_tensor: loading tensor blk.17.attn_v.weight +create_tensor: loading tensor blk.17.attn_output.weight +create_tensor: loading tensor blk.17.attn_q_norm.weight +create_tensor: loading tensor blk.17.attn_k_norm.weight +create_tensor: loading tensor blk.17.post_attention_norm.weight +create_tensor: loading tensor blk.17.layer_output_scale.weight +create_tensor: loading tensor blk.17.ffn_norm.weight +create_tensor: loading tensor blk.17.ffn_gate.weight +create_tensor: loading tensor blk.17.ffn_up.weight +create_tensor: loading tensor blk.17.ffn_down.weight +create_tensor: loading tensor blk.17.post_ffw_norm.weight +create_tensor: loading tensor blk.17.inp_gate.weight +create_tensor: loading tensor blk.17.proj.weight +create_tensor: loading tensor blk.17.post_norm.weight +create_tensor: loading tensor blk.18.attn_norm.weight +create_tensor: loading tensor blk.18.attn_q.weight +create_tensor: loading tensor blk.18.attn_k.weight +create_tensor: loading tensor blk.18.attn_v.weight +create_tensor: loading tensor blk.18.attn_output.weight +create_tensor: loading tensor blk.18.attn_q_norm.weight +create_tensor: loading tensor blk.18.attn_k_norm.weight +create_tensor: loading tensor blk.18.post_attention_norm.weight +create_tensor: loading tensor blk.18.layer_output_scale.weight +create_tensor: loading tensor blk.18.ffn_norm.weight +create_tensor: loading tensor blk.18.ffn_gate.weight +create_tensor: loading tensor blk.18.ffn_up.weight +create_tensor: loading tensor blk.18.ffn_down.weight +create_tensor: loading tensor blk.18.post_ffw_norm.weight +create_tensor: loading tensor blk.18.inp_gate.weight +create_tensor: loading tensor blk.18.proj.weight +create_tensor: loading tensor blk.18.post_norm.weight +create_tensor: loading tensor blk.19.attn_norm.weight +create_tensor: loading tensor blk.19.attn_q.weight +create_tensor: loading tensor blk.19.attn_k.weight +create_tensor: loading tensor blk.19.attn_v.weight +create_tensor: loading tensor blk.19.attn_output.weight +create_tensor: loading tensor blk.19.attn_q_norm.weight +create_tensor: loading tensor blk.19.attn_k_norm.weight +create_tensor: loading tensor blk.19.post_attention_norm.weight +create_tensor: loading tensor blk.19.layer_output_scale.weight +create_tensor: loading tensor blk.19.ffn_norm.weight +create_tensor: loading tensor blk.19.ffn_gate.weight +create_tensor: loading tensor blk.19.ffn_up.weight +create_tensor: loading tensor blk.19.ffn_down.weight +create_tensor: loading tensor blk.19.post_ffw_norm.weight +create_tensor: loading tensor blk.19.inp_gate.weight +create_tensor: loading tensor blk.19.proj.weight +create_tensor: loading tensor blk.19.post_norm.weight +create_tensor: loading tensor blk.20.attn_norm.weight +create_tensor: loading tensor blk.20.attn_q.weight +create_tensor: loading tensor blk.20.attn_k.weight +create_tensor: loading tensor blk.20.attn_v.weight +create_tensor: loading tensor blk.20.attn_output.weight +create_tensor: loading tensor blk.20.attn_q_norm.weight +create_tensor: loading tensor blk.20.attn_k_norm.weight +create_tensor: loading tensor blk.20.post_attention_norm.weight +create_tensor: loading tensor blk.20.layer_output_scale.weight +create_tensor: loading tensor blk.20.ffn_norm.weight +create_tensor: loading tensor blk.20.ffn_gate.weight +create_tensor: loading tensor blk.20.ffn_up.weight +create_tensor: loading tensor blk.20.ffn_down.weight +create_tensor: loading tensor blk.20.post_ffw_norm.weight +create_tensor: loading tensor blk.20.inp_gate.weight +create_tensor: loading tensor blk.20.proj.weight +create_tensor: loading tensor blk.20.post_norm.weight +create_tensor: loading tensor blk.21.attn_norm.weight +create_tensor: loading tensor blk.21.attn_q.weight +create_tensor: loading tensor blk.21.attn_k.weight +create_tensor: loading tensor blk.21.attn_v.weight +create_tensor: loading tensor blk.21.attn_output.weight +create_tensor: loading tensor blk.21.attn_q_norm.weight +create_tensor: loading tensor blk.21.attn_k_norm.weight +create_tensor: loading tensor blk.21.post_attention_norm.weight +create_tensor: loading tensor blk.21.layer_output_scale.weight +create_tensor: loading tensor blk.21.ffn_norm.weight +create_tensor: loading tensor blk.21.ffn_gate.weight +create_tensor: loading tensor blk.21.ffn_up.weight +create_tensor: loading tensor blk.21.ffn_down.weight +create_tensor: loading tensor blk.21.post_ffw_norm.weight +create_tensor: loading tensor blk.21.inp_gate.weight +create_tensor: loading tensor blk.21.proj.weight +create_tensor: loading tensor blk.21.post_norm.weight +create_tensor: loading tensor blk.22.attn_norm.weight +create_tensor: loading tensor blk.22.attn_q.weight +create_tensor: loading tensor blk.22.attn_k.weight +create_tensor: loading tensor blk.22.attn_v.weight +create_tensor: loading tensor blk.22.attn_output.weight +create_tensor: loading tensor blk.22.attn_q_norm.weight +create_tensor: loading tensor blk.22.attn_k_norm.weight +create_tensor: loading tensor blk.22.post_attention_norm.weight +create_tensor: loading tensor blk.22.layer_output_scale.weight +create_tensor: loading tensor blk.22.ffn_norm.weight +create_tensor: loading tensor blk.22.ffn_gate.weight +create_tensor: loading tensor blk.22.ffn_up.weight +create_tensor: loading tensor blk.22.ffn_down.weight +create_tensor: loading tensor blk.22.post_ffw_norm.weight +create_tensor: loading tensor blk.22.inp_gate.weight +create_tensor: loading tensor blk.22.proj.weight +create_tensor: loading tensor blk.22.post_norm.weight +create_tensor: loading tensor blk.23.attn_norm.weight +create_tensor: loading tensor blk.23.attn_q.weight +create_tensor: loading tensor blk.23.attn_k.weight +create_tensor: loading tensor blk.23.attn_v.weight +create_tensor: loading tensor blk.23.attn_output.weight +create_tensor: loading tensor blk.23.attn_q_norm.weight +create_tensor: loading tensor blk.23.attn_k_norm.weight +create_tensor: loading tensor blk.23.post_attention_norm.weight +create_tensor: loading tensor blk.23.layer_output_scale.weight +create_tensor: loading tensor blk.23.ffn_norm.weight +create_tensor: loading tensor blk.23.ffn_gate.weight +create_tensor: loading tensor blk.23.ffn_up.weight +create_tensor: loading tensor blk.23.ffn_down.weight +create_tensor: loading tensor blk.23.post_ffw_norm.weight +create_tensor: loading tensor blk.23.inp_gate.weight +create_tensor: loading tensor blk.23.proj.weight +create_tensor: loading tensor blk.23.post_norm.weight +create_tensor: loading tensor blk.24.attn_norm.weight +create_tensor: loading tensor blk.24.attn_q.weight +create_tensor: loading tensor blk.24.attn_k.weight +create_tensor: loading tensor blk.24.attn_v.weight +create_tensor: loading tensor blk.24.attn_output.weight +create_tensor: loading tensor blk.24.attn_q_norm.weight +create_tensor: loading tensor blk.24.attn_k_norm.weight +create_tensor: loading tensor blk.24.post_attention_norm.weight +create_tensor: loading tensor blk.24.layer_output_scale.weight +create_tensor: loading tensor blk.24.ffn_norm.weight +create_tensor: loading tensor blk.24.ffn_gate.weight +create_tensor: loading tensor blk.24.ffn_up.weight +create_tensor: loading tensor blk.24.ffn_down.weight +create_tensor: loading tensor blk.24.post_ffw_norm.weight +create_tensor: loading tensor blk.24.inp_gate.weight +create_tensor: loading tensor blk.24.proj.weight +create_tensor: loading tensor blk.24.post_norm.weight +create_tensor: loading tensor blk.25.attn_norm.weight +create_tensor: loading tensor blk.25.attn_q.weight +create_tensor: loading tensor blk.25.attn_k.weight +create_tensor: loading tensor blk.25.attn_v.weight +create_tensor: loading tensor blk.25.attn_output.weight +create_tensor: loading tensor blk.25.attn_q_norm.weight +create_tensor: loading tensor blk.25.attn_k_norm.weight +create_tensor: loading tensor blk.25.post_attention_norm.weight +create_tensor: loading tensor blk.25.layer_output_scale.weight +create_tensor: loading tensor blk.25.ffn_norm.weight +create_tensor: loading tensor blk.25.ffn_gate.weight +create_tensor: loading tensor blk.25.ffn_up.weight +create_tensor: loading tensor blk.25.ffn_down.weight +create_tensor: loading tensor blk.25.post_ffw_norm.weight +create_tensor: loading tensor blk.25.inp_gate.weight +create_tensor: loading tensor blk.25.proj.weight +create_tensor: loading tensor blk.25.post_norm.weight +create_tensor: loading tensor blk.26.attn_norm.weight +create_tensor: loading tensor blk.26.attn_q.weight +create_tensor: loading tensor blk.26.attn_k.weight +create_tensor: loading tensor blk.26.attn_v.weight +create_tensor: loading tensor blk.26.attn_output.weight +create_tensor: loading tensor blk.26.attn_q_norm.weight +create_tensor: loading tensor blk.26.attn_k_norm.weight +create_tensor: loading tensor blk.26.post_attention_norm.weight +create_tensor: loading tensor blk.26.layer_output_scale.weight +create_tensor: loading tensor blk.26.ffn_norm.weight +create_tensor: loading tensor blk.26.ffn_gate.weight +create_tensor: loading tensor blk.26.ffn_up.weight +create_tensor: loading tensor blk.26.ffn_down.weight +create_tensor: loading tensor blk.26.post_ffw_norm.weight +create_tensor: loading tensor blk.26.inp_gate.weight +create_tensor: loading tensor blk.26.proj.weight +create_tensor: loading tensor blk.26.post_norm.weight +create_tensor: loading tensor blk.27.attn_norm.weight +create_tensor: loading tensor blk.27.attn_q.weight +create_tensor: loading tensor blk.27.attn_k.weight +create_tensor: loading tensor blk.27.attn_v.weight +create_tensor: loading tensor blk.27.attn_output.weight +create_tensor: loading tensor blk.27.attn_q_norm.weight +create_tensor: loading tensor blk.27.attn_k_norm.weight +create_tensor: loading tensor blk.27.post_attention_norm.weight +create_tensor: loading tensor blk.27.layer_output_scale.weight +create_tensor: loading tensor blk.27.ffn_norm.weight +create_tensor: loading tensor blk.27.ffn_gate.weight +create_tensor: loading tensor blk.27.ffn_up.weight +create_tensor: loading tensor blk.27.ffn_down.weight +create_tensor: loading tensor blk.27.post_ffw_norm.weight +create_tensor: loading tensor blk.27.inp_gate.weight +create_tensor: loading tensor blk.27.proj.weight +create_tensor: loading tensor blk.27.post_norm.weight +create_tensor: loading tensor blk.28.attn_norm.weight +create_tensor: loading tensor blk.28.attn_q.weight +create_tensor: loading tensor blk.28.attn_k.weight +create_tensor: loading tensor blk.28.attn_v.weight +create_tensor: loading tensor blk.28.attn_output.weight +create_tensor: loading tensor blk.28.attn_q_norm.weight +create_tensor: loading tensor blk.28.attn_k_norm.weight +create_tensor: loading tensor blk.28.post_attention_norm.weight +create_tensor: loading tensor blk.28.layer_output_scale.weight +create_tensor: loading tensor blk.28.ffn_norm.weight +create_tensor: loading tensor blk.28.ffn_gate.weight +create_tensor: loading tensor blk.28.ffn_up.weight +create_tensor: loading tensor blk.28.ffn_down.weight +create_tensor: loading tensor blk.28.post_ffw_norm.weight +create_tensor: loading tensor blk.28.inp_gate.weight +create_tensor: loading tensor blk.28.proj.weight +create_tensor: loading tensor blk.28.post_norm.weight +create_tensor: loading tensor blk.29.attn_norm.weight +create_tensor: loading tensor blk.29.attn_q.weight +create_tensor: loading tensor blk.29.attn_k.weight +create_tensor: loading tensor blk.29.attn_v.weight +create_tensor: loading tensor blk.29.attn_output.weight +create_tensor: loading tensor blk.29.attn_q_norm.weight +create_tensor: loading tensor blk.29.attn_k_norm.weight +create_tensor: loading tensor blk.29.post_attention_norm.weight +create_tensor: loading tensor blk.29.layer_output_scale.weight +create_tensor: loading tensor blk.29.ffn_norm.weight +create_tensor: loading tensor blk.29.ffn_gate.weight +create_tensor: loading tensor blk.29.ffn_up.weight +create_tensor: loading tensor blk.29.ffn_down.weight +create_tensor: loading tensor blk.29.post_ffw_norm.weight +create_tensor: loading tensor blk.29.inp_gate.weight +create_tensor: loading tensor blk.29.proj.weight +create_tensor: loading tensor blk.29.post_norm.weight +create_tensor: loading tensor blk.30.attn_norm.weight +create_tensor: loading tensor blk.30.attn_q.weight +create_tensor: loading tensor blk.30.attn_k.weight +create_tensor: loading tensor blk.30.attn_v.weight +create_tensor: loading tensor blk.30.attn_output.weight +create_tensor: loading tensor blk.30.attn_q_norm.weight +create_tensor: loading tensor blk.30.attn_k_norm.weight +create_tensor: loading tensor blk.30.post_attention_norm.weight +create_tensor: loading tensor blk.30.layer_output_scale.weight +create_tensor: loading tensor blk.30.ffn_norm.weight +create_tensor: loading tensor blk.30.ffn_gate.weight +create_tensor: loading tensor blk.30.ffn_up.weight +create_tensor: loading tensor blk.30.ffn_down.weight +create_tensor: loading tensor blk.30.post_ffw_norm.weight +create_tensor: loading tensor blk.30.inp_gate.weight +create_tensor: loading tensor blk.30.proj.weight +create_tensor: loading tensor blk.30.post_norm.weight +create_tensor: loading tensor blk.31.attn_norm.weight +create_tensor: loading tensor blk.31.attn_q.weight +create_tensor: loading tensor blk.31.attn_k.weight +create_tensor: loading tensor blk.31.attn_v.weight +create_tensor: loading tensor blk.31.attn_output.weight +create_tensor: loading tensor blk.31.attn_q_norm.weight +create_tensor: loading tensor blk.31.attn_k_norm.weight +create_tensor: loading tensor blk.31.post_attention_norm.weight +create_tensor: loading tensor blk.31.layer_output_scale.weight +create_tensor: loading tensor blk.31.ffn_norm.weight +create_tensor: loading tensor blk.31.ffn_gate.weight +create_tensor: loading tensor blk.31.ffn_up.weight +create_tensor: loading tensor blk.31.ffn_down.weight +create_tensor: loading tensor blk.31.post_ffw_norm.weight +create_tensor: loading tensor blk.31.inp_gate.weight +create_tensor: loading tensor blk.31.proj.weight +create_tensor: loading tensor blk.31.post_norm.weight +create_tensor: loading tensor blk.32.attn_norm.weight +create_tensor: loading tensor blk.32.attn_q.weight +create_tensor: loading tensor blk.32.attn_k.weight +create_tensor: loading tensor blk.32.attn_v.weight +create_tensor: loading tensor blk.32.attn_output.weight +create_tensor: loading tensor blk.32.attn_q_norm.weight +create_tensor: loading tensor blk.32.attn_k_norm.weight +create_tensor: loading tensor blk.32.post_attention_norm.weight +create_tensor: loading tensor blk.32.layer_output_scale.weight +create_tensor: loading tensor blk.32.ffn_norm.weight +create_tensor: loading tensor blk.32.ffn_gate.weight +create_tensor: loading tensor blk.32.ffn_up.weight +create_tensor: loading tensor blk.32.ffn_down.weight +create_tensor: loading tensor blk.32.post_ffw_norm.weight +create_tensor: loading tensor blk.32.inp_gate.weight +create_tensor: loading tensor blk.32.proj.weight +create_tensor: loading tensor blk.32.post_norm.weight +create_tensor: loading tensor blk.33.attn_norm.weight +create_tensor: loading tensor blk.33.attn_q.weight +create_tensor: loading tensor blk.33.attn_k.weight +create_tensor: loading tensor blk.33.attn_v.weight +create_tensor: loading tensor blk.33.attn_output.weight +create_tensor: loading tensor blk.33.attn_q_norm.weight +create_tensor: loading tensor blk.33.attn_k_norm.weight +create_tensor: loading tensor blk.33.post_attention_norm.weight +create_tensor: loading tensor blk.33.layer_output_scale.weight +create_tensor: loading tensor blk.33.ffn_norm.weight +create_tensor: loading tensor blk.33.ffn_gate.weight +create_tensor: loading tensor blk.33.ffn_up.weight +create_tensor: loading tensor blk.33.ffn_down.weight +create_tensor: loading tensor blk.33.post_ffw_norm.weight +create_tensor: loading tensor blk.33.inp_gate.weight +create_tensor: loading tensor blk.33.proj.weight +create_tensor: loading tensor blk.33.post_norm.weight +create_tensor: loading tensor blk.34.attn_norm.weight +create_tensor: loading tensor blk.34.attn_q.weight +create_tensor: loading tensor blk.34.attn_k.weight +create_tensor: loading tensor blk.34.attn_v.weight +create_tensor: loading tensor blk.34.attn_output.weight +create_tensor: loading tensor blk.34.attn_q_norm.weight +create_tensor: loading tensor blk.34.attn_k_norm.weight +create_tensor: loading tensor blk.34.post_attention_norm.weight +create_tensor: loading tensor blk.34.layer_output_scale.weight +create_tensor: loading tensor blk.34.ffn_norm.weight +create_tensor: loading tensor blk.34.ffn_gate.weight +create_tensor: loading tensor blk.34.ffn_up.weight +create_tensor: loading tensor blk.34.ffn_down.weight +create_tensor: loading tensor blk.34.post_ffw_norm.weight +create_tensor: loading tensor blk.34.inp_gate.weight +create_tensor: loading tensor blk.34.proj.weight +create_tensor: loading tensor blk.34.post_norm.weight +done_getting_tensors: tensor 'token_embd.weight' (q8_0) (and 1 others) cannot be used with preferred buffer type CPU_REPACK, using CPU instead +ggml_metal_log_allocated_size: allocated buffer, size = 4722.30 MiB, ( 4722.75 / 110100.48) +load_tensors: offloading output layer to GPU +load_tensors: offloading 34 repeating layers to GPU +load_tensors: offloaded 36/36 layers to GPU +load_tensors: CPU_Mapped model buffer size = 2788.00 MiB +load_tensors: MTL0_Mapped model buffer size = 4722.29 MiB +......................................... +llama_context: constructing llama_context +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: filtered +llama_kv_cache: layer 4: dev = MTL0 +llama_kv_cache: layer 5: filtered +llama_kv_cache: layer 6: filtered +llama_kv_cache: layer 7: filtered +llama_kv_cache: layer 8: filtered +llama_kv_cache: layer 9: dev = MTL0 +llama_kv_cache: layer 10: filtered +llama_kv_cache: layer 11: filtered +llama_kv_cache: layer 12: filtered +llama_kv_cache: layer 13: filtered +llama_kv_cache: layer 14: dev = MTL0 +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: filtered +llama_kv_cache: - layer 16: filtered +llama_kv_cache: - layer 17: filtered +llama_kv_cache: - layer 18: filtered +llama_kv_cache: - layer 19: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 20: filtered +llama_kv_cache: - layer 21: filtered +llama_kv_cache: - layer 22: filtered +llama_kv_cache: - layer 23: filtered +llama_kv_cache: - layer 24: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 25: filtered +llama_kv_cache: - layer 26: filtered +llama_kv_cache: - layer 27: filtered +llama_kv_cache: - layer 28: filtered +llama_kv_cache: - layer 29: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 30: filtered +llama_kv_cache: - layer 31: filtered +llama_kv_cache: - layer 32: filtered +llama_kv_cache: - layer 33: filtered +llama_kv_cache: - layer 34: reuse layer 14, is_swa = 0 +llama_kv_cache: MTL0 KV buffer size = 24.00 MiB +llama_kv_cache: size = 24.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 12.00 MiB, V (f16): 12.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 512 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 512 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: dev = MTL0 +llama_kv_cache: layer 1: dev = MTL0 +llama_kv_cache: layer 2: dev = MTL0 +llama_kv_cache: layer 3: dev = MTL0 +llama_kv_cache: layer 4: filtered +llama_kv_cache: layer 5: dev = MTL0 +llama_kv_cache: layer 6: dev = MTL0 +llama_kv_cache: layer 7: dev = MTL0 +llama_kv_cache: layer 8: dev = MTL0 +llama_kv_cache: layer 9: filtered +llama_kv_cache: layer 10: dev = MTL0 +llama_kv_cache: layer 11: dev = MTL0 +llama_kv_cache: layer 12: dev = MTL0 +llama_kv_cache: layer 13: dev = MTL0 +llama_kv_cache: layer 14: filtered +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 16: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 17: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 18: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 19: filtered +llama_kv_cache: - layer 20: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 21: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 22: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 23: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 24: filtered +llama_kv_cache: - layer 25: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 26: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 27: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 28: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 29: filtered +llama_kv_cache: - layer 30: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 31: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 32: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 33: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 34: filtered +llama_kv_cache: MTL0 KV buffer size = 48.00 MiB +llama_kv_cache: size = 48.00 MiB ( 4096 cells, 12 layers, 1/1 seqs), K (f16): 24.00 MiB, V (f16): 24.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 256 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 256 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 4816 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 555.02 MiB +sched_reserve: CPU compute buffer size = 39.52 MiB +sched_reserve: graph nodes = 1500 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 19.53 ms, sched copies = 1 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_unary_f32_f32_4', name = 'kernel_unary_f32_f32_4_op=10_cnt=0' +ggml_metal_library_compile_pipeline: loaded kernel_unary_f32_f32_4_op=10_cnt=0 0x107107db0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_cpy_f32_f16', name = 'kernel_cpy_f32_f16' +ggml_metal_library_compile_pipeline: loaded kernel_cpy_f32_f16 0x1071085b0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_rms_norm_mul_f32_4', name = 'kernel_rms_norm_mul_f32_4' +ggml_metal_library_compile_pipeline: loaded kernel_rms_norm_mul_f32_4 0x107108db0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mm_q8_0_f32', name = 'kernel_mul_mm_q8_0_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mm_q8_0_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1 0x1071098b0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_rms_norm_f32_4', name = 'kernel_rms_norm_f32_4' +ggml_metal_library_compile_pipeline: loaded kernel_rms_norm_f32_4 0x10710a0b0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_rope_neox_f32', name = 'kernel_rope_neox_f32_imrope=0' +ggml_metal_library_compile_pipeline: loaded kernel_rope_neox_f32_imrope=0 0x10710a3b0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_set_rows_f16_i64', name = 'kernel_set_rows_f16_i64' +ggml_metal_library_compile_pipeline: loaded kernel_set_rows_f16_i64 0x10710a6b0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mm_bf16_f32', name = 'kernel_mul_mm_bf16_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mm_bf16_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1 0x10710acb0 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_blk', name = 'kernel_flash_attn_ext_blk_nqptg=8_ncpsg=64' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_blk_nqptg=8_ncpsg=64 0xa397cc000 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_f16_dk256_dv256', name = 'kernel_flash_attn_ext_f16_dk256_dv256_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=1_ns10=256_ns20=256_nsg=4' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_f16_dk256_dv256_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=1_ns10=256_ns20=256_nsg=4 0xa397cc300 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_rms_norm_mul_add_f32_4', name = 'kernel_rms_norm_mul_add_f32_4' +ggml_metal_library_compile_pipeline: loaded kernel_rms_norm_mul_add_f32_4 0xa397cc600 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_cpy_f32_f32', name = 'kernel_cpy_f32_f32' +ggml_metal_library_compile_pipeline: loaded kernel_cpy_f32_f32 0xa397cc900 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_geglu_f32', name = 'kernel_geglu_f32' +ggml_metal_library_compile_pipeline: loaded kernel_geglu_f32 0xa397ccc00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_unary_f32_f32_4', name = 'kernel_unary_f32_f32_4_op=103_cnt=1' +ggml_metal_library_compile_pipeline: loaded kernel_unary_f32_f32_4_op=103_cnt=1 0xa397ccf00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_bin_fuse_f32_f32_f32_4', name = 'kernel_bin_fuse_f32_f32_f32_4_op=2_nf=1_rb=0_cb=0' +ggml_metal_library_compile_pipeline: loaded kernel_bin_fuse_f32_f32_f32_4_op=2_nf=1_rb=0_cb=0 0xa397cd200 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_bin_fuse_f32_f32_f32_4', name = 'kernel_bin_fuse_f32_f32_f32_4_op=0_nf=1_rb=0_cb=0' +ggml_metal_library_compile_pipeline: loaded kernel_bin_fuse_f32_f32_f32_4_op=0_nf=1_rb=0_cb=0 0xa397cd500 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_bin_fuse_f32_f32_f32', name = 'kernel_bin_fuse_f32_f32_f32_op=2_nf=1_rb=1_cb=1' +ggml_metal_library_compile_pipeline: loaded kernel_bin_fuse_f32_f32_f32_op=2_nf=1_rb=1_cb=1 0xa397cd800 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_bin_fuse_f32_f32_f32_4', name = 'kernel_bin_fuse_f32_f32_f32_4_op=2_nf=1_rb=1_cb=0' +ggml_metal_library_compile_pipeline: loaded kernel_bin_fuse_f32_f32_f32_4_op=2_nf=1_rb=1_cb=0 0xa397cde00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_f16_dk512_dv512', name = 'kernel_flash_attn_ext_f16_dk512_dv512_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=1_ns10=512_ns20=512_nsg=8' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_f16_dk512_dv512_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=1_ns10=512_ns20=512_nsg=8 0xa397ce100 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_get_rows_f32', name = 'kernel_get_rows_f32' +ggml_metal_library_compile_pipeline: loaded kernel_get_rows_f32 0xa397cdb00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_q8_0_f32', name = 'kernel_mul_mv_q8_0_f32_nsg=4_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_q8_0_f32_nsg=4_ne12=1_r2=1_r3=1 0xa397ce400 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_bin_fuse_f32_f32_f32_4', name = 'kernel_bin_fuse_f32_f32_f32_4_op=0_nf=1_rb=1_cb=0' +ggml_metal_library_compile_pipeline: loaded kernel_bin_fuse_f32_f32_f32_4_op=0_nf=1_rb=1_cb=0 0xa397ce700 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_unary_f32_f32_4', name = 'kernel_unary_f32_f32_4_op=100_cnt=0' +ggml_metal_library_compile_pipeline: loaded kernel_unary_f32_f32_4_op=100_cnt=0 0xa397cea00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_unary_f32_f32_4', name = 'kernel_unary_f32_f32_4_op=10_cnt=1' +ggml_metal_library_compile_pipeline: loaded kernel_unary_f32_f32_4_op=10_cnt=1 0xa397ced00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_bf16_f32_4', name = 'kernel_mul_mv_bf16_f32_4_nsg=4_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_bf16_f32_4_nsg=4_ne12=1_r2=1_r3=1 0xa397cf000 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_vec_f16_dk256_dv256', name = 'kernel_flash_attn_ext_vec_f16_dk256_dv256_mask=1_sink=0_bias=0_scap=0_kvpad=0_ns10=256_ns20=256_nsg=1_nwg=32' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_vec_f16_dk256_dv256_mask=1_sink=0_bias=0_scap=0_kvpad=0_ns10=256_ns20=256_nsg=1_nwg=32 0xa397cf300 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_vec_reduce', name = 'kernel_flash_attn_ext_vec_reduce_dv=256_nwg=32' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_vec_reduce_dv=256_nwg=32 0xa397cf600 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_vec_f16_dk512_dv512', name = 'kernel_flash_attn_ext_vec_f16_dk512_dv512_mask=1_sink=0_bias=0_scap=0_kvpad=0_ns10=512_ns20=512_nsg=1_nwg=32' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_vec_f16_dk512_dv512_mask=1_sink=0_bias=0_scap=0_kvpad=0_ns10=512_ns20=512_nsg=1_nwg=32 0xa397cf900 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_vec_reduce', name = 'kernel_flash_attn_ext_vec_reduce_dv=512_nwg=32' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_vec_reduce_dv=512_nwg=32 0xa397cfc00 | th_max = 1024 | th_width = 32 +[baseline] n=49 78.1 tok/s (prefill+decode 628ms) +[baseline] text: "One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen, Twenty\n" +llama_context: constructing llama_context +llama_context: n_rs_seq=1 requested but model arch does not support recurrent partial rollback; clamping to 0 +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: filtered +llama_kv_cache: layer 4: dev = MTL0 +llama_kv_cache: layer 5: filtered +llama_kv_cache: layer 6: filtered +llama_kv_cache: layer 7: filtered +llama_kv_cache: layer 8: filtered +llama_kv_cache: layer 9: dev = MTL0 +llama_kv_cache: layer 10: filtered +llama_kv_cache: layer 11: filtered +llama_kv_cache: layer 12: filtered +llama_kv_cache: layer 13: filtered +llama_kv_cache: layer 14: dev = MTL0 +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: filtered +llama_kv_cache: - layer 16: filtered +llama_kv_cache: - layer 17: filtered +llama_kv_cache: - layer 18: filtered +llama_kv_cache: - layer 19: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 20: filtered +llama_kv_cache: - layer 21: filtered +llama_kv_cache: - layer 22: filtered +llama_kv_cache: - layer 23: filtered +llama_kv_cache: - layer 24: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 25: filtered +llama_kv_cache: - layer 26: filtered +llama_kv_cache: - layer 27: filtered +llama_kv_cache: - layer 28: filtered +llama_kv_cache: - layer 29: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 30: filtered +llama_kv_cache: - layer 31: filtered +llama_kv_cache: - layer 32: filtered +llama_kv_cache: - layer 33: filtered +llama_kv_cache: - layer 34: reuse layer 14, is_swa = 0 +llama_kv_cache: MTL0 KV buffer size = 24.00 MiB +llama_kv_cache: size = 24.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 12.00 MiB, V (f16): 12.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 512 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 512 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: dev = MTL0 +llama_kv_cache: layer 1: dev = MTL0 +llama_kv_cache: layer 2: dev = MTL0 +llama_kv_cache: layer 3: dev = MTL0 +llama_kv_cache: layer 4: filtered +llama_kv_cache: layer 5: dev = MTL0 +llama_kv_cache: layer 6: dev = MTL0 +llama_kv_cache: layer 7: dev = MTL0 +llama_kv_cache: layer 8: dev = MTL0 +llama_kv_cache: layer 9: filtered +llama_kv_cache: layer 10: dev = MTL0 +llama_kv_cache: layer 11: dev = MTL0 +llama_kv_cache: layer 12: dev = MTL0 +llama_kv_cache: layer 13: dev = MTL0 +llama_kv_cache: layer 14: filtered +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 16: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 17: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 18: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 19: filtered +llama_kv_cache: - layer 20: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 21: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 22: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 23: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 24: filtered +llama_kv_cache: - layer 25: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 26: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 27: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 28: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 29: filtered +llama_kv_cache: - layer 30: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 31: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 32: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 33: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 34: filtered +llama_kv_cache: MTL0 KV buffer size = 48.00 MiB +llama_kv_cache: size = 48.00 MiB ( 4096 cells, 12 layers, 1/1 seqs), K (f16): 24.00 MiB, V (f16): 24.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 256 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 256 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 4816 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 555.02 MiB +sched_reserve: CPU compute buffer size = 39.52 MiB +sched_reserve: graph nodes = 1500 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 24.59 ms, sched copies = 1 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_ext_q8_0_f32_r1_2', name = 'kernel_mul_mv_ext_q8_0_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_ext_q8_0_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1 0xa3a538000 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_ext_bf16_f32_r1_2', name = 'kernel_mul_mv_ext_bf16_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_ext_bf16_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1 0xa3a538300 | th_max = 1024 | th_width = 32 +llama_model_loader: loaded meta data with 42 key-value pairs and 49 tensors from /tmp/mtp/bundles/2b/mtp/drafter-2b.gguf (version GGUF V3 (latest)) +llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output. +llama_model_loader: - kv 0: general.architecture str = gemma4-assistant +llama_model_loader: - kv 1: general.type str = model +llama_model_loader: - kv 2: general.sampling.top_k i32 = 64 +llama_model_loader: - kv 3: general.sampling.top_p f32 = 0.950000 +llama_model_loader: - kv 4: general.sampling.temp f32 = 1.000000 +llama_model_loader: - kv 5: general.name str = Model +llama_model_loader: - kv 6: general.size_label str = 77M +llama_model_loader: - kv 7: gemma4-assistant.block_count u32 = 4 +llama_model_loader: - kv 8: gemma4-assistant.context_length u32 = 131072 +llama_model_loader: - kv 9: gemma4-assistant.embedding_length u32 = 256 +llama_model_loader: - kv 10: gemma4-assistant.feed_forward_length u32 = 2048 +llama_model_loader: - kv 11: gemma4-assistant.attention.head_count u32 = 4 +llama_model_loader: - kv 12: gemma4-assistant.attention.head_count_kv u32 = 1 +llama_model_loader: - kv 13: gemma4-assistant.rope.freq_base f32 = 1000000.000000 +llama_model_loader: - kv 14: gemma4-assistant.rope.freq_base_swa f32 = 10000.000000 +llama_model_loader: - kv 15: gemma4-assistant.attention.layer_norm_rms_epsilon f32 = 0.000001 +llama_model_loader: - kv 16: gemma4-assistant.attention.key_length u32 = 512 +llama_model_loader: - kv 17: gemma4-assistant.attention.value_length u32 = 512 +llama_model_loader: - kv 18: general.file_type u32 = 1 +llama_model_loader: - kv 19: gemma4-assistant.attention.sliding_window u32 = 512 +llama_model_loader: - kv 20: gemma4-assistant.attention.shared_kv_layers u32 = 4 +llama_model_loader: - kv 21: gemma4-assistant.embedding_length_per_layer_input u32 = 0 +llama_model_loader: - kv 22: gemma4-assistant.attention.sliding_window_pattern arr[bool,4] = [true, true, true, false] +llama_model_loader: - kv 23: gemma4-assistant.attention.key_length_swa u32 = 256 +llama_model_loader: - kv 24: gemma4-assistant.attention.value_length_swa u32 = 256 +llama_model_loader: - kv 25: gemma4-assistant.rope.dimension_count u32 = 512 +llama_model_loader: - kv 26: gemma4-assistant.rope.dimension_count_swa u32 = 256 +llama_model_loader: - kv 27: gemma4-assistant.embedding_length_out u32 = 1536 +llama_model_loader: - kv 28: gemma4-assistant.nextn_predict_layers u32 = 1 +llama_model_loader: - kv 29: general.quantization_version u32 = 2 +llama_model_loader: - kv 30: tokenizer.ggml.model str = gemma4 +llama_model_loader: - kv 31: tokenizer.ggml.tokens arr[str,262144] = ["", "", "", "", ... +llama_model_loader: - kv 32: tokenizer.ggml.scores arr[f32,262144] = [-1000.000000, -1000.000000, -1000.00... +llama_model_loader: - kv 33: tokenizer.ggml.token_type arr[i32,262144] = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, ... +llama_model_loader: - kv 34: tokenizer.ggml.merges arr[str,514906] = ["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n", ... +llama_model_loader: - kv 35: tokenizer.ggml.bos_token_id u32 = 2 +llama_model_loader: - kv 36: tokenizer.ggml.eos_token_id u32 = 1 +llama_model_loader: - kv 37: tokenizer.ggml.unknown_token_id u32 = 3 +llama_model_loader: - kv 38: tokenizer.ggml.padding_token_id u32 = 0 +llama_model_loader: - kv 39: tokenizer.ggml.mask_token_id u32 = 4 +llama_model_loader: - kv 40: tokenizer.ggml.add_space_prefix bool = false +llama_model_loader: - kv 41: tokenizer.ggml.add_bos_token bool = true +llama_model_loader: - type f32: 26 tensors +llama_model_loader: - type f16: 23 tensors +print_info: file format = GGUF V3 (latest) +print_info: file type = F16 +print_info: file size = 147.27 MiB (16.00 BPW) +llama_prepare_model_devices: using device MTL0 (Apple M4 Max) (unknown id) - 104123 MiB free +init_tokenizer: initializing tokenizer for type 2 +load: 0 unused tokens +load: control token: 258883 '' is not marked as EOG +load: control token: 258881 '<|audio|>' is not marked as EOG +load: control token: 258880 '<|image|>' is not marked as EOG +load: control token: 256000 '<|audio>' is not marked as EOG +load: control token: 255999 '<|image>' is not marked as EOG +load: control token: 105 '<|turn>' is not marked as EOG +load: control token: 258882 '' is not marked as EOG +load: control-looking token: 50 '<|tool_response>' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 46 '<|tool>' is not marked as EOG +load: control token: 3 '' is not marked as EOG +load: control-looking token: 212 '' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 47 '' is not marked as EOG +load: control token: 4 '' is not marked as EOG +load: control token: 2 '' is not marked as EOG +load: control token: 98 '<|think|>' is not marked as EOG +load: control token: 0 '' is not marked as EOG +load: printing all EOG tokens: +load: - 1 ('') +load: - 50 ('<|tool_response>') +load: - 106 ('') +load: - 212 ('') +load: special_eog_ids contains '<|tool_response>', removing '' token from EOG list +load: special tokens cache size = 23 +load: token to piece cache size = 1.9445 MB +print_info: arch = gemma4-assistant +print_info: vocab_only = 0 +print_info: no_alloc = 0 +print_info: n_ctx_train = 131072 +print_info: n_embd = 256 +print_info: n_embd_inp = 1536 +print_info: n_layer = 4 +print_info: n_head = 4 +print_info: n_head_kv = 1 +print_info: n_rot = 512 +print_info: n_swa = 512 +print_info: is_swa_any = 1 +print_info: n_embd_head_k = 512 +print_info: n_embd_head_v = 512 +print_info: n_gqa = 4 +print_info: n_embd_k_gqa = [256, 256, 256, 512] +print_info: n_embd_v_gqa = [256, 256, 256, 512] +print_info: f_norm_eps = 0.0e+00 +print_info: f_norm_rms_eps = 1.0e-06 +print_info: f_clamp_kqv = 0.0e+00 +print_info: f_max_alibi_bias = 0.0e+00 +print_info: f_logit_scale = 0.0e+00 +print_info: f_attn_scale = 1.0e+00 +print_info: f_attn_value_scale = 0.0000 +print_info: n_ff = 2048 +print_info: n_expert = 0 +print_info: n_expert_used = 0 +print_info: n_expert_groups = 0 +print_info: n_group_used = 0 +print_info: causal attn = 1 +print_info: pooling type = -1 +print_info: rope type = 2 +print_info: rope scaling = linear +print_info: freq_base_train = 1000000.0 +print_info: freq_scale_train = 1 +print_info: freq_base_swa = 10000.0 +print_info: freq_scale_swa = 1 +print_info: n_embd_head_k_swa = 256 +print_info: n_embd_head_v_swa = 256 +print_info: n_rot_swa = 256 +print_info: n_ctx_orig_yarn = 131072 +print_info: rope_yarn_log_mul = 0.0000 +print_info: rope_finetuned = unknown +print_info: model type = E2B +print_info: model params = 77.21 M +print_info: general.name = Model +print_info: vocab type = BPE +print_info: n_vocab = 262144 +print_info: n_merges = 514906 +print_info: BOS token = 2 '' +print_info: EOS token = 1 '' +print_info: UNK token = 3 '' +print_info: PAD token = 0 '' +print_info: MASK token = 4 '' +print_info: LF token = 107 ' +' +print_info: EOG token = 1 '' +print_info: EOG token = 50 '<|tool_response>' +print_info: EOG token = 106 '' +print_info: max token length = 93 +load_tensors: loading model tensors, this can take a while... (mmap = true, direct_io = false) +load_tensors: layer 0 assigned to device MTL0, is_swa = 1 +load_tensors: layer 1 assigned to device MTL0, is_swa = 1 +load_tensors: layer 2 assigned to device MTL0, is_swa = 1 +load_tensors: layer 3 assigned to device MTL0, is_swa = 0 +load_tensors: layer 4 assigned to device MTL0, is_swa = 0 +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor output_norm.weight +create_tensor: loading tensor nextn.post_projection.weight +create_tensor: loading tensor nextn.pre_projection.weight +create_tensor: loading tensor blk.0.attn_norm.weight +create_tensor: loading tensor blk.0.attn_q.weight +create_tensor: loading tensor blk.0.attn_output.weight +create_tensor: loading tensor blk.0.attn_q_norm.weight +create_tensor: loading tensor blk.0.post_attention_norm.weight +create_tensor: loading tensor blk.0.layer_output_scale.weight +create_tensor: loading tensor blk.0.ffn_norm.weight +create_tensor: loading tensor blk.0.ffn_gate.weight +create_tensor: loading tensor blk.0.ffn_up.weight +create_tensor: loading tensor blk.0.ffn_down.weight +create_tensor: loading tensor blk.0.post_ffw_norm.weight +create_tensor: loading tensor blk.1.attn_norm.weight +create_tensor: loading tensor blk.1.attn_q.weight +create_tensor: loading tensor blk.1.attn_output.weight +create_tensor: loading tensor blk.1.attn_q_norm.weight +create_tensor: loading tensor blk.1.post_attention_norm.weight +create_tensor: loading tensor blk.1.layer_output_scale.weight +create_tensor: loading tensor blk.1.ffn_norm.weight +create_tensor: loading tensor blk.1.ffn_gate.weight +create_tensor: loading tensor blk.1.ffn_up.weight +create_tensor: loading tensor blk.1.ffn_down.weight +create_tensor: loading tensor blk.1.post_ffw_norm.weight +create_tensor: loading tensor blk.2.attn_norm.weight +create_tensor: loading tensor blk.2.attn_q.weight +create_tensor: loading tensor blk.2.attn_output.weight +create_tensor: loading tensor blk.2.attn_q_norm.weight +create_tensor: loading tensor blk.2.post_attention_norm.weight +create_tensor: loading tensor blk.2.layer_output_scale.weight +create_tensor: loading tensor blk.2.ffn_norm.weight +create_tensor: loading tensor blk.2.ffn_gate.weight +create_tensor: loading tensor blk.2.ffn_up.weight +create_tensor: loading tensor blk.2.ffn_down.weight +create_tensor: loading tensor blk.2.post_ffw_norm.weight +create_tensor: loading tensor blk.3.attn_norm.weight +create_tensor: loading tensor blk.3.attn_q.weight +create_tensor: loading tensor blk.3.attn_output.weight +create_tensor: loading tensor blk.3.attn_q_norm.weight +create_tensor: loading tensor blk.3.post_attention_norm.weight +create_tensor: loading tensor blk.3.layer_output_scale.weight +create_tensor: loading tensor rope_freqs.weight +create_tensor: loading tensor blk.3.ffn_norm.weight +create_tensor: loading tensor blk.3.ffn_gate.weight +create_tensor: loading tensor blk.3.ffn_up.weight +create_tensor: loading tensor blk.3.ffn_down.weight +create_tensor: loading tensor blk.3.post_ffw_norm.weight +done_getting_tensors: tensor 'token_embd.weight' (f16) (and 0 others) cannot be used with preferred buffer type CPU_REPACK, using CPU instead +ggml_metal_log_allocated_size: allocated buffer, size = 147.28 MiB, ( 6124.34 / 110100.48) +load_tensors: offloading output layer to GPU +load_tensors: offloading 3 repeating layers to GPU +load_tensors: offloaded 5/5 layers to GPU +load_tensors: CPU_Mapped model buffer size = 128.00 MiB +load_tensors: MTL0_Mapped model buffer size = 147.27 MiB +.......... +llama_context: constructing llama_context +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: sharing with sibling layer 34 +llama_kv_cache: size = 8.00 MiB ( 4096 cells, 1 layers, 1/1 seqs), K (f16): 4.00 MiB, V (f16): 4.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 0 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 0 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: sharing with sibling layer 33 +llama_kv_cache: layer 1: sharing with sibling layer 33 +llama_kv_cache: layer 2: sharing with sibling layer 33 +llama_kv_cache: layer 3: filtered +llama_kv_cache: size = 12.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 6.00 MiB, V (f16): 6.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 0 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 0 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 1024 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 515.50 MiB +sched_reserve: CPU compute buffer size = 22.01 MiB +sched_reserve: graph nodes = 128 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 16.24 ms, sched copies = 1 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_concat', name = 'kernel_concat' +ggml_metal_library_compile_pipeline: loaded kernel_concat 0xa3a538600 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_ext_f16_f32_r1_2', name = 'kernel_mul_mv_ext_f16_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_ext_f16_f32_r1_2_nsg=2_nxpsg=16_ne12=1_r2=1_r3=1 0xa3a538900 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_f16_f32_4', name = 'kernel_mul_mv_f16_f32_4_nsg=2_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_f16_f32_4_nsg=2_ne12=1_r2=1_r3=1 0xa3a538c00 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mv_f16_f32_4', name = 'kernel_mul_mv_f16_f32_4_nsg=4_ne12=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mv_f16_f32_4_nsg=4_ne12=1_r2=1_r3=1 0xa3a538f00 | th_max = 1024 | th_width = 32 +common_speculative_init: adding speculative implementation 'draft-mtp' +set_embeddings_pre_norm: value = 1 +set_embeddings_pre_norm: value = 1 +set_embeddings: value = 0 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_mul_mm_f16_f32', name = 'kernel_mul_mm_f16_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1' +ggml_metal_library_compile_pipeline: loaded kernel_mul_mm_f16_f32_bci=0_bco=1_ne12=1_ne13=1_r2=1_r3=1 0xa3a539200 | th_max = 1024 | th_width = 32 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +[mtp] n=48 95.9 tok/s (prefill+decode 501ms) drafted=27 accepted=22 acceptance=0.815 +[mtp] text: "One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen, Sixteen,, Eighteen, Nineteen, Twenty\n" +[check] greedy outputs identical: false + +=== prompt: "List the seven days of the week in order, one per line." +llama_context: constructing llama_context +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: filtered +llama_kv_cache: layer 4: dev = MTL0 +llama_kv_cache: layer 5: filtered +llama_kv_cache: layer 6: filtered +llama_kv_cache: layer 7: filtered +llama_kv_cache: layer 8: filtered +llama_kv_cache: layer 9: dev = MTL0 +llama_kv_cache: layer 10: filtered +llama_kv_cache: layer 11: filtered +llama_kv_cache: layer 12: filtered +llama_kv_cache: layer 13: filtered +llama_kv_cache: layer 14: dev = MTL0 +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: filtered +llama_kv_cache: - layer 16: filtered +llama_kv_cache: - layer 17: filtered +llama_kv_cache: - layer 18: filtered +llama_kv_cache: - layer 19: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 20: filtered +llama_kv_cache: - layer 21: filtered +llama_kv_cache: - layer 22: filtered +llama_kv_cache: - layer 23: filtered +llama_kv_cache: - layer 24: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 25: filtered +llama_kv_cache: - layer 26: filtered +llama_kv_cache: - layer 27: filtered +llama_kv_cache: - layer 28: filtered +llama_kv_cache: - layer 29: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 30: filtered +llama_kv_cache: - layer 31: filtered +llama_kv_cache: - layer 32: filtered +llama_kv_cache: - layer 33: filtered +llama_kv_cache: - layer 34: reuse layer 14, is_swa = 0 +llama_kv_cache: MTL0 KV buffer size = 24.00 MiB +llama_kv_cache: size = 24.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 12.00 MiB, V (f16): 12.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 512 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 512 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: dev = MTL0 +llama_kv_cache: layer 1: dev = MTL0 +llama_kv_cache: layer 2: dev = MTL0 +llama_kv_cache: layer 3: dev = MTL0 +llama_kv_cache: layer 4: filtered +llama_kv_cache: layer 5: dev = MTL0 +llama_kv_cache: layer 6: dev = MTL0 +llama_kv_cache: layer 7: dev = MTL0 +llama_kv_cache: layer 8: dev = MTL0 +llama_kv_cache: layer 9: filtered +llama_kv_cache: layer 10: dev = MTL0 +llama_kv_cache: layer 11: dev = MTL0 +llama_kv_cache: layer 12: dev = MTL0 +llama_kv_cache: layer 13: dev = MTL0 +llama_kv_cache: layer 14: filtered +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 16: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 17: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 18: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 19: filtered +llama_kv_cache: - layer 20: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 21: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 22: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 23: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 24: filtered +llama_kv_cache: - layer 25: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 26: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 27: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 28: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 29: filtered +llama_kv_cache: - layer 30: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 31: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 32: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 33: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 34: filtered +llama_kv_cache: MTL0 KV buffer size = 48.00 MiB +llama_kv_cache: size = 48.00 MiB ( 4096 cells, 12 layers, 1/1 seqs), K (f16): 24.00 MiB, V (f16): 24.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 256 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 256 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 4816 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 555.02 MiB +sched_reserve: CPU compute buffer size = 39.52 MiB +sched_reserve: graph nodes = 1500 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 27.07 ms, sched copies = 1 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_f16_dk256_dv256', name = 'kernel_flash_attn_ext_f16_dk256_dv256_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=0_ns10=256_ns20=256_nsg=4' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_f16_dk256_dv256_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=0_ns10=256_ns20=256_nsg=4 0xa3a539500 | th_max = 1024 | th_width = 32 +ggml_metal_library_compile_pipeline: compiling pipeline: base = 'kernel_flash_attn_ext_f16_dk512_dv512', name = 'kernel_flash_attn_ext_f16_dk512_dv512_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=0_ns10=512_ns20=512_nsg=8' +ggml_metal_library_compile_pipeline: loaded kernel_flash_attn_ext_f16_dk512_dv512_mask=1_sinks=0_bias=0_scap=0_kvpad=0_bcm=0_ns10=512_ns20=512_nsg=8 0xa3a539800 | th_max = 1024 | th_width = 32 +[baseline] n=21 75.3 tok/s (prefill+decode 279ms) +[baseline] text: "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday\n" +llama_context: constructing llama_context +llama_context: n_rs_seq=1 requested but model arch does not support recurrent partial rollback; clamping to 0 +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: filtered +llama_kv_cache: layer 4: dev = MTL0 +llama_kv_cache: layer 5: filtered +llama_kv_cache: layer 6: filtered +llama_kv_cache: layer 7: filtered +llama_kv_cache: layer 8: filtered +llama_kv_cache: layer 9: dev = MTL0 +llama_kv_cache: layer 10: filtered +llama_kv_cache: layer 11: filtered +llama_kv_cache: layer 12: filtered +llama_kv_cache: layer 13: filtered +llama_kv_cache: layer 14: dev = MTL0 +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: filtered +llama_kv_cache: - layer 16: filtered +llama_kv_cache: - layer 17: filtered +llama_kv_cache: - layer 18: filtered +llama_kv_cache: - layer 19: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 20: filtered +llama_kv_cache: - layer 21: filtered +llama_kv_cache: - layer 22: filtered +llama_kv_cache: - layer 23: filtered +llama_kv_cache: - layer 24: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 25: filtered +llama_kv_cache: - layer 26: filtered +llama_kv_cache: - layer 27: filtered +llama_kv_cache: - layer 28: filtered +llama_kv_cache: - layer 29: reuse layer 14, is_swa = 0 +llama_kv_cache: - layer 30: filtered +llama_kv_cache: - layer 31: filtered +llama_kv_cache: - layer 32: filtered +llama_kv_cache: - layer 33: filtered +llama_kv_cache: - layer 34: reuse layer 14, is_swa = 0 +llama_kv_cache: MTL0 KV buffer size = 24.00 MiB +llama_kv_cache: size = 24.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 12.00 MiB, V (f16): 12.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 512 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 512 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: dev = MTL0 +llama_kv_cache: layer 1: dev = MTL0 +llama_kv_cache: layer 2: dev = MTL0 +llama_kv_cache: layer 3: dev = MTL0 +llama_kv_cache: layer 4: filtered +llama_kv_cache: layer 5: dev = MTL0 +llama_kv_cache: layer 6: dev = MTL0 +llama_kv_cache: layer 7: dev = MTL0 +llama_kv_cache: layer 8: dev = MTL0 +llama_kv_cache: layer 9: filtered +llama_kv_cache: layer 10: dev = MTL0 +llama_kv_cache: layer 11: dev = MTL0 +llama_kv_cache: layer 12: dev = MTL0 +llama_kv_cache: layer 13: dev = MTL0 +llama_kv_cache: layer 14: filtered +llama_kv_cache: layer 15: does not have KV cache +llama_kv_cache: layer 16: does not have KV cache +llama_kv_cache: layer 17: does not have KV cache +llama_kv_cache: layer 18: does not have KV cache +llama_kv_cache: layer 19: does not have KV cache +llama_kv_cache: layer 20: does not have KV cache +llama_kv_cache: layer 21: does not have KV cache +llama_kv_cache: layer 22: does not have KV cache +llama_kv_cache: layer 23: does not have KV cache +llama_kv_cache: layer 24: does not have KV cache +llama_kv_cache: layer 25: does not have KV cache +llama_kv_cache: layer 26: does not have KV cache +llama_kv_cache: layer 27: does not have KV cache +llama_kv_cache: layer 28: does not have KV cache +llama_kv_cache: layer 29: does not have KV cache +llama_kv_cache: layer 30: does not have KV cache +llama_kv_cache: layer 31: does not have KV cache +llama_kv_cache: layer 32: does not have KV cache +llama_kv_cache: layer 33: does not have KV cache +llama_kv_cache: layer 34: does not have KV cache +llama_kv_cache: reusing layers: +llama_kv_cache: - layer 0: no reuse +llama_kv_cache: - layer 1: no reuse +llama_kv_cache: - layer 2: no reuse +llama_kv_cache: - layer 3: no reuse +llama_kv_cache: - layer 4: no reuse +llama_kv_cache: - layer 5: no reuse +llama_kv_cache: - layer 6: no reuse +llama_kv_cache: - layer 7: no reuse +llama_kv_cache: - layer 8: no reuse +llama_kv_cache: - layer 9: no reuse +llama_kv_cache: - layer 10: no reuse +llama_kv_cache: - layer 11: no reuse +llama_kv_cache: - layer 12: no reuse +llama_kv_cache: - layer 13: no reuse +llama_kv_cache: - layer 14: no reuse +llama_kv_cache: - layer 15: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 16: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 17: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 18: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 19: filtered +llama_kv_cache: - layer 20: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 21: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 22: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 23: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 24: filtered +llama_kv_cache: - layer 25: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 26: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 27: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 28: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 29: filtered +llama_kv_cache: - layer 30: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 31: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 32: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 33: reuse layer 13, is_swa = 1 +llama_kv_cache: - layer 34: filtered +llama_kv_cache: MTL0 KV buffer size = 48.00 MiB +llama_kv_cache: size = 48.00 MiB ( 4096 cells, 12 layers, 1/1 seqs), K (f16): 24.00 MiB, V (f16): 24.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 256 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 256 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 4816 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 555.02 MiB +sched_reserve: CPU compute buffer size = 39.52 MiB +sched_reserve: graph nodes = 1500 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 31.65 ms, sched copies = 1 +llama_model_loader: loaded meta data with 42 key-value pairs and 49 tensors from /tmp/mtp/bundles/2b/mtp/drafter-2b.gguf (version GGUF V3 (latest)) +llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output. +llama_model_loader: - kv 0: general.architecture str = gemma4-assistant +llama_model_loader: - kv 1: general.type str = model +llama_model_loader: - kv 2: general.sampling.top_k i32 = 64 +llama_model_loader: - kv 3: general.sampling.top_p f32 = 0.950000 +llama_model_loader: - kv 4: general.sampling.temp f32 = 1.000000 +llama_model_loader: - kv 5: general.name str = Model +llama_model_loader: - kv 6: general.size_label str = 77M +llama_model_loader: - kv 7: gemma4-assistant.block_count u32 = 4 +llama_model_loader: - kv 8: gemma4-assistant.context_length u32 = 131072 +llama_model_loader: - kv 9: gemma4-assistant.embedding_length u32 = 256 +llama_model_loader: - kv 10: gemma4-assistant.feed_forward_length u32 = 2048 +llama_model_loader: - kv 11: gemma4-assistant.attention.head_count u32 = 4 +llama_model_loader: - kv 12: gemma4-assistant.attention.head_count_kv u32 = 1 +llama_model_loader: - kv 13: gemma4-assistant.rope.freq_base f32 = 1000000.000000 +llama_model_loader: - kv 14: gemma4-assistant.rope.freq_base_swa f32 = 10000.000000 +llama_model_loader: - kv 15: gemma4-assistant.attention.layer_norm_rms_epsilon f32 = 0.000001 +llama_model_loader: - kv 16: gemma4-assistant.attention.key_length u32 = 512 +llama_model_loader: - kv 17: gemma4-assistant.attention.value_length u32 = 512 +llama_model_loader: - kv 18: general.file_type u32 = 1 +llama_model_loader: - kv 19: gemma4-assistant.attention.sliding_window u32 = 512 +llama_model_loader: - kv 20: gemma4-assistant.attention.shared_kv_layers u32 = 4 +llama_model_loader: - kv 21: gemma4-assistant.embedding_length_per_layer_input u32 = 0 +llama_model_loader: - kv 22: gemma4-assistant.attention.sliding_window_pattern arr[bool,4] = [true, true, true, false] +llama_model_loader: - kv 23: gemma4-assistant.attention.key_length_swa u32 = 256 +llama_model_loader: - kv 24: gemma4-assistant.attention.value_length_swa u32 = 256 +llama_model_loader: - kv 25: gemma4-assistant.rope.dimension_count u32 = 512 +llama_model_loader: - kv 26: gemma4-assistant.rope.dimension_count_swa u32 = 256 +llama_model_loader: - kv 27: gemma4-assistant.embedding_length_out u32 = 1536 +llama_model_loader: - kv 28: gemma4-assistant.nextn_predict_layers u32 = 1 +llama_model_loader: - kv 29: general.quantization_version u32 = 2 +llama_model_loader: - kv 30: tokenizer.ggml.model str = gemma4 +llama_model_loader: - kv 31: tokenizer.ggml.tokens arr[str,262144] = ["", "", "", "", ... +llama_model_loader: - kv 32: tokenizer.ggml.scores arr[f32,262144] = [-1000.000000, -1000.000000, -1000.00... +llama_model_loader: - kv 33: tokenizer.ggml.token_type arr[i32,262144] = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, ... +llama_model_loader: - kv 34: tokenizer.ggml.merges arr[str,514906] = ["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n", ... +llama_model_loader: - kv 35: tokenizer.ggml.bos_token_id u32 = 2 +llama_model_loader: - kv 36: tokenizer.ggml.eos_token_id u32 = 1 +llama_model_loader: - kv 37: tokenizer.ggml.unknown_token_id u32 = 3 +llama_model_loader: - kv 38: tokenizer.ggml.padding_token_id u32 = 0 +llama_model_loader: - kv 39: tokenizer.ggml.mask_token_id u32 = 4 +llama_model_loader: - kv 40: tokenizer.ggml.add_space_prefix bool = false +llama_model_loader: - kv 41: tokenizer.ggml.add_bos_token bool = true +llama_model_loader: - type f32: 26 tensors +llama_model_loader: - type f16: 23 tensors +print_info: file format = GGUF V3 (latest) +print_info: file type = F16 +print_info: file size = 147.27 MiB (16.00 BPW) +llama_prepare_model_devices: using device MTL0 (Apple M4 Max) (unknown id) - 102206 MiB free +init_tokenizer: initializing tokenizer for type 2 +load: 0 unused tokens +load: control token: 258883 '' is not marked as EOG +load: control token: 258881 '<|audio|>' is not marked as EOG +load: control token: 258880 '<|image|>' is not marked as EOG +load: control token: 256000 '<|audio>' is not marked as EOG +load: control token: 255999 '<|image>' is not marked as EOG +load: control token: 105 '<|turn>' is not marked as EOG +load: control token: 258882 '' is not marked as EOG +load: control-looking token: 50 '<|tool_response>' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 46 '<|tool>' is not marked as EOG +load: control token: 3 '' is not marked as EOG +load: control-looking token: 212 '' was not control-type; this is probably a bug in the model. its type will be overridden +load: control token: 47 '' is not marked as EOG +load: control token: 4 '' is not marked as EOG +load: control token: 2 '' is not marked as EOG +load: control token: 98 '<|think|>' is not marked as EOG +load: control token: 0 '' is not marked as EOG +load: printing all EOG tokens: +load: - 1 ('') +load: - 50 ('<|tool_response>') +load: - 106 ('') +load: - 212 ('') +load: special_eog_ids contains '<|tool_response>', removing '' token from EOG list +load: special tokens cache size = 23 +load: token to piece cache size = 1.9445 MB +print_info: arch = gemma4-assistant +print_info: vocab_only = 0 +print_info: no_alloc = 0 +print_info: n_ctx_train = 131072 +print_info: n_embd = 256 +print_info: n_embd_inp = 1536 +print_info: n_layer = 4 +print_info: n_head = 4 +print_info: n_head_kv = 1 +print_info: n_rot = 512 +print_info: n_swa = 512 +print_info: is_swa_any = 1 +print_info: n_embd_head_k = 512 +print_info: n_embd_head_v = 512 +print_info: n_gqa = 4 +print_info: n_embd_k_gqa = [256, 256, 256, 512] +print_info: n_embd_v_gqa = [256, 256, 256, 512] +print_info: f_norm_eps = 0.0e+00 +print_info: f_norm_rms_eps = 1.0e-06 +print_info: f_clamp_kqv = 0.0e+00 +print_info: f_max_alibi_bias = 0.0e+00 +print_info: f_logit_scale = 0.0e+00 +print_info: f_attn_scale = 1.0e+00 +print_info: f_attn_value_scale = 0.0000 +print_info: n_ff = 2048 +print_info: n_expert = 0 +print_info: n_expert_used = 0 +print_info: n_expert_groups = 0 +print_info: n_group_used = 0 +print_info: causal attn = 1 +print_info: pooling type = -1 +print_info: rope type = 2 +print_info: rope scaling = linear +print_info: freq_base_train = 1000000.0 +print_info: freq_scale_train = 1 +print_info: freq_base_swa = 10000.0 +print_info: freq_scale_swa = 1 +print_info: n_embd_head_k_swa = 256 +print_info: n_embd_head_v_swa = 256 +print_info: n_rot_swa = 256 +print_info: n_ctx_orig_yarn = 131072 +print_info: rope_yarn_log_mul = 0.0000 +print_info: rope_finetuned = unknown +print_info: model type = E2B +print_info: model params = 77.21 M +print_info: general.name = Model +print_info: vocab type = BPE +print_info: n_vocab = 262144 +print_info: n_merges = 514906 +print_info: BOS token = 2 '' +print_info: EOS token = 1 '' +print_info: UNK token = 3 '' +print_info: PAD token = 0 '' +print_info: MASK token = 4 '' +print_info: LF token = 107 ' +' +print_info: EOG token = 1 '' +print_info: EOG token = 50 '<|tool_response>' +print_info: EOG token = 106 '' +print_info: max token length = 93 +load_tensors: loading model tensors, this can take a while... (mmap = true, direct_io = false) +load_tensors: layer 0 assigned to device MTL0, is_swa = 1 +load_tensors: layer 1 assigned to device MTL0, is_swa = 1 +load_tensors: layer 2 assigned to device MTL0, is_swa = 1 +load_tensors: layer 3 assigned to device MTL0, is_swa = 0 +load_tensors: layer 4 assigned to device MTL0, is_swa = 0 +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor token_embd.weight +create_tensor: loading tensor output_norm.weight +create_tensor: loading tensor nextn.post_projection.weight +create_tensor: loading tensor nextn.pre_projection.weight +create_tensor: loading tensor blk.0.attn_norm.weight +create_tensor: loading tensor blk.0.attn_q.weight +create_tensor: loading tensor blk.0.attn_output.weight +create_tensor: loading tensor blk.0.attn_q_norm.weight +create_tensor: loading tensor blk.0.post_attention_norm.weight +create_tensor: loading tensor blk.0.layer_output_scale.weight +create_tensor: loading tensor blk.0.ffn_norm.weight +create_tensor: loading tensor blk.0.ffn_gate.weight +create_tensor: loading tensor blk.0.ffn_up.weight +create_tensor: loading tensor blk.0.ffn_down.weight +create_tensor: loading tensor blk.0.post_ffw_norm.weight +create_tensor: loading tensor blk.1.attn_norm.weight +create_tensor: loading tensor blk.1.attn_q.weight +create_tensor: loading tensor blk.1.attn_output.weight +create_tensor: loading tensor blk.1.attn_q_norm.weight +create_tensor: loading tensor blk.1.post_attention_norm.weight +create_tensor: loading tensor blk.1.layer_output_scale.weight +create_tensor: loading tensor blk.1.ffn_norm.weight +create_tensor: loading tensor blk.1.ffn_gate.weight +create_tensor: loading tensor blk.1.ffn_up.weight +create_tensor: loading tensor blk.1.ffn_down.weight +create_tensor: loading tensor blk.1.post_ffw_norm.weight +create_tensor: loading tensor blk.2.attn_norm.weight +create_tensor: loading tensor blk.2.attn_q.weight +create_tensor: loading tensor blk.2.attn_output.weight +create_tensor: loading tensor blk.2.attn_q_norm.weight +create_tensor: loading tensor blk.2.post_attention_norm.weight +create_tensor: loading tensor blk.2.layer_output_scale.weight +create_tensor: loading tensor blk.2.ffn_norm.weight +create_tensor: loading tensor blk.2.ffn_gate.weight +create_tensor: loading tensor blk.2.ffn_up.weight +create_tensor: loading tensor blk.2.ffn_down.weight +create_tensor: loading tensor blk.2.post_ffw_norm.weight +create_tensor: loading tensor blk.3.attn_norm.weight +create_tensor: loading tensor blk.3.attn_q.weight +create_tensor: loading tensor blk.3.attn_output.weight +create_tensor: loading tensor blk.3.attn_q_norm.weight +create_tensor: loading tensor blk.3.post_attention_norm.weight +create_tensor: loading tensor blk.3.layer_output_scale.weight +create_tensor: loading tensor rope_freqs.weight +create_tensor: loading tensor blk.3.ffn_norm.weight +create_tensor: loading tensor blk.3.ffn_gate.weight +create_tensor: loading tensor blk.3.ffn_up.weight +create_tensor: loading tensor blk.3.ffn_down.weight +create_tensor: loading tensor blk.3.post_ffw_norm.weight +done_getting_tensors: tensor 'token_embd.weight' (f16) (and 0 others) cannot be used with preferred buffer type CPU_REPACK, using CPU instead +ggml_metal_log_allocated_size: allocated buffer, size = 147.28 MiB, ( 8041.19 / 110100.48) +load_tensors: offloading output layer to GPU +load_tensors: offloading 3 repeating layers to GPU +load_tensors: offloaded 5/5 layers to GPU +load_tensors: CPU_Mapped model buffer size = 128.00 MiB +load_tensors: MTL0_Mapped model buffer size = 147.27 MiB +.......... +llama_context: constructing llama_context +llama_context: n_seq_max = 1 +llama_context: n_ctx = 4096 +llama_context: n_ctx_seq = 4096 +llama_context: n_batch = 512 +llama_context: n_ubatch = 512 +llama_context: causal_attn = 1 +llama_context: flash_attn = auto +llama_context: kv_unified = false +llama_context: freq_base = 1000000.0 +llama_context: freq_scale = 1 +llama_context: n_rs_seq = 0 +llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized +ggml_metal_init: allocating +ggml_metal_init: found device: Apple M4 Max +ggml_metal_init: picking default device: Apple M4 Max +ggml_metal_init: use fusion = true +ggml_metal_init: use concurrency = true +ggml_metal_init: use graph optimize = true +set_abort_callback: call +llama_context: CPU output buffer size = 1.00 MiB +llama_kv_cache_iswa: using full-size SWA cache (ref: https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) +llama_kv_cache_iswa: creating non-SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: filtered +llama_kv_cache: layer 1: filtered +llama_kv_cache: layer 2: filtered +llama_kv_cache: layer 3: sharing with sibling layer 34 +llama_kv_cache: size = 8.00 MiB ( 4096 cells, 1 layers, 1/1 seqs), K (f16): 4.00 MiB, V (f16): 4.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 0 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 0 +llama_kv_cache_iswa: creating SWA KV cache, size = 4096 cells +llama_kv_cache: layer 0: sharing with sibling layer 33 +llama_kv_cache: layer 1: sharing with sibling layer 33 +llama_kv_cache: layer 2: sharing with sibling layer 33 +llama_kv_cache: layer 3: filtered +llama_kv_cache: size = 12.00 MiB ( 4096 cells, 3 layers, 1/1 seqs), K (f16): 6.00 MiB, V (f16): 6.00 MiB +llama_kv_cache: attn_rot_k = 0, n_embd_head_k_all = 0 +llama_kv_cache: attn_rot_v = 0, n_embd_head_k_all = 0 +llama_context: enumerating backends +llama_context: backend_ptrs.size() = 3 +sched_reserve: reserving ... +sched_reserve: max_nodes = 1024 +sched_reserve: reserving full memory module +sched_reserve: worst-case: n_tokens = 512, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: Flash Attention was auto, set to enabled +sched_reserve: resolving fused Gated Delta Net support: +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +sched_reserve: fused Gated Delta Net (autoregressive) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 16, n_seqs = 1, n_outputs = 16 +sched_reserve: fused Gated Delta Net (chunked) enabled +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +graph_reserve: reserving a graph for ubatch with n_tokens = 1, n_seqs = 1, n_outputs = 1 +graph_reserve: reserving a graph for ubatch with n_tokens = 512, n_seqs = 1, n_outputs = 512 +sched_reserve: MTL0 compute buffer size = 515.50 MiB +sched_reserve: CPU compute buffer size = 22.01 MiB +sched_reserve: graph nodes = 128 +sched_reserve: graph splits = 2 +sched_reserve: reserve took 18.48 ms, sched copies = 1 +common_speculative_init: adding speculative implementation 'draft-mtp' +set_embeddings_pre_norm: value = 1 +set_embeddings_pre_norm: value = 1 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +set_embeddings: value = 0 +[mtp] n=21 93.3 tok/s (prefill+decode 225ms) drafted=11 accepted=10 acceptance=0.909 +[mtp] text: "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday\n" +[check] greedy outputs identical: true + +[TOTAL] drafted=38 accepted=32 acceptance=0.842 +[harness] clean shutdown +/Users/shawwalters/eliza-workspace/milady/eliza/plugins/plugin-local-inference/native/llama.cpp/ggml/src/ggml-metal/ggml-metal-device.m:637: GGML_ASSERT([rsets->data count] == 0) failed +WARNING: Using native backtrace. Set GGML_BACKTRACE_LLDB for more info. +WARNING: GGML_BACKTRACE_LLDB may cause native MacOS Terminal.app to crash. +See: https://github.com/ggml-org/llama.cpp/pull/17869 +0 libggml-base.0.12.0.dylib 0x000000011dce5490 ggml_print_backtrace + 276 +1 libggml-base.0.12.0.dylib 0x000000011dd5eaa0 ggml_abort + 156 +2 libggml-metal.0.12.0.dylib 0x000000013f1fa2e8 ggml_metal_device_init + 0 +3 libggml-metal.0.12.0.dylib 0x000000013f1fac9c ggml_metal_device_free + 24 +4 libggml-metal.0.12.0.dylib 0x000000013f1fcc70 _ZNSt3__16vectorINS_10unique_ptrI17ggml_metal_device25ggml_metal_device_deleterEENS_9allocatorIS4_EEED1B9nqe210106Ev + 72 +5 libsystem_c.dylib 0x000000018e5b542c __cxa_finalize_ranges + 480 +6 libsystem_c.dylib 0x000000018e5b51ec exit + 44 +7 bun 0x000000010300e734 bun + 10217268 +8 bun 0x00000001032b2844 bun + 12986436 +9 bun 0x00000001037d2334 bun + 18359092 +10 bun 0x0000000102a114e0 bun + 3937504 +11 bun 0x00000001030859cc bun + 10705356 +12 bun 0x000000010309ff8c bun + 10813324 +13 bun 0x000000010305dabc bun + 10541756 +14 bun 0x000000010301cf6c bun + 10276716 +15 bun 0x000000010300e670 bun + 10217072 +16 bun 0x000000010300dd0c bun + 10214668 +17 dyld 0x000000018e339d54 start + 7184 diff --git a/.github/issue-evidence/gemma4-cutover-final/README.md b/.github/issue-evidence/gemma4-cutover-final/README.md new file mode 100644 index 0000000000000..dd3291dcdd803 --- /dev/null +++ b/.github/issue-evidence/gemma4-cutover-final/README.md @@ -0,0 +1,107 @@ +# Gemma-4 cutover — final HF `elizaos/eliza-1` arch matrix + hub repair (2026-07-02) + +Non-training finalization pass. Everything below was verified live against the +HF hub (`HfApi.get_paths_info` LFS object metadata + downloaded bytes) and +against the **current-source** downloader validator +(`plugins/plugin-local-inference/src/services/manifest/` `validateManifest` / +`parseManifestOrThrow` — the exact function `downloader.ts:258` calls at +install time). + +## 1. Text-weight arch matrix (final) + +| HF path | size | sha256 (12) | arch | status | +|---|---|---|---|---| +| `bundles/2b/text/eliza-1-2b-128k.gguf` | 4,967,494,592 | `e049411c01fb` | **gemma4** | **SHIPPING** — sole `files.text` entry in the 2b manifest; catalog `eliza-1-2b` textFile | +| `bundles/2b/text/eliza-1-2b-256k.gguf` | 1,270,808,512 | `a511452ec932` | qwen35 (pre-republish bytes; size matches the qwen35 1211 MB 2b documented in `faee4148d9d`) | KEPT — legacy, referenced (see §2) | +| `bundles/2b/text/eliza-1-2b-32k.gguf` | 1,270,808,512 | `a511452ec932` (byte-identical to 2b-256k) | qwen35 | KEPT — legacy, referenced (see §2) | +| `bundles/4b/text/eliza-1-4b-128k.gguf` | 8,031,240,160 | `fb8f0c032de0` | **gemma4** | **SHIPPING** — sole `files.text` entry in the 4b manifest; catalog `eliza-1-4b` textFile | +| `bundles/4b/text/eliza-1-4b-256k.gguf` | 2,952,939,488 | `798092229ce8` | qwen35 | KEPT — legacy, referenced (see §2) | +| `bundles/4b/text/eliza-1-4b-64k.gguf` | 2,871,743,520 | `68c9c6bfeece` | qwen35 | KEPT — legacy, referenced (see §2) | +| 9b / 27b / 27b-256k text | — | — | qwen35 (no `bundles/9b|27b*` trees on HF at all) | catalog-gated `pending` — Gemma fine-tunes are training-gated, out of scope | +| `candidates/gemma-2b-base-v1/text/eliza-1-2b-128k.gguf` | — | — | gemma4 candidate | KEPT — candidate staging tree | + +Vision pairing (verified via LFS metadata): `bundles/2b/vision/mmproj-2b.gguf` +`8a82e0fd831b` and `bundles/4b/vision/mmproj-4b.gguf` `51d4b7fd825e` are the +manifest-pinned gemma4v projectors. + +## 2. Orphan check for the qwen35 variants — verdict: NOT orphans, NOT deleted + +Deletion required "referenced by NO code path", doubly confirmed. The grep +sweep found live references, so **no HF files were deleted**: + +- `packages/training/cloud/ollama/Modelfile.eliza-1-2b-q4_k_m:20` — + `FROM hf.co/elizaos/eliza-1:bundles/2b/text/eliza-1-2b-32k.gguf` pulls the + 32k file **directly from the hub** (and `packages/core/src/testing/inference-provider.ts:260` + tells operators to `ollama create` from that Modelfile). +- `plugins/plugin-local-inference/native/verify/eagle3_drafter_runtime_smoke.mjs:33` + — `eliza-1-2b-256k.gguf` is a `DEFAULT_TARGET` fallback candidate. +- dflash provenance chain on the hub binds to the qwen35 bytes: + `bundles/2b/dflash/target-meta.json` `targetCheckpointSha256 = a511452e…` + (= 2b-256k/32k) and `bundles/4b/dflash/target-meta.json` + `targetCheckpointSha256 = 68c9c6bf…` (= 4b-64k). +- `packages/training/scripts/manifest/audit_hf_eliza1_release.py` expects + `expectedContexts == ["128k", "256k"]` and a `text_artifact_name(tier, "256k")` + dflash target per tier (asserted by its tests). +- Docs/examples: `packages/examples/autonomous/` (`LOCAL_SMALL_MODEL=eliza-1-2b-32k.gguf`), + `packages/docs/guides/local-models.md`. + +Stale doc strings that mention `eliza-1-2b-32k.gguf` as the *embedding default* +(`packages/agent/src/config/schema.ts:742`, `packages/app-core/src/benchmark/server.ts:2054`) +are **not** live download paths — the real embedding preset is +`gte-small_fp16.gguf` from `ChristianAzinn/gte-small-gguf` +(`plugins/plugin-local-inference/src/runtime/embedding-presets.ts`). + +## 3. Manifest verification + repair (the actual blocker found) + +Before this pass, **the current-source downloader could not install either +shipping bundle**: `parseManifestOrThrow` (downloader.ts:258) rejected both +live manifests. + +| Defect (live HF manifest, before) | Effect | Fix (uploaded) | +|---|---|---| +| `files.vision` was an **object**, schema requires an array | schema parse failure → every 2b/4b install throws `Invalid Eliza-1 manifest` | `files.vision` → 1-element array (same path + sha) | +| 4b `files.mtp[0]` = `text/eliza-1-4b-128k.gguf` with the **qwen35 4b-256k sha `79809222…`** while `files.text` pins the gemma4 sha `fb8f0c03…` for the same path | `collectBundleFiles` throws `Conflicting sha256 entries`; the stale qwen35 sha would also defeat the `faee4148d9d` stale-partial detection | dropped (see below) | +| 2b `files.mtp[0]` = `dflash/drafter-2b.gguf` — a drafter distilled against the **Qwen3.5-2B checkpoint `a511452e…`**, not the shipped gemma4 text; validator requires `mtp/drafter-.gguf` | validator error; drafter unusable against gemma4 target | dropped `files.mtp` + `lineage.drafter` on both tiers — matches the code gate `ELIZA_1_HOSTED_MTP_TIER_IDS = []` (catalog.ts: dflash files are documented legacy; MTP is off until real Gemma drafters are published, training-gated) | +| 5 manifest-pinned files were **missing from the bundle trees** (404 at download): `tts/kokoro/kokoro-82m-v1_0-Q4_K_M.gguf` (both tiers), `vad/silero-vad-int8.onnx` (both tiers), 4b `tts/kokoro/model_q4.onnx` | bundle install fails mid-download | restored **byte-exact to the already-pinned shas**: kokoro Q4_K_M `cb5440c3…` from the local 0_8b bundle copy; silero int8 `90b026c9…` from upstream `onnx-community/silero-vad` `onnx/model_int8.onnx` (sha match confirmed before upload); `model_q4.onnx` `04cf570c…` server-side `CommitOperationCopy` from `bundles/2b` | + +`files.text` was already correct on both tiers (gemma4 128k only) and was not +touched: 2b `text/eliza-1-2b-128k.gguf` `e049411c…`, 4b +`text/eliza-1-4b-128k.gguf` `fb8f0c03…` — both byte-verified against the hub +LFS objects. + +## 4. `checksums/SHA256SUMS` regeneration + +The old SUMS predated the gemma4 re-publish and were globally stale — worst +offenders (each of these is exactly the "stale sha defeats the re-publish +detection" failure mode): + +- `text/eliza-1-2b-128k.gguf` listed the **qwen35** sha `a511452e…` (actual gemma4 `e049411c…`) +- `text/eliza-1-4b-128k.gguf` **and** `-256k` both listed the 4b-64k qwen35 sha `68c9c6bf…` (actual `fb8f0c03…` / `79809222…`) +- `vision/mmproj-{2b,4b}.gguf`, the `eliza-1.manifest.json` self-hash, and most + evidence/eval JSON lines no longer matched hosted bytes; several lines pointed + at files no longer hosted. + +Both files were regenerated from the live tree (one line per hosted file under +`bundles//`, LFS-metadata sha for LFS files, downloaded-byte sha +otherwise): 86 lines (2b), 94 lines (4b). + +## 5. HF commits (repo `elizaos/eliza-1`) + +1. `1a7c0c7b8b4ffdc70f938c4b993b909f23b1b652` — restore 5 manifest-referenced files (byte-exact to pinned shas) +2. `c6d9d5cb16d27ae35bfdafa46a79dd31216a81b2` — regenerated `bundles/{2b,4b}/eliza-1.manifest.json` +3. `27ca133883b6893d712c8ad88146f59a7b9773c5` — regenerated `bundles/{2b,4b}/checksums/SHA256SUMS` + +## 6. Post-repair verification (live, current source) + +- `validateManifest` (plugin-local-inference @ this tree): **both live manifests OK** (previously: schema rejection). +- Every `files.*` entry (21 on 2b, 24 on 4b) exists on the hub and its LFS/byte + sha256 **matches the manifest exactly** (0 missing, 0 mismatches). +- New manifest self-hashes match the SUMS lines + (2b `17cd4872…`, 4b `c6074245…`). + +## 7. Honest residuals (all training/model-production, tracked in #9033) + +- 9b / 27b / 27b-256k tiers stay catalog-gated `pending` — need Gemma-4 fine-tunes. +- MTP: no Gemma drafters hosted (`mtp/drafter-.gguf` absent; candidates tree ships `mtp/MISSING.txt`); `files.mtp` and the catalog gate stay empty until they exist. +- ASR gguf on the hub is the frozen qwen3vl-lineage artifact; Gemma ASR is training-gated. +- Kokoro TTS audio-quality defect (native decoder/vocoder path) is unchanged by this pass — the restored Q4_K_M bytes are the exact bytes the manifest already pinned (tracked in the kokoro epic / #10727). diff --git a/.github/issue-evidence/kokoro-metal-perf/README.md b/.github/issue-evidence/kokoro-metal-perf/README.md new file mode 100644 index 0000000000000..f9ba0c06c7ee9 --- /dev/null +++ b/.github/issue-evidence/kokoro-metal-perf/README.md @@ -0,0 +1,46 @@ +# Kokoro TTS perf — profiled root cause + fix (417× total speedup, now faster than real-time) + +**Date:** 2026-07-02 · **Host:** M4 Max · **Build:** `build-desktop-metal` (Metal, `GGML_METAL_EMBED_LIBRARY=ON`, Release `-O3`). +**Phrase (both runs):** `"The quick brown fox jumps over the lazy dog near the riverbank."` · model `kokoro-82m-v1_0-Q4_K_M.gguf` (eliza-1-0_8b bundle) · voice `af_bella`. + +## Before → after (real measured numbers, same phrase/model/voice/harness) + +| Phase | Before (ms) | After (ms) | Speedup | +|---|---:|---:|---:| +| predictor forward | 24,188 | 113 | 214× | +| decoder front | 16,288 | 15 | 1,092× | +| gen: source + STFT | 66 | 27 | 2.4× | +| **generator (iSTFTNet)** | **261,220** | **595** | **439×** | +| decoder forward (total) | 277,509 | 610 | 455× | +| **synthesize total** | **301,697** | **723** | **417×** | + +**RTF:** 4.7 s of audio (112,800 samples @ 24 kHz) took 301.7 s (RTF ≈ 64× *slower* than real-time) → **0.72 s (RTF ≈ 0.15, i.e. ~6.5× faster than real-time)**. + +## Audio correctness (after == before) + +- `after.wav`: **samples=112800 (identical)**, rate=24000, peak **0.4195** (before 0.4212 — fp32 summation-order delta through the conv stacks + `exp()` spec head). +- Pearson correlation before↔after: **0.99959**; RMS 0.03924 vs 0.03924; max abs sample delta 0.0167 (±1 scale). +- faster-whisper (base) transcription of both WAVs: `"The quick brown fox jumps over the lazy dog near the riverbank."` — word-for-word identical. + +## Root cause (corrected from the baseline hypothesis) + +The baseline README hypothesized "conv ops falling back from Metal to CPU". Reality: **the iSTFTNet generator never enters ggml at all** — there is no ggml graph and therefore no Metal dispatch to fall back *from*. The whole StyleTTS-2 decoder (predictor, decoder front, iSTFTNet generator) is a hand-written, header-only, **single-threaded scalar** port (`tools/kokoro/include/kokoro-layers.h`, "CPU scalar" by design), with a branchy per-element bounds check in the innermost Conv1d loop. At the generator's ~85 GMACs per 4.7 s utterance, `-O3` scalar ≈ 261 s. `user≈real` in the baseline (`234 s user / 302 s real`, 1 thread) confirms pure CPU-bound scalar execution — not a shader/backend issue. + +## Fix (this change) + +`kokoro-layers.h` now routes the four hot primitives through **Apple Accelerate BLAS** (AMX-backed) on `__APPLE__`, keeping the portable scalar loops as the non-Apple fallback and readable reference: + +- `conv1d_forward` → im2col + one `cblas_sgemm` (PyTorch `[Cout, Cin, K]` weight is already a row-major `[Cout, Cin*K]` GEMM operand; stride/dilation/zero-pad baked into the column matrix). +- `convtranspose1d_forward` → one `cblas_sgemm` (`tmp[Cout*K, T] = Wᵀ·x`) + cheap col2im scatter-add. +- `linear_forward` → `cblas_sgemv`. +- `lstm_cell_step` gate pre-activations → two `cblas_sgemv` (this is what took the predictor 24.2 s → 0.11 s). + +`tools/kokoro/CMakeLists.txt` links `Accelerate.framework` into `kokoro_lib` (PUBLIC) on Apple; verified propagated into both `kokoro-tts` and the fused `libelizainference.dylib` (`otool -L`). Same math, same fp32 accumulation — only the summation order differs. + +## Remaining work (true GPU port — optional now) + +The fork's Metal backend already supports every op an iSTFTNet ggml graph would need (`GGML_OP_IM2COL`, `GGML_OP_CONV_TRANSPOSE_1D`, `GGML_OP_PAD_REFLECT_1D`, `GGML_OP_SIN`/`COS`/`EXP` for the Snake activation and spec/phase heads, `GGML_OP_NORM`, and the custom `GGML_OP_ISTFT` / ELIZA-ISTFT-DISPATCH-V1 — see `ggml/src/ggml-metal/ggml-metal-device.m`). Building the generator as a ggml graph on Metal is now a latency/energy optimization, not a correctness/usability blocker: at RTF 0.15 on CPU/AMX the vocoder is comfortably real-time. Non-Apple hosts (Android/Windows) still take the scalar path and would benefit first from a ggml-graph port or a NEON/threaded fallback. + +## Files +- `before-profile.log` / `before.wav` — baseline (scalar), RTF 64×. +- `after-profile.log` / `after.wav` — Accelerate BLAS path, RTF 0.15, audio equivalent (corr 0.99959, identical transcript). diff --git a/.github/issue-evidence/kokoro-metal-perf/after-profile.log b/.github/issue-evidence/kokoro-metal-perf/after-profile.log new file mode 100644 index 0000000000000..a6507cbae4d07 --- /dev/null +++ b/.github/issue-evidence/kokoro-metal-perf/after-profile.log @@ -0,0 +1,8 @@ +[kokoro-profile] predictor forward 113.0 ms +[kokoro-profile] decoder front 14.9 ms +[kokoro-profile] gen: source+stft 27.0 ms +[kokoro-profile] generator (iSTFTNet) 595.2 ms +[kokoro-profile] decoder forward 610.4 ms +[kokoro-profile] synthesize total 723.4 ms + 0.81 real 0.81 user 0.06 sys +kokoro-tts: wrote /Users/shawwalters/eliza-workspace/milady/eliza/.github/issue-evidence/kokoro-metal-perf/after.wav (samples=112800, rate=24000, peak=0.4195) diff --git a/.github/issue-evidence/kokoro-metal-perf/after.wav b/.github/issue-evidence/kokoro-metal-perf/after.wav new file mode 100644 index 0000000000000..7d4a4081ecbf5 Binary files /dev/null and b/.github/issue-evidence/kokoro-metal-perf/after.wav differ diff --git a/.github/issue-evidence/kokoro-metal-perf/before-profile.log b/.github/issue-evidence/kokoro-metal-perf/before-profile.log new file mode 100644 index 0000000000000..9bc1269b398b6 --- /dev/null +++ b/.github/issue-evidence/kokoro-metal-perf/before-profile.log @@ -0,0 +1,8 @@ +[kokoro-profile] predictor forward 24188.1 ms +[kokoro-profile] decoder front 16288.3 ms +[kokoro-profile] gen: source+stft 66.1 ms +[kokoro-profile] generator (iSTFTNet) 261219.8 ms +[kokoro-profile] decoder forward 277509.0 ms +[kokoro-profile] synthesize total 301697.1 ms +kokoro-tts: wrote /Users/shawwalters/eliza-workspace/milady/eliza/.github/issue-evidence/kokoro-metal-perf/before.wav (samples=112800, rate=24000, peak=0.4212) + 302.06 real 234.40 user 1.02 sys diff --git a/.github/issue-evidence/kokoro-metal-perf/before.wav b/.github/issue-evidence/kokoro-metal-perf/before.wav new file mode 100644 index 0000000000000..7f9b4835bc448 Binary files /dev/null and b/.github/issue-evidence/kokoro-metal-perf/before.wav differ diff --git a/.github/issue-evidence/vision-gemma4-describe/README.md b/.github/issue-evidence/vision-gemma4-describe/README.md new file mode 100644 index 0000000000000..7bd0e7f199108 --- /dev/null +++ b/.github/issue-evidence/vision-gemma4-describe/README.md @@ -0,0 +1,28 @@ +# eliza-1 vision (IMAGE_DESCRIPTION) — PROVEN working end-to-end through the fused product path + +**Date:** 2026-07-02 · **Tier:** eliza-1-2b (Gemma-4 E2B) · **Backend:** fused `libelizainference` (`activeBackendId=llama-cpp`), NOT `llama-mtmd-cli`. + +## What was wrong (and wasn't) +The long-standing "vision dimension mismatch (`text n_embd 2048 ≠ mmproj 1536`)" was a **phantom caused by a stale local model file**, not a code/model bug. The copy under `~/.local/state/eliza/models/bundles/2b/text/eliza-1-2b-128k.gguf` was a pre-cutover **qwen35** artifact (1211 MB, `embedding_length=2048`). The current HF `elizaos/eliza-1` file is **gemma4** (4737 MB, `embedding_length=1536`) and matches `mmproj-2b` (`projector_type=gemma4v`, `projection_dim=1536`). 4b pairs identically: gemma4 `embedding_length=2560` = `mmproj-4b` `projection_dim=2560`. Both shipping tiers are correctly paired on HF. + +## Proof — the real product path +Harness drove `createImageDescriptionRuntime(tier=eliza-1-2b, root=/tmp/vision/gemma4/bundles/2b)` → `engine.canDescribeImages()=true` → invoked `ModelType.IMAGE_DESCRIPTION` via the **MemoryArbiter path** (the same path the running agent uses), against the real gemma4-2b bundle + `mmproj-2b.gguf` + `input-test.jpg`. + +- `image slice encoded in 518 ms`, `image decoded (batch 1/1) in 37 ms`, **handler returned in 9586 ms** +- Marker: `ELIZA1_VISION_HANDLER_PRESENT=1` +- The gemma4 chat template (`<|image>` sentinels, 256 image tokens) is applied **inside** the fused describe path — no external `--jinja` needed at the product layer. + +### Model output (full description, verbatim excerpt) +> The image is a diagram or logo featuring two distinct elements: a red circle and a blue square. +> 1. **Red Circle:** There is a large, solid red circle in the center-left of the image. +> 2. **Blue Square:** There is a solid blue square in the center-right of the image. +> The word "HELLO" appears twice in the image: once below the red circle, once below the blue square. + +The test image (`input-test.jpg`) is exactly a red circle + blue rectangle + the word "HELLO" — the description is **fully correct**, including spatial layout and the doubled text. This is real on-device vision, not a mock. + +## Files +- `fused-describe-run.log` — full run log (bundle load → arbiter IMAGE_DESCRIPTION → description → unload). +- `input-test.jpg` — the input image. + +## Related issues +Evidence for the vision leg of **#9033** (Gemma-4 cutover + multi-backend `libelizainference`) and **#10727** (local-model full-lifecycle verification). Not a standalone close — both are broader umbrellas. diff --git a/.github/issue-evidence/vision-gemma4-describe/input-test.jpg b/.github/issue-evidence/vision-gemma4-describe/input-test.jpg new file mode 100644 index 0000000000000..0ceab266b385e Binary files /dev/null and b/.github/issue-evidence/vision-gemma4-describe/input-test.jpg differ diff --git a/packages/shared/src/local-inference/catalog.test.ts b/packages/shared/src/local-inference/catalog.test.ts index 16b72e28e5cdd..66c807ff2c6ef 100644 --- a/packages/shared/src/local-inference/catalog.test.ts +++ b/packages/shared/src/local-inference/catalog.test.ts @@ -72,13 +72,28 @@ describe("Eliza-1 runtime quant metadata", () => { } }); - it("does not advertise Gemma MTP metadata until drafter GGUFs are hosted", () => { + it("advertises Gemma MTP metadata only for tiers with hosted drafter GGUFs", () => { expect(ELIZA_1_MTP_TIER_IDS).toEqual(ELIZA_1_TIER_IDS); - expect(ELIZA_1_HOSTED_MTP_TIER_IDS).toEqual([]); + // 2b hosts the gemma4-assistant drafter at bundles/2b/mtp/drafter-2b.gguf + // (converted from google/gemma-4-E2B-it-assistant, 2026-07-02). + expect(ELIZA_1_HOSTED_MTP_TIER_IDS).toEqual(["eliza-1-2b"]); + const hosted: ReadonlySet = new Set(ELIZA_1_HOSTED_MTP_TIER_IDS); for (const id of ELIZA_1_MTP_TIER_IDS) { const entry = MODEL_CATALOG.find((model) => model.id === id); - expect(entry?.runtime?.mtp).toBeUndefined(); - expect(entry?.sourceModel?.components.mtp).toBeUndefined(); + const slug = id.slice("eliza-1-".length); + if (hosted.has(id)) { + expect(entry?.runtime?.mtp?.specType).toBe("draft-mtp"); + expect(entry?.runtime?.mtp?.drafterFile).toBe( + `mtp/drafter-${slug}.gguf`, + ); + expect(entry?.runtime?.mtp?.draftMax).toBe(1); + expect(entry?.sourceModel?.components.mtp?.file).toBe( + `bundles/${slug}/mtp/drafter-${slug}.gguf`, + ); + } else { + expect(entry?.runtime?.mtp).toBeUndefined(); + expect(entry?.sourceModel?.components.mtp).toBeUndefined(); + } } }); diff --git a/packages/shared/src/local-inference/catalog.ts b/packages/shared/src/local-inference/catalog.ts index 689d01903a8ec..bcc034b527172 100644 --- a/packages/shared/src/local-inference/catalog.ts +++ b/packages/shared/src/local-inference/catalog.ts @@ -63,13 +63,19 @@ export const ELIZA_1_MTP_TIER_IDS = [ * Tiers whose Gemma MTP drafter GGUFs are present at * `bundles//mtp/drafter-.gguf` in the active HF tree. * - * Current HF state (2026-06-25): the active bundles only expose legacy - * `dflash/` drafter paths, while the Gemma candidate publishes - * `candidates/gemma-2b-base-v1/mtp/MISSING.txt`. Keep this empty so the - * runtime and downloader do not advertise or fetch missing MTP artifacts. + * Current HF state (2026-07-02): `bundles/2b/mtp/drafter-2b.gguf` hosts the + * gemma4-assistant drafter converted from `google/gemma-4-E2B-it-assistant` + * (arch `gemma4-assistant`, f16, embedding_length_out=1536; sha256 + * 0495d34e08d0…, manifest `files.mtp` + `lineage.drafter` + `evals.mtp` + * populated — acceptance 0.84, speedup ~1.53x greedy on M4 Max Metal at + * `--spec-draft-n-max 1`). The remaining tiers still only expose legacy + * `dflash/` paths; add a tier here only once its `mtp/drafter-.gguf` + * is actually hosted, so the runtime and downloader never advertise or + * fetch missing MTP artifacts. */ -export const ELIZA_1_HOSTED_MTP_TIER_IDS = - [] as const satisfies ReadonlyArray; +export const ELIZA_1_HOSTED_MTP_TIER_IDS = [ + "eliza-1-2b", +] as const satisfies ReadonlyArray; function hostedMtpDrafterAvailableForTier(id: Eliza1TierId): boolean { return ELIZA_1_HOSTED_MTP_TIER_IDS.some((mtpId) => mtpId === id); @@ -409,10 +415,10 @@ function sourceModelForTier(id: Eliza1TierId): CatalogModel["sourceModel"] { `vision/mmproj-${tierSlug(id)}.gguf`, ); } - // Separate-drafter MTP remains the Gemma release target, but the active HF - // tree does not host `mtp/drafter-.gguf` yet. The available `dflash/` - // files are legacy artifacts, so only advertise this component when the - // hosted Gemma drafter list is explicitly populated. + // Separate-drafter MTP is the Gemma release shape. Advertise the component + // only for tiers whose gemma4-assistant drafter GGUF is actually hosted at + // `bundles//mtp/drafter-.gguf` (ELIZA_1_HOSTED_MTP_TIER_IDS); + // the `dflash/` files still present on other tiers are legacy artifacts. if (hostedMtpDrafterAvailableForTier(id)) { components.mtp = bundleComponent(id, `mtp/drafter-${tierSlug(id)}.gguf`); } diff --git a/plugins/plugin-local-inference/__tests__/mmproj-routing.test.ts b/plugins/plugin-local-inference/__tests__/mmproj-routing.test.ts index 6d9fd6ebdbcb4..03fb2c6829f1c 100644 --- a/plugins/plugin-local-inference/__tests__/mmproj-routing.test.ts +++ b/plugins/plugin-local-inference/__tests__/mmproj-routing.test.ts @@ -140,11 +140,35 @@ describe("WS2 mmproj routing", () => { expect(resolved.modelPath).toBe(bundle.textPath); }); - it("ignores an on-disk MTP drafter until the catalog advertises hosted Gemma MTP", async () => { + it("resolves the bundled gemma4-assistant drafter for the hosted MTP tier (2b)", async () => { const tier = "2b"; - // The active HF tree does not yet host `mtp/drafter-.gguf` for - // Gemma, so the catalog must not enable speculative decoding just because - // a local file with that shape exists. + // bundles/2b/mtp/drafter-2b.gguf is hosted (gemma4-assistant, converted + // from google/gemma-4-E2B-it-assistant) and the catalog advertises + // runtime.mtp for eliza-1-2b, so the resolver must wire the on-disk + // drafter with the catalog's draft window. + const catalog = findCatalogModel(`eliza-1-${tier}`); + expect(catalog?.runtime?.mtp?.specType).toBe("draft-mtp"); + const bundle = makeTempBundle({ hasMmproj: true, hasMtp: true, tier }); + const installed = installedModel({ + id: `eliza-1-${tier}`, + bundleRoot: bundle.bundleRoot, + path: bundle.textPath, + }); + const resolved = await resolveLocalInferenceLoadArgs(installed); + expect(resolved.modelPath).toBe(bundle.textPath); + expect(resolved.draftModelPath).toBe( + pathJoin(bundle.bundleRoot, "mtp", `drafter-${tier}.gguf`), + ); + expect(resolved.draftMin).toBe(catalog?.runtime?.mtp?.draftMin); + expect(resolved.draftMax).toBe(catalog?.runtime?.mtp?.draftMax); + }); + + it("ignores an on-disk MTP drafter for tiers without a hosted Gemma drafter", async () => { + const tier = "4b"; + // The active HF tree does not host `mtp/drafter-4b.gguf`, so the catalog + // must not enable speculative decoding just because a local file with + // that shape exists. + expect(findCatalogModel(`eliza-1-${tier}`)?.runtime?.mtp).toBeUndefined(); const bundle = makeTempBundle({ hasMmproj: true, hasMtp: true, tier }); const installed = installedModel({ id: `eliza-1-${tier}`, diff --git a/plugins/plugin-local-inference/native/llama.cpp b/plugins/plugin-local-inference/native/llama.cpp index ba598f562576d..114eee08ea1b6 160000 --- a/plugins/plugin-local-inference/native/llama.cpp +++ b/plugins/plugin-local-inference/native/llama.cpp @@ -1 +1 @@ -Subproject commit ba598f562576df61b2a3faba69c4c9cf1e1ce40f +Subproject commit 114eee08ea1b678b7d9c7fbe48e0586685f76904 diff --git a/plugins/plugin-local-inference/src/services/catalog.test.ts b/plugins/plugin-local-inference/src/services/catalog.test.ts index ced6d12cd0096..bf08283706db5 100644 --- a/plugins/plugin-local-inference/src/services/catalog.test.ts +++ b/plugins/plugin-local-inference/src/services/catalog.test.ts @@ -125,22 +125,26 @@ describe("local inference catalog", () => { expect(offenders).toEqual([]); }); - it("does not declare native MTP until Gemma drafter GGUFs are hosted", () => { + it("declares native MTP exactly for the tiers with hosted Gemma drafter GGUFs", () => { const hostedMtpTiers: ReadonlySet = new Set( ELIZA_1_HOSTED_MTP_TIER_IDS, ); expect(ELIZA_1_MTP_TIER_IDS).toEqual(ELIZA_1_TIER_IDS); - expect(ELIZA_1_HOSTED_MTP_TIER_IDS).toEqual([]); + // 2b hosts the gemma4-assistant drafter at bundles/2b/mtp/drafter-2b.gguf + // (converted from google/gemma-4-E2B-it-assistant, 2026-07-02). + expect(ELIZA_1_HOSTED_MTP_TIER_IDS).toEqual(["eliza-1-2b"]); for (const id of ELIZA_1_MTP_TIER_IDS) { const model = findCatalogModel(id); - expect(model?.runtime?.mtp, `${id} mtp`).toBeUndefined(); expect(model?.companionModelIds, `${id} companions`).toBeUndefined(); - } - for (const id of ELIZA_1_TIER_IDS.filter( - (tier) => !hostedMtpTiers.has(tier), - )) { - const model = findCatalogModel(id); - expect(model?.runtime?.mtp, `${id} mtp`).toBeUndefined(); + if (hostedMtpTiers.has(id)) { + const slug = id.slice("eliza-1-".length); + expect(model?.runtime?.mtp?.specType, `${id} mtp`).toBe("draft-mtp"); + expect(model?.runtime?.mtp?.drafterFile, `${id} drafter`).toBe( + `mtp/drafter-${slug}.gguf`, + ); + } else { + expect(model?.runtime?.mtp, `${id} mtp`).toBeUndefined(); + } } }); diff --git a/plugins/plugin-local-inference/src/services/downloader.test.ts b/plugins/plugin-local-inference/src/services/downloader.test.ts index 48950e0105042..7f7f74c57921a 100644 --- a/plugins/plugin-local-inference/src/services/downloader.test.ts +++ b/plugins/plugin-local-inference/src/services/downloader.test.ts @@ -216,6 +216,99 @@ function installFetchFixture(files: Map): void { }) as unknown as typeof fetch; } +/** + * A fetch fixture that honors `Range: bytes=N-` the way the HuggingFace CDN + * does (HTTP 206 + the current file's bytes from offset N). This is what makes + * the stale-partial corruption reproducible: a Range resume against a + * re-published file appends NEW-version bytes onto OLD-version bytes. + * Returns the ranges each remote path was requested with, so tests can assert + * resume-vs-fresh behavior. + */ +function installRangeAwareFetchFixture(files: Map): { + rangeRequests: Map; +} { + const rangeRequests = new Map(); + globalThis.fetch = vi.fn( + async (url: string | URL | Request, init?: RequestInit) => { + const remotePath = remotePathOf(url); + const body = files.get(remotePath); + if (body === undefined) { + return new Response(`missing ${remotePath}`, { status: 404 }); + } + const headers = (init?.headers ?? {}) as Record; + const range = headers.range; + if (range) { + const seen = rangeRequests.get(remotePath) ?? []; + seen.push(range); + rangeRequests.set(remotePath, seen); + const match = /^bytes=(\d+)-$/.exec(range); + const start = match?.[1] ? Number.parseInt(match[1], 10) : 0; + const buf = Buffer.from(body); + const tail = buf.subarray(start); + return new Response(tail, { + status: 206, + headers: { + "content-length": String(tail.length), + "content-range": `bytes ${start}-${buf.length - 1}/${buf.length}`, + }, + }); + } + return new Response(body, { + status: 200, + headers: { "content-length": String(Buffer.byteLength(body)) }, + }); + }, + ) as unknown as typeof fetch; + return { rangeRequests }; +} + +/** Standard 2b bundle content set for stale-content robustness tests. */ +const freshBundleBytes = { + text: "GGUF gemma4 text model (4737MB in prod, tiny here)", + voice: "GGUF voice model", + asr: "GGUF asr model", + vad: "VAD onnx", + cache: "voice preset", + vision: "vision projector", +} as const; + +function freshBundleFixtureFiles(): Map { + const manifest = eliza1Manifest({ + shaFor: (k) => sha256(freshBundleBytes[k as keyof typeof freshBundleBytes]), + }); + return new Map([ + [eliza1BundleManifestPath(), manifest], + [ + eliza1BundleRemotePath("text/eliza-1-2b-128k.gguf"), + freshBundleBytes.text, + ], + [eliza1BundleRemotePath("tts/voice.gguf"), freshBundleBytes.voice], + [eliza1BundleRemotePath("asr/asr.gguf"), freshBundleBytes.asr], + [eliza1BundleRemotePath("vad/eliza-1-vad.onnx"), freshBundleBytes.vad], + [ + eliza1BundleRemotePath("cache/voice-preset-default.bin"), + freshBundleBytes.cache, + ], + [eliza1BundleRemotePath("vision/mmproj-2b.gguf"), freshBundleBytes.vision], + ]); +} + +/** Staging `.part` path the downloader derives for a 2b bundle file. */ +function eliza1StagingPartPath(root: string, filePath: string): string { + const safe = `eliza-1-2b__${filePath}`.replace(/[^a-zA-Z0-9._-]/g, "_"); + return path.join(root, "local-inference", "downloads", `${safe}.part`); +} + +function eliza1BundleFinalPath(root: string, filePath: string): string { + return path.join( + root, + "local-inference", + "models", + "eliza-1-2b.bundle", + filePath, + ); +} + function waitForTerminal( downloader: Downloader, modelId: string, @@ -447,7 +540,15 @@ describe("local inference downloader status", () => { expect(job.error).toContain( `SHA256 mismatch for bundle file ${model.bundleManifestFile}`, ); - expect(fetchSpy).toHaveBeenCalledTimes(1); + // The sha gate re-fetches once (bounded) to rule out a transient/stale + // CDN edge before failing. Both calls are manifest fetches — no weight + // byte is ever requested. + expect(fetchSpy).toHaveBeenCalledTimes(2); + for (const [u] of fetchSpy.mock.calls) { + expect(remotePathOf(u as string | URL | Request)).toBe( + eliza1BundleManifestPath(), + ); + } }); it("rejects custom CatalogModel specs before starting a download", async () => { @@ -892,3 +993,234 @@ describe("local inference downloader status", () => { expect(fetchSpy).not.toHaveBeenCalled(); }); }); + +/** + * Hub re-publish robustness: HuggingFace re-uploads bundle files under STABLE + * filenames (the real incident: `bundles/2b/text/eliza-1-2b-128k.gguf` went + * from qwen35 1211MB to gemma4 4737MB). A device holding the old bytes — as a + * completed install or an interrupted `.part` — must detect the mismatch + * against the freshly fetched manifest and re-pull cleanly, never resume the + * stale bytes into corruption or silently keep them. + * + * These tests drive the REAL Downloader end to end (staging, Range resume, + * rename, hashFile, registry); only the network edge is a fixture, and it + * honors Range requests exactly like the HF CDN so the corruption path is + * actually reachable. + */ +describe("local inference downloader stale-content robustness", () => { + it("re-downloads a completed bundle file whose hub content changed under the same filename", async () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-download-test-")); + process.env.ELIZA_STATE_DIR = root; + const model = findCatalogModel("eliza-1-2b"); + if (!model) throw new Error("missing test catalog model"); + installFetchFixture(freshBundleFixtureFiles()); + + // The incident: a previous install left the OLD model at the SAME final + // path inside the bundle root, and the registry considers it installed. + const textFinal = eliza1BundleFinalPath(root, "text/eliza-1-2b-128k.gguf"); + fs.mkdirSync(path.dirname(textFinal), { recursive: true }); + fs.writeFileSync( + textFinal, + "GGUF qwen35 stale text model (1211MB in prod)", + ); + + const downloader = new Downloader({ + probeDeviceCaps: async () => cpuOnlyCaps, + }); + const completed = waitForTerminal(downloader, model.id); + await downloader.start(model.id); + const job = await completed; + + expect(job.state).toBe("completed"); + // The stale blob was replaced by the current content, byte for byte. + expect(fs.readFileSync(textFinal, "utf8")).toBe(freshBundleBytes.text); + const main = readOwnedRegistryModels().find((m) => m.id === model.id); + expect(main?.sha256).toBe(sha256(freshBundleBytes.text)); + }); + + it("discards a stale .part instead of range-resuming it into a corrupt blob", async () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-download-test-")); + process.env.ELIZA_STATE_DIR = root; + const model = findCatalogModel("eliza-1-2b"); + if (!model) throw new Error("missing test catalog model"); + const { rangeRequests } = installRangeAwareFetchFixture( + freshBundleFixtureFiles(), + ); + + // Two stale-partial provenances, both from the OLD content version: + // - text: `.part` stamped with the OLD content's sha (a download of the + // qwen35 file was interrupted, then the hub re-published gemma4); + // - voice: `.part` with no sidecar at all (pre-fix partial, unknown + // provenance). + // Resuming either would append new-version bytes onto old-version bytes. + const textPart = eliza1StagingPartPath(root, "text/eliza-1-2b-128k.gguf"); + fs.mkdirSync(path.dirname(textPart), { recursive: true }); + fs.writeFileSync(textPart, "GGUF qwen35 partial"); + fs.writeFileSync( + `${textPart}.expected`, + sha256("GGUF qwen35 stale text model (1211MB in prod)"), + ); + const voicePart = eliza1StagingPartPath(root, "tts/voice.gguf"); + fs.writeFileSync(voicePart, "GGUF old voice par"); + + const downloader = new Downloader({ + probeDeviceCaps: async () => cpuOnlyCaps, + }); + const completed = waitForTerminal(downloader, model.id); + await downloader.start(model.id); + const job = await completed; + + expect(job.state).toBe("completed"); + // Neither stale partial was resumed: no Range request went out for them. + expect( + rangeRequests.get(eliza1BundleRemotePath("text/eliza-1-2b-128k.gguf")), + ).toBeUndefined(); + expect( + rangeRequests.get(eliza1BundleRemotePath("tts/voice.gguf")), + ).toBeUndefined(); + // The installed files are the current content, byte for byte. + expect( + fs.readFileSync( + eliza1BundleFinalPath(root, "text/eliza-1-2b-128k.gguf"), + "utf8", + ), + ).toBe(freshBundleBytes.text); + expect( + fs.readFileSync(eliza1BundleFinalPath(root, "tts/voice.gguf"), "utf8"), + ).toBe(freshBundleBytes.voice); + const main = readOwnedRegistryModels().find((m) => m.id === model.id); + expect(main?.sha256).toBe(sha256(freshBundleBytes.text)); + // No staging residue (part or sidecar) left behind. + expect(fs.existsSync(textPart)).toBe(false); + expect(fs.existsSync(`${textPart}.expected`)).toBe(false); + }); + + it("still range-resumes a valid .part recorded against the current manifest sha", async () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-download-test-")); + process.env.ELIZA_STATE_DIR = root; + const model = findCatalogModel("eliza-1-2b"); + if (!model) throw new Error("missing test catalog model"); + const { rangeRequests } = installRangeAwareFetchFixture( + freshBundleFixtureFiles(), + ); + + // A genuine interrupted download of the CURRENT content: the partial is + // a strict prefix and the sidecar records the current manifest sha. + const prefixLen = 17; + const textPart = eliza1StagingPartPath(root, "text/eliza-1-2b-128k.gguf"); + fs.mkdirSync(path.dirname(textPart), { recursive: true }); + fs.writeFileSync(textPart, freshBundleBytes.text.slice(0, prefixLen)); + fs.writeFileSync(`${textPart}.expected`, sha256(freshBundleBytes.text)); + + const downloader = new Downloader({ + probeDeviceCaps: async () => cpuOnlyCaps, + }); + const completed = waitForTerminal(downloader, model.id); + await downloader.start(model.id); + const job = await completed; + + expect(job.state).toBe("completed"); + // The resume path fired: one Range request from the partial's offset... + expect( + rangeRequests.get(eliza1BundleRemotePath("text/eliza-1-2b-128k.gguf")), + ).toEqual([`bytes=${prefixLen}-`]); + // ...and prefix + tail joined into the exact current content. + expect( + fs.readFileSync( + eliza1BundleFinalPath(root, "text/eliza-1-2b-128k.gguf"), + "utf8", + ), + ).toBe(freshBundleBytes.text); + const main = readOwnedRegistryModels().find((m) => m.id === model.id); + expect(main?.sha256).toBe(sha256(freshBundleBytes.text)); + }); + + it("re-fetches from scratch when a completed transfer fails the sha gate (stale edge)", async () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-download-test-")); + process.env.ELIZA_STATE_DIR = root; + const model = findCatalogModel("eliza-1-2b"); + if (!model) throw new Error("missing test catalog model"); + + // First fetch of the text file serves stale bytes (e.g. a CDN edge that + // has not seen the re-publish yet); the second serves the current bytes. + const files = freshBundleFixtureFiles(); + const textRemote = eliza1BundleRemotePath("text/eliza-1-2b-128k.gguf"); + let textServes = 0; + globalThis.fetch = vi.fn(async (url: string | URL | Request) => { + const remotePath = remotePathOf(url); + let body = files.get(remotePath); + if (body === undefined) { + return new Response(`missing ${remotePath}`, { status: 404 }); + } + if (remotePath === textRemote) { + textServes += 1; + if (textServes === 1) body = "GGUF qwen35 stale text model"; + } + return new Response(body, { + status: 200, + headers: { "content-length": String(Buffer.byteLength(body)) }, + }); + }) as unknown as typeof fetch; + + const downloader = new Downloader({ + probeDeviceCaps: async () => cpuOnlyCaps, + }); + const completed = waitForTerminal(downloader, model.id); + await downloader.start(model.id); + const job = await completed; + + expect(job.state).toBe("completed"); + expect(textServes).toBe(2); + expect( + fs.readFileSync( + eliza1BundleFinalPath(root, "text/eliza-1-2b-128k.gguf"), + "utf8", + ), + ).toBe(freshBundleBytes.text); + const main = readOwnedRegistryModels().find((m) => m.id === model.id); + expect(main?.sha256).toBe(sha256(freshBundleBytes.text)); + }); + + it("fails after bounded re-fetches and leaves no wrong-content file on disk", async () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-download-test-")); + process.env.ELIZA_STATE_DIR = root; + const model = findCatalogModel("eliza-1-2b"); + if (!model) throw new Error("missing test catalog model"); + + // The hub persistently serves bytes that do not match the manifest sha + // (manifest and weights out of sync). Every attempt must be discarded. + const files = freshBundleFixtureFiles(); + const textRemote = eliza1BundleRemotePath("text/eliza-1-2b-128k.gguf"); + files.set(textRemote, "GGUF qwen35 stale text model"); + + installFetchFixture(files); + + const downloader = new Downloader({ + probeDeviceCaps: async () => cpuOnlyCaps, + }); + const failed = new Promise((resolve) => { + const unsub = downloader.subscribe((event) => { + if (event.job.modelId === model.id && event.type === "failed") { + unsub(); + resolve(event.job); + } + }); + }); + await downloader.start(model.id); + const job = await failed; + + expect(job.error).toMatch( + /SHA256 mismatch for bundle file text\/eliza-1-2b-128k\.gguf after 2 attempts/, + ); + // The wrong bytes never survive under the final name, nothing is + // registered, and no staging residue remains. + const textFinal = eliza1BundleFinalPath(root, "text/eliza-1-2b-128k.gguf"); + expect(fs.existsSync(textFinal)).toBe(false); + expect(readOwnedRegistryModels().some((m) => m.id === model.id)).toBe( + false, + ); + const textPart = eliza1StagingPartPath(root, "text/eliza-1-2b-128k.gguf"); + expect(fs.existsSync(textPart)).toBe(false); + expect(fs.existsSync(`${textPart}.expected`)).toBe(false); + }); +}); diff --git a/plugins/plugin-local-inference/src/services/downloader.ts b/plugins/plugin-local-inference/src/services/downloader.ts index 618040a72bb49..76e7e388ce234 100644 --- a/plugins/plugin-local-inference/src/services/downloader.ts +++ b/plugins/plugin-local-inference/src/services/downloader.ts @@ -160,6 +160,15 @@ const TERMINAL_DOWNLOADS_FILENAME = "download-status.json"; const TERMINAL_DOWNLOAD_LIMIT = 32; /** Headroom kept free above the download size for the disk-space preflight. */ const DISK_HEADROOM_GB = 0.5; +/** + * Attempts per sha256-verified bundle file. The hub re-publishes files under + * stable names (a tier's weights can move to a new base model), so a mismatch + * after a completed transfer can be a transient race (stale CDN edge, content + * changed mid-download) — one clean re-fetch from byte 0 resolves those; a + * second mismatch means the manifest and the published bytes genuinely + * disagree and the job fails. + */ +const SHA_MISMATCH_MAX_ATTEMPTS = 2; interface TerminalDownloadsFile { version: 1; @@ -312,6 +321,53 @@ async function partialSize(stagingPath: string): Promise { } } +/** Sidecar recording which expected sha256 a `.part` file was started against. */ +function stagingMetaPath(stagingPath: string): string { + return `${stagingPath}.expected`; +} + +/** + * A `.part` file is resumable only when it was started against the SAME + * content hash the current manifest declares for the file. HuggingFace + * re-publishes bundle files under stable names (e.g. `eliza-1-2b-128k.gguf` + * moving from qwen35 to gemma4 weights), so a partial from a previous + * manifest version must be discarded — a Range resume would append + * new-version bytes onto old-version bytes and produce a corrupt blob that + * only fails at the final sha256 gate, gigabytes later. A partial with no + * sidecar has unknown provenance and is discarded too. + */ +async function resumableStartByte( + stagingPath: string, + expectedSha256: string, +): Promise { + const size = await partialSize(stagingPath); + if (size <= 0) { + await fsp + .rm(stagingMetaPath(stagingPath), { force: true }) + .catch(() => undefined); + return 0; + } + let recorded: string | undefined; + try { + recorded = ( + await fsp.readFile(stagingMetaPath(stagingPath), "utf8") + ).trim(); + } catch { + recorded = undefined; + } + if (recorded === expectedSha256) return size; + logger.warn( + `[Downloader] discarding stale partial ${path.basename(stagingPath)} ` + + `(started against ${recorded ? `sha256 ${recorded.slice(0, 12)}…` : "unknown content"}, ` + + `manifest now expects ${expectedSha256.slice(0, 12)}…)`, + ); + await fsp.rm(stagingPath, { force: true }).catch(() => undefined); + await fsp + .rm(stagingMetaPath(stagingPath), { force: true }) + .catch(() => undefined); + return 0; +} + export class Downloader { private readonly active = new Map(); private readonly terminal = new Map(); @@ -910,6 +966,12 @@ export class Downloader { sha256: currentSha256, }; } + // Same filename, different content: the hub re-published this + // path. The stale blob must never be kept — discard and re-fetch. + logger.warn( + `[Downloader] stale ${remotePath} on disk ` + + `(sha256 ${currentSha256.slice(0, 12)}… != manifest ${expectedSha256.slice(0, 12)}…); re-downloading`, + ); await fsp.rm(finalPath, { force: true }); } } catch { @@ -923,83 +985,110 @@ export class Downloader { await fsp.mkdir(path.dirname(finalPath), { recursive: true }); await fsp.mkdir(path.dirname(stagingPath), { recursive: true }); - let startByte = expectedSha256 ? await partialSize(stagingPath) : 0; - record.job.received = baseBytes + startByte; + const maxAttempts = expectedSha256 ? SHA_MISMATCH_MAX_ATTEMPTS : 1; + for (let attempt = 1; ; attempt++) { + let startByte = 0; + if (expectedSha256) { + startByte = await resumableStartByte(stagingPath, expectedSha256); + // Stamp the partial with the content hash it is being fetched + // against so a later resume can tell whether the .part still + // belongs to THIS content version. + await fsp.writeFile( + stagingMetaPath(stagingPath), + expectedSha256, + "utf8", + ); + } + record.job.received = baseBytes + startByte; - const url = buildHuggingFaceResolveUrlForPath(catalogEntry, remotePath); - const headers: Record = { - "user-agent": "Eliza-LocalInference/1.0", - ...resolveHfDownloadBase().authHeader, - }; - if (startByte > 0) { - headers.range = `bytes=${startByte}-`; - } + const url = buildHuggingFaceResolveUrlForPath(catalogEntry, remotePath); + const headers: Record = { + "user-agent": "Eliza-LocalInference/1.0", + ...resolveHfDownloadBase().authHeader, + }; + if (startByte > 0) { + headers.range = `bytes=${startByte}-`; + } - const httpClient = await this.loadHttpClient(); - const response = await httpClient.request(url, { - method: "GET", - headers, - signal: record.abortController.signal, - }); + const httpClient = await this.loadHttpClient(); + const response = await httpClient.request(url, { + method: "GET", + headers, + signal: record.abortController.signal, + }); - if (response.statusCode >= 400) { - throw new Error( - `HTTP ${response.statusCode} from model hub for ${catalogEntry.hfRepo}/${remotePath}`, - ); - } - if (startByte > 0 && response.statusCode !== 206) { - startByte = 0; - record.job.received = baseBytes; - } + if (response.statusCode >= 400) { + throw new Error( + `HTTP ${response.statusCode} from model hub for ${catalogEntry.hfRepo}/${remotePath}`, + ); + } + if (startByte > 0 && response.statusCode !== 206) { + startByte = 0; + record.job.received = baseBytes; + } - const contentLengthHeader = response.headers["content-length"]; - const contentLength = Array.isArray(contentLengthHeader) - ? Number.parseInt(contentLengthHeader[0] ?? "0", 10) - : Number.parseInt(contentLengthHeader ?? "0", 10); - if (Number.isFinite(contentLength) && contentLength > 0) { - record.job.total = Math.max( - record.job.total, - baseBytes + startByte + contentLength, - ); - } + const contentLengthHeader = response.headers["content-length"]; + const contentLength = Array.isArray(contentLengthHeader) + ? Number.parseInt(contentLengthHeader[0] ?? "0", 10) + : Number.parseInt(contentLengthHeader ?? "0", 10); + if (Number.isFinite(contentLength) && contentLength > 0) { + record.job.total = Math.max( + record.job.total, + baseBytes + startByte + contentLength, + ); + } - const writeStream: Writable = fs.createWriteStream(stagingPath, { - flags: startByte > 0 ? "a" : "w", - }); + const writeStream: Writable = fs.createWriteStream(stagingPath, { + flags: startByte > 0 ? "a" : "w", + }); - let lastSampleBytes = record.job.received; - let lastSampleAt = Date.now(); - const bodyStream = Readable.from(response.body); - bodyStream.on("data", (chunk: Buffer) => { - record.job.received += chunk.length; - - const now = Date.now(); - const elapsed = now - lastSampleAt; - if (elapsed >= 1000) { - record.job.bytesPerSec = - ((record.job.received - lastSampleBytes) * 1000) / elapsed; - record.job.etaMs = - record.job.bytesPerSec > 0 - ? ((record.job.total - record.job.received) * 1000) / - record.job.bytesPerSec - : null; - lastSampleAt = now; - lastSampleBytes = record.job.received; - } + let lastSampleBytes = record.job.received; + let lastSampleAt = Date.now(); + const bodyStream = Readable.from(response.body); + bodyStream.on("data", (chunk: Buffer) => { + record.job.received += chunk.length; - this.throttleEmit(record); - }); + const now = Date.now(); + const elapsed = now - lastSampleAt; + if (elapsed >= 1000) { + record.job.bytesPerSec = + ((record.job.received - lastSampleBytes) * 1000) / elapsed; + record.job.etaMs = + record.job.bytesPerSec > 0 + ? ((record.job.total - record.job.received) * 1000) / + record.job.bytesPerSec + : null; + lastSampleAt = now; + lastSampleBytes = record.job.received; + } - await pipeline(bodyStream, writeStream); - await fsp.rename(stagingPath, finalPath); + this.throttleEmit(record); + }); - const stat = await fsp.stat(finalPath); - const sha256 = await hashFile(finalPath); - if (expectedSha256 && sha256 !== expectedSha256) { - await fsp.rm(finalPath, { force: true }); - throw new Error(`SHA256 mismatch for bundle file ${remotePath}`); + await pipeline(bodyStream, writeStream); + await fsp.rename(stagingPath, finalPath); + + const stat = await fsp.stat(finalPath); + const sha256 = await hashFile(finalPath); + await fsp + .rm(stagingMetaPath(stagingPath), { force: true }) + .catch(() => undefined); + if (expectedSha256 && sha256 !== expectedSha256) { + // Wrong bytes must never stay on disk under the final name. + await fsp.rm(finalPath, { force: true }); + if (attempt < maxAttempts) { + logger.warn( + `[Downloader] SHA256 mismatch for bundle file ${remotePath} ` + + `(attempt ${attempt}/${maxAttempts}); re-fetching from scratch`, + ); + continue; + } + throw new Error( + `SHA256 mismatch for bundle file ${remotePath} after ${maxAttempts} attempts`, + ); + } + return { path: finalPath, sizeBytes: stat.size, sha256 }; } - return { path: finalPath, sizeBytes: stat.size, sha256 }; } private async loadHttpClient(): Promise<{ diff --git a/plugins/plugin-local-inference/src/services/system-memory.test.ts b/plugins/plugin-local-inference/src/services/system-memory.test.ts index deb9a18a1cf17..62d4c2bd3dff0 100644 --- a/plugins/plugin-local-inference/src/services/system-memory.test.ts +++ b/plugins/plugin-local-inference/src/services/system-memory.test.ts @@ -9,6 +9,21 @@ Cached: 7651200 kB SwapTotal: 0 kB `; +// Real M4 Max capture: freemem() saw only "Pages free" (7.2 GiB of 128 GiB, +// under the 5% critical water mark) while the kernel held ~52 GiB of +// reclaimable inactive file cache. +const SAMPLE_VM_STAT = `Mach Virtual Memory Statistics: (page size of 16384 bytes) +Pages free: 462821. +Pages active: 3371849. +Pages inactive: 3305280. +Pages speculative: 57490. +Pages throttled: 0. +Pages wired down: 446316. +Pages purgeable: 2266. +"Translation faults": 18052423203. +Pages copy-on-write: 589493003. +`; + describe("readSystemMemory", () => { it("prefers MemAvailable + MemTotal from /proc/meminfo", () => { const mem = readSystemMemory(() => SAMPLE_MEMINFO); @@ -44,4 +59,37 @@ describe("readSystemMemory", () => { expect(mem.totalBytes).toBeGreaterThan(0); expect(mem.freeBytes).toBeGreaterThan(0); }); + + it("counts macOS reclaimable pages from vm_stat, not just Pages free", () => { + const mem = readSystemMemory( + () => null, + () => SAMPLE_VM_STAT, + ); + const pageSize = 16384; + const expected = (462_821 + 3_305_280 + 57_490 + 2_266) * pageSize; // free+inactive+spec+purgeable + // totalmem() on the test host caps the reading; below the cap the exact + // page math must hold. + expect(mem.freeBytes).toBe(Math.min(expected, mem.totalBytes)); + // The whole point: available is far more than the bare free-page count. + expect(mem.freeBytes).toBeGreaterThan(462_821 * pageSize * 5); + }); + + it("falls back to os when vm_stat output is malformed", () => { + const mem = readSystemMemory( + () => null, + () => "garbage\nnot vm_stat\n", + ); + expect(mem.totalBytes).toBeGreaterThan(0); + expect(mem.freeBytes).toBeGreaterThan(0); + expect(mem.freeBytes).toBeLessThanOrEqual(mem.totalBytes); + }); + + it("meminfo wins over vm_stat when both are present (Linux path untouched)", () => { + const mem = readSystemMemory( + () => SAMPLE_MEMINFO, + () => SAMPLE_VM_STAT, + ); + expect(mem.freeBytes).toBe(10_342_988 * 1024); + expect(mem.totalBytes).toBe(16_277_856 * 1024); + }); }); diff --git a/plugins/plugin-local-inference/src/services/system-memory.ts b/plugins/plugin-local-inference/src/services/system-memory.ts index 0d35502a3783a..223ebc4b50826 100644 --- a/plugins/plugin-local-inference/src/services/system-memory.ts +++ b/plugins/plugin-local-inference/src/services/system-memory.ts @@ -12,11 +12,22 @@ * `/proc/meminfo`'s `MemAvailable` is the kernel's own estimate of how much * memory is available for starting new applications without swapping (free + * reclaimable cache/slab, minus the low watermark). That is exactly the number - * the arbiter wants. Read it on Linux/Android; fall back to `os.freemem()` / - * `os.totalmem()` everywhere else (macOS, Windows) or if `/proc/meminfo` is - * unreadable or pre-3.14 (no `MemAvailable`). + * the arbiter wants. Read it on Linux/Android. + * + * macOS has the same undercount, worse: `os.freemem()` maps to Mach "Pages + * free" only, and the kernel deliberately keeps that near zero by holding + * reclaimable file cache in the inactive/speculative/purgeable lists. On a + * healthy 128 GB Mac, `freemem()` routinely reports < 5% while the kernel's + * own `memory_pressure` tool reports > 80% free — which tripped the arbiter's + * critical-pressure gate and made it refuse every non-text capability + * (vision-describe, ASR, TTS, image-gen). Read `vm_stat` and count + * free + inactive + speculative + purgeable pages as available instead. + * + * Windows falls back to `os.freemem()` / `os.totalmem()` (which maps to + * `ullAvailPhys` there — already an availability metric). */ +import { execFileSync } from "node:child_process"; import { readFileSync } from "node:fs"; import os from "node:os"; @@ -45,15 +56,61 @@ function parseMeminfoKb(text: string, key: string): number | null { return Number.isFinite(kb) ? kb : null; } +/** Injectable for tests: returns the raw `vm_stat` output text, or null. */ +export type VmStatReader = () => string | null; + +const defaultVmStatReader: VmStatReader = () => { + if (os.platform() !== "darwin") return null; + try { + return execFileSync("/usr/bin/vm_stat", { + encoding: "utf8", + timeout: 2_000, + }); + } catch { + return null; + } +}; + +/** + * Parse macOS `vm_stat` output into available bytes: + * (free + inactive + speculative + purgeable) × page size. Inactive and + * speculative pages are the reclaimable file cache; purgeable is memory the + * owner volunteered to give back. This mirrors what Linux `MemAvailable` + * counts and is conservative relative to the kernel's own + * `memory_pressure` "free percentage". + */ +function parseVmStatAvailableBytes(text: string): number | null { + const pageSizeMatch = /page size of (\d+) bytes/.exec(text); + const pageSize = pageSizeMatch ? Number.parseInt(pageSizeMatch[1], 10) : NaN; + if (!Number.isFinite(pageSize) || pageSize <= 0) return null; + const pages = (label: string): number | null => { + // Lines look like: `Pages free: 462821.` + const match = new RegExp(`^${label}:\\s+(\\d+)\\.`, "m").exec(text); + if (!match) return null; + const n = Number.parseInt(match[1], 10); + return Number.isFinite(n) ? n : null; + }; + const free = pages("Pages free"); + const inactive = pages("Pages inactive"); + if (free === null || inactive === null) return null; + const speculative = pages("Pages speculative") ?? 0; + const purgeable = pages("Pages purgeable") ?? 0; + return (free + inactive + speculative + purgeable) * pageSize; +} + /** * Read available + total system memory in bytes. Prefers `/proc/meminfo` - * `MemAvailable`/`MemTotal` on Linux; falls back to `os.freemem()/totalmem()`. + * `MemAvailable`/`MemTotal` on Linux and `vm_stat` reclaimable-page math on + * macOS; falls back to `os.freemem()/totalmem()`. * * @param read injectable meminfo reader (tests). Defaults to reading * `/proc/meminfo` on Linux and returning null elsewhere. + * @param readVmStat injectable vm_stat reader (tests). Defaults to running + * `/usr/bin/vm_stat` on macOS and returning null elsewhere. */ export function readSystemMemory( read: MeminfoReader = defaultMeminfoReader, + readVmStat: VmStatReader = defaultVmStatReader, ): SystemMemory { const text = read(); if (text) { @@ -63,5 +120,13 @@ export function readSystemMemory( return { freeBytes: availKb * 1024, totalBytes: totalKb * 1024 }; } } + const vmStatText = readVmStat(); + if (vmStatText) { + const availBytes = parseVmStatAvailableBytes(vmStatText); + const totalBytes = os.totalmem(); + if (availBytes !== null && totalBytes > 0) { + return { freeBytes: Math.min(availBytes, totalBytes), totalBytes }; + } + } return { freeBytes: os.freemem(), totalBytes: os.totalmem() }; }