[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-deepseek-ai--FlashMLA":3,"tool-deepseek-ai--FlashMLA":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 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[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":80,"owner_email":81,"owner_twitter":80,"owner_website":82,"owner_url":83,"languages":84,"stars":101,"forks":102,"last_commit_at":103,"license":104,"difficulty_score":105,"env_os":106,"env_gpu":107,"env_ram":106,"env_deps":108,"category_tags":113,"github_topics":80,"view_count":23,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":114,"updated_at":115,"faqs":116,"releases":152},2885,"deepseek-ai\u002FFlashMLA","FlashMLA","FlashMLA: Efficient Multi-head Latent Attention Kernels","FlashMLA 是深度求索（DeepSeek）推出的一套高效注意力机制内核库，专为加速大语言模型的推理与训练而生。它作为核心引擎，成功支撑了 DeepSeek-V3 及 V3.2 系列模型的运行。\n\n针对大模型在处理长文本时计算量大、显存占用高的问题，FlashMLA 提供了稀疏与稠密两种注意力内核方案。其独特亮点在于实现了令牌级（Token-level）稀疏注意力，并创新性地支持 FP8 精度的 KV 缓存技术。这不仅大幅降低了显存需求，更在 NVIDIA H800 等高端显卡上实现了惊人的计算效率：预填充阶段算力可达 640 TFlops，解码阶段高达 410 TFlops，显著提升了模型响应速度。\n\n该工具主要面向 AI 研究人员、大模型开发者以及系统优化工程师。如果你正在尝试复现 DeepSeek 架构、部署高性能大模型服务，或致力于探索底层算子优化，FlashMLA 将提供强大的技术支持。需要注意的是，使用它需要具备一定的 CUDA 编程基础，并配备支持 SM90 或 SM100 架构的最新一代 GPU 硬件。通过集成 FlashMLA，开发者能够轻松突破性能瓶颈，让大模型","FlashMLA 是深度求索（DeepSeek）推出的一套高效注意力机制内核库，专为加速大语言模型的推理与训练而生。它作为核心引擎，成功支撑了 DeepSeek-V3 及 V3.2 系列模型的运行。\n\n针对大模型在处理长文本时计算量大、显存占用高的问题，FlashMLA 提供了稀疏与稠密两种注意力内核方案。其独特亮点在于实现了令牌级（Token-level）稀疏注意力，并创新性地支持 FP8 精度的 KV 缓存技术。这不仅大幅降低了显存需求，更在 NVIDIA H800 等高端显卡上实现了惊人的计算效率：预填充阶段算力可达 640 TFlops，解码阶段高达 410 TFlops，显著提升了模型响应速度。\n\n该工具主要面向 AI 研究人员、大模型开发者以及系统优化工程师。如果你正在尝试复现 DeepSeek 架构、部署高性能大模型服务，或致力于探索底层算子优化，FlashMLA 将提供强大的技术支持。需要注意的是，使用它需要具备一定的 CUDA 编程基础，并配备支持 SM90 或 SM100 架构的最新一代 GPU 硬件。通过集成 FlashMLA，开发者能够轻松突破性能瓶颈，让大模型应用跑得更快、更稳。","# FlashMLA\n\n## Introduction\n\nFlashMLA is DeepSeek's library of optimized attention kernels, powering the [DeepSeek-V3](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3) and [DeepSeek-V3.2-Exp](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp) models. This repository contains the following implementations:\n\n**Sparse Attention Kernels**\n\n*These kernels power DeepSeek Sparse Attention (DSA), as introduced in [this paper](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp).*\n\n- Token-level sparse attention for the prefill stage\n- Token-level sparse attention for the decoding stage, with FP8 KV cache\n\n**Dense Attention Kernels**\n\n- Dense attention for the prefill stage\n- Dense attention for the decoding stage\n\n## News\n\n- **2025.09.29 Release of Sparse Attention Kernels**: With the launch of [DeepSeek-V3.2](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp), we are releasing the corresponding token-level sparse attention kernels. These kernels power the model's DeepSeek Sparse Attention (DSA) and achieve up to 640 TFlops during prefilling and 410 TFlops during decoding. We also release a deep-dive blog for our new FP8 sparse decoding kernel. Check it out [here](docs\u002F20250929-hopper-fp8-sparse-deep-dive.md).\n- **2025.08.01 Kernels for MHA on SM100**: Thanks to [NVIDIA's PR](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fpull\u002F76) for MHA forward \u002F backward kernels on SM100!\n- **2025.04.22 Deep-Dive Blog**: We'd love to share the technical details behind the new FlashMLA kernel! Check out our deep-dive write-up [here](docs\u002F20250422-new-kernel-deep-dive.md).\n- **2025.04.22 Performance Update**: We're excited to announce the new release of Flash MLA, which delivers 5% ~ 15% performance improvement for compute-bound workloads, achieving up to 660 TFlops on NVIDIA H800 SXM5 GPUs. The interface of the new version is fully compatible with the old one. Simply upgrade to the new version for an immediate performance boost! 🚀🚀🚀\n\n## Performance\n\n#### Test & benchmark MLA decoding (Sparse & Dense):\n\n```bash\npython tests\u002Ftest_flash_mla_dense_decoding.py\npython tests\u002Ftest_flash_mla_sparse_decoding.py\n```\n\nThe dense MLA decoding kernel achieves up to 3000 GB\u002Fs in memory-bound configuration and 660 TFLOPS in computation-bound configuration on H800 SXM5 with CUDA 12.8. The token-level sparse MLA decoding kernel (which uses an FP8 KV cache while performing the matrix multiplication in bfloat16) achieves 410 TFLOPS in compute-bound configuration on H800 SXM5 with CUDA 12.8, and achieves up to 350 TFlops on B200 (which is not really optimized yet).\n\n#### Test & benchmark MHA prefill (Dense):\n\n```bash\npython tests\u002Ftest_fmha_sm100.py\n```\n\nIt achieves up to 1460 TFlops in forward and 1000 TFlops in backward computation on B200, as reported by NVIDIA.\n\n#### Test & benchmark MLA prefill (Sparse):\n\n```bash\npython tests\u002Ftest_flash_mla_sparse_prefill.py\n```\n\nIt achieves up to 640 TFlops in forward computation on H800 SXM5 with CUDA 12.8, and achieves up to 1450 TFlops on B200, CUDA 12.9.\n\n## Requirements\n\n- SM90 \u002F SM100 (See the support matrix below)\n- CUDA 12.8 and above (CUDA 12.9+ is required for SM100 kernels)\n- PyTorch 2.0 and above\n\nSupport matrix:\n\n| Kernel | GPU Architecture | MLA Mode [2] | KVCache Format |\n| :---: | :---: | :---: | :---: |\n| Dense Decoding | SM90 | MQA | BF16 |\n| Sparse Decoding | SM90 & SM100 | MQA | FP8 [1] |\n| Dense Prefill | SM100 | MHA |  |\n| Sparse Prefill | SM90 & SM100 | MQA |  |\n\n[1]: For more details on using FP8 KV cache, see documents below.\n\n[2]: Here \"MLA Mode\" refers to the mode used for MLA calculation. MQA stands for Multi-Query Attention mode (i.e. `head_dim_k` =  576 with `head_dim_v` = 512), while MHA stands for Multi-Head Attention mode (i.e. `head_dim_k` = 192 \u002F 128 with `head_dim_v` = 128). For a detailed explanation of these modes, please refer to the appendix of [DeepSeek V3.2's Paper](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp).\n\n## Installation\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA.git flash-mla\ncd flash-mla\ngit submodule update --init --recursive\npip install -v .\n```\n\n## Usage\n\n### MLA Decoding\n\nTo use the MLA decoding kernels, call get_mla_metadata once before the decoding loop to get the tile scheduler metadata. Then, call flash_mla_with_kvcache in each decoding step. For example:\n\n```python\nfrom flash_mla import get_mla_metadata, flash_mla_with_kvcache\n\ntile_scheduler_metadata, num_splits = get_mla_metadata(\n    cache_seqlens,\n    s_q * h_q \u002F\u002F h_kv,\n    h_kv,\n    h_q,\n    is_fp8,\n    topk,\n)\n\nfor i in range(num_layers):\n    ...\n    o_i, lse_i = flash_mla_with_kvcache(\n        q_i, kvcache_i, block_table, cache_seqlens, dv,\n        tile_scheduler_metadata, num_splits,\n        is_causal, is_fp8_kvcache, indices,\n    )\n    ...\n```\n\nWhere\n\n- `s_q` is the number of q tokens per q sequence. If MTP (speculative decoding) is disabled, it should be 1.\n- `h_kv` is the number of key-value heads.\n- `h_q` is the number of query heads.\n\n**FP8 KV Cache:**\nIf `is_fp8_kvcache` is set to `True`, the kernel reads the KV cache in the \"FP8 with scale\" format (described below). It dequantizes the cache to bfloat16 and performs attention computation in bfloat16. The output is also in bfloat16.\n\nIn the \"FP8 with scale\" format, each token's KV cache is 656 Bytes, structured as:\n-   **First 512 bytes:** The \"quantized NoPE\" part, containing 512 `float8_e4m3` values.\n-   **Next 16 bytes:** Scale factors, containing 4 `float32` values. The first `float32` is the scale for the first 128 `float8_e4m3` values, the second for the next 128, and so on.\n-   **Last 128 bytes:** The \"RoPE\" part, containing 64 `bfloat16` values. This part is not quantized for accuracy.\n\nSee `tests\u002Fquant.py` for quantization and dequantization details.\n\n**Sparse Attention (`indices` tensor):**\nThe `indices` tensor (if provided) enables token-level sparse attention by instructing the kernel to compute attention only for specified tokens.\n\n-   **Shape:** `indices` should be a 3D tensor of shape `(batch_size, seq_len_q, topk)`.\n-   **Format:** `indices_in_kvcache[i][j][k] = (the index of the page block where token t resides) * page_block_size + (the offset of token t within the page block)`, where `t` is the k-th token for the j-th query sequence in the i-th batch. Since the index of the page block has already been encoded into `indices_in_kvcache`, the kernel does not require the `block_table` parameter.\n-   **Invalid entries:** Set invalid indices to `-1`.\n\n**Return Values:**\nThe kernel returns `(out, lse)`, where:\n-   `out` is the attention result.\n-   `lse` is the log-sum-exp value of the attention scores for each query head.\n\nSee `tests\u002Ftest_flash_mla_decoding.py` for a complete example.\n\n### Sparse MLA Prefill\n\nFor the sparse MLA prefill kernel, call `flash_mla_sparse_fwd` directly with the following parameters:\n-   `q`: Query tensor of shape `[s_q, h_q, d_qk]`\n-   `kv`: Key-Value tensor of shape `[s_kv, h_kv, d_qk]`\n-   `indices`: Indices tensor of shape `[s_q, h_kv, topk]`\n-   `sm_scale`: A scalar value\n\n**Note on batching:** This kernel does not support a batch dimension. For multi-batch inference, reshape the input tensors and adjust the `indices` parameter to simulate batch processing.\n\n**Invalid indices:** Set invalid entries in `indices` to `-1` or any number `>= s_kv`.\n\n**Return Values and Equivalent PyTorch Code:**\nThe kernel returns `(out, max_logits, lse)`. This is equivalent to the following PyTorch operations:\n\n```python\nQ: [s_q, h_q, d_qk], bfloat16\nkv: [s_kv, h_kv, d_qk], bfloat16\nindices: [s_q, h_kv, topk], int32\n\nkv = kv.squeeze(1)  # [s_kv, d_qk], h_kv must be 1\nindices = indices.squeeze(1)    # [s_q, topk]\nfocused_kv = kv[indices]    # For the i-th sequence (s_q), the corresponding KV tokens are selected from the KV cache based on indices[i, :]. This operation results in a tensor of shape [s_q, topk, d_qk].\n\nP = (Q @ focused_kv.transpose(-1, -2)) * sm_scale * math.log2(math.e)    # [s_q, h_q, topk]\nmax_logits = P.max(dim=-1) # [s_q, h_q]\nlse = log2sumexp2(P, dim=-1, base=2)   # [s_q, h_q]，\"log2sumexp2\" means that the exponentiation and logarithm are base-2\nS = exp2(P - lse)      # [s_q, h_q, topk]\nout = S @ focused_kv  # [s_q, h_q, d_qk]\n\nreturn (out, max_logits, lse)\n```\n\nSee `tests\u002Ftest_flash_mla_prefill.py` for a complete example.\n\n### Dense MHA Prefill\n\nThis kernel implements the standard dense Multi-Head Attention (MHA) forward and backward operations. It can be called using:\n-   `flash_attn_varlen_func`\n-   `flash_attn_varlen_qkvpacked_func`\n-   `flash_attn_varlen_kvpacked_func`\n\nThe usage is similar to the `flash_attn` package. See `tests\u002Ftest_fmha_sm100.py` for a complete example.\n\n## Acknowledgement\n\nFlashMLA is inspired by [FlashAttention 2&3](https:\u002F\u002Fgithub.com\u002Fdao-AILab\u002Fflash-attention\u002F) and [cutlass](https:\u002F\u002Fgithub.com\u002Fnvidia\u002Fcutlass) projects.\n\n## Community Support\n\n### MetaX\nFor MetaX GPUs, visit the official website: [MetaX](https:\u002F\u002Fwww.metax-tech.com).\n\nThe corresponding FlashMLA version can be found at: [MetaX-MACA\u002FFlashMLA](https:\u002F\u002Fgithub.com\u002FMetaX-MACA\u002FFlashMLA)\n\n\n### Moore Threads\nFor the Moore Threads GPU, visit the official website: [Moore Threads](https:\u002F\u002Fwww.mthreads.com\u002F).\n\nThe corresponding FlashMLA version is available on GitHub: [MooreThreads\u002FMT-flashMLA](https:\u002F\u002Fgithub.com\u002FMooreThreads\u002FMT-flashMLA).\n\n\n### Hygon DCU\nFor the Hygon DCU, visit the official website: [Hygon Developer](https:\u002F\u002Fdeveloper.sourcefind.cn\u002F).\n\nThe corresponding FlashMLA version is available here: [OpenDAS\u002FMLAttention](https:\u002F\u002Fdeveloper.sourcefind.cn\u002Fcodes\u002FOpenDAS\u002FMLAttention).\n\n\n### Intellifusion\nFor the Intellifusion NNP, visit the official website: [Intellifusion](https:\u002F\u002Fwww.intellif.com).\n\nThe corresponding FlashMLA version is available on Gitee: [Intellifusion\u002Ftyllm](https:\u002F\u002Fgitee.com\u002FIntellifusion_2025\u002Ftyllm\u002Fblob\u002Fmaster\u002Fpython\u002Ftylang\u002Fflash_mla.py).\n\n\n### Iluvatar Corex\nFor Iluvatar Corex GPUs, visit the official website: [Iluvatar Corex](https:\u002F\u002Fwww.iluvatar.com).\n\nThe corresponding FlashMLA version is available on GitHub: [Deep-Spark\u002FFlashMLA](https:\u002F\u002Fgithub.com\u002FDeep-Spark\u002FFlashMLA\u002Ftree\u002Filuvatar_flashmla)\n\n\n### AMD Instinct\nFor AMD Instinct GPUs, visit the official website: [AMD Instinct](https:\u002F\u002Fwww.amd.com\u002Fen\u002Fproducts\u002Faccelerators\u002Finstinct.html).\n\nThe corresponding FlashMLA version can be found at: [AITER\u002FMLA](https:\u002F\u002Fgithub.com\u002FROCm\u002Faiter\u002Fblob\u002Fmain\u002Faiter\u002Fmla.py)\n\n## Citation\n\n```bibtex\n@misc{flashmla2025,\n      title={FlashMLA: Efficient Multi-head Latent Attention Kernels},\n      author={Jiashi Li, Shengyu Liu},\n      year={2025},\n      publisher = {GitHub},\n      howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA}},\n}\n```\n","# FlashMLA\n\n## 简介\n\nFlashMLA 是 DeepSeek 的优化注意力核函数库，为 [DeepSeek-V3](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3) 和 [DeepSeek-V3.2-Exp](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp) 模型提供支持。本仓库包含以下实现：\n\n**稀疏注意力核函数**\n\n*这些核函数驱动了 DeepSeek 稀疏注意力（DSA），如 [这篇论文](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp) 中所述。*\n\n- 预填充阶段的 token 级别稀疏注意力\n- 解码阶段的 token 级别稀疏注意力，采用 FP8 KV 缓存\n\n**密集注意力核函数**\n\n- 预填充阶段的密集注意力\n- 解码阶段的密集注意力\n\n## 最新消息\n\n- **2025年9月29日 发布稀疏注意力核函数**：随着 [DeepSeek-V3.2](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp) 的推出，我们发布了相应的 token 级别稀疏注意力核函数。这些核函数支持模型的 DeepSeek 稀疏注意力（DSA），在预填充时最高可达 640 TFlops，在解码时可达 410 TFlops。我们还发布了一篇关于我们全新 FP8 稀疏解码核函数的深度解析博客，请点击 [这里](docs\u002F20250929-hopper-fp8-sparse-deep-dive.md) 查看。\n- **2025年8月1日 SM100 上的 MHA 核函数**：感谢 [NVIDIA 的 PR](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fpull\u002F76)，为我们带来了 SM100 上的 MHA 前向和后向核函数！\n- **2025年4月22日 深度解析博客**：我们非常乐意分享新 FlashMLA 核函数背后的技术细节！请查看我们的深度解析文章 [这里](docs\u002F20250422-new-kernel-deep-dive.md)。\n- **2025年4月22日 性能更新**：我们很高兴宣布 Flash MLA 的新版本发布，该版本在计算密集型工作负载上实现了 5% 至 15% 的性能提升，在 NVIDIA H800 SXM5 GPU 上最高可达 660 TFlops。新版本的接口与旧版本完全兼容，只需升级到新版本即可立即获得性能提升！🚀🚀🚀\n\n## 性能\n\n#### 测试与基准测试 MLA 解码（稀疏与密集）：\n\n```bash\npython tests\u002Ftest_flash_mla_dense_decoding.py\npython tests\u002Ftest_flash_mla_sparse_decoding.py\n```\n\n在内存受限的配置下，密集 MLA 解码核函数可达到最高 3000 GB\u002Fs 的吞吐量；而在计算受限的配置下，则可在 H800 SXM5 上以 CUDA 12.8 实现 660 TFLOPS 的计算性能。使用 bfloat16 进行矩阵乘法并采用 FP8 KV 缓存的 token 级别稀疏 MLA 解码核函数，在 H800 SXM5 上以 CUDA 12.8 可实现 410 TFLOPS 的计算性能，而在尚未完全优化的 B200 上则可达到最高 350 TFLOPS。\n\n#### 测试与基准测试 MHA 预填充（密集）：\n\n```bash\npython tests\u002Ftest_fmha_sm100.py\n```\n\n据 NVIDIA 报道，它在 B200 上的前向计算最高可达 1460 TFLOPS，后向计算则可达 1000 TFLOPS。\n\n#### 测试与基准测试 MLA 预填充（稀疏）：\n\n```bash\npython tests\u002Ftest_flash_mla_sparse_prefill.py\n```\n\n在 H800 SXM5 上以 CUDA 12.8 运行时，其前向计算最高可达 640 TFLOPS；而在 B200 上以 CUDA 12.9 运行时，则最高可达 1450 TFLOPS。\n\n## 系统要求\n\n- SM90 \u002F SM100（参见下方的支持矩阵）\n- CUDA 12.8 及以上版本（SM100 核函数需 CUDA 12.9+）\n- PyTorch 2.0 及以上版本\n\n支持矩阵：\n\n| 核函数 | GPU 架构 | MLA 模式 [2] | KV 缓存格式 |\n| :---: | :---: | :---: | :---: |\n| 密集解码 | SM90 | MQA | BF16 |\n| 稀疏解码 | SM90 & SM100 | MQA | FP8 [1] |\n| 密集预填充 | SM100 | MHA |  |\n| 稀疏预填充 | SM90 & SM100 | MQA |  |\n\n[1]: 关于如何使用 FP8 KV 缓存的更多详情，请参阅下方文档。\n\n[2]: 此处“MLA 模式”指用于 MLA 计算的模式。MQA 代表多查询注意力模式（即 `head_dim_k` = 576，`head_dim_v` = 512），而 MHA 则代表多头注意力模式（即 `head_dim_k` = 192 \u002F 128，`head_dim_v` = 128）。有关这些模式的详细解释，请参阅 [DeepSeek V3.2 论文](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V3.2-Exp) 的附录。\n\n## 安装\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA.git flash-mla\ncd flash-mla\ngit submodule update --init --recursive\npip install -v .\n```\n\n## 使用方法\n\n### MLA 解码\n\n要使用 MLA 解码核函数，需在解码循环之前调用一次 `get_mla_metadata` 来获取分块调度器元数据。然后在每一步解码中调用 `flash_mla_with_kvcache`。例如：\n\n```python\nfrom flash_mla import get_mla_metadata, flash_mla_with_kvcache\n\ntile_scheduler_metadata, num_splits = get_mla_metadata(\n    cache_seqlens,\n    s_q * h_q \u002F\u002F h_kv,\n    h_kv,\n    h_q,\n    is_fp8,\n    topk,\n)\n\nfor i in range(num_layers):\n    ...\n    o_i, lse_i = flash_mla_with_kvcache(\n        q_i, kvcache_i, block_table, cache_seqlens, dv,\n        tile_scheduler_metadata, num_splits,\n        is_causal, is_fp8_kvcache, indices,\n    )\n    ...\n```\n\n其中\n\n- `s_q` 是每个查询序列中的查询 token 数量。如果禁用了 MTP（推测性解码），则应为 1。\n- `h_kv` 是键值头的数量。\n- `h_q` 是查询头的数量。\n\n**FP8 KV 缓存：**\n如果将 `is_fp8_kvcache` 设置为 `True`，核函数将以“FP8 with scale”格式读取 KV 缓存（如下所述）。它会将缓存去量化为 bfloat16，并以 bfloat16 进行注意力计算。输出结果同样为 bfloat16。\n\n在“FP8 with scale”格式中，每个 token 的 KV 缓存大小为 656 字节，结构如下：\n-   **前 512 字节：** “量化 NoPE”部分，包含 512 个 `float8_e4m3` 值。\n-   **接下来的 16 字节：** 缩放因子，包含 4 个 `float32` 值。第一个 `float32` 是前 128 个 `float8_e4m3` 值的缩放因子，第二个是接下来的 128 个的缩放因子，以此类推。\n-   **最后 128 字节：** “RoPE”部分，包含 64 个 `bfloat16` 值。这部分未被量化，以保证精度。\n\n有关量化和去量化的详细信息，请参阅 `tests\u002Fquant.py`。\n\n**稀疏注意力（`indices` 张量）：**\n`indices` 张量（如果提供）可通过指示核函数仅对指定 token 进行注意力计算，从而实现 token 级别的稀疏注意力。\n\n-   **形状：** `indices` 应为一个三维张量，形状为 `(batch_size, seq_len_q, topk)`。\n-   **格式：** `indices_in_kvcache[i][j][k] = （token t 所在页块的索引）* 页块大小 + （token t 在页块内的偏移量）`，其中 `t` 是第 i 个批次中第 j 个查询序列的第 k 个 token。由于页块的索引已编码进 `indices_in_kvcache`，因此核函数无需 `block_table` 参数。\n-   **无效条目：** 将无效索引设为 `-1`。\n\n**返回值：**\n核函数返回 `(out, lse)`，其中：\n-   `out` 是注意力计算结果。\n-   `lse` 是每个查询头的注意力分数的 log-sum-exp 值。\n\n完整示例请参阅 `tests\u002Ftest_flash_mla_decoding.py`。\n\n### 稀疏 MLA 预填充\n\n对于稀疏 MLA 预填充核函数，可直接调用 `flash_mla_sparse_fwd`，参数如下：\n-   `q`: 查询张量，形状为 `[s_q, h_q, d_qk]`\n-   `kv`: 键值张量，形状为 `[s_kv, h_kv, d_qk]`\n-   `indices`: 索引张量，形状为 `[s_q, h_kv, topk]`\n-   `sm_scale`: 一个标量值\n\n**关于批处理的说明：** 此核函数不支持批量维度。若需进行多批次推理，可对输入张量进行重塑，并调整 `indices` 参数以模拟批处理过程。\n\n**无效索引：** 将 `indices` 中的无效条目设置为 `-1` 或任何大于等于 `s_kv` 的数值。\n\n**返回值及等效 PyTorch 代码：**\n该核函数返回 `(out, max_logits, lse)`。这与以下 PyTorch 操作等价：\n\n```python\nQ: [s_q, h_q, d_qk], bfloat16\nkv: [s_kv, h_kv, d_qk], bfloat16\nindices: [s_q, h_kv, topk], int32\n\nkv = kv.squeeze(1)  # [s_kv, d_qk], h_kv 必须为 1\nindices = indices.squeeze(1)    # [s_q, topk]\nfocused_kv = kv[indices]    # 对于第 i 个序列 (s_q)，根据 indices[i, :] 从 KV 缓存中选择对应的 KV 令牌。此操作会生成一个形状为 [s_q, topk, d_qk] 的张量。\n\nP = (Q @ focused_kv.transpose(-1, -2)) * sm_scale * math.log2(math.e)    # [s_q, h_q, topk]\nmax_logits = P.max(dim=-1) # [s_q, h_q]\nlse = log2sumexp2(P, dim=-1, base=2)   # [s_q, h_q]，“log2sumexp2” 表示指数和对数均以 2 为底\nS = exp2(P - lse)      # [s_q, h_q, topk]\nout = S @ focused_kv  # [s_q, h_q, d_qk]\n\nreturn (out, max_logits, lse)\n```\n\n完整示例请参阅 `tests\u002Ftest_flash_mla_prefill.py`。\n\n### 密集 MHA 预填充\n\n该核函数实现了标准的密集多头注意力（MHA）前向和反向运算。可通过以下函数调用：\n-   `flash_attn_varlen_func`\n-   `flash_attn_varlen_qkvpacked_func`\n-   `flash_attn_varlen_kvpacked_func`\n\n使用方法与 `flash_attn` 包类似。完整示例请参阅 `tests\u002Ftest_fmha_sm100.py`。\n\n## 致谢\n\nFlashMLA 受到 [FlashAttention 2&3](https:\u002F\u002Fgithub.com\u002Fdao-AILab\u002Fflash-attention\u002F) 和 [cutlass](https:\u002F\u002Fgithub.com\u002Fnvidia\u002Fcutlass) 项目的启发。\n\n## 社区支持\n\n### MetaX\n针对 MetaX GPU，请访问其官方网站：[MetaX](https:\u002F\u002Fwww.metax-tech.com)。\n\n相应的 FlashMLA 版本可在以下地址找到：[MetaX-MACA\u002FFlashMLA](https:\u002F\u002Fgithub.com\u002FMetaX-MACA\u002FFlashMLA)。\n\n### Moore Threads\n针对 Moore Threads GPU，请访问其官方网站：[Moore Threads](https:\u002F\u002Fwww.mthreads.com\u002F)。\n\n相应的 FlashMLA 版本已在 GitHub 上发布：[MooreThreads\u002FMT-flashMLA](https:\u002F\u002Fgithub.com\u002FMooreThreads\u002FMT-flashMLA)。\n\n### Hygon DCU\n针对 Hygon DCU，请访问其官方网站：[Hygon Developer](https:\u002F\u002Fdeveloper.sourcefind.cn\u002F)。\n\n相应的 FlashMLA 版本在此处提供：[OpenDAS\u002FMLAttention](https:\u002F\u002Fdeveloper.sourcefind.cn\u002Fcodes\u002FOpenDAS\u002FMLAttention)。\n\n### Intellifusion\n针对 Intellifusion NNP，请访问其官方网站：[Intellifusion](https:\u002F\u002Fwww.intellif.com)。\n\n相应的 FlashMLA 版本已在 Gitee 上发布：[Intellifusion\u002Ftyllm](https:\u002F\u002Fgitee.com\u002FIntellifusion_2025\u002Ftyllm\u002Fblob\u002Fmaster\u002Fpython\u002Ftylang\u002Fflash_mla.py)。\n\n### Iluvatar Corex\n针对 Iluvatar Corex GPU，请访问其官方网站：[Iluvatar Corex](https:\u002F\u002Fwww.iluvatar.com)。\n\n相应的 FlashMLA 版本已在 GitHub 上发布：[Deep-Spark\u002FFlashMLA](https:\u002F\u002Fgithub.com\u002FDeep-Spark\u002FFlashMLA\u002Ftree\u002Filuvatar_flashmla)。\n\n### AMD Instinct\n针对 AMD Instinct GPU，请访问其官方网站：[AMD Instinct](https:\u002F\u002Fwww.amd.com\u002Fen\u002Fproducts\u002Faccelerators\u002Finstinct.html)。\n\n相应的 FlashMLA 版本可在以下地址找到：[AITER\u002FMLA](https:\u002F\u002Fgithub.com\u002FROCm\u002Faiter\u002Fblob\u002Fmain\u002Faiter\u002Fmla.py)。\n\n## 引用\n\n```bibtex\n@misc{flashmla2025,\n      title={FlashMLA: 高效多头潜在注意力核函数},\n      author={Jiashi Li, Shengyu Liu},\n      year={2025},\n      publisher = {GitHub},\n      howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA}},\n}\n```","# FlashMLA 快速上手指南\n\nFlashMLA 是 DeepSeek 推出的高性能注意力机制内核库，专为 DeepSeek-V3 及 V3.2 系列模型优化。它支持稀疏（Sparse）和稠密（Dense）两种注意力模式，并在 NVIDIA H800\u002FB200 等最新硬件上实现了极致的推理性能。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下硬件和软件要求：\n\n*   **GPU 架构**：\n    *   NVIDIA SM90 (如 H800, H100)\n    *   NVIDIA SM100 (如 B200, Blackwell 系列)\n*   **CUDA 版本**：\n    *   基础要求：CUDA 12.8 及以上\n    *   SM100 专用：必须使用 CUDA 12.9 及以上\n*   **框架依赖**：\n    *   PyTorch 2.0 及以上\n*   **操作系统**：Linux (推荐 Ubuntu 20.04\u002F22.04)\n\n> **注意**：不同内核模式对显存格式有特定要求。例如，稀疏解码（Sparse Decoding）支持 FP8 KV Cache，而稠密解码通常使用 BF16。\n\n## 安装步骤\n\n通过源码安装是最推荐的方式，可确保获取最新优化特性。\n\n```bash\n# 1. 克隆仓库\ngit clone https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA.git flash-mla\ncd flash-mla\n\n# 2. 初始化子模块 (重要：包含底层优化代码)\ngit submodule update --init --recursive\n\n# 3. 执行安装\npip install -v .\n```\n\n> **国内加速建议**：如果克隆速度较慢，可使用 Gitee 镜像（如有）或配置 Git 代理。安装过程中若 pip 下载慢，建议添加国内源：\n> `pip install -v . -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`\n\n## 基本使用\n\nFlashMLA 提供了针对不同场景的 API，以下是两种最核心用法的极简示例。\n\n### 1. MLA 解码 (Decoding)\n\n适用于推理阶段的逐 token 生成。需先获取调度元数据，然后在循环中调用内核。\n\n```python\nfrom flash_mla import get_mla_metadata, flash_mla_with_kvcache\n\n# 第一步：在解码循环前获取元数据\n# s_q: 每个序列的 query token 数 (无推测解码时为 1)\n# h_kv: KV 头数，h_q: Query 头数\ntile_scheduler_metadata, num_splits = get_mla_metadata(\n    cache_seqlens,\n    s_q * h_q \u002F\u002F h_kv,\n    h_kv,\n    h_q,\n    is_fp8,       # 是否使用 FP8 KV Cache\n    topk,         # 稀疏模式的 topk 值\n)\n\n# 第二步：在每一层解码循环中调用\nfor i in range(num_layers):\n    # ... 准备 q_i, kvcache_i, block_table 等张量 ...\n    \n    o_i, lse_i = flash_mla_with_kvcache(\n        q_i, kvcache_i, block_table, cache_seqlens, dv,\n        tile_scheduler_metadata, num_splits,\n        is_causal,      # 是否因果掩码\n        is_fp8_kvcache, # KV Cache 是否为 FP8 格式\n        indices,        # 稀疏模式下的索引张量，稠密模式可为 None\n    )\n    # ... 后续处理 ...\n```\n\n**关于 FP8 KV Cache**：\n若 `is_fp8_kvcache=True`，内核会自动将 FP8 格式的 KV Cache 反量化为 BF16 进行计算。FP8 格式结构为：512 字节量化数据 + 16 字节缩放因子 + 128 字节未量化的 RoPE 数据。\n\n### 2. 稀疏 MLA 预填充 (Sparse Prefill)\n\n适用于处理长上下文输入时的稀疏注意力计算。此接口不支持 batch 维度，多 Batch 需自行 reshape。\n\n```python\nfrom flash_mla import flash_mla_sparse_fwd\n\n# 准备输入张量\n# q: [s_q, h_q, d_qk], bfloat16\n# kv: [s_kv, h_kv, d_qk], bfloat16\n# indices: [s_q, h_kv, topk], int32 (无效索引设为 -1)\n# sm_scale: 缩放标量\n\nout, max_logits, lse = flash_mla_sparse_fwd(\n    q,\n    kv,\n    indices,\n    sm_scale\n)\n```\n\n**参数说明**：\n*   `indices`：指定每个 query token 需要关注的 key token 索引。形状为 `(seq_len_q, h_kv, topk)`。\n*   **返回值**：返回 `(out, max_logits, lse)`，分别对应注意力输出、最大 logits 值和 log-sum-exp 值。\n\n> 更多详细测试用例请参考仓库中的 `tests\u002Ftest_flash_mla_decoding.py` 和 `tests\u002Ftest_flash_mla_prefill.py`。","某大型金融科技公司正在基于 DeepSeek-V3.2 架构部署实时智能风控系统，需处理海量交易流水并毫秒级生成风险报告。\n\n### 没有 FlashMLA 时\n- **推理延迟过高**：在长上下文（如整日交易记录）解码阶段，传统注意力机制计算缓慢，导致风险预警平均滞后 200 毫秒，无法满足高频交易拦截需求。\n- **显存资源浪费**：存储全量 KV Cache 占用巨大显存，迫使团队减少并发请求数或降低模型精度，限制了系统吞吐量。\n- **算力利用率不足**：在 NVIDIA H800 等高端显卡上，密集计算任务无法跑满硬件性能，TFLOPS 利用率低，造成昂贵的算力闲置。\n- **稀疏加速缺失**：缺乏针对预填充和解码阶段的令牌级稀疏优化，难以有效处理交易数据中大量无关的噪声信息。\n\n### 使用 FlashMLA 后\n- **解码速度飞跃**：利用 FlashMLA 的稀疏解码内核，配合 FP8 KV Cache，解码算力提升至 410 TFLOPS，将风险响应延迟压缩至 50 毫秒以内。\n- **显存效率倍增**：通过 FP8 格式压缩缓存，显著降低显存占用，使单卡并发处理能力翻倍，无需牺牲模型精度即可支撑更大流量。\n- **硬件性能榨干**：在计算密集型场景下，预填充阶段算力高达 640 TFLOPS，充分释放 H800\u002FB200 显卡潜能，大幅降低单次推理成本。\n- **动态稀疏适配**：原生支持令牌级稀疏注意力，自动聚焦关键交易特征，忽略冗余数据，在保证准确率的同时进一步提升处理效率。\n\nFlashMLA 通过极致的内核优化与稀疏算法，将高端显卡的理论算力转化为真实的业务低延迟与高吞吐能力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_FlashMLA_7ff28394.png","deepseek-ai","DeepSeek","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdeepseek-ai_04503588.png","",null,"service@deepseek.com","https:\u002F\u002Fwww.deepseek.com\u002F","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai",[85,89,93,97],{"name":86,"color":87,"percentage":88},"C++","#f34b7d",49,{"name":90,"color":91,"percentage":92},"Cuda","#3A4E3A",39,{"name":94,"color":95,"percentage":96},"Python","#3572A5",11.9,{"name":98,"color":99,"percentage":100},"C","#555555",0.1,12550,1005,"2026-04-03T09:42:24","MIT",4,"未说明","必需 NVIDIA GPU，架构需为 SM90 (如 H800 SXM5) 或 SM100 (如 B200)。CUDA 版本需 12.8 及以上（SM100 架构需 CUDA 12.9+）。",{"notes":109,"python":106,"dependencies":110},"该工具专为 DeepSeek-V3 系列模型优化。不同内核对 GPU 架构有特定要求：稀疏解码和预填充支持 SM90 和 SM100，密集解码仅支持 SM90，密集预填充仅支持 SM100。稀疏解码模式支持 FP8 KV Cache 以节省显存并提升速度。安装时需初始化 git submodule。另有针对 MetaX、摩尔线程、海光 DCU 等非 NVIDIA 硬件的社区移植版本。",[111,112],"torch>=2.0","cuda-python (隐含，需匹配 CUDA 12.8+)",[26,13],"2026-03-27T02:49:30.150509","2026-04-06T09:46:15.712008",[117,122,127,132,137,142,147],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},13343,"未来会支持昇腾（Ascend）910B 或其他非 NVIDIA 硬件吗？","目前官方没有计划直接支持昇腾硬件。由于代码已开源，社区或昇腾官方可以自行进行适配工作。有用户指出昇腾 910B 与 910A 架构差异较大，可能存在兼容性问题，建议关注社区贡献或直接联系昇腾团队推动适配。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F31",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},13344,"未来会支持 NVIDIA Blackwell (B200) 架构吗？","官方明确表示目前没有支持 Blackwell 架构的计划。对于需要在 B200 上运行的用户，建议在 vllm 等框架中使用 Cutlass MLA 实现作为替代方案。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F83",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},13345,"是否支持 FP8 精度推理？","官方正在开发 FP8 KV-Cache 的支持功能。虽然尚未完全发布，但维护者已确认该功能在计划中，用户可以关注后续更新以获取 FP8 推理能力。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F44",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},13346,"为什么稀疏 FlashMLA Prefill 内核只支持 batch_size=1？如何实现多批次处理？","该内核本身不支持大于 1 的 batch_size。但由于其稀疏特性，用户可以通过调整输入张量的形状（reshape）并修改 `indices` 参数来模拟多批次（batch_size > 1）的处理逻辑。具体方法可参考 README 文件中关于批处理的说明。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F105",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},13347,"代码中 `sum_lse != sum_lse` 这个看似永远为假的条件有什么作用？","这不是一个永假条件，而是利用 IEEE 754 浮点数标准中 NaN（非数字）的特性：NaN 不等于任何值，包括它自己。因此 `sum_lse != sum_lse` 等价于 `std::isnan(sum_lse)`，用于检测并屏蔽计算过程中产生的 NaN 值。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F64",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},13348,"有没有 DeepSeek V3 的训练反向传播（Backward）代码开源？","目前仓库主要专注于推理优化。对于训练需求，社区已有其他开源项目提供了 DeepSeek V3 的训练配置和实现，例如 FlagOpen 的 FlagScale 项目或阿里巴巴的 Pai-Megatron-Patch 项目，用户可以参考这些仓库获取训练相关的代码和配置文件。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F5",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},13349,"运行 backward 时遇到报错 'Trying to create tensor with negative dimension' 或分配极大 workspace 怎么办？","这是一个已知问题，源于 cutlass 代码库中计算 backward buffer 时的数值溢出 bug。维护者已经提交了 PR (#91) 修复此问题，该修复也将合并到上游 cutlass 项目中。如果遇到此错误，请拉取包含该修复的最新代码或等待 cutlass 更新。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FFlashMLA\u002Fissues\u002F90",[]]