[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Tiiny-AI--PowerInfer":3,"tool-Tiiny-AI--PowerInfer":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",145895,2,"2026-04-08T11:32:59",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":122,"forks":123,"last_commit_at":124,"license":125,"difficulty_score":126,"env_os":127,"env_gpu":128,"env_ram":129,"env_deps":130,"category_tags":136,"github_topics":137,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":143,"updated_at":144,"faqs":145,"releases":174},5665,"Tiiny-AI\u002FPowerInfer","PowerInfer","High-speed Large Language Model Serving for Local Deployment","PowerInfer 是一款专为个人电脑设计的高速大语言模型推理引擎，旨在让普通消费级显卡也能流畅运行大型 AI 模型。它主要解决了在本地设备部署大模型时显存受限、推理速度慢的难题，无需依赖昂贵的服务器集群即可实现高效响应。\n\n无论是希望保护数据隐私的开发者、需要快速验证算法的研究人员，还是想在本地体验先进 AI 能力的普通用户，都能从中受益。PowerInfer 的核心技术亮点在于巧妙利用了大模型推理过程中的“激活局部性”特征（即神经元激活遵循幂律分布），通过 CPU 与 GPU 的协同工作，仅动态加载和计算关键参数。这种机制大幅降低了显存占用并提升了计算效率。实测数据显示，在单张 RTX 4090 显卡上运行 400 亿参数的模型时，其速度可比传统方案提升 11 倍以上。此外，它还支持 Windows 及 AMD ROCm 环境，并推出了针对手机端优化的版本，真正推动了高性能 AI 在终端设备上的普及。","# PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU\n\n## TL;DR\nPowerInfer is a CPU\u002FGPU LLM inference engine leveraging **activation locality** for your device.\n\n\u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F6186\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_4a68feb902da.png\" alt=\"SJTU-IPADS%2FPowerInfer | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\u003C\u002Fa>\n\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\n[Project Kanban](https:\u002F\u002Fgithub.com\u002Forgs\u002FSJTU-IPADS\u002Fprojects\u002F2\u002Fviews\u002F2)\n\n## Latest News 🔥\n- [2026\u002F1\u002F5] We released **[Tiiny AI Pocket Lab](https:\u002F\u002Ftiiny.ai\u002F)**, the world's first pocket-size supercomputer. It runs GPT-OSS-120B (int4) locally at **20 tokens\u002Fs**. Featured at CES 2026.\n- [2025\u002F7\u002F27] We released [SmallThinker-21BA3B-Instruct](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FSmallThinker-21BA3B-Instruct) and [SmallThinker-4BA0.6B-Instruct](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FSmallThinker-4BA0.6B-Instruct). We also released a corresponding framework for efficient [on-device inference](.\u002Fsmallthinker\u002FREADME.md). \n- [2024\u002F6\u002F11] We are thrilled to introduce [PowerInfer-2](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.06282), our highly optimized inference framework designed specifically for smartphones. With TurboSparse-Mixtral-47B, it achieves an impressive speed of 11.68 tokens per second, which is up to 22 times faster than other state-of-the-art frameworks.\n- [2024\u002F6\u002F11] We are thrilled to present [Turbo Sparse](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.05955), our TurboSparse models for fast inference. With just $0.1M, we sparsified the original Mistral and Mixtral model to nearly 90% sparsity while maintaining superior performance! For a Mixtral-level model, our TurboSparse-Mixtral activates only **4B** parameters!\n- [2024\u002F5\u002F20] **Competition Recruitment: CCF-TCArch Customized Computing Challenge 2024**. The CCF TCARCH CCC is a national competition organized by the Technical Committee on Computer Architecture (TCARCH) of the China Computer Federation (CCF). This year's competition aims to optimize the PowerInfer inference engine using the open-source ROCm\u002FHIP. More information about the competition can be found [here](https:\u002F\u002Fccf-tcarch-ccc.github.io\u002F2024\u002F).\n- [2024\u002F5\u002F17] We now provide support for AMD devices with ROCm.\n- [2024\u002F3\u002F28] We are trilled to present [Bamboo LLM](https:\u002F\u002Fgithub.com\u002FSJTU-IPADS\u002FBamboo) that achieves both top-level performance and unparalleled speed with PowerInfer! Experience it with Bamboo-7B [Base](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-gguf) \u002F [DPO](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-gguf).\n- [2024\u002F3\u002F14] We supported ProSparse Llama 2 ([7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-7b)\u002F[13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-13b)), ReLU models with ~90% sparsity, matching original Llama 2's performance (Thanks THUNLP & ModelBest)!\n- [2024\u002F1\u002F11] We supported Windows with GPU inference!\n- [2023\u002F12\u002F24] We released an online [gradio demo](https:\u002F\u002Fpowerinfer-gradio.vercel.app\u002F) for Falcon(ReLU)-40B-FP16!\n- [2023\u002F12\u002F19] We officially released PowerInfer!\n\n## Demo 🔥\n\nhttps:\u002F\u002Fgithub.com\u002FSJTU-IPADS\u002FPowerInfer\u002Fassets\u002F34213478\u002Ffe441a42-5fce-448b-a3e5-ea4abb43ba23\n\nPowerInfer v.s. llama.cpp on a single RTX 4090(24G) running Falcon(ReLU)-40B-FP16 with a 11x speedup!\n\n\u003Csub>Both PowerInfer and llama.cpp were running on the same hardware and fully utilized VRAM on RTX 4090.\u003C\u002Fsub>\n\n> [!NOTE]\n> **Live Demo Online⚡️**\n>\n> Try out our [Gradio server](https:\u002F\u002Fpowerinfer-gradio.vercel.app\u002F) hosting Falcon(ReLU)-40B-FP16 on a RTX 4090!\n>\n> \u003Csub>Experimental and without warranties 🚧\u003C\u002Fsub>\n\n## Abstract\n\nWe introduce PowerInfer, a high-speed Large Language Model (LLM) inference engine on a personal computer (PC)\nequipped with a single consumer-grade GPU. The key underlying the design of PowerInfer is exploiting the high **locality**\ninherent in LLM inference, characterized by a power-law distribution in neuron activation.\n\nThis distribution indicates that a small subset of neurons, termed hot neurons, are consistently activated\nacross inputs, while the majority, cold neurons, vary based on specific inputs.\nPowerInfer exploits such an insight to design a GPU-CPU hybrid inference engine:\nhot-activated neurons are preloaded onto the GPU for fast access, while cold-activated neurons are computed\non the CPU, thus significantly reducing GPU memory demands and CPU-GPU data transfers.\nPowerInfer further integrates adaptive predictors and neuron-aware sparse operators,\noptimizing the efficiency of neuron activation and computational sparsity.\n\nEvaluation shows that PowerInfer attains an average token generation rate of 13.20 tokens\u002Fs, with a peak of 29.08 tokens\u002Fs, across various LLMs (including OPT-175B) on a single NVIDIA RTX 4090 GPU,\nonly 18\\% lower than that achieved by a top-tier server-grade A100 GPU.\nThis significantly outperforms llama.cpp by up to 11.69x while retaining model accuracy.\n\n## Features\nPowerInfer is a high-speed and easy-to-use inference engine for deploying LLMs locally.\n\nPowerInfer is fast with:\n\n- **Locality-centric design**: Utilizes sparse activation and 'hot'\u002F'cold' neuron concept for efficient LLM inference, ensuring high speed with lower resource demands.\n- **Hybrid CPU\u002FGPU Utilization**: Seamlessly integrates memory\u002Fcomputation capabilities of CPU and GPU for a balanced workload and faster processing.\n\nPowerInfer is flexible and easy to use with:\n\n- **Easy Integration**: Compatible with popular [ReLU-sparse models](https:\u002F\u002Fhuggingface.co\u002FSparseLLM).\n- **Local Deployment Ease**: Designed and deeply optimized for local deployment on consumer-grade hardware, enabling low-latency LLM inference and serving on a single GPU.\n- **Backward Compatibility**: While distinct from llama.cpp, you can make use of most of `examples\u002F` the same way as llama.cpp such as server and batched generation. PowerInfer also supports inference with llama.cpp's model weights for compatibility purposes, but there will be no performance gain.\n\nYou can use these models with PowerInfer today:\n\n- Falcon-40B\n- Llama2 family\n- ProSparse Llama2 family\n- Bamboo-7B\n\nWe have tested PowerInfer on the following platforms:\n\n- x86-64 CPUs with AVX2 instructions, with or without NVIDIA GPUs, under **Linux**.\n- x86-64 CPUs with AVX2 instructions, with or without NVIDIA GPUs, under **Windows**.\n- Apple M Chips (CPU only) on **macOS**. (As we do not optimize for Mac, the performance improvement is not significant now.)\n\nAnd new features coming soon:\n\n- Metal backend for sparse inference on macOS\n\nPlease kindly refer to our [Project Kanban](https:\u002F\u002Fgithub.com\u002Forgs\u002FSJTU-IPADS\u002Fprojects\u002F2\u002Fviews\u002F2) for our current focus of development.\n\n## Getting Started\n\n- [Installation](#setup-and-installation)\n- [Model Weights](#model-weights)\n- [Inference](#inference)\n\n## Setup and Installation\n\n### Pre-requisites\n\nPowerInfer requires the following dependencies:\n\n- CMake (3.17+)\n- Python (3.8+) and pip (19.3+), for converting model weights and automatic FFN offloading\n\n### Get the Code\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\ncd PowerInfer\npip install -r requirements.txt # install Python helpers' dependencies\n```\n### Build\n\nIn order to build PowerInfer you have two different options. These commands are supposed to be run from the root directory of the project.\n\nUsing `CMake`(3.17+):\n* If you have an NVIDIA GPU:\n```bash\ncmake -S . -B build -DLLAMA_CUBLAS=ON\ncmake --build build --config Release\n```\n* If you have an AMD GPU:\n```bash\n# Replace '1100' to your card architecture name, you can get it by rocminfo\nCC=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang CXX=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang++ cmake -S . -B build -DLLAMA_HIPBLAS=ON -DAMDGPU_TARGETS=gfx1100\ncmake --build build --config Release\n```\n\n* If you have just CPU:\n\n```bash\ncmake -S . -B build\ncmake --build build --config Release\n```\n\n## Model Weights\n\nPowerInfer models are stored in a special format called *PowerInfer GGUF* based on GGUF format, consisting of both LLM weights and predictor weights.\n\n### Download PowerInfer GGUF via Hugging Face\n\nYou can obtain PowerInfer GGUF weights at `*.powerinfer.gguf` as well as profiled model activation statistics for 'hot'-neuron offloading from each Hugging Face repo below.\n\n| Base Model            | PowerInfer GGUF                                                                                               |\n| --------------------- | ------------------------------------------------------------------------------------------------------------- |\n| LLaMA(ReLU)-2-7B      | [PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF)     |\n| LLaMA(ReLU)-2-13B     | [PowerInfer\u002FReluLLaMA-13B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-13B-PowerInfer-GGUF)   |\n| Falcon(ReLU)-40B      | [PowerInfer\u002FReluFalcon-40B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluFalcon-40B-PowerInfer-GGUF) |\n| LLaMA(ReLU)-2-70B     | [PowerInfer\u002FReluLLaMA-70B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-70B-PowerInfer-GGUF)   |\n| ProSparse-LLaMA-2-7B  | [PowerInfer\u002FProSparse-LLaMA-2-7B-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-7b-gguf)           |\n| ProSparse-LLaMA-2-13B | [PowerInfer\u002FProSparse-LLaMA-2-13B-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-13b-gguf)         |\n| Bamboo-base-7B 🌟      | [PowerInfer\u002FBamboo-base-v0.1-gguf](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-gguf)                   |\n| Bamboo-DPO-7B 🌟       | [PowerInfer\u002FBamboo-DPO-v0.1-gguf](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-gguf)                     |\n\nWe recommend using [`huggingface-cli`](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fhuggingface_hub\u002Fguides\u002Fcli) to download the whole model repo. For example, the following command will download [PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF) into the `.\u002FReluLLaMA-7B` directory.\n\n```shell\nhuggingface-cli download --resume-download --local-dir ReluLLaMA-7B --local-dir-use-symlinks False PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF\n```\n\nAs such, PowerInfer can automatically make use of the following directory structure for feature-complete model offloading:\n```\n.\n├── *.powerinfer.gguf (Unquantized PowerInfer model)\n├── *.q4.powerinfer.gguf (INT4 quantized PowerInfer model, if available)\n├── activation (Profiled activation statistics for fine-grained FFN offloading)\n│   ├── activation_x.pt (Profiled activation statistics for layer x)\n│   └── ...\n├── *.[q4].powerinfer.gguf.generated.gpuidx (Generated GPU index at runtime for corresponding model)\n```\n\n### Convert from Original Model Weights + Predictor Weights\n\nHugging Face limits single model weight to 50GiB. For unquantized models >= 40B, you can convert PowerInfer GGUF from the original model weights and predictor weights obtained from Hugging Face.\n\n| Base Model            | Original Model                                                                            | Predictor                                                                                                       |\n| --------------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |\n| LLaMA(ReLU)-2-7B      | [SparseLLM\u002FReluLLaMA-7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-7B)                   | [PowerInfer\u002FReluLLaMA-7B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-Predictor)                   |\n| LLaMA(ReLU)-2-13B     | [SparseLLM\u002FReluLLaMA-13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-13B)                 | [PowerInfer\u002FReluLLaMA-13B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-13B-Predictor)                 |\n| Falcon(ReLU)-40B      | [SparseLLM\u002FReluFalcon-40B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluFalcon-40B)               | [PowerInfer\u002FReluFalcon-40B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluFalcon-40B-Predictor)               |\n| LLaMA(ReLU)-2-70B     | [SparseLLM\u002FReluLLaMA-70B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-70B)                 | [PowerInfer\u002FReluLLaMA-70B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-70B-Predictor)                 |\n| ProSparse-LLaMA-2-7B  | [SparseLLM\u002FProSparse-LLaMA-2-7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-7b)   | [PowerInfer\u002FProSparse-LLaMA-2-7B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-7b-predictor)   |\n| ProSparse-LLaMA-2-13B | [SparseLLM\u002FProSparse-LLaMA-2-13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-13b) | [PowerInfer\u002FProSparse-LLaMA-2-13B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-13b-predictor) |\n| Bamboo-base-7B 🌟      | [PowerInfer\u002FBamboo-base-v0.1](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0_1)         | [PowerInfer\u002FBamboo-base-v0.1-predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-predictor)           |\n| Bamboo-DPO-7B 🌟       | [PowerInfer\u002FBamboo-DPO-v0.1](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0_1)           | [PowerInfer\u002FBamboo-DPO-v0.1-predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-predictor)             |\n\nYou can use the following command to convert the original model weights and predictor weights to PowerInfer GGUF:\n```bash\n# make sure that you have done `pip install -r requirements.txt`\npython convert.py --outfile \u002FPATH\u002FTO\u002FPOWERINFER\u002FGGUF\u002FREPO\u002FMODELNAME.powerinfer.gguf \u002FPATH\u002FTO\u002FORIGINAL\u002FMODEL \u002FPATH\u002FTO\u002FPREDICTOR\n# python convert.py --outfile .\u002FReluLLaMA-70B-PowerInfer-GGUF\u002Fllama-70b-relu.powerinfer.gguf .\u002FSparseLLM\u002FReluLLaMA-70B .\u002FPowerInfer\u002FReluLLaMA-70B-Predictor\n```\nFor the same reason, we suggest keeping the same directory structure as PowerInfer GGUF repos after conversion.\n\n\u003Cdetails>\n\n\u003Csummary>Convert Original models into dense GGUF models(compatible with llama.cpp)\u003C\u002Fsummary>\n\n```bash\npython convert-dense.py --outfile \u002FPATH\u002FTO\u002FDENSE\u002FGGUF\u002FREPO\u002FMODELNAME.gguf \u002FPATH\u002FTO\u002FORIGINAL\u002FMODEL\n# python convert-dense.py --outfile .\u002FBamboo-DPO-v0.1-gguf\u002Fbamboo-7b-dpo-v0.1.gguf --outtype f16 .\u002FBamboo-DPO-v0.1\n```\n\nPlease note that the generated dense GGUF models might not work properly with llama.cpp, as we have altered activation functions (for ReluLLaMA and Prosparse models), or the model architecture (for Bamboo models). The dense GGUF models generated by convert-dense.py can be used for PowerInfer in dense inference mode, but might not work properly with llama.cpp.\n\n\u003C\u002Fdetails>\n\n## Inference\n\nFor CPU-only and CPU-GPU hybrid inference with all available VRAM, you can use the following instructions to run PowerInfer:\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FMODEL -n $output_token_count -t $thread_num -p $prompt\n# e.g.: .\u002Fbuild\u002Fbin\u002Fmain -m .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.q4.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\"\n# For Windows: .\\build\\bin\\Release\\main.exe -m .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.q4.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\"\n```\n\nIf you want to limit the VRAM usage of GPU:\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FMODEL -n $output_token_count -t $thread_num -p $prompt --vram-budget $vram_gb\n# e.g.: .\u002Fbuild\u002Fbin\u002Fmain -m .\u002FReluLLaMA-7B-PowerInfer-GGUF\u002Fllama-7b-relu.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\" --vram-budget 8\n# For Windows: .\\build\\bin\\Release\\main.exe -m .\\ReluLLaMA-7B-PowerInfer-GGUF\\llama-7b-relu.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\" --vram-budget 8\n```\nUnder CPU-GPU hybrid inference, PowerInfer will automatically offload all dense activation blocks to GPU, then split FFN and offload to GPU if possible.\n\n\u003Cdetails>\n\u003Csummary>Dense inference mode (limited support)\u003C\u002Fsummary>\n\nIf you want to run PowerInfer to infer with the dense variants of the PowerInfer model family, you can use similarly as llama.cpp does:\n\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FDENSE\u002FMODEL -n $output_token_count -t $thread_num -p $prompt -ngl $num_gpu_layers\n# e.g.: .\u002Fbuild\u002Fbin\u002Fmain -m .\u002FBamboo-base-v0.1-gguf\u002Fbamboo-7b-v0.1.gguf -n 128 -t 8 -p \"Once upon a time\" -ngl 12\n```\n\nSo is the case for other `examples\u002F` like `server` and `batched_generation`. Please note that the dense inference mode is not a \"compatible mode\" for all models. We have altered activation functions (for ReluLLaMA and Prosparse models) in this mode to match with our model family. \n\n\u003C\u002Fdetails>\n\n## Serving, Perplexity Evaluation, and more applications\n\nPowerInfer supports serving and batched generation with the same instructions as llama.cpp. Generally, you can use the same command as llama.cpp, except for `-ngl` argument which has been replaced by `--vram-budget` for PowerInfer. Please refer to the detailed instructions in each `examples\u002F` directory. For example:\n\n- [Serving](.\u002Fexamples\u002Fserver\u002FREADME.md)\n- [Perplexity Evaluation](.\u002Fexamples\u002Fperplexity\u002FREADME.md)\n- [Batched Generation](.\u002Fexamples\u002Fbatched\u002FREADME.md)\n\n## Quantization\n\nPowerInfer has optimized quantization support for INT4(`Q4_0`) models. You can use the following instructions to quantize PowerInfer GGUF model:\n```bash\n.\u002Fbuild\u002Fbin\u002Fquantize \u002FPATH\u002FTO\u002FMODEL \u002FPATH\u002FTO\u002FOUTPUT\u002FQUANTIZED\u002FMODEL Q4_0\n# e.g.: .\u002Fbuild\u002Fbin\u002Fquantize .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.powerinfer.gguf .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.q4.powerinfer.gguf Q4_0\n# For Windows: .\\build\\bin\\Release\\quantize.exe .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.powerinfer.gguf .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.q4.powerinfer.gguf Q4_0\n```\nThen you can use the quantized model for inference with PowerInfer with the same instructions as above.\n\n## More Documentation\n- [Performance troubleshooting](.\u002Fdocs\u002Ftoken_generation_performance_tips.md)\n\n## Evaluation\n\nWe evaluated PowerInfer vs. llama.cpp on a single RTX 4090(24G) with a series of FP16 ReLU models under inputs of length 64, and the results are shown below. PowerInfer achieves up to 11x speedup on Falcon 40B and up to 3x speedup on Llama 2 70B.\n\n![github-eval-4090](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_c6cb0b04fb57.png)\n\u003Csub>The X axis indicates the output length, and the Y axis represents the speedup compared with llama.cpp. The number above each bar indicates the end-to-end generation speed (total prompting + generation time \u002F total tokens generated, in tokens\u002Fs).\u003C\u002Fsub>\n\nWe also evaluated PowerInfer on a single RTX 2080Ti(11G) with INT4 ReLU models under inputs of length 8, and the results are illustrated in the same way as above. PowerInfer achieves up to 8x speedup on Falcon 40B and up to 3x speedup on Llama 2 70B.\n\n![github-eval-2080ti-q4](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_d78c16f4146c.png)\n\nPlease refer to our [paper](https:\u002F\u002Fipads.se.sjtu.edu.cn\u002F_media\u002Fpublications\u002Fpowerinfer-20231219.pdf) for more evaluation details.\n\n## FAQs\n1. What if I encountered `CUDA_ERROR_OUT_OF_MEMORY`?\n   - You can try to run with `--reset-gpu-index` argument to rebuild the GPU index for this model to avoid any stale cache.\n   - Due to our current implementation, model offloading might not be as accurate as expected. You can try with `--vram-budget` with a slightly lower value or `--disable-gpu-index` to disable FFN offloading.\n\n2. Does PowerInfer support mistral, original llama, Qwen, ...?\n   - Now we only support models with ReLU\u002FReGLU\u002FSquared ReLU activation function. So we do not support these models now. It's worth mentioning that a [paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2310.04564.pdf) has demonstrated that using the ReLU\u002FReGLU activation function has a negligible impact on convergence and performance.\n\n3. Why is there a noticeable downgrade in the performance metrics of our current ReLU model, particularly the 70B model?\n   - In contrast to the typical requirement of around 2T tokens for LLM training, our model's fine-tuning was conducted with only 5B tokens. This insufficient retraining has resulted in the model's inability to regain its original performance. We are actively working on updating to a more capable model, so please stay tuned.\n\n4. What if...\n   - Issues are welcomed! Please feel free to open an issue and attach your running environment and running parameters. We will try our best to help you.\n\n## TODOs\nWe will release the code and data in the following order, please stay tuned!\n\n- [x] Release core code of PowerInfer, supporting Llama-2, Falcon-40B.\n- [x] Support ~~Mistral-7B~~ (Bamboo-7B)\n- [x] Support Windows\n- [ ] Support text-generation-webui\n- [x] Release perplexity evaluation code\n- [ ] Support Metal for Mac\n- [ ] Release code for OPT models\n- [ ] Release predictor training code\n- [x] Support online split for FFN network\n- [ ] Support Multi-GPU\n\n\n## Paper and Citation\nMore technical details can be found in our [paper](https:\u002F\u002Fipads.se.sjtu.edu.cn\u002F_media\u002Fpublications\u002Fpowerinfer-20231219.pdf).\n\nIf you find PowerInfer useful or relevant to your project and research, please kindly cite our paper:\n\n```bibtex\n@misc{song2023powerinfer,\n      title={PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU},\n      author={Yixin Song and Zeyu Mi and Haotong Xie and Haibo Chen},\n      year={2023},\n      eprint={2312.12456},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n\n## Acknowledgement\nWe are thankful for the easily modifiable operator library [ggml](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml) and execution runtime provided by [llama.cpp](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fllama.cpp). We also extend our gratitude to [THUNLP](https:\u002F\u002Fnlp.csai.tsinghua.edu.cn\u002F) for their support of ReLU-based sparse models. We also appreciate the research of [Deja Vu](https:\u002F\u002Fproceedings.mlr.press\u002Fv202\u002Fliu23am.html), which inspires PowerInfer.\n","# PowerInfer：使用消费级显卡实现快速的大语言模型推理\n\n## 简要说明\nPowerInfer 是一款利用**激活局部性**为您的设备提供服务的 CPU\u002FGPU LLM 推理引擎。\n\n\u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F6186\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_4a68feb902da.png\" alt=\"SJTU-IPADS%2FPowerInfer | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\u003C\u002Fa>\n\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\n[项目看板](https:\u002F\u002Fgithub.com\u002Forgs\u002FSJTU-IPADS\u002Fprojects\u002F2\u002Fviews\u002F2)\n\n## 最新消息 🔥\n- [2026年1月5日] 我们发布了 **[Tiiny AI Pocket Lab](https:\u002F\u002Ftiiny.ai\u002F)**，这是全球首款袖珍型超级计算机。它可以在本地以 **20 tokens\u002Fs** 的速度运行 GPT-OSS-120B (int4)。该产品已在 CES 2026 上亮相。\n- [2025年7月27日] 我们发布了 [SmallThinker-21BA3B-Instruct](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FSmallThinker-21BA3B-Instruct) 和 [SmallThinker-4BA0.6B-Instruct](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FSmallThinker-4BA0.6B-Instruct)。同时，我们还发布了一个用于高效 [设备端推理](.\u002Fsmallthinker\u002FREADME.md) 的相应框架。\n- [2024年6月11日] 我们非常高兴地推出 [PowerInfer-2](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.06282)，这是我们专为智能手机设计的高度优化的推理框架。借助 TurboSparse-Mixtral-47B，其速度达到了惊人的每秒 11.68 个 token，比其他最先进的框架快高达 22 倍。\n- [2024年6月11日] 我们很高兴地推出 [Turbo Sparse](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.05955)，我们的 TurboSparse 模型旨在实现快速推理。仅花费 10 万美元，我们就将原始的 Mistral 和 Mixtral 模型稀疏化至近 90% 的稀疏度，同时保持卓越性能！对于 Mixtral 级别的模型，我们的 TurboSparse-Mixtral 只激活 **4B** 个参数！\n- [2024年5月20日] **竞赛招募：CCF-TCArch 定制计算挑战赛 2024**。CCF TCARCH CCC 是由中国计算机学会（CCF）计算机体系结构技术委员会（TCARCH）组织的全国性竞赛。今年的比赛旨在使用开源 ROCm\u002FHIP 对 PowerInfer 推理引擎进行优化。有关比赛的更多信息，请参见 [这里](https:\u002F\u002Fccf-tcarch-ccc.github.io\u002F2024\u002F)。\n- [2024年5月17日] 我们现在为配备 ROCm 的 AMD 设备提供支持。\n- [2024年3月28日] 我们很高兴地推出 [Bamboo LLM](https:\u002F\u002Fgithub.com\u002FSJTU-IPADS\u002FBamboo)，它结合 PowerInfer 实现了顶级性能和无与伦比的速度！您可以体验 Bamboo-7B [Base](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-gguf) \u002F [DPO](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-gguf)。\n- [2024年3月14日] 我们支持了 ProSparse Llama 2 ([7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-7b)\u002F[13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-13b))，这些 ReLU 模型具有约 90% 的稀疏度，性能与原版 Llama 2 相当（感谢 THUNLP & ModelBest）！\n- [2024年1月11日] 我们支持了 Windows 平台上的 GPU 推理！\n- [2023年12月24日] 我们发布了 Falcon(ReLU)-40B-FP16 的在线 [gradio 演示](https:\u002F\u002Fpowerinfer-gradio.vercel.app\u002F)！\n- [2023年12月19日] 我们正式发布了 PowerInfer！\n\n## 演示 🔥\n\nhttps:\u002F\u002Fgithub.com\u002FSJTU-IPADS\u002FPowerInfer\u002Fassets\u002F34213478\u002Ffe441a42-5fce-448b-a3e5-ea4abb43ba23\n\n在单块 RTX 4090(24G) 上运行 Falcon(ReLU)-40B-FP16 时，PowerInfer 与 llama.cpp 的对比，速度提升了 11 倍！\n\n\u003Csub>PowerInfer 和 llama.cpp 都在同一硬件上运行，并充分利用了 RTX 4090 的显存。\u003C\u002Fsub>\n\n> [!NOTE]\n> **在线实时演示⚡️**\n>\n> 试试我们在 RTX 4090 上托管 Falcon(ReLU)-40B-FP16 的 [Gradio 服务器](https:\u002F\u002Fpowerinfer-gradio.vercel.app\u002F)！\n>\n> \u003Csub>实验性质，不提供任何保证🚧\u003C\u002Fsub>\n\n## 摘要\n\n我们推出了 PowerInfer，这是一款在配备单个消费级显卡的个人电脑（PC）上运行的高速大语言模型（LLM）推理引擎。PowerInfer 设计的核心在于利用 LLM 推理中固有的高 **局部性**，其特征是神经元激活呈现幂律分布。\n\n这种分布表明，一小部分被称为“热神经元”的神经元会在不同输入之间持续被激活，而大多数“冷神经元”则会根据具体输入而变化。PowerInfer 利用这一洞察，设计了一种 GPU-CPU 混合推理引擎：热激活的神经元被预先加载到 GPU 中以便快速访问，而冷激活的神经元则在 CPU 上进行计算，从而显著降低 GPU 显存需求和 CPU-GPU 数据传输量。此外，PowerInfer 还集成了自适应预测器和神经元感知稀疏算子，进一步优化了神经元激活效率和计算稀疏性。\n\n评估结果显示，在单个 NVIDIA RTX 4090 GPU 上，PowerInfer 在多种 LLM（包括 OPT-175B）上实现了平均 13.20 tokens\u002Fs 的令牌生成速率，峰值可达 29.08 tokens\u002Fs，仅比顶级服务器级 A100 GPU 的表现低 18%。这显著优于 llama.cpp，速度最高可提升 11.69 倍，同时保持模型精度。\n\n## 特点\nPowerInfer 是一款高速且易于使用的推理引擎，可用于在本地部署 LLM。\n\nPowerInfer 的优势在于：\n\n- **以局部性为核心的设计**：利用稀疏激活和“热”\u002F“冷”神经元概念，实现高效的 LLM 推理，确保在较低资源消耗下仍能保持高速。\n- **CPU\u002FGPU 混合利用**：无缝整合 CPU 和 GPU 的内存与计算能力，实现负载均衡和更快的处理速度。\n\nPowerInfer 具有灵活性和易用性，具体体现在：\n\n- **易于集成**：兼容流行的 [ReLU 稀疏模型](https:\u002F\u002Fhuggingface.co\u002FSparseLLM)。\n- **本地部署便捷**：专为消费级硬件的本地部署而设计并深度优化，可在单个 GPU 上实现低延迟的 LLM 推理和服务。\n- **向后兼容性**：尽管与 llama.cpp 不同，您仍然可以像使用 llama.cpp 一样使用大部分 `examples\u002F` 文件，例如服务器模式和批量生成。PowerInfer 也支持使用 llama.cpp 的模型权重进行推理，以确保兼容性，但不会带来性能提升。\n\n您今天就可以使用以下模型与 PowerInfer 配合：\n\n- Falcon-40B\n- Llama2 系列\n- ProSparse Llama2 系列\n- Bamboo-7B\n\n我们已经在以下平台上测试过 PowerInfer：\n\n- 具备 AVX2 指令集的 x86-64 CPU，无论是否配备 NVIDIA 显卡，均在 **Linux** 系统上运行。\n- 具备 AVX2 指令集的 x86-64 CPU，无论是否配备 NVIDIA 显卡，均在 **Windows** 系统上运行。\n- Apple M 芯片（仅 CPU），在 **macOS** 系统上运行。（由于我们尚未针对 Mac 进行优化，目前性能提升并不显著。）\n\n即将推出的新功能：\n\n- 适用于 macOS 的 Metal 后端，用于稀疏推理。\n\n请参阅我们的 [项目看板](https:\u002F\u002Fgithub.com\u002Forgs\u002FSJTU-IPADS\u002Fprojects\u002F2\u002Fviews\u002F2) 以了解我们当前的开发重点。\n\n## 开始使用\n\n- [安装](#setup-and-installation)\n- [模型权重](#model-weights)\n- [推理](#inference)\n\n## 设置与安装\n\n### 前置条件\n\nPowerInfer 需要以下依赖项：\n\n- CMake (3.17+)\n- Python (3.8+) 和 pip (19.3+)，用于模型权重转换及自动 FFN 卸载\n\n### 获取代码\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\ncd PowerInfer\npip install -r requirements.txt # 安装 Python 辅助工具的依赖\n```\n\n### 构建\n\n为了构建 PowerInfer，您有两种不同的选项。这些命令应在项目的根目录下执行。\n\n使用 `CMake`（3.17+）：\n\n* 如果您有 NVIDIA 显卡：\n```bash\ncmake -S . -B build -DLLAMA_CUBLAS=ON\ncmake --build build --config Release\n```\n\n* 如果您有 AMD 显卡：\n```bash\n# 将 '1100' 替换为您显卡的架构名称，可通过 rocminfo 获取\nCC=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang CXX=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang++ cmake -S . -B build -DLLAMA_HIPBLAS=ON -DAMDGPU_TARGETS=gfx1100\ncmake --build build --config Release\n```\n\n* 如果您只有 CPU：\n```bash\ncmake -S . -B build\ncmake --build build --config Release\n```\n\n## 模型权重\n\nPowerInfer 模型以基于 GGUF 格式的特殊格式 *PowerInfer GGUF* 存储，包含 LLM 权重和预测器权重。\n\n### 通过 Hugging Face 下载 PowerInfer GGUF\n\n您可以在以下 Hugging Face 仓库中获取 *.powerinfer.gguf* 格式的 PowerInfer GGUF 权重，以及用于“热点”神经元卸载的模型激活统计信息。\n\n| 基础模型            | PowerInfer GGUF                                                                                               |\n| --------------------- | ------------------------------------------------------------------------------------------------------------- |\n| LLaMA(ReLU)-2-7B      | [PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF)     |\n| LLaMA(ReLU)-2-13B     | [PowerInfer\u002FReluLLaMA-13B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-13B-PowerInfer-GGUF)   |\n| Falcon(ReLU)-40B      | [PowerInfer\u002FReluFalcon-40B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluFalcon-40B-PowerInfer-GGUF) |\n| LLaMA(ReLU)-2-70B     | [PowerInfer\u002FReluLLaMA-70B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-70B-PowerInfer-GGUF)   |\n| ProSparse-LLaMA-2-7B  | [PowerInfer\u002FProSparse-LLaMA-2-7B-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-7b-gguf)           |\n| ProSparse-LLaMA-2-13B | [PowerInfer\u002FProSparse-LLaMA-2-13B-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-13b-gguf)         |\n| Bamboo-base-7B 🌟      | [PowerInfer\u002FBamboo-base-v0.1-gguf](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-gguf)                   |\n| Bamboo-DPO-7B 🌟       | [PowerInfer\u002FBamboo-DPO-v0.1-gguf](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-gguf)                     |\n\n我们建议使用 [`huggingface-cli`](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fhuggingface_hub\u002Fguides\u002Fcli) 下载整个模型仓库。例如，以下命令会将 [PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF) 下载到 `.\u002FReluLLaMA-7B` 目录中。\n\n```shell\nhuggingface-cli download --resume-download --local-dir ReluLLaMA-7B --local-dir-use-symlinks False PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF\n```\n\n因此，PowerInfer 可以自动利用以下目录结构实现功能完整的模型卸载：\n```\n.\n├── *.powerinfer.gguf (未量化 PowerInfer 模型)\n├── *.q4.powerinfer.gguf (如果可用，则为 INT4 量化 PowerInfer 模型)\n├── activation (用于细粒度 FFN 卸载的已分析激活统计信息)\n│   ├── activation_x.pt (第 x 层的已分析激活统计信息)\n│   └── ...\n├── *.[q4].powerinfer.gguf.generated.gpuidx (运行时为相应模型生成的 GPU 索引)\n```\n\n### 从原始模型权重 + 预测器权重转换\n\nHugging Face 对单个模型权重的大小限制为 50GiB。对于 ≥ 40B 的未量化模型，您可以使用从 Hugging Face 获取的原始模型权重和预测器权重来转换为 PowerInfer GGUF。\n\n| 基础模型            | 原始模型                                                                            | 预测器                                                                                                       |\n| --------------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |\n| LLaMA(ReLU)-2-7B      | [SparseLLM\u002FReluLLaMA-7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-7B)                   | [PowerInfer\u002FReluLLaMA-7B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-7B-Predictor)                   |\n| LLaMA(ReLU)-2-13B     | [SparseLLM\u002FReluLLaMA-13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-13B)                 | [PowerInfer\u002FReluLLaMA-13B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-13B-Predictor)                 |\n| Falcon(ReLU)-40B      | [SparseLLM\u002FReluFalcon-40B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluFalcon-40B)               | [PowerInfer\u002FReluFalcon-40B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluFalcon-40B-Predictor)               |\n| LLaMA(ReLU)-2-70B     | [SparseLLM\u002FReluLLaMA-70B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002FReluLLaMA-70B)                 | [PowerInfer\u002FReluLLaMA-70B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FReluLLaMA-70B-Predictor)                 |\n| ProSparse-LLaMA-2-7B  | [SparseLLM\u002FProSparse-LLaMA-2-7B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-7b)   | [PowerInfer\u002FProSparse-LLaMA-2-7B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-7b-predictor)   |\n| ProSparse-LLaMA-2-13B | [SparseLLM\u002FProSparse-LLaMA-2-13B](https:\u002F\u002Fhuggingface.co\u002FSparseLLM\u002Fprosparse-llama-2-13b) | [PowerInfer\u002FProSparse-LLaMA-2-13B-Predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002Fprosparse-llama-2-13b-predictor) |\n| Bamboo-base-7B 🌟      | [PowerInfer\u002FBamboo-base-v0.1](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0_1)         | [PowerInfer\u002FBamboo-base-v0.1-predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-base-v0.1-predictor)           |\n| Bamboo-DPO-7B 🌟       | [PowerInfer\u002FBamboo-DPO-v0.1](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0_1)           | [PowerInfer\u002FBamboo-DPO-v0.1-predictor](https:\u002F\u002Fhuggingface.co\u002FPowerInfer\u002FBamboo-DPO-v0.1-predictor)             |\n\n您可以使用以下命令将原始模型权重和预测器权重转换为 PowerInfer GGUF：\n```bash\n# 确保已执行 `pip install -r requirements.txt`\npython convert.py --outfile \u002FPATH\u002FTO\u002FPOWERINFER\u002FGGUF\u002FREPO\u002FMODELNAME.powerinfer.gguf \u002FPATH\u002FTO\u002FORIGINAL\u002FMODEL \u002FPATH\u002FTO\u002FPREDICTOR\n\n# python convert.py --outfile .\u002FReluLLaMA-70B-PowerInfer-GGUF\u002Fllama-70b-relu.powerinfer.gguf .\u002FSparseLLM\u002FReluLLaMA-70B .\u002FPowerInfer\u002FReluLLaMA-70B-Predictor\n```\n出于同样的原因，我们建议在转换后保持与 PowerInfer GGUF 仓库相同的目录结构。\n\n\u003Cdetails>\n\n\u003Csummary>将原始模型转换为稠密 GGUF 模型（与 llama.cpp 兼容）\u003C\u002Fsummary>\n\n```bash\npython convert-dense.py --outfile \u002FPATH\u002FTO\u002FDENSE\u002FGGUF\u002FREPO\u002FMODELNAME.gguf \u002FPATH\u002FTO\u002FORIGINAL\u002FMODEL\n# python convert-dense.py --outfile .\u002FBamboo-DPO-v0.1-gguf\u002Fbamboo-7b-dpo-v0.1.gguf --outtype f16 .\u002FBamboo-DPO-v0.1\n```\n\n请注意，生成的稠密 GGUF 模型可能无法与 llama.cpp 正常工作，因为我们修改了激活函数（针对 ReluLLaMA 和 Prosparse 模型），或模型架构（针对 Bamboo 模型）。由 convert-dense.py 生成的稠密 GGUF 模型可用于 PowerInfer 的稠密推理模式，但可能无法与 llama.cpp 正常配合使用。\n\n\u003C\u002Fdetails>\n\n## 推理\n\n对于仅使用 CPU 或 CPU-GPU 混合推理且充分利用所有显存的情况，您可以按照以下说明运行 PowerInfer：\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FMODEL -n $output_token_count -t $thread_num -p $prompt\n# 例如：.\u002Fbuild\u002Fbin\u002Fmain -m .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.q4.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\"\n# 对于 Windows：.\\build\\bin\\Release\\main.exe -m .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.q4.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\"\n```\n\n如果您希望限制 GPU 的显存使用量：\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FMODEL -n $output_token_count -t $thread_num -p $prompt --vram-budget $vram_gb\n# 例如：.\u002Fbuild\u002Fbin\u002Fmain -m .\u002FReluLLaMA-7B-PowerInfer-GGUF\u002Fllama-7b-relu.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\" --vram-budget 8\n# 对于 Windows：.\\build\\bin\\Release\\main.exe -m .\\ReluLLaMA-7B-PowerInfer-GGUF\\llama-7b-relu.powerinfer.gguf -n 128 -t 8 -p \"Once upon a time\" --vram-budget 8\n```\n在 CPU-GPU 混合推理模式下，PowerInfer 会自动将所有稠密激活块卸载到 GPU 上，并在可能的情况下拆分 FFN 并将其卸载到 GPU。\n\n\u003Cdetails>\n\u003Csummary>稠密推理模式（有限支持）\u003C\u002Fsummary>\n\n如果您想使用 PowerInfer 推理家族中的稠密变体，可以像使用 llama.cpp 一样操作：\n\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m \u002FPATH\u002FTO\u002FDENSE\u002FMODEL -n $output_token_count -t $thread_num -p $prompt -ngl $num_gpu_layers\n# 例如：.\u002Fbuild\u002Fbin\u002Fmain -m .\u002FBamboo-base-v0.1-gguf\u002Fbamboo-7b-v0.1.gguf -n 128 -t 8 -p \"Once upon a time\" -ngl 12\n```\n\n其他 `examples\u002F` 目录下的示例，如 `server` 和 `batched_generation`，也是如此。请注意，稠密推理模式并非适用于所有模型的“兼容模式”。在此模式下，我们为了匹配我们的模型家族，修改了激活函数（针对 ReluLLaMA 和 Prosparse 模型）。\n\n\u003C\u002Fdetails>\n\n## 服务、困惑度评估及其他应用\n\nPowerInfer 支持与 llama.cpp 相同的服务和批量生成指令。通常，您可以使用与 llama.cpp 相同的命令，只是将 `-ngl` 参数替换为 PowerInfer 的 `--vram-budget`。请参阅每个 `examples\u002F` 目录中的详细说明。例如：\n\n- [服务](.\u002Fexamples\u002Fserver\u002FREADME.md)\n- [困惑度评估](.\u002Fexamples\u002Fperplexity\u002FREADME.md)\n- [批量生成](.\u002Fexamples\u002Fbatched\u002FREADME.md)\n\n## 量化\n\nPowerInfer 针对 INT4（`Q4_0`）模型优化了量化支持。您可以使用以下指令对 PowerInfer GGUF 模型进行量化：\n```bash\n.\u002Fbuild\u002Fbin\u002Fquantize \u002FPATH\u002FTO\u002FMODEL \u002FPATH\u002FTO\u002FOUTPUT\u002FQUANTIZED\u002FMODEL Q4_0\n# 例如：.\u002Fbuild\u002Fbin\u002Fquantize .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.powerinfer.gguf .\u002FReluFalcon-40B-PowerInfer-GGUF\u002Ffalcon-40b-relu.q4.powerinfer.gguf Q4_0\n# 对于 Windows：.\\build\\bin\\Release\\quantize.exe .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.powerinfer.gguf .\\ReluFalcon-40B-PowerInfer-GGUF\\falcon-40b-relu.q4.powerinfer.gguf Q4_0\n```\n然后您就可以使用量化后的模型，按照上述相同的方法进行 PowerInfer 推理。\n\n## 更多文档\n- [性能故障排除](.\u002Fdocs\u002Ftoken_generation_performance_tips.md)\n\n## 评估\n\n我们在单块 RTX 4090（24G）上，使用一系列 FP16 ReLU 模型，在输入长度为 64 的情况下，对 PowerInfer 与 llama.cpp 进行了对比评估，结果如下所示。PowerInfer 在 Falcon 40B 上实现了最高 11 倍的加速，在 Llama 2 70B 上实现了最高 3 倍的加速。\n\n![github-eval-4090](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_c6cb0b04fb57.png)\n\u003Csub>X 轴表示输出长度，Y 轴表示相对于 llama.cpp 的加速倍数。每个柱状图上方的数字表示端到端生成速度（总提示时间 + 生成时间 \u002F 总生成令牌数，单位为 tokens\u002Fs）。\u003C\u002Fsub>\n\n我们还在单块 RTX 2080Ti（11G）上，使用 INT4 ReLU 模型，在输入长度为 8 的情况下进行了评估，结果以相同的方式展示。PowerInfer 在 Falcon 40B 上实现了最高 8 倍的加速，在 Llama 2 70B 上实现了最高 3 倍的加速。\n\n![github-eval-2080ti-q4](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_readme_d78c16f4146c.png)\n\n更多评估细节，请参阅我们的[论文](https:\u002F\u002Fipads.se.sjtu.edu.cn\u002F_media\u002Fpublications\u002Fpowerinfer-20231219.pdf)。\n\n## 常见问题解答\n1. 如果遇到 `CUDA_ERROR_OUT_OF_MEMORY` 错误怎么办？\n   - 您可以尝试使用 `--reset-gpu-index` 参数来重建该模型的 GPU 索引，以避免任何过时的缓存。\n   - 由于我们目前的实现方式，模型卸载可能不如预期准确。您可以尝试使用略低的 `--vram-budget` 值，或使用 `--disable-gpu-index` 来禁用 FFN 卸载。\n\n2. PowerInfer 是否支持 Mistral、原始 Llama、通义千问等模型？\n   - 目前我们仅支持具有 ReLU\u002FReGLU\u002F平方 ReLU 激活函数的模型。因此，我们暂时不支持这些模型。值得一提的是，一篇[论文](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2310.04564.pdf)表明，使用 ReLU\u002FReGLU 激活函数对收敛性和性能的影响可以忽略不计。\n\n3. 为什么我们当前的 ReLU 模型，尤其是 70B 模型，在性能指标上出现了明显下降？\n   - 与 LLM 训练通常需要约 2T 个标记不同，我们的模型仅使用了 5B 个标记进行微调。这种不足的再训练导致模型无法恢复其原有的性能。我们正在积极努力更新到更强大的模型，请继续关注。\n\n4. 如果……\n   - 欢迎提出任何问题！请随时创建一个议题，并附上您的运行环境和运行参数。我们将尽最大努力帮助您。\n\n## 待办事项\n我们将按照以下顺序发布代码和数据，请持续关注！\n\n- [x] 发布 PowerInfer 核心代码，支持 Llama-2 和 Falcon-40B。\n- [x] 支持 ~~Mistral-7B~~（Bamboo-7B）\n- [x] 支持 Windows 系统\n- [ ] 支持 text-generation-webui\n- [x] 发布困惑度评估代码\n- [ ] 支持 Mac 上的 Metal 加速\n- [ ] 发布 OPT 模型相关代码\n- [ ] 发布预测器训练代码\n- [x] 支持 FFN 网络的在线拆分\n- [ ] 支持多 GPU 运行\n\n\n## 论文与引用\n更多技术细节请参阅我们的[论文](https:\u002F\u002Fipads.se.sjtu.edu.cn\u002F_media\u002Fpublications\u002Fpowerinfer-20231219.pdf)。\n\n如果您认为 PowerInfer 对您的项目或研究有帮助或相关性，请引用我们的论文：\n\n```bibtex\n@misc{song2023powerinfer,\n      title={PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU},\n      author={Yixin Song and Zeyu Mi and Haotong Xie and Haibo Chen},\n      year={2023},\n      eprint={2312.12456},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n\n## 致谢\n我们感谢 [ggml](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml) 易于修改的算子库以及 [llama.cpp](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fllama.cpp) 提供的执行运行时。同时，我们也感谢 [THUNLP](https:\u002F\u002Fnlp.csai.tsinghua.edu.cn\u002F) 对基于 ReLU 的稀疏模型的支持。此外，我们还受益于 [Deja Vu](https:\u002F\u002Fproceedings.mlr.press\u002Fv202\u002Fliu23am.html) 的研究成果，这些工作为 PowerInfer 提供了灵感。","# PowerInfer 快速上手指南\n\nPowerInfer 是一款专为消费级 GPU 设计的高速大语言模型（LLM）推理引擎。它利用神经元激活的“局部性”原理，将高频激活的“热神经元”驻留显存，低频激活的“冷神经元”卸载至 CPU 计算，从而在单张显卡上实现接近服务器级 GPU 的推理速度。\n\n## 环境准备\n\n### 系统要求\nPowerInfer 支持以下平台：\n- **Linux \u002F Windows**: x86-64 架构 CPU（需支持 AVX2 指令集），可选配 NVIDIA 或 AMD GPU。\n- **macOS**: Apple M 系列芯片（仅 CPU 模式，目前性能优化有限）。\n\n### 前置依赖\n在开始之前，请确保系统已安装以下工具：\n- **CMake**: 版本 3.17 或更高\n- **Python**: 版本 3.8 或更高\n- **pip**: 版本 19.3 或更高\n- **GPU 驱动**: \n  - NVIDIA 用户需安装 CUDA Toolkit\n  - AMD 用户需安装 ROCm\u002FHIP\n\n## 安装步骤\n\n### 1. 获取代码与依赖\n克隆项目仓库并安装 Python 辅助工具依赖：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\ncd PowerInfer\npip install -r requirements.txt\n```\n\n### 2. 编译构建\n根据硬件配置选择对应的编译命令（在项目根目录执行）：\n\n**场景 A：拥有 NVIDIA GPU**\n```bash\ncmake -S . -B build -DLLAMA_CUBLAS=ON\ncmake --build build --config Release\n```\n\n**场景 B：拥有 AMD GPU**\n*注意：请将 `gfx1100` 替换为你显卡的实际架构名称（可通过 `rocminfo` 查询）。*\n```bash\nCC=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang CXX=\u002Fopt\u002Frocm\u002Fllvm\u002Fbin\u002Fclang++ cmake -S . -B build -DLLAMA_HIPBLAS=ON -DAMDGPU_TARGETS=gfx1100\ncmake --build build --config Release\n```\n\n**场景 C：仅使用 CPU**\n```bash\ncmake -S . -B build\ncmake --build build --config Release\n```\n\n## 基本使用\n\n### 1. 下载模型权重\nPowerInfer 需要使用特定的 `*.powerinfer.gguf` 格式模型（包含模型权重及预测器权重）。推荐从 Hugging Face 下载预转换好的模型。\n\n以 **Llama2-7B (ReLU)** 为例，使用 `huggingface-cli` 下载到本地 `ReluLLaMA-7B` 目录：\n\n```shell\nhuggingface-cli download --resume-download --local-dir ReluLLaMA-7B --local-dir-use-symlinks False PowerInfer\u002FReluLLaMA-7B-PowerInfer-GGUF\n```\n\n*注：国内用户若访问 Hugging Face 困难，可配置镜像源或使用代理加速。*\n\n下载完成后，目录结构应包含 `.powerinfer.gguf` 文件及 `activation` 统计文件夹。\n\n### 2. 运行推理\n编译完成后，可执行生成的二进制文件进行推理。以下是最简单的命令行交互示例（假设生成的可执行文件位于 `build\u002Fbin` 目录下，具体文件名请参考编译输出，通常为 `main` 或 `server`）：\n\n**交互式对话示例：**\n```bash\n.\u002Fbuild\u002Fbin\u002Fmain -m .\u002FReluLLaMA-7B\u002Frelullama-7b-fp16.powerinfer.gguf -p \"你好，请介绍一下 PowerInfer。\" -n 256\n```\n\n**启动本地 API 服务示例：**\n```bash\n.\u002Fbuild\u002Fbin\u002Fserver -m .\u002FReluLLaMA-7B\u002Frelullama-7b-fp16.powerinfer.gguf --host 0.0.0.0 --port 8080\n```\n\n*参数说明：*\n- `-m`: 指定模型路径。\n- `-p`: 输入提示词（Prompt）。\n- `-n`: 生成 token 的最大数量。\n- `server`: 启动类似 llama.cpp 的 HTTP 服务端，兼容大多数前端界面。","一位独立开发者试图在配备单张 RTX 4090 显卡的工作站上，本地部署并运行参数量巨大的 Falcon-40B 模型，以构建一个完全离线、数据隐私安全的代码辅助助手。\n\n### 没有 PowerInfer 时\n- **推理速度极慢**：由于显存带宽瓶颈，生成代码的速度仅为每秒几个 token，回答延迟高达数秒，严重打断编程思路。\n- **硬件门槛过高**：为了勉强运行大模型，不得不将量化精度压得过低导致智能程度下降，或者被迫租用昂贵的云端 GPU 集群。\n- **资源利用率低**：传统推理引擎（如 llama.cpp）无法有效利用神经元激活的稀疏性，导致计算资源浪费，风扇狂转却产出缓慢。\n- **交互体验割裂**：漫长的等待时间使得“流式输出”失去意义，开发者无法在模型生成过程中实时预览和干预结果。\n\n### 使用 PowerInfer 后\n- **推理速度飞跃**：利用激活局部性（Activation Locality）技术，在同等硬件下将 Falcon-40B 的生成速度提升 11 倍，达到流畅的对话级响应。\n- **消费级显卡胜任**：无需升级硬件或上云，单张消费级 GPU 即可全精度流畅运行 40B 级别大模型，大幅降低部署成本。\n- **稀疏计算优化**：PowerInfer 智能跳过非活跃神经元，仅计算关键参数，在保证模型智商不降级的前提下极大减少了计算量。\n- **实时流式交互**：生成的代码几乎随想随出，开发者可以像与真人结对编程一样，实时观察并修正模型输出的每一行代码。\n\nPowerInfer 通过挖掘模型内部的稀疏特性，让普通开发者的本地电脑也能拥有媲美云超算的大模型推理速度，真正实现了高性能 AI 的普惠化。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTiiny-AI_PowerInfer_c6cb0b04.png","Tiiny-AI","Tiiny AI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FTiiny-AI_f8ffe8c6.png","",null,"dev@tiiny.ai","TiinyAILab","http:\u002F\u002Ftiiny.ai\u002F","https:\u002F\u002Fgithub.com\u002FTiiny-AI",[82,86,90,94,98,102,106,110,114,118],{"name":83,"color":84,"percentage":85},"C++","#f34b7d",56.4,{"name":87,"color":88,"percentage":89},"C","#555555",16.1,{"name":91,"color":92,"percentage":93},"Python","#3572A5",8.8,{"name":95,"color":96,"percentage":97},"Cuda","#3A4E3A",7,{"name":99,"color":100,"percentage":101},"Objective-C","#438eff",2.3,{"name":103,"color":104,"percentage":105},"Metal","#8f14e9",2.2,{"name":107,"color":108,"percentage":109},"Shell","#89e051",1.7,{"name":111,"color":112,"percentage":113},"CMake","#DA3434",1.3,{"name":115,"color":116,"percentage":117},"HTML","#e34c26",0.9,{"name":119,"color":120,"percentage":121},"TypeScript","#3178c6",0.8,9280,554,"2026-04-08T15:19:54","MIT",4,"Linux, Windows, macOS","非必需（支持纯 CPU 运行）。若使用 GPU：支持 NVIDIA (需开启 CUBLAS) 或 AMD (需开启 HIPBLAS\u002FROCm)。macOS 目前仅支持 CPU，Metal 后端开发中。显存大小未明确说明，但设计目标为消费级显卡（如 RTX 4090），通过冷热神经元分离技术降低显存需求以运行大模型。","未说明（需容纳冷神经元计算及模型权重，建议大容量内存）",{"notes":131,"python":132,"dependencies":133},"1. CPU 需支持 AVX2 指令集。2. 核心特性是利用激活局部性（Activation Locality），将‘热’神经元预加载至 GPU，‘冷’神经元在 CPU 计算，从而在单张消费级显卡上运行超大模型（如 40B+）。3. 必须使用特定的 PowerInfer GGUF 格式模型（包含预测器权重和激活统计信息），直接使用普通 llama.cpp 权重无法获得性能提升。4. AMD 用户需根据显卡架构设置 AMDGPU_TARGETS（如 gfx1100）。5. macOS (M 芯片) 目前性能优化不明显。","3.8+",[134,135],"CMake (3.17+)","pip (19.3+)",[35,14],[138,139,140,141,142],"large-language-models","llama","llm","llm-inference","local-inference","2026-03-27T02:49:30.150509","2026-04-09T05:21:31.076193",[146,151,156,161,166,170],{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},25697,"如何将 SmallThinker 的 HuggingFace 格式模型转换为 PowerInfer 专用的 .powerinfer.gguf 格式并进行量化？","1. 在转换前，需要先将 `model_lm_head.pt` 合并到 safetensors 文件中（这是基础操作，项目未提供专门代码）。\n2. 使用 `convert_hf_to_gguf.py` 脚本进行转换，注意添加 `--transpose-down all` 参数。\n3. 编译量化工具：运行 `cmake --build build --config RelWithDebInfo --target llama-quantize -j32`。\n4. 参考官方文档中的转换说明：https:\u002F\u002Fgithub.com\u002FSJTU-IPADS\u002FPowerInfer\u002Ftree\u002Fmain\u002Fsmallthinker#convert-model","https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\u002Fissues\u002F263",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},25698,"为什么在显存足够容纳整个模型（如 7B INT4 模型 vs 8GB 显存）时，PowerInfer 的推理速度反而比预期慢？","当模型可以完全放入显存时，PowerInfer 引入的 CPU-GPU 同步开销会导致性能下降。此外，随着上下文长度增加（默认 512 token），KV Cache 的大小也会影响性能。如果生成速度在约 500 token 后显著下降，可以尝试通过设置 `-c` 或 `--ctx-size` 参数来增大 KV Cache 以缓解此问题。","https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\u002Fissues\u002F131",{"id":157,"question_zh":158,"answer_zh":159,"source_url":160},25699,"启用 GPU 分割（gpu split）后推理结果异常或不可用，如何解决？","这是一个已修复的 INT4 推理关键 Bug。请执行以下操作：\n1. 拉取最新的代码提交（git pull）并重新编译项目。\n2. 运行时**不要**使用 `--reset-gpu-index` 参数，以便程序使用之前生成的 GPU 索引文件。\n更新后通常能恢复正常推理结果。","https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\u002Fissues\u002F77",{"id":162,"question_zh":163,"answer_zh":164,"source_url":165},25700,"运行时报错 'No module named powerinfer' 且无法生成 GPU 分割，如何解决 Python 依赖问题？","该问题通常由 Python 版本或依赖库缺失引起。解决步骤如下：\n1. 将 Python 升级至 3.8 及以上版本（推荐 3.10）。\n2. 重新编译 `cvxopt` 并确保支持 `glpk`。\n3. 运行 `pip install -r requirements.txt` 安装所有依赖。\n项目已在后续版本中修复了相关的 Python 依赖问题。","https:\u002F\u002Fgithub.com\u002FTiiny-AI\u002FPowerInfer\u002Fissues\u002F55",{"id":167,"question_zh":168,"answer_zh":169,"source_url":150},25701,"编译 smallthinker 目录后找不到 llama-quantize 可执行文件，或者量化时报错 'unknown model architecture: smallthinker' 怎么办？","如果在 smallthinker 子目录编译只生成了 `llama-cli`，请尝试退回根目录 `PowerInfer` 进行完整编译：\n1. 运行 `cmake -S . -B build` 和 `cmake --build build --config Release`。\n2. 此时 `PowerInfer\u002Fbuild\u002Fbin` 下会有 `quantize` 可执行文件。\n3. 如果仍报错架构未知，请确保在转换模型前已按照要求合并了 `model_lm_head.pt`，并使用正确的转换脚本生成 GGUF 文件。",{"id":171,"question_zh":172,"answer_zh":173,"source_url":155},25702,"为什么在长文本生成（超过 500 tokens）时速度会急剧下降到 2 tokens\u002Fs 左右？","这通常是因为默认的上下文窗口大小（context size）限制导致的。默认值为 512 token，当生成的 token 数接近或超过此限制时，性能会大幅下降。解决方法是在运行命令时通过 `-c` 或 `--ctx-size` 参数设置一个更大的上下文窗口值。",[]]