Repository navigation
Conversation
Non-budget Metal profile for long prompts: AD-IQ2_M with DSpark 3/32, q4_0 KV, flash attention, 1024 prefill blocks, and mmap+mlock so expert weights stay resident under memory pressure. Measured on M5 Max / 64 GB (scripts/bench-long-prefill.py, warm, cache reuse off), decode +84-98% and prefill +10-20% at 14.7K-35.7K prompt tokens versus the same build without mlock: 14,727 tok: prefill 539.8 -> 591.2 t/s, decode 34.7 -> 68.6 t/s 35,653 tok: prefill 364.3 -> 437.0 t/s, decode 29.4 -> 54.1 t/s The doc also records what was tested and rejected: ubatch >= 2048 (Metal compute reservation exceeds the device working set), -sm row (unsupported on Metal), 12 batch threads (no gain), dev/TurboQuant branch (cannot load inkling2_loop), and ngram-cache speculative decoding (correct answers regress on cached multi-turn requests, so draft-dspark alone is used). Prefix caching makes the real doc-QA workflow fast: follow-up questions on a cached 14.7K document answer in ~1.6s versus 57.8s cold.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A production launch profile plus a benchmark harness for serving Inkling 2 Mini (AD-IQ2_M) on the non-budget Metal path when the workload is long prompts. Three new files, no changes to existing code:
profiles/inkling-long-input.sh- the launch profilescripts/bench-long-prefill.py- the measurement tool (prefill / decode / TTFT by prompt size, cache reuse disabled)docs/inkling-long-input-profile.md- measurements, rejected alternatives, reproduction stepsWhy the non-budget path
The budgeted Metal profiles are the fastest option but carry hard startup limits, verified on this build:
engine budget profile requires explicit ctx <= 4096, batch <= 4096, ubatch <= 1024, one sequence, <=16 threads, no embeddingsengine budget requires -fit off, a supported speculative profile if selected, and no multimodal projectorA 4096-token window cannot hold a long document, and the budget path rejects the vision projector. For long-input serving the ordinary Metal path is the only option, so the tuning targets that path.
Measured results
M5 Max / 64 GB, Docker Desktop running, warm server, cache reuse off, greedy decoding,
scripts/bench-long-prefill.py. Baseline is the identical build without--load-mode mmap+mlock; everything else (AD-IQ2_M, DSpark 3/32, q4_0 KV, flash attention, 1024 prefill blocks) unchanged.The single change behind the deltas is
--load-mode mmap+mlock: the mmapped expert weights stay resident instead of being evicted and re-read from SSD under memory pressure. Footprint grows 3.36 -> 3.74 GiB at 40K (the mlock cost).Long-document Q&A (the actual workflow)
With the default prefix cache on (as Open WebUI runs it), only the first question pays the full prefill:
Follow-up questions on a cached document answer 17-36x faster than a cold prefill and stay correct.
Tested and rejected (with data)
--ubatch-size 2048/4096: fails at load. The Metal compute-graph reservation scales with ubatch (104 GiB requested at 2048) and exceeds the device working set. 1024 is the ceiling on this machine.-sm row:device MTL0 does not support split buffers.--threads 12 --threads-batch 12: +3% at 2.5K tokens, no change at 14.7K/35.7K.unknown model architecture: 'inkling2_loop'. The architecture lives on the engine branches, so turbo KV cache types are unavailable for Inkling 2.--spec-type ngram-cache,draft-dspark): +24-26% decode on repetitive prompts, but it produces wrong answers on cached multi-turn requests (it proposes the previous turn's answer from the cached prefix and the target accepts it). Rejected: correctness on the doc-QA workflow outranks the decode gain.Notes and limits
s[::-]instead ofs[::-1]at effort none/medium, correct at effort low). That is a quantization artifact of the IQ2_M target, not a serving-path issue; the profile works unchanged with AD-IQ3_S if code quality matters more than the 4.3 GiB.engine-development. The diff is three new files; no existing behavior changes.Reproduce
python3 scripts/bench-long-prefill.py 8081 "label" 2500,16500,40000Run each size twice (first request pays Metal pipeline compilation) and measure with a single llama-server instance: two concurrent servers on a 64 GB box drive the machine into Metal OOM (
Insufficient Memory), which poisons the backend until restart.