AI Skills AI技能 2h ago Updated 1h ago 更新于 1小时前 48

Speculative Decoding on CPUs: Nearly 4x Faster Token Generation with DFlash CPU上的投机解码:DFlash实现近4倍更快的Token生成

DFlash speculative decoding is now supported in vLLM v0.25.0 for CPU inference, enabling lossless acceleration without changing model output distribution Testing with Qwen3.5-9B on Intel Xeon 6-powered AWS r8i instances achieved a 3.92x throughput increase at concurrency 1, translating to a 74% cost reduction per generated token DFlash uses a block-diffusion drafter that predicts an entire block of tokens in one pass with bidirectional attention, combined with target model hidden feature injecti DFlash是Z Lab开发的投机解码方法,通过块扩散草稿模型和目标模型KV特征注入,实现CPU上LLM推理的无损加速 vLLM v0.25.0已支持CPU版DFlash,在Qwen3.5-9B模型+Intel Xeon 6处理器的AWS r8i实例上,单并发吞吐量提升3.92倍 投机解码通过草稿模型并行提议多个token、目标模型单次验证,将内存带宽瓶颈转化为计算利用率,接受率75%时Token生成成本降低74% 性能增益高度依赖提示类型:结构化任务(代码/数学)接受率显著高于对话场景,需匹配领域专用草稿模型

65
Hot 热度
72
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • DFlash speculative decoding is now supported in vLLM v0.25.0 for CPU inference, enabling lossless acceleration without changing model output distribution
  • Testing with Qwen3.5-9B on Intel Xeon 6-powered AWS r8i instances achieved a 3.92x throughput increase at concurrency 1, translating to a 74% cost reduction per generated token
  • DFlash uses a block-diffusion drafter that predicts an entire block of tokens in one pass with bidirectional attention, combined with target model hidden feature injection into the draft model's KV cache
  • Acceptance rates vary by domain: higher for structured prompts (code, math) and lower for conversational or out-of-domain use cases
  • The optimal num_speculative_tokens parameter depends on the target/draft model pair, dataset, concurrency, and hardware characteristics

Why It Matters

Speculative decoding on CPU represents a significant milestone for making high-performance LLM inference accessible beyond GPU-only deployments, potentially democratizing cost-effective AI serving. The 3.92x speedup with DFlash demonstrates that CPU-based inference can now compete meaningfully with traditional autoregressive baselines, offering a practical path for organizations looking to reduce cloud infrastructure costs. For AI practitioners, this means speculative decoding is no longer an GPU-exclusive optimization and can be deployed on widely available CPU instances.

Technical Details

  • DFlash Architecture: Developed by Z Lab, DFlash uses a small block-diffusion drafter that predicts all masked positions in a single forward pass with bidirectional attention within the block, rather than generating draft tokens serially. Hidden features from the target model are injected into each draft layer's KV cache to improve draft quality without requiring the drafter to reconstruct full context independently.
  • Lossless Acceleration: Unlike quantization or other lossy optimizations, speculative decoding uses rejection sampling to recover the exact target distribution, ensuring zero accuracy degradation.
  • Hardware Optimization for Xeon: At small batch sizes, DFlash transforms per-token matrix-vector operations (relying on Intel AVX-512) into matrix-matrix operations accelerated by Intel AMX, reusing target weights across multiple candidate positions and trading spare compute for saved memory bandwidth.
  • Benchmark Results (Qwen3.5-9B, concurrency 1, output length 128): GSM8K achieved 4.16x speedup (75.98% acceptance rate), HumanEval achieved 3.99x speedup (74.93% acceptance rate), and MT-Bench showed strong gains as well. Average across all three datasets: 3.92x throughput improvement.
  • Deployment: Enabled via a single vLLM configuration flag (--speculative-config) specifying the DFlash method, draft model (z-lab/Qwen3.5-9B-DFlash), and num_speculative_tokens (tested at 15).

Industry Insight

  • Organizations running LLM workloads on CPU infrastructure can achieve near-4x throughput improvements with zero accuracy loss, making CPU-based serving a viable cost-optimization strategy alongside GPU deployments.
  • Practitioners should align their benchmarking datasets with their target model's domain—structured tasks like code and math show higher acceptance rates and greater speedups, while conversational workloads may see diminished returns; domain-specific models require matching drafters for optimal results.
  • The availability of pre-trained drafters through Z Lab's DFlash collection and Red Hat AI's Speculator library lowers the barrier to adoption, but teams should expect to tune num_speculative_tokens and other parameters per workload rather than relying on defaults.

TL;DR

  • DFlash是Z Lab开发的投机解码方法,通过块扩散草稿模型和目标模型KV特征注入,实现CPU上LLM推理的无损加速
  • vLLM v0.25.0已支持CPU版DFlash,在Qwen3.5-9B模型+Intel Xeon 6处理器的AWS r8i实例上,单并发吞吐量提升3.92倍
  • 投机解码通过草稿模型并行提议多个token、目标模型单次验证,将内存带宽瓶颈转化为计算利用率,接受率75%时Token生成成本降低74%
  • 性能增益高度依赖提示类型:结构化任务(代码/数学)接受率显著高于对话场景,需匹配领域专用草稿模型

为什么值得看

本文首次验证投机解码在CPU推理中的规模化价值,证明通过算法优化可突破内存带宽限制,为资源受限场景提供无损加速方案。对AI从业者而言,DFlash的vLLM集成降低了CPU部署门槛,74%成本下降直接改善LLM服务经济性。

技术解析

  • 块扩散草稿机制:DFlash使用小型块扩散草稿模型一次性预测整个token块(非串行生成),通过双向注意力处理块内掩码位置,num_speculative_tokens参数控制投机长度(测试中设为15)
  • 目标模型特征注入:将目标模型的隐藏层特征融合注入草稿模型的KV缓存,使草稿无需重建完整上下文即可生成高质量候选token,接受长度达6.93-7.08
  • CPU硬件协同优化:验证阶段将逐token矩阵向量运算转化为矩阵矩阵运算,充分利用Intel AMX加速权重复用,在低并发下激活闲置计算单元
  • 无损加速原理:通过拒绝采样恢复目标分布,与量化等有损优化不同,输出质量完全保留;成本节省源于减少目标模型前向传播次数
  • 部署配置:基于vLLM v0.25.0的Docker部署,需指定--speculative-config启用DFlash方法,并配置草稿模型(如z-lab/Qwen3.5-9B-DFlash

行业启示

  • CPU推理经济性拐点:74%成本降低证明投机解码可使CPU成为LLM推理的可行选项,缓解GPU供应链压力,适合延迟敏感型批处理场景
  • 场景适配策略:接受率差异揭示投机解码需匹配任务结构——代码/数学等确定性提示收益显著,而开放对话需定制领域草稿模型或调整投机长度
  • 开源生态加速:vLLM集成+Z Lab草稿模型库降低技术门槛,推动投机解码从研究走向生产,建议从业者优先评估结构化任务场景的部署可行性

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Inference 推理 Deployment 部署 Open Source 开源 LLM 大模型