[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-IST-DASLab--marlin":3,"tool-IST-DASLab--marlin":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":10,"env_os":98,"env_gpu":99,"env_ram":98,"env_deps":100,"category_tags":108,"github_topics":109,"view_count":10,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":114,"updated_at":115,"faqs":116,"releases":144},506,"IST-DASLab\u002Fmarlin","marlin","FP16xINT4 LLM inference kernel that can achieve near-ideal ~4x speedups up to medium batchsizes of 16-32 tokens.","Marlin 是一款专为大语言模型（LLM）推理打造的开源计算内核，专注于 FP16 与 INT4 的混合精度矩阵乘法运算。它的核心目标是突破现有量化方案的瓶颈，在保持高精度的同时显著提升推理速度。\n\n以往的大多数 4 位量化内核在处理较大批量数据时，往往因显存带宽或计算单元利用率不足而导致加速比下降，通常仅支持 1 到 2 个 token 的批量。Marlin 解决了这一问题，能够在 16 到 32 个 token 的中等批量下，实现接近理论极限的 4 倍加速。这得益于其精妙的底层优化：通过智能管理 L2 缓存与共享内存，采用异步加载和双缓冲机制重叠数据传输与计算，并精细调度反量化与张量核心指令，确保 GPU 资源被全方位饱和利用。\n\nMarlin 特别适合需要高效部署 LLM 的开发者、从事模型压缩研究的科研人员，以及致力于降低推理成本的技术团队。无论是大规模在线服务、推测解码还是复杂的思维链推理，Marlin 都能提供卓越的性能表现，帮助你在有限硬件上释放最大算力。","\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_5e387beb0364.png\" width=\"250\"\u002F>\n\u003C\u002Fdiv>\n\n# Marlin\n\nThis is Marlin, a **M**ixed **A**uto-**R**egressive **Lin**ear kernel (and the name of one of the planet's fastest fish), an extremely optimized FP16xINT4 matmul kernel aimed at LLM inference that can deliver close to ideal (4x)\nspeedups up to batchsizes of 16-32 tokens (in contrast to the 1-2 tokens of prior work with comparable speedup). This makes Marlin well suited for larger-scale\nserving, speculative decoding or advanced multi-inference schemes such as CoT-Majority.\n\n## Techniques:\n\nMost modern GPUs feature FLOP to byte ratios of around 100-200.\nHence, as long as we perform less than 25-50 (tensor core) multiply-accumulates per 4-bit quantized weight, it should (theoretically) be possible to maintain near ideal 4x speedup over FP16 weights.\nThis means that the full performance benefits of weight-only quantization should, in principle, extend to batchsizes 4-8x larger than what is currently achieved by existing kernels.\nHowever, actually realizing this in practice is very challenging, since we essentially need to fully utilize all available GPU resources (global memory, L2 cache, shared memory, tensor cores, vector cores), *simultaneously*.\nMarlin accomplishes this through numerous techniques and optimizations, briefly sketched below:\n\n* We organize computation in such a way that all activations are essentially always fetched from L2 cache and are further reused several times within registers to make sure that repeated loading from shared memory does not become a bottleneck either.\n* We execute global weight loads asynchronously, to all compute operations but also activations loads, with a cache policy that allows immediate eviction in order to not unnecessary pollute the L2 cache with values that are never reused.\n* We perform shared memory loads, whose footprint is quite significant due to relatively large activations, via double buffering to overlap them with computation and global loads.\n* We carefully order dequantization and tensor core instructions to ensure that both GPU pipelines are well saturated and do not bottleneck each other.\n* In general, both quantized weights and group scales are reshuffled offline, into a layout that gives ideal access patterns during execution, allowing for instance directly dequantizing weights into tensor core organization.\n* We have multiple warps in a threadblock compute partial results of the same output tile, in order to achieve higher warp counts, maximizing compute and latency hiding, without increasing the output tile size, which would make good partioning on realistic matrices difficult.\n* All loads use maximum vector length for peak efficiency and we also perform several layout transformations to guarantee that all shared memory reads and writes are conflict-free, in particular for matrix loading instructions, and that global reduction happens at minimal memory overhead.\n* We set up and unroll loops such that the majority of memory offsets are static, minimizing runtime index calculations.\n* We implement a \"striped\" paritioning scheme where the segment of tiles processed by each SM may (partially) span over multiple column \"slices\". This leads to good SM utlization on most matrix shapes, while minimizing required global reduction steps.\n* Global reduction happens directly in the output buffer (temporarily downcasting FP32 accumulators to FP16) which is kept in L2 cache; reduction operations are generally optimized to avoid any unnecessary reads or writes as well.\n* Overall, the kernel's PTX assembly was extensively analyzed in NSight-Compute, and the CUDA code features several more redundant or slightly suboptimal constructions that however compile to faster PTX.\n\n## Benchmarks:\n\nWe first compare the performance of Marlin with other popular 4-bit inference kernels, on a large matrix that can be\nideally partioned on an NVIDIA A10 GPU. This allows all kernels to reach pretty much their best possible performance.\nAll kernels are executed at groupsize 128 (however, we note that scale formats are not 100% identical).\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_bf59a11e65a0.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\nWhile existing kernels achieve relatively close to the optimal 3.87x (note the 0.125 bits storage overhead of the\ngroup scales) speedup at batchsize 1, their performance degrades quickly as the number of inputs is increased. In\ncontrast, Marlin delivers essentially ideal speedups at all batchsizes, enabling the maximum possible 3.87x speedup up\nto batchsizes around 16-32.\n\nDue to its striped partioning scheme, Marlin brings strong performance also on real (smaller) matrices and various GPUs.\nThis is demonstrated by the below results, where we benchmark, at batchsize 16, the overall runtime across all linear\nlayers in Transformer blocks of popular open-source models.\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_e06deb862acb.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\nFinally, we also study what performance can be sustained over longer periods of time, at locked base GPU clock.\nInterestingly, we find that reduced clock speeds significantly harm the relative speedups of prior kernels, but have no\neffect on Marlin's virtually optimal performance (relative to the lower clock setting).\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_849280af30fa.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\n## Requirements:\n\n* CUDA >= 11.8 (in particular also for the `nvcc` compiler, the version of which should match with torch)\n* NVIDIA GPU with compute capability >= 8.0 (Ampere or Ada, Marlin is not yet optimized for Hopper)\n* `torch>=2.0.0`\n* `numpy`\nFor running quantization script one also needs:\n* `transformers`\n* `datasets`\n* `sentencepiece`\n\n## Usage:\n\nIf all requirements are met, it should be possible to install Marlin by calling\n\n```\npip install .\n```\n\nin the root folder of this repository.\n\nAfterwards, the easiest way to use the  Marlin kernel is via a `marlin.Layer`, a torch-module representing a Marlin\nquantized layer. It allows converting a \"fake-quantized\" (dequantized values stored in FP16) `torch.Linear` layer into\nthe compressed Marlin format via `marlin.Layer.pack(linear, scales)`. Alternatively, the kernel can also be called\ndirectly through `marlin.mul(..)`, provided that weights and scales have already been appropriately preprocessed (see\n`marlin.Layer.pack(...)`). The kernel itself can be found in the self-contained `marlin\u002Fmarlin_cuda_kernel.cu` file,\nwhich does not contain any dependencies beyond base-CUDA and should thus be easy to integrate into other lower-level\nframeworks.\n\nCorrectness tests can be executed via `python test.py` and benchmarks via `python bench.py`. Please note that in order\nto reproduce our \"sustainable performance\" benchmarks, the GPU clocks need to be locked to their respective base values\nusing:\n\n```\nsudo nvidia-smi --lock-gpu-clocks=BASE_GPU_CLOCK --lock-memory-clocks=BASE_MEM_CLOCK\n```\n\nAdditionally, if ECC is enabled (e.g., on an A10), then the maximum achievable memory bandwidth will be 10-15% lower\nthan in the official spec sheet as every memory requests will contain checksum overheads. This can be disabled via \n\n```\nsudo nvidia-smi -e 0\n```\n\nwhich we do in our A10 benchmarks.\n\n## GPTQ Example:\n\nIn the `gptq` subfolder, we also provide a slightly improved version of the [GPTQ](https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fgptq) algorithm, with better group grid clipping and non-uniform calibration sample length, that can produce Marlin-compatible 4-bit versions of Llama2 models.\nAdditionally, there is a script to evaluate such compressed models (using Marlin kernels) in the popular [LLM eval harness](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness).\nThe script below was tested with `lm-eval-harness==0.4.0` and may not work with newer or older versions. \nHere are corresponding sample commands (`marlin`, `transformers` and `datasets` packages must be installed):\n\n```\n% Compress Llama2 model and export model in Marlin format.\npython llama2.py LLAMA2_CHECKPOINT --wbits 4 --save checkpoint.pt\n% Perform perplexity evaluation of uncompressed model.\npython llama2.py LLAMA2_CHECKPOINT\n% Evaluate compressed model (with Marlin kernels) in the eval harness.\npython eval.py --model hf --model_args pretrained=LLAMA2_CHECKPOINT --tasks mmlu \\\n  --marlin_checkpoint checkpoint.marlin.g128\n% Evaluate full precision baseline.\npython eval.py --model hf --model_args pretrained=LLAMA2_CHECKPOINT --tasks mmlu \n```\n\nWe measure the following WikiText and Red-Pajama perplexities, as well as MMLU zero-shot accuracy, for 4-bit (group=128) Marlin models:\n\n| Llama2 | Wiki2 (FP16) | Wiki2 (INT4) | RedPaj (FP16) | RedPaj (INT4) | MMLU (FP16) | MMLU (INT4)  |\n|:---:|:----:|:----:|:----:|:----:|:-----:|:-----:|\n| 7B  | 5.12 | 5.27 | 6.14 | 6.30 | 41.80 | 40.07 |\n| 13B | 4.57 | 4.67 | 5.67 | 5.79 | 52.10 | 51.13 |\n| 70B | 3.12 | 3.21 | 4.74 | 4.81 | 65.43 | 64.81 |\n\nWe note that this GPTQ example is currently intended mostly as a demonstration of how to produce accurate Marlin models and as an end-to-end validation of kernel correctness (rather than to be a flexible compression tool).\n\n## Cite:\n\nIf you found this work useful, please consider citing:\n\n```\n@article{frantar2024marlin,\n  title={MARLIN: Mixed-Precision Auto-Regressive Parallel Inference on Large Language Models},\n  author={Frantar, Elias and Castro, Roberto L and Chen, Jiale and Hoefler, Torsten and Alistarh, Dan},\n  journal={arXiv preprint arXiv:2408.11743},\n  year={2024}\n}\n```\n","\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_5e387beb0364.png\" width=\"250\"\u002F>\n\u003C\u002Fdiv>\n\n# Marlin\n\n这是 Marlin，一个**混合自回归线性**（**M**ixed **A**uto-**R**egressive **Lin**ear）内核（也是地球上速度最快的鱼类之一的名字），这是一个针对大语言模型（LLM）推理的极度优化的 FP16xINT4 矩阵乘法（matmul）内核，能够在批量大小达到 16-32 个 token 时，提供接近理想值（4 倍）的加速比（相比之下，具有可比加速比的前期工作仅支持 1-2 个 token）。这使得 Marlin 非常适合大规模服务、推测性解码或高级多推理方案，例如思维链多数投票（CoT-Majority）。\n\n## 技术细节：\n\n大多数现代 GPU（图形处理器）的浮点运算次数（FLOP）与字节数的比率约为 100-200。\n因此，只要每个 4 位量化权重执行的乘累加操作少于 25-50 次（张量核心），理论上就应该能够保持相对于 FP16 权重的近理想 4 倍加速比。\n这意味着，原则上，仅权重量化的全部性能优势应扩展到比现有内核当前实现的批量大小大 4-8 倍的规模。\n然而，在实践中实现这一点非常具有挑战性，因为我们本质上需要同时充分利用所有可用的 GPU 资源（全局内存、L2 缓存、共享内存、张量核心、向量核心）。\nMarlin 通过多种技术和优化实现了这一点，简要概述如下：\n\n* 我们组织计算的方式使得所有激活值基本上总是从 L2 缓存获取，并在寄存器中多次重用，以确保重复从共享内存加载也不会成为瓶颈。\n* 我们以异步方式执行全局权重加载，针对所有计算操作以及激活值加载，采用允许立即驱逐的缓存策略，以免用永远不会重用的值不必要地污染 L2 缓存。\n* 我们通过双缓冲技术执行共享内存加载（由于激活值相对较大，其占用空间相当显著），以使其与计算和全局加载重叠。\n* 我们仔细排序反量化和张量核心指令，以确保两个 GPU 流水线都得到充分饱和且不会相互成为瓶颈。\n* 通常，量化权重和组缩放因子都会离线重新排列成一种布局，以便在执行期间提供理想的访问模式，例如允许直接将权重反量化为张量核心组织形式。\n* 我们在一个线程块中使用多个 warp（线程束）来计算同一输出瓦片的局部结果，以实现更高的 warp 数量，最大化计算和延迟隐藏，而不增加输出瓦片的大小（否则会使现实矩阵的良好分区变得困难）。\n* 所有加载使用最大向量长度以达到峰值效率，我们还执行几种布局转换，以确保所有共享内存读写无冲突，特别是对于矩阵加载指令，并且全局归约以最小的内存开销发生。\n* 我们设置并展开循环，使得大部分内存偏移量是静态的，从而最小化运行时索引计算。\n* 我们实现了一种“条纹”分区方案，其中每个 SM（流式多处理器）处理的瓦片段可能（部分）跨越多个列“切片”。这导致在大多数矩阵形状上具有良好的 SM 利用率，同时最小化所需的全局归约步骤。\n* 全局归约直接在输出缓冲区中发生（暂时将 FP32 累加器降维到 FP16），该缓冲区保留在 L2 缓存中；归约操作通常也经过优化以避免任何不必要的读写。\n* 总体而言，内核的 PTX（并行线程执行）汇编代码在 NSight-Compute 中进行了广泛分析，CUDA 代码包含几个更多冗余或稍次优的结构，但它们编译后能生成更快的 PTX。\n\n## 基准测试：\n\n我们首先在 NVIDIA A10 GPU 上可以理想分区的大矩阵上，比较 Marlin 与其他流行的 4 位推理内核的性能。\n这使得所有内核都能达到几乎最佳的潜在性能。\n所有内核均在组大小（groupsize）128 下执行（不过，我们注意到缩放格式并不完全相同）。\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_bf59a11e65a0.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\n虽然现有内核在批量大小为 1 时能达到接近最优的 3.87 倍加速比（注意组缩放的 0.125 位存储开销），但随着输入数量的增加，其性能迅速下降。\n相比之下，Marlin 在所有批量大小下都能提供近乎理想的加速比，使得在批量大小约为 16-32 时仍能实现最大可能的 3.87 倍加速比。\n\n由于其条纹分区方案，Marlin 在实际（较小）矩阵和各种 GPU 上也带来了强劲的性能。\n以下结果证明了这一点，我们在批量大小为 16 的情况下，对流行开源模型的 Transformer 块中所有线性层的整体运行时间进行了基准测试。\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_e06deb862acb.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\n最后，我们还研究了在锁定的基础 GPU 时钟下，长时间运行能维持何种性能。\n有趣的是，我们发现降低时钟速度会显著损害前期内核的相对加速比，但对 Marlin 的近乎最优性能（相对于较低的时钟设置）没有影响。\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_readme_849280af30fa.png\" width=\"500\"\u002F>\n\u003C\u002Fdiv>\n\n## 要求：\n\n* CUDA >= 11.8（特别是 `nvcc` 编译器，其版本应与 `torch` 匹配）\n* 计算能力 >= 8.0 的 NVIDIA GPU（Ampere 或 Ada 架构，Marlin 尚未针对 Hopper 架构进行优化）\n* `torch>=2.0.0`\n* `numpy`\n运行量化脚本还需要：\n* `transformers`\n* `datasets`\n* `sentencepiece`\n\n## 用法：\n\n如果满足所有要求，可以通过调用以下命令在该仓库的根文件夹中安装 Marlin：\n\n```\npip install .\n```\n\n此后，使用 Marlin 内核（Marlin kernel）最简单的方式是通过 `marlin.Layer`，这是一个代表 Marlin 量化层（quantized layer）的 torch-module (torch 模块)。它允许通过 `marlin.Layer.pack(linear, scales)` 将“伪量化”（以 FP16 存储的去量化值）的 `torch.Linear` 层转换为压缩的 Marlin 格式。或者，如果权重和缩放系数已经过适当的预处理（参见 `marlin.Layer.pack(...)`），也可以直接通过 `marlin.mul(..)` 调用该内核。内核本身位于自包含的 `marlin\u002Fmarlin_cuda_kernel.cu` 文件中，除了 base-CUDA (基础 CUDA) 之外不包含任何依赖项，因此应易于集成到其他底层框架中。\n\n正确性测试可通过 `python test.py` 执行，基准测试（benchmarks）可通过 `python bench.py` 执行。请注意，为了复现我们的“可持续性能”基准测试，需要使用以下命令将 GPU 时钟（GPU clocks）锁定到各自的基准值：\n\n```\nsudo nvidia-smi --lock-gpu-clocks=BASE_GPU_CLOCK --lock-memory-clocks=BASE_MEM_CLOCK\n```\n\n此外，如果启用了 ECC (错误检查和纠正)（例如在 A10 上），则由于每个内存请求都将包含校验和开销（checksum overheads），实际可达到的最大内存带宽（memory bandwidth）将比官方规格表低 10-15%。这可以通过以下方式禁用：\n\n```\nsudo nvidia-smi -e 0\n```\n\n我们在 A10 基准测试中就是这样做的。\n\n## GPTQ 示例：\n\n在 `gptq` 子文件夹中，我们还提供了一个略微改进的 [GPTQ](https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fgptq) 算法版本，具有更好的组网格裁剪和非均匀校准样本长度，可以生成与 Marlin 兼容的 Llama2 模型的 4 位版本。此外，还有一个脚本可以在流行的 [LLM eval harness](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness) 中评估此类压缩模型（使用 Marlin 内核）。下面的脚本是在 `lm-eval-harness==0.4.0` 下测试的，可能不适用于更新或更旧的版本。以下是相应的示例命令（必须安装 `marlin`、`transformers` 和 `datasets` 包）：\n\n```\n% Compress Llama2 model and export model in Marlin format.\npython llama2.py LLAMA2_CHECKPOINT --wbits 4 --save checkpoint.pt\n% Perform perplexity evaluation of uncompressed model.\npython llama2.py LLAMA2_CHECKPOINT\n% Evaluate compressed model (with Marlin kernels) in the eval harness.\npython eval.py --model hf --model_args pretrained=LLAMA2_CHECKPOINT --tasks mmlu \\\n  --marlin_checkpoint checkpoint.marlin.g128\n% Evaluate full precision baseline.\npython eval.py --model hf --model_args pretrained=LLAMA2_CHECKPOINT --tasks mmlu \n```\n\n我们测量了 4 位（group=128）Marlin 模型的以下 WikiText 和 Red-Pajama 困惑度（perplexities），以及 MMLU 零样本准确率（zero-shot accuracy）：\n\n| Llama2 | Wiki2 (FP16) | Wiki2 (INT4) | RedPaj (FP16) | RedPaj (INT4) | MMLU (FP16) | MMLU (INT4)  |\n|:---:|:----:|:----:|:----:|:----:|:-----:|:-----:|\n| 7B  | 5.12 | 5.27 | 6.14 | 6.30 | 41.80 | 40.07 |\n| 13B | 4.57 | 4.67 | 5.67 | 5.79 | 52.10 | 51.13 |\n| 70B | 3.12 | 3.21 | 4.74 | 4.81 | 65.43 | 64.81 |\n\n我们注意到，此 GPTQ 示例目前主要旨在演示如何生成准确的 Marlin 模型，并作为内核正确性的端到端验证（而不是作为一个灵活的压缩工具）。\n\n## 引用：\n\n如果您觉得这项工作有用，请考虑引用：\n\n```\n@article{frantar2024marlin,\n  title={MARLIN: Mixed-Precision Auto-Regressive Parallel Inference on Large Language Models},\n  author={Frantar, Elias and Castro, Roberto L and Chen, Jiale and Hoefler, Torsten and Alistarh, Dan},\n  journal={arXiv preprint arXiv:2408.11743},\n  year={2024}\n}\n```","# Marlin 快速上手指南\n\n**Marlin** 是一款专为大语言模型（LLM）推理设计的混合精度自回归线性内核（Mixed Auto-Regressive Linear kernel）。它通过高度优化的 FP16xINT4 矩阵乘法，在 NVIDIA GPU 上提供接近理论极限的 4 倍加速比，特别适用于批量推理和推测性解码场景。\n\n## 环境准备\n\n在使用 Marlin 之前，请确保您的开发环境满足以下硬件和软件要求：\n\n*   **GPU 要求**: NVIDIA 显卡，计算能力（Compute Capability）>= 8.0（如 Ampere 或 Ada 架构，例如 A10、RTX 30\u002F40 系列）。\n    *   *注意：目前尚未针对 Hopper 架构优化。*\n*   **CUDA 版本**: >= 11.8（需与 PyTorch 安装的 CUDA 版本一致）。\n*   **Python 依赖**:\n    *   `torch>=2.0.0`\n    *   `numpy`\n*   **量化脚本依赖** (如需运行 GPTQ 压缩示例):\n    *   `transformers`\n    *   `datasets`\n    *   `sentencepiece`\n\n## 安装步骤\n\n1.  **克隆仓库**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002FMarlin.git\n    cd Marlin\n    ```\n\n2.  **安装基础依赖**\n    推荐使用国内镜像源以加快下载速度：\n    ```bash\n    pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple torch>=2.0.0 numpy\n    ```\n\n3.  **安装 Marlin 核心包**\n    在项目根目录下执行：\n    ```bash\n    pip install .\n    ```\n\n4.  *(可选)* **安装量化工具依赖**\n    如果您需要运行 `gptq` 子目录中的模型压缩脚本：\n    ```bash\n    pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple transformers datasets sentencepiece\n    ```\n\n## 基本使用\n\nMarlin 提供了两种主要的使用方式：通过 `marlin.Layer` 模块封装层，或直接调用底层算子。\n\n### 1. 使用 `marlin.Layer` 封装量化层\n\n这是最便捷的方式，可将标准的 `torch.Linear` 层转换为压缩后的 Marlin 格式。\n\n```python\nimport marlin\nimport torch.nn as nn\n\n# 假设 linear 是已加载的模型层，scales 是对应的缩放参数\n# 将“伪量化”层打包为 Marlin 格式\nlinear_marlin = marlin.Layer()\nlinear_marlin.pack(linear, scales)\n```\n\n### 2. 直接调用算子\n\n如果权重和缩放参数已经过预处理，可直接调用 `marlin.mul` 进行计算。\n\n```python\n# 前提：weights 和 scales 已完成必要的预处理\noutput = marlin.mul(weights, scales, input_activations)\n```\n\n### 3. 测试与基准验证\n\n安装完成后，您可以运行内置脚本来验证正确性或测试性能：\n\n*   **运行正确性测试**:\n    ```bash\n    python test.py\n    ```\n*   **运行性能基准测试**:\n    ```bash\n    python bench.py\n    ```\n\n> **注意**: 若要复现官方文档中的“可持续性能”基准测试结果，需要将 GPU 频率锁定至基础值。请在终端执行以下命令（需 sudo 权限）：\n> ```bash\n> sudo nvidia-smi --lock-gpu-clocks=BASE_GPU_CLOCK --lock-memory-clocks=BASE_MEM_CLOCK\n> ```\n> 此外，若使用带有 ECC 功能的显卡（如 A10），建议关闭 ECC 以获得最大内存带宽：\n> ```bash\n> sudo nvidia-smi -e 0\n> ```","某金融科技公司正在构建实时风控对话系统，需在高并发下快速分析大量交易数据并生成合规报告。\n\n### 没有 marlin 时\n- 推理延迟过高，单用户生成回复需数秒，严重影响客户体验与业务流转。\n- 批量处理受限，现有内核仅支持极小批量，导致昂贵的 GPU 计算资源大量闲置。\n- 硬件成本压力大，为支撑高并发量必须采购大量高端 A100 显卡，运维负担重。\n- 复杂逻辑推理困难，长上下文或思维链任务容易触发显存带宽瓶颈，生成中断。\n\n### 使用 marlin 后\n- marlin 实现近 4 倍加速，首字生成时间缩短至毫秒级，交互体验接近人类语速。\n- 支持 16-32 token 的中大型批量，GPU 利用率显著提升，单位时间吞吐量翻倍。\n- 显存与计算效率优化，同等算力下可承载更多并发会话，直接节省一半硬件开支。\n- 稳定支持思维链等高级推理方案，复杂风控报告的生成质量与速度双双获得提升。\n\nmarlin 凭借高效的 INT4 量化内核，让企业在有限预算下也能跑通大规模大模型服务。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIST-DASLab_marlin_bf59a11e.png","IST-DASLab","IST Austria Distributed Algorithms and Systems Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FIST-DASLab_6d4d2549.png","",null,"https:\u002F\u002Fista.ac.at\u002Fen\u002Fresearch\u002Falistarh-group\u002F","https:\u002F\u002Fgithub.com\u002FIST-DASLab",[83,87,91],{"name":84,"color":85,"percentage":86},"Python","#3572A5",56.8,{"name":88,"color":89,"percentage":90},"Cuda","#3A4E3A",40.2,{"name":92,"color":93,"percentage":10},"C++","#f34b7d",1048,87,"2026-04-03T09:27:38","Apache-2.0","未说明","需要 NVIDIA GPU，计算能力 >= 8.0 (Ampere 或 Ada)，不支持 Hopper，CUDA 版本 >= 11.8",{"notes":101,"python":98,"dependencies":102},"1. nvcc 编译器版本需与 torch 匹配；2. 运行量化脚本需额外安装 transformers\u002Fdatasets\u002Fsentencepiece；3. 基准测试建议锁定 GPU 频率并关闭 ECC；4. 主要面向 LLM 推理，支持 FP16xINT4 混合精度。",[103,104,105,106,107],"torch>=2.0.0","numpy","transformers","datasets","sentencepiece",[13,26],[110,111,112,113],"4bit","kernel","llm","quantization","2026-03-27T02:49:30.150509","2026-04-06T06:44:10.414473",[117,122,126,131,135,139],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},2018,"Marlin 是否支持 AWQ 量化方法？","目前不计划添加 AWQ 支持。实验表明，当 GPTQ 和 Marlin 都经过调优时，其量化质量与 AWQ 相当。例如在 LLaMA-3-8B-Instruct 上，两者准确率基本一致。","https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fmarlin\u002Fissues\u002F24",{"id":123,"question_zh":124,"answer_zh":125,"source_url":121},2019,"推荐的量化配置参数（如 AWQ\u002FGPTQ）是什么？","AWQ 可参考 casperhansen 的配置：\"bits\": 4, \"group_size\": 128, \"quant_method\": \"awq\", \"version\": \"gemm\", \"zero_point\": true。对于 GPTQ，建议启用 actorder 参数，可使用 AutoGPTQ 复现相关结果。",{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},2020,"Marlin 内核在哪些场景下性能最优？","适用于自回归解码阶段，特别是短序列长度（\u003C30-50 tokens）。在此模式下，即使 Batch Size 大于 1，Marlin 也能保持低延迟。但在长序列或大 Batch 下，fp16 或 exllamav2 可能更快。","https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fmarlin\u002Fissues\u002F2",{"id":132,"question_zh":133,"answer_zh":134,"source_url":130},2021,"为什么 Marlin 使用 fp32 而非 fp16 进行累加？","虽然 fp16 允许更大的 Tile 尺寸从而可能更快，但 fp32 累加更安全稳定。PyTorch 在某些 GEMM 操作中也会将累积转换为 fp32。为了安全起见，Marlin 选择了 fp32 累加。",{"id":136,"question_zh":137,"answer_zh":138,"source_url":130},2022,"如何进行准确的性能基准测试？","建议使用时钟锁定的 GPU 以减少波动。代码示例需使用 torch.cuda.Event(enable_timing=True) 记录开始和结束时间，并在前后调用 torch.cuda.synchronize()。非锁定时钟可能导致显著差异（约 10-20%）。",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},2023,"权重重排 (_perm\u002F_scale_perm) 的设计目的是什么？","旨在最大化内存效率，利用最大向量长度（每个 Warp 线程一个 int4）。通过子字节重排，使后续生成的 half2 寄存器中包含连续的 FP16 权重，便于通过位操作并行转换。","https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fmarlin\u002Fissues\u002F12",[]]