Accelerating vision-language models with LFM2.5-VL-DSpark
https://huggingface.co/blog/LiquidAI/lfm2-5-vl-dspark📌 LFM2.5-VL-DSpark:VLM 推測解碼實測最高加速 3.13 倍
TL;DR:Liquid AI 釋出 VLM 專用推測解碼草稿模型,多推論框架即測即用且不損輸出品質。
推測解碼(speculative decoding)在純文字 LLM 上已證明能大幅加速,但視覺語言模型(VLM)多了一個影像編碼與大量視覺 token 的前置流程,這個技巧還適用嗎?Liquid AI 針對自家 LFM2.5-VL-3B 給出了實測答案。
🤔 VLM 的推測解碼要解決什麼問題
繼日前推出文字版 LFM2.5-DSpark 草稿模型後,Liquid AI 這次釋出實驗性的 LFM2.5-VL-3B 專用 DSpark 草稿模型,用少量記憶體換取更大的解碼加速,且不改變輸出品質。官方數字:on-device 解碼加速最高 3.13 倍、H100 上最高 2.66 倍,端到端加速最高分別達 2.62 倍與 2.27 倍;草稿模型只增加 2.8 億參數,相當於 3B 目標模型多 8.9% 的體積。
🧩 沿用文字草稿的推測解碼算法,只是輸入模態變了
視覺草稿模型(vision drafter)沿用與文字版 LFM2.5-DSpark 草稿模型相同的架構:擷取目標模型在固定幾層(tapped layers)的隱藏狀態,以此為條件草擬一個包含 k 個候選 token 的區塊。關鍵在於,影像 patch 與文字 token 會在進入這些層之前先被投影到同一個共享表示空間,因此草稿模型看到的隱藏狀態向量維度一致,不論輸入是圖還是文字,推論演算法因此與文字模型完全相同,不需要額外設計。
訓練上沿用 DSpark 配方,使用依預期服務工作負載加權過的視覺語言 SFT 資料混合集。團隊針對 3、4、5 層做了消融實驗,最終選定 4 層、block size 為 9 的純 attention 草稿模型架構;在最終資料混合上訓練 10 個 epoch,並在每個 epoch 後量測接受率(acceptance rate),結果隨訓練 token 增加而提升,直到報酬遞減。推論時建議依硬體選擇 block size 8 或 9。
模型組成細節(參數量):
| 元件 | 參數量 |
|---|---|
| Decoder stack(4 層) | 193.0M |
| Hidden-state projection | 21.0M |
| Markov head | 65.5M |
| Norms + confidence head | 6.4k |
| 總計 | 279.5M |
📊 六項視覺任務的實測加速
團隊依循 MMSpec benchmark,在 general VQA、text VQA、image captioning、chart VQA、複雜推理、多輪對話等六種視覺任務上量測 on-device 與 GPU 推論表現,block size 統一為 8:
- MLX on M5 Max:解碼依任務提升 2.30 倍到 3.13 倍,端到端提升 1.56 倍到 2.62 倍。
- llama.cpp on M3 Ultra:解碼提升 1.57 倍到 2.14 倍,端到端提升 1.30 倍到 1.77 倍。
- H100:解碼最高提升 2.66 倍,端到端提升 1.64 倍到 2.27 倍。
⚠️ 邊緣裝置上的加速上限:Amdahl’s law
推測解碼只加速「解碼」階段,不加速視覺編碼與 prefill。VLM 的 prefill 比純文字模型更重:影像要先經過視覺編碼器,語言主幹接著要處理數百個視覺 token 加上文字提示。邊緣裝置算力遠低於資料中心 GPU,prefill 在整體延遲中的佔比因此更高(M5 的每核心 GPU 神經加速器能部分縮小這個差距)。這正是 Amdahl’s law 的體現:當 prefill、視覺編碼這類無法被加速的部分佔比高時,即使解碼加速再大,端到端的整體收益也會被壓縮。
🧩 怎麼用
三個推論框架都已日內支援:
SGLang(需支援 DSpark 的 build,PR #40651):
python -m sglang.launch_server \
--model-path LiquidAI/LFM2.5-VL-3B \
--speculative-algorithm DSPARK \
--speculative-draft-model-path LiquidAI/LFM2.5-VL-3B-DSpark \
--speculative-draft-attention-backend flashinfer \
--speculative-dspark-block-size 9 \
--disable-radix-cache
接著查詢 OpenAI 相容端點 http://localhost:30000/v1,block size 會從草稿模型的 config.json 讀取;拿掉三個 --speculative-* 參數即是基準版本。
llama.cpp(需對應 build,PR #29339)與 MLX-VLM(需對應 build,PR #2280)也各自提供對應指令,細節可參考原文。
值得注意的是,推測解碼是精確(exact)的:目標模型會驗證每個被提議的 token,貪婪解碼下的輸出與單獨使用目標模型完全一致,每次回應的計時資訊會回報 draft_n 與 draft_n_accepted。
🎯 實務啟示
模型與草稿模型皆以 Safetensors 與 GGUF 格式開源在 Hugging Face 上,權重可自由下載、微調、部署。若你的 VLM 服務瓶頸主要在解碼階段(例如多輪對話、長輸出的場景),這類草稿模型是值得優先嘗試的低成本加速手段;但若場景是短輸出、長 prompt(例如單次描述一張高解析度圖),別忘了 Amdahl’s law 提醒的天花板,實際效益要看 prefill 佔比而定。
🔗 來源
- 標題:Accelerating vision-language models with LFM2.5-VL-DSpark
- 作者/機構:Liquid AI
- 連結:https://huggingface.co/blog/LiquidAI/lfm2-5-vl-dspark
#SpeculativeDecoding #VLM #EdgeAI #LiquidAI #LLMInference #SGLang #llamacpp #MLX #OpenWeights #ModelOptimization
原始資料 HuggingFace Blog · 收集於 2026-09-24
摘要原文
Back to Articles Accelerating vision-language models with LFM2.5-VL-DSpark Team Article Published September 24, 2026 Upvote 7 +1 xx tugot17 Follow LiquidAI Yuri Khrustalev ykhrustalev Follow LiquidAI Leonie Monigatti iamleonie Follow LiquidAI Viviana Márquez vivianamarquez Follow LiquidAI Today, we release an experimental DSpark draft model for our vision-language model (VLM) LFM2.5-VL-3B . As with our recently released LFM2.5-DSpark drafter models , it adds a speculative decoding path that trades a minimal increase in memory footprint for a larger speedup without changing output quality. Faster inference: decode speedups up to 3.13x on device and 2.66x on an H100, with end-to-end gains up to 2.62x and 2.27x. Small memory cost: the drafter adds 280M parameters, 8.9% on top of the 3B target Day-one support: LFM-compatible DSpark integrations for llama.cpp, MLX-VLM, and SGLang How does speculative decoding work for VLMs The vision drafter uses the same architecture as our text LFM2.5-DSpark drafters: it captures the target model's hidden states at a fixed set of tapped layers and conditions on them to draft a block of k candidate tokens. Image patches and text tokens are projected into a shared representation before those layers, so the drafter operates on hidden-state vectors of identical dimensionality regardless of input modality. The inference algorithm is therefore unchanged from the text models. Training and Architecture We follow the DSpark recipe with a mixture of vision-language SFT data, weighted toward the workloads we expect the model to serve. Based on ablations across 3, 4, and 5 layers, the draft model is a simplified attention-only drafter with 4 layers and a block size of 9. We ran 10 epochs on the final mixture and measured acceptance after each, which improved with additional training tokens before reaching diminishing returns. At inference time, we recommend a block size of 8 or 9 depending on the hardware. The resulting drafter has approximately 280M parameters and increases the deployed model’s parameter count by just 8.9%. Component LFM2.5-VL-3B Decoder stack (4 layers) 193.0M Hidden-state projection 21.0M Markov head 65.5M Norms + confidence head 6.4k Total 279.5M Inference Speedup on CPU and GPU The DSpark draft model for LFM2.5-VL-3B ships with day-one support for llama.cpp , MLX-VLM , and SGLang . We measure both on-device inference and GPU inference. Both configurations use a DSpark block size of 8 and are evaluated on six diverse vision-based tasks, including general VQA, text VQA, image captioning, chart VQA, complex reasoning, and multi-turn conversation, following the MMSpec benchmark . On-device inference. With MLX on an M5 Max, decoding runs 2.30x to 3.13x faster by task. End-to-end latency improves by 1.56x to 2.62x. With llama.cpp on an M3 Ultra, decoding improves by 1.57x to 2.14x and end-to-end by 1.30x to 1.77x. GPU inference. On H100, the same drafter delivers 20.4x to 2.66x faster decoding, with end-to-end improvements of 1.64x to 2.27x. Limitations of speculation for vision workloads In LLMs, prefill is mostly compute-bound, and its cost grows (sub)quadratically with prompt length. VLMs add to this because the image first passes through a vision encoder, then the language backbone processes hundreds of visual tokens along with the text prompt. Edge devices have far less compute than datacenter GPUs, so prefill takes up more of the end-to-end latency, as time-to-first-token and decode measurements on Apple silicon and H100 show. (The M5's per-core GPU neural accelerators narrow this gap). Speculative decoding speeds up only decode, not vision encoding or prefill. When those stages already take up much of the wall time, even a large decode speedup gives only a modest end-to-end gain. This is Amdahl's law, where the overall speedup is capped by the part of the workload that isn't accelerated. How to use LFM2.5-VL-DSpark Running the DSpark draft models with SGLang requires an SGLang build with DSpark support for LFM2 targets ( PR #40651 ). Launch the target with the draft attached: python -m sglang.launch_server \ --model-path LiquidAI/LFM2.5-VL-3B \ --speculative-algorithm DSPARK \ --speculative-draft-model-path LiquidAI/LFM2.5-VL-3B-DSpark \ --speculative-draft-attention-backend flashinfer \ --speculative-dspark-block-size 9 \ --disable-radix-cache Then query the OpenAI-compatible endpoint at http://localhost:30000/v1 . The block size is read from the draft's config.json ; the baseline is the same command without the three --speculative-* flags. Running them with llama.cpp requires the respective llama.cpp build ( PR#29339 ). llama-server -m models/LFM2.5-VL-3B-F16.gguf \ --mmproj models/mmproj-LFM2.5-VL-3B-F16.gguf \ -md LFM2.5-2.6B-DSpark-F16.gguf \ --spec-type draft-dspark --spec-draft-n-max 8 --spec-draft-n-min 0 \ -fa on -ngl 99 -c 8192 Running them with MLX-VLM requires the respective build ( PR#2280 ). mlx_vlm.server --model LiquidAI/LFM2.5-VL-3B --draft-model LiquidAI/LFM2.5-VL-3B-DSpark The block size is read from the sidecar metadata (n-max is clamped to it). Speculative decoding is exact : the target verifies every proposed token, so greedy output equals the target alone; per-response timings report draft_n / draft_n_accepted . Get Started Our vision DSpark draft model is available on Hugging Face in Safetensors and GGUF formats . With LFM2.5, we're delivering on our vision of AI that runs anywhere. These models are: Open-weight — Download, fine-tune, and deploy without restrictions. Fast from day one — Day-one support for llama.cpp, MLX, and SGLang. A complete family — From base models for customization to specialized audio and vision variants, one architecture covers diverse use cases We can’t wait to see what you build. Citation For citations, please use the following reference or BibTeX: Liquid AI, "LFM2.5-VL-DSpark: Accelerating vision-language models on edge and beyond", Liquid AI Blog, Sep 2026. @article{liquidAI2026vldspark, author = {Liquid AI}, title = {LFM2.5-VL-DSpark: Accelerating vision-language models on edge and beyond}, journal = {Liquid AI Blog}, year = {2026}, note = {www.liquid.ai/blog/lfm2-5-vl-dspark}, }
由 claude-code/sonnet 自動生成