README 未说明具体依赖版本与默认端口,需按官方文档确认;模型需先用 MNN 转换工具从 TensorFlow/ONNX 等格式转换后才能加载;部分后端(如 Hexagon、CoreML)需单独编译或受硬件限制。
MNN
alibabaApache-2.0活跃维护阿里开源的轻量级端侧推理引擎,主打手机和嵌入式设备上的高性能模型推理,能跑大模型和常规深度学习网络。
MNN: A blazing-fast, lightweight inference engine battle-tested by Alibaba, powering high-performance on-device LLMs and Edge AI.
README 未给出安装命令,构建与使用方式见官方文档 https://mnn-docs.readthedocs.io/en/latestREADME 未给出具体显存要求;CPU 覆盖 x86/x64(SSE4.1、AVX2、AVX512)、ARMv7a、ARMv8、ARMv9、RISC-V,GPU 支持 OpenCL、Vulkan、Metal、CUDA,NPU 支持 CoreML、Hexagon、NeuroPilot、HIAI、NNAPI、QNN;系统要求 iOS 8.0+、Android 4.3+ 或带 POSIX 接口的嵌入式设备。
阿里开源的轻量级端侧深度学习推理引擎,主打手机和嵌入式设备上跑 LLM 与视觉模型
阿里开源的轻量级端侧推理引擎,主打手机和嵌入式设备上的高性能模型推理,能跑大模型和常规深度学习网络。
核心能力
- 支持 TensorFlow、Caffe、ONNX、TorchScript 模型转换与推理
- 用 Metal、OpenCL、Vulkan、CUDA 做 GPU 推理,另有 Hexagon 等 NPU 后端
- 支持 FP16、INT8、INT4 量化,模型体积可压缩 50%-70%
- 提供 MNN-LLM 与 MNN-Diffusion 端侧大模型和扩散模型运行时
- 带 Python API 和类 OpenCV 的轻量图像处理模块
容易踩的坑
- 3.6.2最新正式版2026-10-29 · 2026-10-29 09:38 UTC
MNN 3.6.2 版本发布说明
发布日期: 2026年10月
📦 安装:
pip install mnn==3.6.2| PyPI📌 版本概述
MNN 3.6.2 聚焦 端侧异构推理性能与投机解码加速。本版本以 Metal、Hexagon 和 DFlash 为重点,持续提升 Qwen3 / Qwen3.5 在 CPU、GPU 与 NPU 上的推理效率。
典型性能:Qwen3.5-2B 在 iPad Pro M5 的 GPU 上通过 Metal 后端运行,Prefill 达到 3542.91 tok/s;启用 DFlash 后,Decode 从 111.89 提升至 233.98 tok/s,达到常规解码的 2.09 倍。
🚀 版本亮点
- Metal / Apple GPU Neural Accelerators 优化:通过 Metal Tensor API 利用 Apple GPU 内的神经网络加速单元,提升 Qwen3 / Qwen3.5 Dense 推理性能
- Hexagon 推理优化:提升 NPU 上的 Prefill 效率,减少 Decode 阶段的计算与调度开销
- DFlash 投机解码加速:加速草稿生成与验证,复用目标模型输出层权重,提高生成吞吐并减少内存占用
- CPU / OpenCL 性能优化:改进 OpenCL Attention 与融合解码,完善 CPU 的 SME2 检测与 SME2 / NEON 混合执行
- LinearAttention 与 MoE 多后端优化:提升 Qwen3.5 LinearAttention 在 Metal、Hexagon DSP、x86 与 RISC-V 上的执行效率,优化 MoE 专家计算
- RISC-V / 进迭时空 K3 LLM 适配:完善 RVV 与 IME2 支持,优化低比特 LLM 推理和动态输入处理
📊 性能基准
图:左侧为 iPad Pro M5 的 CPU / Metal GPU 性能,Qwen3.5-2B 额外展示 DFlash 投机解码;右侧为 OnePlus 13 的 CPU / OpenCL GPU / Hexagon NPU 性能。上排 Prefill,下排 Decode。
✨ 新功能与性能优化
Metal 后端
- Apple GPU Neural Accelerators:围绕 Metal Tensor API 优化矩阵计算、Attention 和 LinearAttention 的分块与数据访问,发挥 M5 等受支持 GPU 内神经网络加速单元的计算能力
- Metal 低比特计算:新增 W2 / W3 解码 GEMV 与 conv1x1 支持,优化 Q4 权重读取、分块计算和投机解码块处理
- Metal Attention 与融合计算:优化 prefill / decode Attention、RMSNorm、RoPE、融合 QKV / SwiGLU 投影及命令提交,减少中间计算与同步开销
- Metal LinearAttention:优化 gated delta rule 的融合计算,为 Tensor API 和 SIMD-group 矩阵计算提供分块 prefill 路径,并优化短输入和 decode 命令回放
- Metal 上下文释放:新增 context release API
Hexagon / NPU 后端
- Hexagon 融合解码:新增融合 INT4 GEMV、GatedRMSNorm 与 norm + RoPE 路径,减少解码阶段的算子调度
- Hexagon DSP LinearAttention:支持 Qwen3.5 gated delta rule 与 LFM2 short convolution,并引入分块 prefill 与 HMX 计算
- Hexagon prefill 优化:优化 INT4 反量化、HMX GEMM、分组因果 Attention、DMA 双缓冲和 VTCM 工作区,复用 prefill / decode 间的 KV 页面与动态内存池
- Hexagon 模型与量化覆盖:新增 Qwen3-VL 支持,完善对称 / 非对称分块量化、INT8 及 FP16 激活计算
- Rockchip RKNN 后端:新增 RKNN NPU 后端的初步支持
- QNN 工具与算子:新增 Deconvolution、中间 Tensor dump 和 VTCM 大小配置,支持 LLM / visual 模型导出至同一 QNN 目录
LLM / 推理与导出
- MoE 专家计算优化:将 Token 按专家归组,批量执行专家投影,融合 gate / up 与 SwiGLU;为 prefill 和 decode 提供对应的计算路径,覆盖 CPU / Metal / OpenCL / CUDA / Vulkan
- Transformer 融合优化:导出时融合投影层与 gated norm,并保留 split-LoRA 导出中的 FusedLinear 融合
- DFlash 投机解码优化:将特征投影、拼接与 argmax 放到设备端,增量维护草稿 KVCache,减少主机往返与重复计算;Metal 使用适合短验证块的 Q4 分块矩阵计算与 K 维切分
- DFlash 权重复用:草稿模型共享目标模型的 lm_head,减少磁盘与运行时的重复权重
升级提示:旧版 DFlash 草稿模型需重新导出。
- QAT checkpoint 导出:新增
--qat,读取qat_config.json与 safetensors,保留 scale / zero_point,支持 2 / 3 / 4 / 8-bit 权重 - 可选文本 Token 压缩:新增
MNN_LLM_TOKEN_COMPRESS编译选项和token_compress配置,按 Token 预算选取文本句子;默认关闭,支持纯文本请求及多模态模型的纯文本输入 - OpenCL 前缀 KVCache 文件:新增
setPrefixCacheFile支持 - Attention mask 统一:统一 mask 构造及各后端的处理语义
CPU 后端
- SME2 计算单元检测:识别可用计算单元及共享分组,为任务划分提供准确的硬件信息
- SME2 / NEON 混合优化:依据计算单元数量分配矩阵任务,优化 Attention、INT8 和 KleidiAI 混合执行,减少线程调度开销
- Arm Attention / RoPE / LayerNorm:优化 FlashAttention prefill / decode,新增 Arm82 FP16 RoPE,优化 packed FP16 C4 LayerNorm
- RISC-V RVV 算子扩展:新增或优化 LinearAttention、Attention mask、KVCache 量化、GEMV、矩阵计算、卷积 / 反卷积、采样、Scale / PReLU 和 INT8 算子
- 进迭时空 K3 / IME2:优化低比特矩阵计算与激活打包,在动态 prefill 中保留执行对象并复用权重预打包结果,减少输入长度变化时的重复准备开销。采用 8 线程、W4B64 配置,Qwen3.5-2B 实测 Prefill(PP512)达到 85.60 tok/s,Decode(TG128)达到 17.68 tok/s
- 卷积与图像算子:优化反卷积输出复用、2×2 反卷积后处理及双线性采样
其他 GPU 后端
- OpenCL FlashAttention 与调优:重构 prefill / decode kernel,完善 mask、尾块、KV 布局和长输入处理;优化异步准备、运行时调优与 kernel 程序拆分
- OpenCL 融合解码:融合 C4 gated / binary RMSNorm 和 FusedLinear GEMV,优化 decode RoPE,减少 QCOM record replay 同步开销
- Vulkan cooperative matrix:优化 INT4
- 3.6.12026-07-23 · 2026-07-23 02:13 UTC
查看更新说明
MNN 3.6.1 版本发布说明
发布日期: 2026年7月
📦 安装:
pip install mnn==3.6.1| PyPI📌 版本概述
MNN 3.6.1 版本聚焦于 Hexagon NPU 后端、Transformer C4 Fuse 全后端性能优化 与 稳定性修复 三大核心主题:
- Hexagon NPU 后端:新增高通 Hexagon NPU 直接编程后端,Qwen3-0.6B(W4 对称量化,block64)在骁龙 8 Elite(Hexagon v79)上 prefill 达 2667 tok/s,为 CPU 的 7.9×。
- Transformer C4 Fuse 全后端性能优化:新增 fused LLM 算子(RoPE / Attention / LayerNorm 等 C4 路径)并在 CPU / Metal / OpenCL / CUDA 全后端启用 Transformer C4 图;优化 C4 导出与 packed RoPE 路径;Metal 新增 LLM prefill/decode 优化 kernel 与 Fused Q4/Q8 dequant+GEMM(M_TILE=64);OpenCL 修复 NC4HW4 raster L2 cache-set 抖动并优化 int4 GEMM。
- 稳定性修复与工具增强:新增 MNN-aware QLoRA 微调;修复 mmap 分配失败崩溃、推测解码 KVCache 索引、Arm82 LinearAttention fp16 精度等多项问题。
🚀 版本亮点
- Hexagon 后端(高通 NPU 直接编程):Qwen3-0.6B 在骁龙 8 Elite 上 pp512 达 2667 tok/s(CPU 的 7.9×,OpenCL GPU 的 1.8×)
- Transformer C4 图全后端启用:fused LLM 算子 + C4 后端路径覆盖 CPU / Metal / OpenCL / CUDA,包含 packed RoPE fuse 优化
- Metal LLM Prefill 大幅优化:Fused Q4/Q8 dequant+GEMM kernel、M_TILE=64 变体(面向 M5)、prefill/decode kernel 与 shape/RoPE 基础设施重构,并新增 Metal Op Profile
- MNN-aware QLoRA 微调:新增面向 MNN 部署的 QLoRA 微调能力
✨ 新功能
后端:Hexagon(新增)
- Hexagon NPU 后端:新增高通 Hexagon NPU 直接编程后端(HexagonBackend / HexagonRuntime / DSP kernel),支持 Attention 等 LLM 关键算子;附带
skills/hexagon开发文档
LLM / 推理加速
- Fused LLM 算子与 C4 后端路径:新增 CPURoPE、SharedGather 等 fused 算子及 CPU/Metal C4 计算路径
- C4 导出与 packed RoPE 优化:优化 C4 图导出;CPU / Metal / OpenCL 的 RoPE fuse(packed RoPE)路径优化
- Transformer C4 图全后端启用:CPU / Metal / OpenCL / CUDA(新增 RoPEExecution.cu、LayerNorm/LinearAttention C4 适配)统一启用 C4 图
- MNN-aware QLoRA 微调:新增 QLoRA 微调支持
GPU 后端
- Metal LLM prefill/decode kernel 优化:prefill/decode kernel、shape/RoPE 基础设施与 MetalConvolution1x1 SIMD-group 路径重构,新增 Metal Op Profile 工具
- Metal Fused Q4/Q8 dequant+GEMM:新增融合反量化+GEMM kernel 及 M_TILE=64 变体,优化 M5 上的 LLM prefill
- OpenCL raster 与 int4 GEMM 优化:转置遍历顺序修复 NC4HW4 L2 cache-set 抖动;优化 int4 GEMM 性能;拆分 binary_layernorm_c4 kernel
- Vulkan Range 算子:新增 Range 算子 image 实现
- QNN Interp/Resize 算子:QNN 后端新增 Interp/Resize 支持
CPU 后端
- RVV CommonOptFunction 适配:为 RISC-V RVV 架构适配 CommonOptFunction
工具
- llm_bench
-fa选项:新增 flash attention 开关(默认 1,启用 flash attention)
🐛 缺陷修复
LLM / VLM
- Qwen3.5 fused 推理正确性:修复 Qwen3.5 fused 推理结果错误
- C4 fuse 保护与 Metal raster:为 C4 fuse 增加 guard 条件并修复 Metal raster 问题
- RoPE schema 编译错误:修复 rope schema 引入的编译错误
- MPS 大 tensor Q4 量化静默全零:修复在 MPS 上量化大 tensor 时 Q4 权重静默全零的问题
- 通用 embedding scale 导出:修复导出时 embedding scale 缺失
- WikiText 校准数据集加载:修复量化校准数据集加载失败
- QNN 导出 chunk_size:修复 QNN prefill IO 生成未遵循
--chunk_size的问题 - decoder embedding 导出 causal mask:decoder 类 embedding 模型导出改用 causal mask
GPU 后端
- Metal ATTENTION_C4 输出分支缺失:修复 prefill_qkv_tensor 缺少 ATTENTION_C4 输出分支
- Metal attention kv_cache flag:修复 Metal attention 未遵循 kv_cache flag
- OpenCL attention c4 kernel 编译:修复 attention c4 的 OpenCL kernel 编译错误
- OpenCL c4 长 prefill attention:修复 GEMM tune 时 V-buffer 越界与 NC4HW4 输出布局缺失
- OpenCL maskless attention setArg 溢出:修复导致 Adreno 上 SD UNet 输出错误的 setArg 溢出(issue #4653),同时修复 LinearAttention 越界写、共享 runtime gpuMode 被覆盖及 shared_gather 构建错误
- CUDA pooling pads 与 TopKV2 largest flag:修复显式 pooling pads 与 TopKV2 largest flag 处理,并重组相关测试
- QNN mmpose 模型:修复运行 mmpose 模型时的若干问题
- QNN context 生成栈溢出:提高 context 生成的栈上限
CPU 后端
- Arm82 LinearAttention fp16 精度:改用 fp32 累加器,修复 fp16 精度损失
- 推测解码 KVCache 索引:修复 CPU KVCache value 索引错误导致 Eagle3 输出质量下降(issue #4591)
- ConvInt8 SIGSEGV:修复 Conv 缺少量化权重时 ConvInt8 崩溃
- RVV 源文件缺失 Macro.h:补全 RISC-V RVV 源文件的头文件包含
- RVV Int8 函数修复:修复 MNNLineDepthWiseInt8AddBiasScaleUnit 等 RVV int8 函数问题(issue #4454)
框架 / 其它
- mmap 分配失败崩溃:修复各后端 mmap
- 3.6.02026-06-16 · 2026-06-16 07:58 UTC
查看更新说明
MNN 3.6.0 版本发布说明
发布日期: 2026年6月
📦 安装:
pip install mnn==3.6.0| PyPI📌 版本概述
MNN 3.6.0 版本聚焦于 多模态 LLM 模型扩展与推理加速、GPU 多后端深度优化 以及 低比特量化与硬件适配增强 三大核心主题:
- 多模态 LLM 模型扩展与推理加速:新增 Gemma4(文本/视觉/语音)、Qwen3.5、Hymt2 等模型支持;推出 dflash 推测解码;Omni 模型 Thinker/Talker 交错生成将 TTFA 降低 2.7×;引入 fp16 存储的 weight-quant scale/zero-point;通过 onClone 重构 KV Cache 复用机制。
- GPU 多后端深度优化:Vulkan 新增 VulkanConv1x1CoopA8(W8A8 coopMat)与 no-subgroup 回退路径;OpenCL 引入 GEMM/GEMV 启发式调度、int4 image1d_buffer_t 优化、原生 TopKV2 与 2/3-bit 权重量化;Metal 优化 Conv1x1 分支选择;CUDA 支持 Blackwell(sm_120)并优化 Eagle 推测解码;QNN 支持 Qwen3.5 与离线图多进程并行导出。
- 低比特量化与硬件适配增强:CPU 与 GPU 全栈支持 2/3-bit 权重量化(ARM low-bit 量化内核 + OpenCL/Metal/Vulkan);ARMv8.2/v8.6 decode 路径深度优化;KleidiAI 升级到 v1.16.0;新增 RVV 向量化的 Int8/Norm/Gelu/SiLu/ExpC8 等核心算子;新增 fused MNNFusedGatedDelta(LinearAttention prefill);新增 LinearAttention L=1 decode 快速路径。
🚀 版本亮点
- Gemma4 全模态支持:新增 Gemma4 文本、视觉与音频模型的完整推理支持
- Wan2.1-T2V-1.3B 视频生成:新增 Wan2.1-T2V-1.3B 文生视频模型的导出与推理能力
- LLM 推理加速:新增 dflash 推测解码;Omni 模型 Thinker/Talker 交错生成,TTFA 降低 2.7×
- CPU/GPU 2/3-bit 权重量化全栈支持:CPU 新增 low-bit ARM 量化内核,OpenCL/Metal/Vulkan 同步支持 2/3-bit 权重量化
- Vulkan W8A8 coopMat:新增 VulkanConv1x1CoopA8,支持动态量化 W8A8 + Cooperative Matrix
✨ 新功能
LLM / VLM
- Gemma4 模型支持:新增 Gemma4 文本、视觉、音频全模态推理
- dflash 推测解码:新增 dflash 推测解码方案
- Omni Thinker/Talker 交错生成:Omni 模型 Thinker 与 Talker 交错执行,TTFA 降低 2.7×
- fp16 Scale/Zero-Point 存储:权重量化的 scale/zero-point 支持 fp16 存储
- KV Cache onClone 重构:通过 onClone 统一各后端 KV Cache 复用逻辑
- LLM log 保存到 context:支持将 LLM 推理日志保存到 context
- linear_attention 视为 full attention:性能优化路径
模型导出 / 模型支持
- Gemma4 模型导出:支持 Gemma4 多模态导出
- Stable Diffusion 3.5 Medium:新增 SD 3.5 Medium 模型支持
- Wan2.1-T2V-1.3B 视频模型:新增视频生成模型的导出与推理
GPU 后端
- Vulkan VulkanConv1x1CoopA8:新增 W8A8 动态量化 + Cooperative Matrix 卷积
- Vulkan LinearAttention 无 subgroup 回退:兼容不支持 subgroup 的设备
- Vulkan gemv decode 无 subgroup 回退:decode 路径的兼容性增强
- Vulkan 持久状态跨响应复用:支持持久状态在多次响应间复用
- Vulkan LayerNorm onClone:支持 LayerNorm onClone,opt pipeline 构造时初始化
- OpenCL GEMM/GEMV 启发式调度:量化 GEMM/GEMV 启发式 + XGEMM FP local size 设置
- OpenCL int4 GEMM/GEMV 优化:使用 image1d_buffer_t 优化 int4 GEMM/GEMV,免除 dequant 时额外的 -8
- OpenCL 原生 TopKV2:OpenCL IMAGE 与 Vulkan(image/buffer)新增原生 TopKV2 实现
- OpenCL LinearAttention chunk 分支优化:优化 chunk 分支性能
- OpenCL/Metal/Vulkan 2/3-bit 权重量化:GPU 三后端统一支持 2/3-bit 权重量化(CPU 端通过 low-bit ARM 量化内核支持)
- Metal Conv1x1 分支选择优化:MetalConvolution1x1 分支路径优化
- CUDA Blackwell (sm_120) 支持:新增 sm_120 计算架构支持
- CUDA Eagle 推测解码优化:CUDA Eagle 推测解码性能优化
- QNN Qwen3.5 支持:QNN 后端支持 Qwen3.5 及视觉模型修复
- QNN 离线图多进程并行导出:使用多进程并行加速离线图导出
- QNN Binary 算子优化:加速视觉模型的 binary op 路径
CPU 后端
- RVV Int8 加速:新增 RVV 加速的 Int8 函数
- RVV 通用 opt 函数:新增 RVV 向量化的 MNNNorm、MNNGelu、MNNSiLu、MNNExpC8 等
- ARM v8.2/v8.6 Decode 优化:手机端 LLM decode 性能显著提升
- LinearAttention prefill fused kernel:新增 MNNFusedGatedDelta fused kernel
- LinearAttention L=1 decode 快速路径:新增 decode 快速路径
- Low-bit ARM 量化内核:CPU 新增 2/3-bit 等低比特 ARM 量化内核支持
- fp16 alpha lowMemory 优化:跳过 fp32 round-trip
- int4 reorder 性能优化:减少非 fast path 的 int4 reorder 开销
构建 / 测试 / 工具
- MNN 发布工作流升级:新增 LLM/OMNI、Harmony、Android 16K 页大小支持
- test_ci.sh:新增统一 CI 入口脚本
- CMake 生成 podspec:从 CMake 自动生成 podspec
- GEMM 性能基准:新增 FP32/INT8/Block32-INT4 GEMM 基准
- GEMV 带宽基准:新增 CPU/Metal w8/w4/w3/w2 GEMV 带宽基准
应用
- MNNChat Android 0.8.3 模型市场:为 Android 用户准备 0.8.3 版本模型目录
🐛 缺陷修复
LLM / VLM
- Qwen3.5 head_dim 自动检测:修复 gated attention 模型的 head_dim 自动检测
- LinearAttention prefix disk cache:修复 LinearAttention prefix disk cache 精度及混合模型支持问题
- prefix kvcache 损坏崩溃:修复 prefix kvcache
- 3.5.02026-04-07 · 2026-04-07 12:23 UTC
查看更新说明
MNN 3.5.0 版本发布说明
发布日期: 2026年4月
📌 版本概述
MNN 3.5.0 版本聚焦于 多后端 LLM 推理能力扩展、高性能量化与采样优化 以及 端侧语音交互体验增强 三大核心主题:
- 多后端 LLM 推理: Vulkan 后端新增 LLM 推理支持;摩尔线程 MUSA 后端全新接入;QNN 后端支持 Attention 算子和更多 LLM 算子;RISC-V 向量扩展(RVV)支持落地。
- 高性能量化与采样优化: 全新 TurboQuant TQ3/TQ4 KV Cache 量化方案;Sampler 重构为 Pipeline 架构并新增 Penalty 支持;多端 TopKV2 算子优化;多轮对话 Prompt Cache 支持。
- 端侧语音交互增强: 异步三阶段 Token2Wav 流水线(DiT ∥ Vocoder);智能打断(AEC Barge-in)支持;实时视觉语音交互能力;TTS 模型支持(supertonic-tts-mnn)。
🚀 版本亮点
- Vulkan LLM 推理: Vulkan 后端全面支持 LLM 推理,拓展 GPU 推理覆盖面
- MUSA 后端支持: 全新接入摩尔线程 MUSA GPU 后端,支持国产 GPU 推理
- RISC-V RVV 支持: CPU 后端新增 RISC-V 向量扩展支持,拓展 RISC-V 生态
- TurboQuant TQ3/TQ4: 全新 KV Cache 量化方案,降低内存占用的同时保持推理质量
- Sampler Pipeline 重构: 采样器重构为流水线架构,支持 Penalty 等高级采样策略
- 多轮对话 Prompt Cache: 文本级别 Prompt Cache,显著加速多轮对话首 Token 延迟
- 异步 Token2Wav 三阶段流水线: DiT 与 Vocoder 并行的三阶段流水线,大幅提升语音合成吞吐
- 智能语音打断(AEC Barge-in): 支持回声消除的智能语音打断,提升语音交互自然度
- Tokenizer 全面重构: minja → jinja 模板引擎迁移,二进制 tokenizer 格式(tokenizer.mtok),加载速度 20x+ 提升
- GLM-OCR / LFM 模型支持: 新增 GLM-OCR 和 LFM(Liquid Foundation Model)模型推理支持
- Metal/CUDA/OpenCL TopKV2: 多端 TopKV2 算子实现与优化
✨ 新功能
LLM/VLM
- 多轮对话 Prompt Cache: 新增文本级别 Prompt Cache,多轮对话场景下显著加速首 Token 生成
- GLM-OCR 支持: 新增 GLM-OCR 模型推理支持
- LFM 支持: 新增 Liquid Foundation Model (LFM) 推理支持
- Qwen3.5 Smooth/Omni 导出: 支持 Qwen3.5 的 Smooth 量化和 Omni 模态导出
- Sampler Pipeline 重构: 采样器重构为流水线架构,新增 Penalty 机制支持
- 异步 Token2Wav 三阶段流水线: 将 Token 到音频的转换拆分为 DiT 和 Vocoder 并行的三阶段流水线
- 异步 Token2Wav 多运行时支持: Talker 的 LLM 和处理器使用不同运行时时支持异步 Token2Wav
- Tokenizer 重构: 全面重构 Tokenizer 系统:minja → jinja 模板引擎迁移;新增二进制 tokenizer 格式(tokenizer.mtok)替代文本格式;统一 JSON 处理(ujson.hpp);加载速度提升 20x+,编解码性能数倍提升;对齐 HuggingFace Transformers 实现
- Linear Attention 磁盘存储: 支持 Linear Attention 循环状态的磁盘读写
- mmap_size 配置: 新增 mmap_size 配置项,支持控制内存映射大小
- llm_bench Profile: llm_bench 新增 Profile 功能
GPU 后端
- Vulkan LLM 推理: Vulkan 后端全面支持 LLM 模型推理
- MUSA 后端: 全新接入摩尔线程 MUSA GPU 后端
- Metal TopKV2: Metal 后端新增 TopKV2 算子实现
- OpenCL TopKV2: OpenCL 后端新增 TopKV2 算子实现
- CUDA TopKV2 优化: 使用堆排序替代插入排序并结合循环展开,大幅提升 TopKV2 性能
- Metal While/BatchMatMul 4x4 分块: 通过 4x4 寄存器分块优化 While 和 BatchMatMul 算子
- Metal gemv/Binary/Scale 优化: 优化 gemv localsize、Binary 平面调度和 Scale 无偏置路径;移除 defer encoder
- OpenCL LinearAttention 优化: 优化 OpenCL LinearAttention 算子性能
- Metal LinearAttention 优化: 优化 Metal LinearAttention 算子性能
- OpenCL 内核创建保护: 为所有 OpenCL 算子添加内核创建保护机制
- QNN Attention 支持: QNN 后端支持 LLM Attention 算子,含 max_history_token 配置
- QNN 新增算子: QNN 后端新增 Transpose/UnPack/Pack 算子支持
- CUDA Qwen3.5 优化: CUDA 后端针对 Qwen3.5 模型进行优化
CPU 后端
- RISC-V RVV 支持: CPU 后端新增 RISC-V 向量扩展(RVV)支持
- TurboQuant TQ3/TQ4: 新增 TQ3/TQ4 KV Cache 量化方案
- LinearAttention NEON 优化: 使用 NEON 汇编和 FP16 优化 LinearAttention 算子
应用与工具
- 智能语音打断(AEC Barge-in): MNNChat 支持基于回声消除的智能语音打断
- 实时视觉语音交互: MNNChat 实现交互式语音聊天的实时视觉能力
- TTS 模型支持: Android MNNChat 支持 supertonic-tts-mnn 模型
- 繁体中文支持: Android 应用新增繁体中文(zh-rTW)语言支持
- F-Droid 上架: 新增 Fastlane 元数据,支持 F-Droid 应用商店上架
- CDN 自动上传: 新增基于 ali-oss 的 CDN 自动上传和市场配置上传脚本
🐛 缺陷修复
- Prefix Disk Cache: 修复首次响应后前缀磁盘缓存未加载的问题
- Jinja 渲染上下文: 修复 enable_thinking 等 Jinja 上下文未传递到模板渲染的问题
- Jinja 数组拼接: 修复 Jinja 二元加法处理数组时的错误
- mmap 权重死锁: 增强状态验证,避免部分初始化的 mmap 权重导致死锁
- KV Cache 污染: 修复 OmniQuant 校准前向传播中的 KV Cache 污染问题
- LLM 文件加载检查: Llm::load 中新增文件存在性和权限检查
- LLM 状态检查: 修复 LLM 运行状态检查逻辑
- MoE 专家属性获取: 修复 [email protected] 中 MoE 专家 getattr 兼容性问题
- llmexport Windows 崩溃: 修复 Windows 下使用 os.dup2 导致的 llmexport 崩溃
- llm_bench 修复: 使用 context 中的 n_gen 修复 llm_bench 统计
- Qwen3-Embedding QNN 导出: 修复 Qwen3-Embedding 的 QNN 导出流程
- 离线量化余弦距离: 修复离线量化中余弦距离计算错误
- 3.4.12026-03-05 · 2026-03-05 14:33 UTC
查看更新说明
MNN 3.4.1 版本发布说明
发布日期: 2026年3月
📌 版本概述
MNN 3.4.1 版本聚焦于 Qwen3.5 模型支持与 Linear Attention 算子、LLM 资源管理优化 与 安全性修复 三大核心主题:
- Qwen3.5 支持与 Linear Attention: 全新实现 Linear Attention 算子,覆盖 CPU、Metal、OpenCL、Vulkan 四大后端(性能待优化),支持 Qwen3.5 系列混合注意力架构;llmexport 新增对应模型导出能力。
- LLM 资源管理优化: LLM 实例内置独立 Executor 并在所有公开方法中使用 ExecutorScope,确保计算资源正确作用域化和及时释放,解决 Python 调用场景下的资源泄漏问题。
- 安全性与稳定性: 修复多个 Shape 算子和执行算子中的内存安全漏洞;修复 HQQ 量化 OOM 和大词表 Embedding 溢出;修复多个 LLM 和 GPU 后端缺陷。
🚀 版本亮点
- Qwen3.5 模型支持: 全新支持 Qwen3.5 及 Qwen3.5-MoE 系列模型,包括导出和推理
- Linear Attention 算子: CPU/Metal/OpenCL/Vulkan 四端实现(性能待优化),支持 Gated Delta Rule 循环状态更新
- Vulkan CoopMat Conv1x1: Vulkan 后端 Conv1x1 算子支持协作矩阵加速,进一步提升矩阵计算性能
- LLM Executor 内置化: 每个 LLM 实例自带独立 Executor,Python 绑定下资源释放更可靠
- 内存安全修复: 修复 7 个 Shape/执行算子中的越界访问、零步长、重复索引等安全漏洞
- HQQ 大模型量化修复: 修复 Qwen3.5-27B 等大模型 HQQ 量化 OOM 问题
- Sana Diffusion 增强: iOS/Android 全面支持 Sana 风格迁移、Omni 音频输出、视频输入等新功能
- Metal 后端增强: MetalConvolutionDepthwise 支持 Clone;修复 INT8/INT4 Conv2D 计算错误
✨ 新功能
LLM/VLM
- Qwen3.5 模型支持: 支持 Qwen3.5 和 Qwen3.5-MoE 模型的导出与推理,包括混合线性注意力架构
- Linear Attention 算子: 全新实现,包含 Conv1D + SiLU 激活、QKV 拆分、GQA(分组查询注意力)、L2 归一化和 Gated Delta Rule 循环状态更新
- CPU: 完整实现含卷积状态和循环状态缓冲区管理
- Metal: 三个 Compute Pipeline(conv_silu、conv_state_update、gated_delta_rule)
- OpenCL: Buffer 模式实现含专用 OpenCL 内核
- Vulkan: 三个 GLSL Compute Shader 实现
- 以上实现均为功能实现,性能还需优化
- LLM Executor 内置化: 每个 Llm 实例构造时创建独立 Executor,所有公开方法自动使用 ExecutorScope,析构时确保资源完整释放
- 新增 Tokenizer Demo(
tokenizer_demo.cpp)
GPU 后端
- Vulkan CoopMat Conv1x1: 新增
VulkanConv1x1Coop实现,包含 C4/COOP 数据布局转换和 INT4/INT8 权重转换 Shader - Metal Clone 支持: MetalConvolutionDepthwise 支持
onClone()操作
应用与工具
- Sana Diffusion(iOS): 新增风格迁移、Omni 音频输出、视频输入支持;新增批量测试框架
- Sana Diffusion(Android): 新增 Sana 原生 JNI 层和 Kotlin 会话封装;新增 Diffusion 设置界面
- Android Debug 工具: 新增 Benchmark/Download/Market/Sana/OpenAPI 多个 Stetho Dumper 插件
- Android 冒烟测试: 新增完整的冒烟测试框架,包含环境检查、安装、UI 捕获、回归测试和报告生成
- Sana 独立应用: 新增
apps/sana/独立脚本工具,支持 Android 和主机端 Benchmark
🔒 安全修复
修复多个算子中的内存安全漏洞:
- CPURandomUniform: 增加
size <= 0边界检查和low < high验证;增加类型特定处理 - ShapeSliceTf: 修复负值/越界
begin值导致的越界访问 - ShapeSpaceToBatchND: 增加
blockSize + spatialStart越界检查和blockData <= 0验证 - ShapeSpaceToDepth: 将
MNN_ASSERT替换为正确的错误返回;增加 H/W 对 blockSize 的整除检查 - ShapeSqueeze: 增加维度数上限检查和轴范围验证
- ShapeStridedSlice: 增加零步长检查,替换
MNN_ASSERT为优雅失败 - ShapeTranspose: 增加重复排列索引检测,防止非法内存访问
🐛 缺陷修复
- HQQ 量化 OOM: 修复 Qwen3.5-27B 等大模型量化时单 GPU 显存溢出,采用分块量化策略
- Embedding 整数溢出: 大词表(~240K tokens)场景下 DiskEmbedding 偏移量从
int改为size_t - LLM JSON 合并: 修复 Jinja 配置中
merge_and_clear的 JSON 递归合并问题 - 多模态 OOB 崩溃: 修复
llm_bench中多模态模型的越界崩溃 - Reranker Demo 崩溃: 修复未加载模型时 reranker_demo 崩溃
- Metal INT8/INT4 Conv2D: 修复
weighti8i4conv2d算子测试错误 - Benchmark 崩溃: 修复 Android Benchmark 崩溃问题
- Sana Resize 阈值: 修正 Sana resize 阈值设置
📚 其他改进
- CI: 新增 LLM PR Review 自动化流程;pymnn 发布工作流升级至 macOS-14
- Android 测试: 新增大量单元测试(ChatPresenter、ChatRouter、ChatInput、ModelListManager、ModelMarket 等)
- iOS 应用: 本地化全面更新;新增后端配置 UI;新增本地模型索引管理
- Android 应用: 模型市场大幅扩充;新增主设置页面;Debug Activity 增强
🙏 致谢
衷心感谢所有贡献者对本版本的宝贵贡献:
- @jxt1234 - Metal Clone 支持与后端修复
- @yanxing - LLM Benchmark 修复与 CI 改进
- @若遗 - Sana Android 集成与 Benchmark 修复
📦 不兼容变更
- LLM 实例现在内置独立 Executor,
llm_demo.cpp中不再需要外部创建 ExecutorScope(已自动移除)
完整变更日志: https://github.com/alibaba/MNN/compare/3.4.0...3.4.1
MNN 3.4.1 Release Notes
Release Date: March 2026
📌 Overview
MNN 3.4.1 focuses on three core themes: Qwen3.5 Model Support with Linear Attention, **LLM
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
News 🔥
-
[2026/11/04] We released MNN-Pocket-0.3B, a 300M-parameter mobile-app-native language model for Chinese/English instruction following. The MNN team co-designed its architecture, training methods, and inference engine around smartphone apps' task requirements and resource budgets. It supports 32K context; the INT4 (W4A16) QAT MNN build occupies only 173 MB and achieves 350 tok/s decode throughput in tests on iPhone 18 Pro. Released under Apache 2.0.
-
[2026/07/22] MNN 3.6.1 is released with a new 🚀 Hexagon backend, enabling accelerated model inference on Qualcomm Hexagon DSPs. Learn more.
-
[2026/03/05] Support Qwen3.5 Series.
- [2026/02/13] MNN-Sana-Edit-V2 is now available at apps, offering cartoon-style photo editing based on Sana.
- [2025/10/16] Support Qwen3-VL Series.
- [2025/06/11] New App MNN TaoAvatar released, you can talk with 3DAvatar offline with LLM, ASR, TTS, A2BS and NNR models all run local on your device!! MNN TaoAvatar
- [2025/05/12] android app support qwen2.5 omni 3b and 7b MNN Chat App.
- [2025/04/30] android app support qwen3 and dark mode MNN Chat App.
- [2025/02/18] iOS multimodal LLM App is released MNN LLM iOS.
- [2025/02/11] android app support for deepseek r1 1.5b.
- [2025/01/23] We released our full multimodal LLM Android App:MNN-LLM-Android. including text-to-text, image-to-text, audio-to-text, and text-to-image generation.
Intro
MNN is a highly efficient and lightweight deep learning framework. It supports inference and training of deep learning models and has industry-leading performance for inference and training on-device. At present, MNN has been integrated into more than 30 apps of Alibaba Inc, such as Taobao, Tmall, Youku, DingTalk, Xianyu, etc., covering more than 70 usage scenarios such as live broadcast, short video capture, search recommendation, product searching by image, interactive marketing, equity distribution, security risk control. In addition, MNN is also used on embedded devices, such as IoT.
MNN-LLM is a large language model runtime solution developed based on the MNN engine. The mission of this project is to deploy LLM models locally on everyone's platforms(Mobile Phone/PC/IOT). It supports popular large language models such as Qianwen, Baichuan, Zhipu, LLAMA, and others. MNN-LLM User guide
MNN-Diffusion is a stable diffusion model runtime solution developed based on the MNN engine. The mission of this project is to deploy stable diffusion models locally on everyone's platforms. MNN-Diffusion User guide

Inside Alibaba, MNN works as the basic module of the compute container in the Walle System, the first end-to-end, general-purpose, and large-scale production system for device-cloud collaborative machine learning, which has been published in the top system conference OSDI’22. The key design principles of MNN and the extensive benchmark testing results (vs. TensorFlow, TensorFlow Lite, PyTorch, PyTorch Mobile, TVM) can be found in the OSDI paper. The scripts and instructions for benchmark testing are put in the path “/benchmark”. If MNN or the design of Walle helps your research or production use, please cite our OSDI paper as follows:
@inproceedings {proc:osdi22:walle,
author = {Chengfei Lv and Chaoyue Niu and Renjie Gu and Xiaotang Jiang and Zhaode Wang and Bin Liu and Ziqi Wu and Qiulin Yao and Congyu Huang and Panos Huang and Tao Huang and Hui Shu and Jinde Song and Bin Zou and Peng Lan and Guohuan Xu and Fei Wu and Shaojie Tang and Fan Wu and Guihai Chen},
title = {Walle: An {End-to-End}, {General-Purpose}, and {Large-Scale} Production System for {Device-Cloud} Collaborative Machine Learning},
booktitle = {16th USENIX Symposium on Operating Systems Design and Implementation (OSDI 22)},
year = {2022},
isbn = {978-1-939133-28-1},
address = {Carlsbad, CA},
pages = {249--265},
url = {https://www.usenix.org/conference/osdi22/presentation/lv},
publisher = {USENIX Association},
month = jul,
}
Documentation and Workbench
MNN's docs are in place in Read the docs.
You can also read docs/README to build docs's html.
MNN Workbench could be downloaded from MNN's homepage, which provides pretrained models, visualized training tools, and one-click deployment of models to devices.
Key Features
Lightweight
- Optimized for devices, no dependencies, can be easily deployed to mobile devices and a variety of embedded devices.
- iOS platform: static library size will full option for armv7+arm64 platforms is about 12MB, size increase of linked executables is about 2M.
- Android platform: core so size is about 800KB (armv7a - c++_shared).
- Using MNN_BUILD_MINI can reduce package size by about 25%, with a limit of fixed model input size
- Support FP16 / Int8 quantize, can reduce model size 50%-70%
Versatility
- Supports
Tensorflow,Caffe,ONNX,Torchscriptsand supports common neural networks such asCNN,RNN,GAN,Transformer. - Supports AI model with multi-inputs or multi-outputs, every kind of dimension format, dynamic inputs, controlflow.
- MNN supports approximate full OPs used for the AI Model. The converter supports 178
TensorflowOPs, 52CaffeOPs, 163TorchscriptsOPs, 158ONNXOPs. - Supports iOS 8.0+, Android 4.3+, and embedded devices with POSIX interface.
- Supports hybrid computing on multiple devices. Currently supports CPU and GPU.
High performance
- Implements core computing with lots of optimized assembly code to make full use of the ARM / x64 CPU.
- Use Metal / OpenCL / Vulkan to support GPU inference on mobile.
- Use CUDA and tensorcore to support NVIDIA GPU for better performance
- Convolution and transposition convolution algorithms are efficient and stable. The Winograd convolution algorithm is widely used to better symmetric convolutions such as 3x3,4x4,5x5,6x6,7x7.
- Twice speed increase for the new architecture ARM v8.2 with FP16 half-precision calculation support. 2.5 faster to use sdot for ARM v8.2 and VNNI.
Ease of use
- Support use MNN's OP to do numerical calculating like numpy.
- Support lightweight image process module like OpenCV, which is only 100k.
- Support build model and train it on PC / mobile.
- MNN Python API helps ML engineers to easily use MNN to infer, train, and process images, without dipping their toes in C++ code.
The Architecture / Precision MNN supported is shown below:
- S :Support and work well, deeply optimized, recommend to use
- A :Support and work well, can use
- B :Support but has bug or not optimized, no recommend to use
- C :Not Support
| Architecture / Precision | Normal | FP16 | BF16 | INT8 / INT4 | |
|---|---|---|---|---|---|
| CPU | Native | B | C | B | B |
| x86/x64-SSE4.1 | A | C | C | A | |
| x86/x64-AVX2 | S | C | C | A | |
| x86/x64-AVX512 | S | C | C | S | |
| ARMv7a | S | C | S | S | |
| ARMv8 | S | S (ARMv8.2) | S(ARMv8.6) | S | |
| ARMv9 (SME2) | S | S | B | S | |
| RISC-V (RVV) | A | C | C | B | |
| GPU | OpenCL | A | S | C | S |
| Vulkan | A | A | C | A | |
| Metal | A | S | C | S | |
| CUDA | A | S | C | A | |
| NPU | CoreML | A | A | C | C |
| Hexagon | A | A | C | B | |
| NeuroPilot | B | B | C | B | |
| HIAI | A | C | C | C | |
| NNAPI | B | B | C | B | |
| QNN | C | B | C | A |
CoreML primarily uses FP16 MIL tensors and weights in Precision_Normal; Precision_Low is not a separate execution path. Core ML selects the compute device for each operation.
Hexagon uses FP16 device tensors even with normal-precision host input.
ARMv9 can use ARMv8 paths; SME2 acceleration requires a supported CPU and build configuration. BF16 uses the existing ARM path and requires MNN_SUPPORT_BF16. RISC-V IME2 optimizations target SpacemiT K3.
INT8 / INT4 ratings cover supported quantized model paths, including weight-only quantization; they do not imply full integer execution for every operator. Hexagon LLM currently documents symmetric INT4 weights with FP16 activations. QNN support depends on the target and quantization configuration.
Tools
Base on MNN (Tensor compute engine), we provided a series of tools for inference, train and general computation.
- MNN-Converter: Convert other models to MNN models for inference, such as Tensorflow(lite), Caffe, ONNX, Torchscripts. And do graph optimization to reduce computation.
- MNN-Compress: Compress model to reduce size and increase performance / speed
- MNN-Express: Support model with controlflow, use MNN's OP to do general-purpose computing.
- MNN-CV: An OpenCV-like library, but based on MNN and then much more lightweight.
- MNN-Train: Support train MNN model.
How to Discuss and Get Help From the MNN Community
The group discussions are predominantly Chinese. But we welcome and will help English speakers.
Dingtalk discussion groups:
Group #4 (Available): 160170007549
Group #3 (Full)
Group #2 (Full): 23350225
Group #1 (Full): 23329087
Historical Paper
The preliminary version of MNN, as mobile inference engine and with the focus on manual optimization, has also been published in MLSys 2020. Please cite the paper, if MNN previously helped your research:
@inproceedings{alibaba2020mnn,
author = {Jiang, Xiaotang and Wang, Huan and Chen, Yiliu and Wu, Ziqi and Wang, Lichuan and Zou, Bin and Yang, Yafeng and Cui, Zongyang and Cai, Yu and Yu, Tianhang and Lv, Chengfei and Wu, Zhihua},
title = {MNN: A Universal and Efficient Inference Engine},
booktitle = {MLSys},
year = {2020}
}
License
Apache 2.0
Acknowledgement
MNN participants: Taobao Technology Department, Search Engineering Team, DAMO Team, Youku and other Alibaba Group employees.
MNN refers to the following projects:
