[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-BobMcDear--attorch":3,"tool-BobMcDear--attorch":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":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":81,"owner_email":82,"owner_twitter":80,"owner_website":80,"owner_url":83,"languages":84,"stars":89,"forks":90,"last_commit_at":91,"license":92,"difficulty_score":10,"env_os":93,"env_gpu":94,"env_ram":93,"env_deps":95,"category_tags":100,"github_topics":101,"view_count":23,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":109,"updated_at":110,"faqs":111,"releases":142},3830,"BobMcDear\u002Fattorch","attorch","A subset of PyTorch's neural network modules, written in Python using OpenAI's Triton.","attorch 是一个基于 OpenAI Triton 用纯 Python 编写的深度学习模块库，它实现了 PyTorch `nn` 模块的核心子集。该项目旨在解决开发者在自定义深度学习算子时面临的困境：既不满意纯 PyTorch 实现的运行速度，又缺乏编写高性能 CUDA 内核的技术门槛或资源。通过利用 Triton 编译器，attorch 在保持代码易读、易修改的同时，实现了媲美甚至超越原生 PyTorch 的执行效率。\n\n与多数专注于 NLP 和 Transformer 架构的同类框架不同，attorch 的适用范围更加广泛，不仅支持多头注意力机制，还涵盖了卷积（1D\u002F2D）、池化以及多种激活函数等计算机视觉常用层，并且完整支持前向传播与反向传播，可直接用于模型训练阶段。此外，它还内置了自动混合精度（AMP）支持，并能灵活融合 Dropout 操作。\n\nattorch 特别适合那些希望深入理解底层算子实现、需要快速原型验证自定义网络结构的研究人员，以及想要优化模型性能但不愿涉足复杂 CUDA 编程的算法工程师。作为一个设计直观、自包含的项目，它为探索高效深度学习操作提供了一个理想","attorch 是一个基于 OpenAI Triton 用纯 Python 编写的深度学习模块库，它实现了 PyTorch `nn` 模块的核心子集。该项目旨在解决开发者在自定义深度学习算子时面临的困境：既不满意纯 PyTorch 实现的运行速度，又缺乏编写高性能 CUDA 内核的技术门槛或资源。通过利用 Triton 编译器，attorch 在保持代码易读、易修改的同时，实现了媲美甚至超越原生 PyTorch 的执行效率。\n\n与多数专注于 NLP 和 Transformer 架构的同类框架不同，attorch 的适用范围更加广泛，不仅支持多头注意力机制，还涵盖了卷积（1D\u002F2D）、池化以及多种激活函数等计算机视觉常用层，并且完整支持前向传播与反向传播，可直接用于模型训练阶段。此外，它还内置了自动混合精度（AMP）支持，并能灵活融合 Dropout 操作。\n\nattorch 特别适合那些希望深入理解底层算子实现、需要快速原型验证自定义网络结构的研究人员，以及想要优化模型性能但不愿涉足复杂 CUDA 编程的算法工程师。作为一个设计直观、自包含的项目，它为探索高效深度学习操作提供了一个理想的起点。","# attorch\n\n• **[Introduction](#introduction)**\u003Cbr>\n• **[Installation](#installation)**\u003Cbr>\n• **[Layers](#layers)**\u003Cbr>\n• **[Math Functions](#math-functions)**\u003Cbr>\n• **[PyTorch Fallback](#pytorch-fallback)**\u003Cbr>\n• **[Tests](#tests)**\u003Cbr>\n• **[Examples](#examples)**\u003Cbr>\n• **[Citations](#citations)**\u003Cbr>\n\n## Introduction\n\nattorch is a subset of PyTorch's [```nn```](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Fnn.html) module, written purely in Python using OpenAI's [Triton](https:\u002F\u002Fgithub.com\u002Fopenai\u002Ftriton). Its goal is to be an easily hackable, self-contained, and readable collection of neural network modules whilst maintaining or improving upon the efficiency of PyTorch. In other words, it intends to be a forkable project endowed with a simple, intuitive design that can serve as an accessible starting point for those who are seeking to develop custom deep learning operations but are not satisfied with the speed of a pure PyTorch implementation and do not have the technical expertise or resources to write CUDA kernels.\n\nThere already exist a number of wonderful PyTorch-like frameworks powered by Triton, including [kernl](https:\u002F\u002Fgithub.com\u002FELS-RD\u002Fkernl\u002Ftree\u002Fmain), [xFormers](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers), [Unsloth](https:\u002F\u002Fgithub.com\u002Funslothai\u002Funsloth), and [```fla```](https:\u002F\u002Fgithub.com\u002Fsustcsonglin\u002Fflash-linear-attention), but most concentrate mainly on Transformers and NLP applications, whereas attorch aims to be more inclusive by also presenting a variety of layers pertaining to areas beyond NLP, such as computer vision. Moreover, attorch is not an inference-only package and fully supports both forward and backward passes, meaning it can be used during training as well as inference, though its performance for the latter is generally not on par with dedicated inference engines.\n\n## Installation\n\nThe only dependencies of attorch are ```torch==2.4.0``` and ```triton==3.0.0```. Please install the specified versions of these two libraries and clone this repository to get started.\n\n## Layers\n\nCurrently implemented layers, with automatic mixed precision (AMP) support, are:\n\n* ```attorch.Conv1d```: 1D-convolves over the input using weights, optionally adding bias.\n* ```attorch.Conv2d```: 2D-convolves over the input using weights, optionally adding bias.\n* ```attorch.AvgPool1d```: Averages 1D windows of pixels in the input.\n* ```attorch.AvgPool2d```: Averages 2D windows of pixels in the input.\n* ```attorch.MultiheadAttention```: Applies multi-headed scaled dot-product attention to the inputs.\n* ```attorch.ELU```: Applies ELU to the input, optionally fusing dropout.\n* ```attorch.Hardshrink```: Applies hard shrink to the input, optionally fusing dropout.\n* ```attorch.Hardsigmoid```: Applies hard sigmoid to the input, optionally fusing dropout.\n* ```attorch.Hardswish```: Applies hard Swish to the input, optionally fusing dropout.\n* ```attorch.Hardtanh```: Applies hard tanh to the input, optionally fusing dropout.\n* ```attorch.LeakyReLU```: Applies leaky ReLU to the input, optionally fusing dropout.\n* ```attorch.LogSigmoid```: Applies the log of sigmoid to the input, optionally fusing dropout.\n* ```attorch.CELU```: Applies CELU to the input, optionally fusing dropout.\n* ```attorch.GELU```: Applies GELU to the input, optionally fusing dropout.\n* ```attorch.ReLU```: Applies ReLU to the input, optionally fusing dropout.\n* ```attorch.ReLU6```: Applies ReLU6 to the input, optionally fusing dropout.\n* ```attorch.SELU```: Applies SELU to the input, optionally fusing dropout.\n* ```attorch.SiLU```: Applies SiLU to the input, optionally fusing dropout.\n* ```attorch.Mish```: Applies Mish to the input, optionally fusing dropout.\n* ```attorch.Softplus```: Applies softplus to the input, optionally fusing dropout.\n* ```attorch.Softshrink```: Applies softshrink to the input, optionally fusing dropout.\n* ```attorch.Softsign```: Applies softsign to the input, optionally fusing dropout.\n* ```attorch.Sigmoid```: Applies sigmoid to the input, optionally fusing dropout.\n* ```attorch.Tanh```: Applies tanh to the input, optionally fusing dropout.\n* ```attorch.Tanhshrink```: Applies tanh to the input, optionally fusing dropout.\n* ```attorch.GLU```: Applies the gated linear unit with an arbitrary activation function to the input.\n* ```attorch.LogSoftmax```: Normalizes the input using softmax and takes its log.\n* ```attorch.Softmax```: Normalizes the input using softmax.\n* ```attorch.Softmin```: Normalizes the input using softmin.\n* ```attorch.BatchNorm1d```: Batch-normalizes the 2D or 3D input, optionally fusing an activation function and adding a residual to the pre-activation result.\n* ```attorch.BatchNorm2d```: Batch-normalizes the 4D input, optionally fusing an activation function and adding a residual to the pre-activation result.\n* ```attorch.LayerNorm```: Layer-normalizes the input.\n* ```attorch.RMSNorm```: Root-mean-square-normalizes the input.\n* ```attorch.Linear```: Linearly transforms the input using weights, optionally adding bias and fusing an activation function.\n* ```attorch.Dropout```: Randomly zeroes elements in the input during training.\n* ```attorch.L1Loss```: Measures the L1 error (mean absolute error) between the input and target.\n* ```attorch.MSELoss```: Measures the squared L2 error (mean squared error) between the input and target.\n* ```attorch.CrossEntropyLoss```: Measures the mean cross entropy loss between the input and target, with optional reweighting of each class.\n* ```attorch.NLLLoss```: Measures the negative log likelihood loss between the input and target, with optional reweighting of each class.\n* ```attorch.HuberLoss```: Measures the Huber loss between the input and target.\n* ```attorch.SmoothL1Loss```: Measures the smooth L1 error between the input and target.\n\nUnless otherwise noted in their docstrings, the aforementioned layers behave identically to their PyTorch equivalents.\n\n## Math Functions\nTriton kernels are generally composed of two parts: One handles the loading and storing of the relevant tensors, the other transforms the data using appropriate mathematical functions. For instance, a layer normalization kernel reads one or several rows from the input (load), standardizes the features (math), and writes the results into a container (store). A selection of these pure math functions is supplied by ```attorch.math```, the objective being to facilitate the implementation of custom kernels and operation fusion. Although only the forward passes of the said functions are available in ```attorch.math```, thanks to their purity and absence of I\u002FO actions, their gradients can be automatically derived via the [```triton-autodiff```](https:\u002F\u002Fgithub.com\u002Fsrush\u002Ftriton-autodiff) library. Significant portions of attorch's kernels can be refactored by supplanting their math bits with the corresponding ```attorch.math``` transformations or their derivatives, but doing so would sacrifice the single-file and self-contained design of attorch, so ```attorch.math``` and the rest of the library will remain separate.\n\n## PyTorch Fallback\n\nTo enable easier integration of attorch and PyTorch layers, ```attorch.nn``` is offered, which provides an interface to attorch's modules with PyTorch fallback should a desired layer not be available, as seen below:\n\n```python\nfrom attorch import nn\n\n\nlin = nn.Linear(10, 20) # Uses attorch's linear layer\ngap = nn.AdaptiveAvgPool2d(1) # Uses PyTorch's global pooling since GAP is not available in attorch\n```\n\nEven though attorch comes with convolutional and pooling layers, the performance of these modules is extremely slow compared to PyTorch. Therefore, ```attorch.nn``` exposes PyTorch's, and not attorch's, convolutions and pools.\n\n## Tests\n\nEach module can be tested against its PyTorch counterpart to ensure correctness. These tests are included under ```tests\u002F``` and can be executed using ```pytest```. A switch, `--subset`, is provided that runs the tests on a smaller subset of data shapes for faster yet less thorough evaluation. It should be noted that some tests may fail owing to numerical precision issues, but in most practical use cases, that should not be a problem.\n\n## Examples\n\n[`examples\u002F`](https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Ftree\u002Fmain\u002Fexamples) contains a handful of common deep learning workflows implemented in both attorch and PyTorch. Although attorch can be used as drop-in replacements for `torch.nn`, some modules offer optional kernel fusion and therefore require additional arguments that are not compatible with their PyTorch analogs. Such distinctions are illustrated in these examples.\n\n## Citations\n\n```bibtex\n@inproceedings{tillet2019triton,\n  title={Triton: an intermediate language and compiler for tiled neural network computations},\n  author={Tillet, Philippe and Kung, Hsiang-Tsung and Cox, David},\n  booktitle={Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages},\n  pages={10--19},\n  year={2019}\n}\n```\n\n```bibtex\n@Misc{xFormers2022,\n  author =       {Benjamin Lefaudeux and Francisco Massa and Diana Liskovich and Wenhan Xiong and Vittorio Caggiano and Sean Naren and Min Xu and Jieru Hu and Marta Tintore and Susan Zhang and Patrick Labatut and Daniel Haziza and Luca Wehrstedt and Jeremy Reizenstein and Grigory Sizov},\n  title =        {xFormers: A modular and hackable Transformer modelling library},\n  howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers}},\n  year =         {2022}\n}\n```\n\n```bibtex\n@software{yang2024fla,\n  title  = {FLA: A Triton-Based Library for Hardware-Efficient Implementations of Linear Attention Mechanism},\n  author = {Yang, Songlin and Zhang, Yu},\n  url    = {https:\u002F\u002Fgithub.com\u002Ffla-org\u002Fflash-linear-attention},\n  month  = jan,\n  year   = {2024}\n}\n```\n","# attorch\n\n• **[简介](#introduction)**\u003Cbr>\n• **[安装](#installation)**\u003Cbr>\n• **[层](#layers)**\u003Cbr>\n• **[数学函数](#math-functions)**\u003Cbr>\n• **[PyTorch 回退](#pytorch-fallback)**\u003Cbr>\n• **[测试](#tests)**\u003Cbr>\n• **[示例](#examples)**\u003Cbr>\n• **[引用](#citations)**\u003Cbr>\n\n## 简介\n\nattorch 是 PyTorch 的 [```nn```](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Fnn.html) 模块的一个子集，完全用 Python 编写，并基于 OpenAI 的 [Triton](https:\u002F\u002Fgithub.com\u002Fopenai\u002Ftriton) 实现。其目标是提供一个易于修改、自包含且可读性强的神经网络模块集合，同时保持或提升与 PyTorch 相当的效率。换句话说，它旨在成为一个可分支的项目，具有简单直观的设计，为那些希望开发自定义深度学习操作、但对纯 PyTorch 实现的速度不满意，且缺乏编写 CUDA 内核的技术专长或资源的人们，提供一个易于上手的起点。\n\n目前已有许多优秀的基于 Triton 的类 PyTorch 框架，包括 [kernl](https:\u002F\u002Fgithub.com\u002FELS-RD\u002Fkernl\u002Ftree\u002Fmain)、[xFormers](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers)、[Unsloth](https:\u002F\u002Fgithub.com\u002Funslothai\u002Funsloth) 和 [```fla```](https:\u002F\u002Fgithub.com\u002Fsustcsonglin\u002Fflash-linear-attention)，但它们大多专注于 Transformer 和自然语言处理应用。相比之下，attorch 则更加全面，不仅涵盖 NLP 领域，还提供了计算机视觉等其他领域的多种层。此外，attorch 并非仅用于推理的包，它完全支持前向和反向传播，因此既可用于训练也可用于推理，尽管其在推理方面的性能通常不如专门的推理引擎。\n\n## 安装\n\nattorch 的唯一依赖是 ```torch==2.4.0``` 和 ```triton==3.0.0```。请安装这两个库的指定版本，并克隆本仓库以开始使用。\n\n## 层\n\n目前已实现的层，并支持自动混合精度（AMP），包括：\n\n* ```attorch.Conv1d```: 使用权重对输入进行 1D 卷积，可选地添加偏置。\n* ```attorch.Conv2d```: 使用权重对输入进行 2D 卷积，可选地添加偏置。\n* ```attorch.AvgPool1d```: 对输入中的 1D 像素窗口取平均。\n* ```attorch.AvgPool2d```: 对输入中的 2D 像素窗口取平均。\n* ```attorch.MultiheadAttention```: 对输入应用多头缩放点积注意力机制。\n* ```attorch.ELU```: 对输入应用 ELU 激活函数，可选地融合 Dropout。\n* ```attorch.Hardshrink```: 对输入应用硬收缩激活函数，可选地融合 Dropout。\n* ```attorch.Hardsigmoid```: 对输入应用硬 Sigmoid 激活函数，可选地融合 Dropout。\n* ```attorch.Hardswish```: 对输入应用硬 Swish 激活函数，可选地融合 Dropout。\n* ```attorch.Hardtanh```: 对输入应用硬双曲正切激活函数，可选地融合 Dropout。\n* ```attorch.LeakyReLU```: 对输入应用 Leaky ReLU 激活函数，可选地融合 Dropout。\n* ```attorch.LogSigmoid```: 对输入应用 Sigmoid 函数的对数，可选地融合 Dropout。\n* ```attorch.CELU```: 对输入应用 CELU 激活函数，可选地融合 Dropout。\n* ```attorch.GELU```: 对输入应用 GELU 激活函数，可选地融合 Dropout。\n* ```attorch.ReLU```: 对输入应用 ReLU 激活函数，可选地融合 Dropout。\n* ```attorch.ReLU6```: 对输入应用 ReLU6 激活函数，可选地融合 Dropout。\n* ```attorch.SELU```: 对输入应用 SELU 激活函数，可选地融合 Dropout。\n* ```attorch.SiLU```: 对输入应用 SiLU 激活函数，可选地融合 Dropout。\n* ```attorch.Mish```: 对输入应用 Mish 激活函数，可选地融合 Dropout。\n* ```attorch.Softplus```: 对输入应用 Softplus 激活函数，可选地融合 Dropout。\n* ```attorch.Softshrink```: 对输入应用 Softshrink 激活函数，可选地融合 Dropout。\n* ```attorch.Softsign```: 对输入应用 Softsign 激活函数，可选地融合 Dropout。\n* ```attorch.Sigmoid```: 对输入应用 Sigmoid 激活函数，可选地融合 Dropout。\n* ```attorch.Tanh```: 对输入应用 Tanh 激活函数，可选地融合 Dropout。\n* ```attorch.Tanhshrink```: 对输入应用 Tanh 激活函数，可选地融合 Dropout。\n* ```attorch.GLU```: 对输入应用门控线性单元，可选地指定激活函数。\n* ```attorch.LogSoftmax```: 使用 Softmax 对输入进行归一化，并取其对数。\n* ```attorch.Softmax```: 使用 Softmax 对输入进行归一化。\n* ```attorch.Softmin```: 使用 Softmin 对输入进行归一化。\n* ```attorch.BatchNorm1d```: 对 2D 或 3D 输入进行批归一化，可选地融合激活函数，并在归一化前的结果上添加残差。\n* ```attorch.BatchNorm2d```: 对 4D 输入进行批归一化，可选地融合激活函数，并在归一化前的结果上添加残差。\n* ```attorch.LayerNorm```: 对输入进行层归一化。\n* ```attorch.RMSNorm```: 对输入进行均方根归一化。\n* ```attorch.Linear```: 使用权重对输入进行线性变换，可选地添加偏置并融合激活函数。\n* ```attorch.Dropout```: 在训练过程中随机将输入中的元素置零。\n* ```attorch.L1Loss```: 计算输入与目标之间的 L1 误差（平均绝对误差）。\n* ```attorch.MSELoss```: 计算输入与目标之间的平方 L2 误差（均方误差）。\n* ```attorch.CrossEntropyLoss```: 计算输入与目标之间的平均交叉熵损失，可选地对各类别进行加权。\n* ```attorch.NLLLoss```: 计算输入与目标之间的负对数似然损失，可选地对各类别进行加权。\n* ```attorch.HuberLoss```: 计算输入与目标之间的 Huber 损失。\n* ```attorch.SmoothL1Loss```: 计算输入与目标之间的平滑 L1 误差。\n\n除非在其文档字符串中另有说明，上述各层的行为与其对应的 PyTorch 版本完全一致。\n\n## 数学函数\nTriton 内核通常由两部分组成：一部分负责相关张量的加载和存储，另一部分则使用适当的数学函数对数据进行变换。例如，层归一化内核会从输入中读取一行或多行数据（加载），对特征进行标准化处理（数学运算），然后将结果写入目标容器（存储）。`attorch.math` 提供了一系列纯数学函数，旨在简化自定义内核的实现以及操作融合。尽管 `attorch.math` 中目前仅实现了这些函数的前向传播，但由于其纯函数特性且不涉及 I\u002FO 操作，其梯度可以通过 [```triton-autodiff```](https:\u002F\u002Fgithub.com\u002Fsrush\u002Ftriton-autodiff) 库自动推导出来。`attorch` 的许多内核都可以通过用对应的 `attorch.math` 变换或其导数替换其中的数学部分来重构，但这样做会牺牲 `attorch` 单文件、自包含的设计理念，因此 `attorch.math` 与库的其他部分仍将保持分离。\n\n## PyTorch 回退机制\n\n为了更方便地将 `attorch` 与 PyTorch 层集成，提供了 `attorch.nn` 模块，它为 `attorch` 的模块提供了一个接口，并在所需层未实现时回退到 PyTorch 实现，如下所示：\n\n```python\nfrom attorch import nn\n\n\nlin = nn.Linear(10, 20) # 使用 attorch 的线性层\ngap = nn.AdaptiveAvgPool2d(1) # 由于 attorch 中没有 GAP 层，因此使用 PyTorch 的全局池化层\n```\n\n尽管 `attorch` 自带卷积和池化层，但这些模块的性能相比 PyTorch 极为缓慢。因此，`attorch.nn` 暴露的是 PyTorch 的卷积和池化操作，而非 `attorch` 自身的实现。\n\n## 测试\n每个模块都可以与其对应的 PyTorch 实现进行对比测试，以确保正确性。这些测试位于 `tests\u002F` 目录下，可以使用 `pytest` 运行。此外，还提供了一个 `--subset` 选项，用于在较小的数据形状子集上运行测试，从而加快评估速度，但准确性会有所降低。需要注意的是，由于数值精度问题，部分测试可能会失败，但在大多数实际应用场景中，这通常不会构成问题。\n\n## 示例\n[`examples\u002F`](https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Ftree\u002Fmain\u002Fexamples) 目录下包含了一些常见的深度学习工作流，分别用 `attorch` 和 PyTorch 实现。虽然 `attorch` 可以作为 `torch.nn` 的直接替代品使用，但某些模块支持可选的内核融合功能，因此需要额外的参数，而这些参数与 PyTorch 对应的实现并不兼容。这些差异在示例中得到了展示。\n\n## 引用\n```bibtex\n@inproceedings{tillet2019triton,\n  title={Triton: an intermediate language and compiler for tiled neural network computations},\n  author={Tillet, Philippe and Kung, Hsiang-Tsung and Cox, David},\n  booktitle={Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages},\n  pages={10--19},\n  year={2019}\n}\n```\n\n```bibtex\n@Misc{xFormers2022,\n  author =       {Benjamin Lefaudeux and Francisco Massa and Diana Liskovich and Wenhan Xiong and Vittorio Caggiano and Sean Naren and Min Xu and Jieru Hu and Marta Tintore and Susan Zhang and Patrick Labatut and Daniel Haziza and Luca Wehrstedt and Jeremy Reizenstein and Grigory Sizov},\n  title =        {xFormers: A modular and hackable Transformer modelling library},\n  howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers}},\n  year =         {2022}\n}\n```\n\n```bibtex\n@software{yang2024fla,\n  title  = {FLA: A Triton-Based Library for Hardware-Efficient Implementations of Linear Attention Mechanism},\n  author = {Yang, Songlin and Zhang, Yu},\n  url    = {https:\u002F\u002Fgithub.com\u002Ffla-org\u002Fflash-linear-attention},\n  month  = jan,\n  year   = {2024}\n}\n```","# attorch 快速上手指南\n\nattorch 是一个基于 OpenAI Triton 纯 Python 实现的 PyTorch `nn` 模块子集。它旨在提供一套易读、可修改且自包含的神经网络组件，在保持或超越 PyTorch 效率的同时，为开发者提供自定义深度学习算子的便捷起点，无需编写复杂的 CUDA 代码。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：支持 Linux (推荐) 或 macOS。\n*   **Python 版本**：建议 Python 3.8+。\n*   **核心依赖**：\n    *   `torch == 2.4.0`\n    *   `triton == 3.0.0`\n\n> **注意**：attorch 对版本有严格要求，请务必安装指定版本的 PyTorch 和 Triton，否则可能导致兼容性问题。\n\n## 安装步骤\n\n1.  **安装依赖**\n    建议使用国内镜像源加速安装过程。请运行以下命令安装指定版本的依赖：\n\n    ```bash\n    pip install torch==2.4.0 triton==3.0.0 -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n\n    *(注：如果您的 GPU 驱动较新或需要特定 CUDA 版本的 torch，请参考 PyTorch 官网获取对应的安装命令，但需确保最终版本为 2.4.0)*\n\n2.  **克隆项目**\n    由于 attorch 目前主要通过源码使用，请克隆仓库到本地：\n\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch.git\n    cd attorch\n    ```\n\n3.  **验证安装**\n    进入项目目录后，您可以直接导入模块进行测试：\n\n    ```bash\n    python -c \"import attorch; print('attorch imported successfully')\"\n    ```\n\n## 基本使用\n\nattorch 的设计初衷是作为 `torch.nn` 的替代品。您可以直接从 `attorch` 导入层，或者使用 `attorch.nn` 接口（该接口会在 attorch 未实现某层时自动回退到 PyTorch 原生实现）。\n\n### 示例 1：直接使用 attorch 层\n\n以下示例展示了如何使用 attorch 实现的线性层 (`Linear`) 和激活函数 (`ReLU`)：\n\n```python\nimport torch\nfrom attorch import Linear, ReLU\n\n# 定义输入张量 (Batch Size=2, Input Dim=10)\nx = torch.randn(2, 10).cuda()\n\n# 实例化 attorch 层\nlinear_layer = Linear(10, 20)\nactivation = ReLU()\n\n# 前向传播\nout = activation(linear_layer(x))\n\nprint(out.shape) # 输出: torch.Size([2, 20])\n```\n\n### 示例 2：使用混合回退模式 (推荐)\n\n使用 `attorch.nn` 可以无缝混合使用 attorch 优化层和 PyTorch 原生层。例如，attorch 目前不包含自适应池化层，会自动调用 PyTorch 实现：\n\n```python\nfrom attorch import nn\n\n# 使用 attorch 优化的 Linear 层\nlin = nn.Linear(10, 20) \n\n# 使用 PyTorch 原生的 AdaptiveAvgPool2d (因为 attorch 暂未实现)\ngap = nn.AdaptiveAvgPool2d(1) \n\nprint(f\"Linear type: {type(lin)}\")\nprint(f\"Pool type: {type(gap)}\")\n```\n\n### 特别说明\n\n*   **卷积与池化性能**：虽然 attorch 实现了 `Conv1d`, `Conv2d`, `AvgPool` 等层，但其性能目前远慢于 PyTorch 原生实现。在使用 `attorch.nn` 时，卷积和池化操作会自动指向 PyTorch 版本以保证速度。\n*   **训练支持**：attorch 完整支持前向和反向传播，可用于模型训练。\n*   **算子融合**：部分激活函数层（如 `ReLU`, `GELU`）支持可选的 Dropout 融合，使用时可查看具体文档或示例代码以利用此特性。","某计算机视觉初创团队正在训练一个基于自定义激活函数（如 Mish 和 Hardswish）的轻量级图像分类模型，以部署在边缘设备上。\n\n### 没有 attorch 时\n- 开发者若想优化自定义算子的速度，必须深入学习 CUDA 编程并编写复杂的底层内核，技术门槛极高且耗时漫长。\n- 直接沿用原生 PyTorch 实现虽然代码易写，但在处理大规模卷积与特定激活函数融合时，显存占用高且训练迭代速度慢。\n- 现有的 Triton 加速库（如 xFormers）主要聚焦于 NLP 领域的 Transformer 架构，缺乏对计算机视觉中常用的 Conv2d 及多种激活函数的原生支持。\n- 尝试手动融合“卷积 + 激活 +Dropout\"操作时，极易因反向传播逻辑复杂而导致梯度计算错误，调试成本巨大。\n\n### 使用 attorch 后\n- 团队直接调用 attorch.Conv2d 和 attorch.Mish 等模块，无需编写一行 CUDA 代码，即可利用 Triton 自动获得接近手写内核的执行效率。\n- 借助 attorch 内置的算子融合特性（如在激活层中可选融合 Dropout），显著减少了 GPU 显存访问次数，训练吞吐量提升明显。\n- 获得了专为视觉任务优化的完整图层支持，涵盖了从 AvgPool2d 到多种硬激活函数（Hardswish, Hardshrink），填补了通用加速库在 CV 领域的空白。\n- 保持了纯 Python 的代码可读性，前后向传播逻辑透明且易于修改，开发人员能快速针对特定需求定制新的神经网络层。\n\nattorch 让不具备底层硬件开发经验的算法工程师，也能轻松构建出兼具高性能与高可定制性的深度学习模型。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBobMcDear_attorch_937fab3d.png","BobMcDear","Borna Ahmadzadeh","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FBobMcDear_431b443f.jpg","Machine learning developer",null,"Toronto, Ontario, Canada","borna.ahz@gmail.com","https:\u002F\u002Fgithub.com\u002FBobMcDear",[85],{"name":86,"color":87,"percentage":88},"Python","#3572A5",100,599,32,"2026-04-03T09:04:40","MIT","未说明","需要支持 Triton 的 NVIDIA GPU（Triton 通常仅支持 Linux 下的 NVIDIA GPU），具体型号和显存大小未说明，需匹配 torch==2.4.0 和 triton==3.0.0 的 CUDA 要求",{"notes":96,"python":93,"dependencies":97},"该工具是基于 Triton 编写的 PyTorch nn 模块子集，旨在提供可定制且高效的神经网络层。虽然支持训练和推理，但其卷积和池化层的性能远低于原生 PyTorch，因此通过 attorch.nn 接口调用时会回退到 PyTorch 实现。部分测试可能因数值精度问题失败，但不影响实际使用。",[98,99],"torch==2.4.0","triton==3.0.0",[13],[102,103,104,105,106,107,108],"cuda","deep-learning","machine-learning","pytorch","triton","openai","openai-triton","2026-03-27T02:49:30.150509","2026-04-06T07:05:48.024867",[112,117,122,127,132,137],{"id":113,"question_zh":114,"answer_zh":115,"source_url":116},17542,"为什么融合线性算子（Fused Linear Operator）的输出结果与 PyTorch 原生实现存在微小的数值差异？","这是浮点运算的固有特性。浮点数不满足结合律，这意味着计算向量点积时，结果取决于对应元素乘积相加的顺序。例如，(a1*b1 + a2*b2) + (a3*b3 + a4*b4) 可能不完全等于 a1*b1 + a2*b2 + a3*b3 + a4*b4，从而导致微小误差。并行代码尤其容易出现此问题，因为大量数据块被分开处理后再聚合，其顺序往往不可预测。这属于正常现象，并非代码错误。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F10",{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},17543,"在 Tesla V100 等 GPU 上，为什么 Batch Norm 的前向内核速度比 PyTorch 慢很多？","默认的小批量大小（如 32）对于 V100 的显存来说太小，导致 GPU 资源利用率严重不足。解决方法是增大批量大小（Batch Size）。例如，在 ResNet-101 测试中，将批量大小设置为硬件允许的最大值（如 128），attorch 的速度将会超过或持平 PyTorch。如果前向和反向传播时间变快但总训练时间仍较长，可能需要检查数据加载或其他非内核部分的开销。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F7",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},17544,"项目是否有计划实现循环神经网络层（如 RNN、LSTM 或 GRU）？","目前暂无计划。高效的循环核（Recurrent Kernels）在 Triton 中开发需要巨大的工作量，尤其是缺乏参考实现的情况下，维护者目前无法承诺投入此类开发。如果社区成员有建议或能实现一个粗略的基线版本，欢迎重新开启该议题或提交贡献。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F11",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},17545,"在 Triton 编程模型中，GROUP 概念与 BLOCK 有什么区别？","可以将 GROUP 理解为输出矩阵的一个子矩阵（sub-matrix），多个 BLOCK 会被分配任务来计算同一个输出 GROUP。需要注意的是，GROUP 本身并不执行计算，它只是一种抽象概念，用于修改 BLOCK 计算的排序逻辑（具体可见代码中 batch_pid 和 out_feat_pid 的计算公式）。层级关系大致可理解为：GROUP 包含多个 BLOCK，BLOCK 包含多个线程（THREAD）。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F3",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},17546,"是否考虑将加载\u002F存储逻辑与数学运算分离，以便更容易进行算子融合（如融合 Dropout）？","是的，维护者计划保持现有层的设计不变，但会添加一个独立的 math 模块。该模块将实现基本数学函数的前向传播，其梯度可通过 triton-autodiff 推导。这将允许开发者将这些函数插入到其他内核中，在 attorch 不支持特定用例时自行实现融合。虽然这会涉及一些重复代码，但为了保持神经网络模块的简洁性，这是首选方案。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F1",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},17547,"模型转换为 Triton 形式后推理速度变慢，且生成了大量中间 IR 文件，如何解决？","关于推理速度慢的问题，通常与缓存或特定的 Triton IR 配置有关，建议直接在 Triton 官方仓库提交 issue 以获得更专业的支持，因为这不属于 attorch 的直接范畴。关于保存 IR 文件，Triton 编译器默认将所有中间文件保存在 ~\u002F.triton\u002Fdump 目录下，每个文件夹对应一个算子的中间表示。目前 attorch 维护者指出其不具备处理 Triton IR 的专业知识，若需整合 IR 文件或优化推理性能，需深入查阅 Triton 文档或在 Triton 社区寻求关于 IR 合并与推理执行的特定指导。","https:\u002F\u002Fgithub.com\u002FBobMcDear\u002Fattorch\u002Fissues\u002F4",[]]