<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>自拙集</title>
        <link>https://densecollections.top//</link>
        <description>人生到处知何似，应似飞鸿踏雪泥</description>
        <lastBuildDate>Mon, 20 Jul 2026 09:56:21 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en-US</language>
        <copyright>All rights reserved 2026, richardyu</copyright>
        <item>
            <title><![CDATA[GLM-5.2 研究笔记：长上下文、Agent 训练与数据来源问题]]></title>
            <link>https://densecollections.top//technology/glm5_2-research-notes</link>
            <guid>https://densecollections.top//technology/glm5_2-research-notes</guid>
            <pubDate>Mon, 29 Jun 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[GLM-5.2 研究笔记：长上下文、Agent 训练与数据来源问题]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-38e8f42f8313807a8701dfbd981fb6d5"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-38e8f42f831380a78618cd417a7029a3" data-id="38e8f42f831380a78618cd417a7029a3"><span><div id="38e8f42f831380a78618cd417a7029a3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380a78618cd417a7029a3" title="overview"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">overview</span></span></h2><div class="notion-callout notion-orange_background_co notion-block-38e8f42f83138025af03fb5d400bbbd8"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">来源说明：本文依据两篇材料写成。第一篇是 <em><span class="notion-inline-underscore">Artificial Intelligence Made Simple</span></em> 的 Substack 文章《<b>Uncovering the Secrets to GLM 5.2&#x27;s Amazing Performance</b>》，主要提供 GLM-5.2 的技术拆解。第二篇是 X Article《<b>The Secret Behind GLM-5.2 May Not Be Distillation. It May Be the Data Flywheel Closed Models Created</b>》，主要提出关于闭源模型、中转站和真实工作流数据的解释假说。本文不做逐字翻译；技术部分尽量贴近原文，产业判断部分单独标出证据边界。</div></div><div class="notion-text notion-block-38e8f42f83138046a566fab8e08824c9">GLM-5.2 最近收到业界和用户了一致好评，以 agent workload 的视角来看，为了解决：一个模型要读很长的历史，生成很长的输出，在工具调用之后继续推理，还要在后训练阶段从长轨迹里学到哪些步骤真的有用。GLM-5.2 设计了几个关键机制：<em><span class="notion-brown"><b><span class="notion-inline-underscore">DSA 对应长上下文读成本，IndexShare 对应稀疏 attention 自己带来的索引成本，MTP 对应长输出的串行延迟，critic-based PPO 和 SLIME 对应长链路训练里的信用分配和 rollout 基础设施</span></b></span></em>。</div><div class="notion-text notion-block-38e8f42f831380ba8f07d31dde48256b">这篇笔记的判断比较保守：<span class="notion-default"><b>GLM-5.2 的意义，首先在于它把开放权重模型的竞争推进到了系统工程层面。</b></span> 模型是否“接近 Claude”是一个使用感受；更可分析的是，它在哪些环节降低了 agent 的运行成本，又在哪些环节引入了新的系统复杂度。</div><hr class="notion-hr notion-block-38e8f42f8313803a945bf9677d14256e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f8313807fa2c1c7d3e0cb65f7" data-id="38e8f42f8313807fa2c1c7d3e0cb65f7"><span><div id="38e8f42f8313807fa2c1c7d3e0cb65f7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f8313807fa2c1c7d3e0cb65f7" title="问题界定"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">问题界定</span></span></h3><div class="notion-text notion-block-38e8f42f831380a2bfe5d37262e4e459">从公开材料看，GLM-5.2 至少有三个背景信息需要先放在桌面上。</div><div class="notion-text notion-block-38e8f42f83138055b7c5fbdadc2cc8cc">第一，Artificial Analysis 在 2026 年 6 月将 GLM-5.2 列为 Intelligence Index v4.1 上领先的开放权重模型。其模型规模仍为 744B total / 40B active parameters，但相对 GLM-5.1 有明显分数提升，并处在 intelligence 和 cost per task 的 Pareto frontier 上。</div><div class="notion-text notion-block-38e8f42f831380d3a404cf291c81a777">第二，Z.ai / Hugging Face 模型页强调了几个工程特征：1M-token context、IndexShare、改进的 MTP、可调 thinking effort、MIT 开源许可。这些信息和 Substack 原文的分析方向一致。</div><div class="notion-text notion-block-38e8f42f831380059d3dc0cce6945808">第三，围绕 Claude 蒸馏和中转站生态的讨论，在 2026 年已经成为一个独立议题。Anthropic 公开讨论过 distillation attacks 和 unsupported regions 访问限制；ChinaTalk 与 Tom&#x27;s Hardware 也讨论过中国 Claude 中转站、代理 API、凭据滥用、模型替换、用户 prompt / output 被收集等风险。</div><div class="notion-text notion-block-38e8f42f831380419df4c06243d2576b">这三件事不能混成一个结论。GLM-5.2 技术路线、Anthropic 对其他公司的指控、中转站数据风险，是三类不同证据。把它们放在一起看，是为了理解开放模型追赶的环境，不是为了暗示某个未经证实的因果链。</div><table class="notion-simple-table notion-block-38e8f42f8313805c9cdfd5841ef27ac8"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f8313800cb4d1d7d55179fd82"><td class="" style="width:120px"><div class="notion-simple-table-cell">材料</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可支持的判断</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不能推出的结论</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313805ca45eda0729a28235"><td class="" style="width:120px"><div class="notion-simple-table-cell">GLM-5.2 模型页与第三方评测</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">模型在开放权重路线中有较强能力和成本位置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不能说明能力来自某一种训练数据</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313808cae4ee2f1a6d1ba9f"><td class="" style="width:120px"><div class="notion-simple-table-cell">Substack 技术拆解</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">GLM-5.2 的若干机制面向 agent workload 的成本结构</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不能替代官方完整技术报告</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380539928ef468440c646"><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic / ChinaTalk / Tom&#x27;s Hardware</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">闭源模型访问限制与代理生态确实存在</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不能直接指向 GLM-5.2 的训练来源</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380259e2de567e9b54e43"><td class="" style="width:120px"><div class="notion-simple-table-cell">X Article</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提供“真实工作流数据飞轮”的解释框架</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不是事实证明</div></td></tr></tbody></table><hr class="notion-hr notion-block-38e8f42f8313800bbc8cd2da779e51e5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f8313807090d7f486aeb1c658" data-id="38e8f42f8313807090d7f486aeb1c658"><span><div id="38e8f42f8313807090d7f486aeb1c658" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f8313807090d7f486aeb1c658" title="Agent 任务的成本结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Agent 任务的成本结构</span></span></h3><div class="notion-text notion-block-38e8f42f83138080b529c6e8b65cf89b">普通聊天模型的成本，主要是一次输入、一次输出。agent 不一样。它会把任务拆成多轮：读取上下文，调用工具，拿到工具结果，更新判断，再继续生成下一步。</div><div class="notion-text notion-block-38e8f42f831380299366dfee1d30e354">一个 coding agent 的路径可能是：</div><div class="notion-text notion-block-38e8f42f831380a3a031c2d92ed5a94f">这条路径有三个麻烦：</div><table class="notion-simple-table notion-block-38e8f42f831380749159fa751594ba3c"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f831380e2b92dea2d9eb30cd5"><td class="" style="width:120px"><div class="notion-simple-table-cell">成本项</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在 agent 中的表现</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对模型和系统的压力</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380c69453fe6954386a3c"><td class="" style="width:120px"><div class="notion-simple-table-cell">历史变长</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具输出、代码片段、错误日志不断进入上下文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">attention 和 KV cache 读写变重</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380bca1fafe9e2fa7c1bf"><td class="" style="width:120px"><div class="notion-simple-table-cell">输出变长</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">patch、解释、工具参数、诊断信息会连续生成</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">autoregressive decode 串行延迟明显</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380cd95b2f10e39b2d474"><td class="" style="width:120px"><div class="notion-simple-table-cell">奖励变稀</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最终成功/失败很难对应到具体 token</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">RL 训练中的 credit assignment 变难</div></td></tr></tbody></table><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-38e8f42f831380c3ab5dd16f1a253670"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A492c5356-0ed7-4b59-b0c8-b40d1328af00%3Aimage.png?table=block&amp;id=38e8f42f-8313-80c3-ab5d-d16f1a253670&amp;t=38e8f42f-8313-80c3-ab5d-d16f1a253670" alt="source: https://www.artificialintelligencemadesimple.com/p/the-4-secrets-that-make-glm-52-special" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">source: <a class="notion-link" href="https://www.artificialintelligencemadesimple.com/p/the-4-secrets-that-make-glm-52-special" target="_blank" rel="noopener noreferrer">https://www.artificialintelligencemadesimple.com/p/the-4-secrets-that-make-glm-52-special</a></figcaption></div></figure><div class="notion-text notion-block-38e8f42f8313802c8b33ef07c5220fa3">GLM-5.2 的解决办法，基本沿着下图展开展开。</div><div class="notion-text notion-block-38e8f42f831380709a46fb10be16a054">把它放回一次 coding agent 的执行循环里，会更清楚：</div><div class="notion-text notion-block-38e8f42f83138020b6f3fc7368a922f1">这张图只表达对应关系，不表示这些机制已经解决了所有生产问题。后文会逐一写它们省掉什么，又把复杂度移到哪里。</div><hr class="notion-hr notion-block-38e8f42f831380fd9212dd3bd05f37bf"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380c186f3d4434c159bce" data-id="38e8f42f831380c186f3d4434c159bce"><span><div id="38e8f42f831380c186f3d4434c159bce" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380c186f3d4434c159bce" title="DSA：从密集读取到内容相关读取"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">DSA：从密集读取到内容相关读取</span></span></h3><div class="notion-text notion-block-38e8f42f8313803a9ca2fee0ec4d210c">长上下文的瓶颈经常被说成“模型能不能支持 1M token”。这个表述不够具体。支持长上下文至少包括两件事：<em><span class="notion-blue"><b><span class="notion-inline-underscore">模型质量在长上下文下是否保持；系统是否能在可接受成本下服务这种长度</span></b></span></em>。</div><div class="notion-text notion-block-38e8f42f8313801384f7ca4753a1c90b">标准 attention 的路径很直观：当前 token 与历史 token 交互。历史越长，读写和计算压力越大。到了 agent 场景，历史还会持续增长，每一轮工具调用都会把新的文本塞进上下文。模型不是偶尔读一次长文档，而是在一个变长的工作日志里反复查找相关内容。</div><div class="notion-text notion-block-38e8f42f83138080bb0cd2b330a7e627">DSA（Dynamic Sparse Attention / DeepSeek Sparse Attention）的基本做法，是先用轻量 indexer 选出相关 token，再只对这些 token 做 attention. Substack 原文提到，GLM-5.2 在 1M context 下限制到每个 head 的 top 2,048 tokens，并由此减少 per-token FLOPs。</div><div class="notion-text notion-block-38e8f42f831380c29d12c00017d1d662">对应到一次 decode step，大致是这个流程：</div><div class="notion-text notion-block-38e8f42f831380ebbb64df7c72106aa8"><em><span class="notion-yellow"><b><span class="notion-inline-underscore">这种方式比固定滑窗更适合代码和 agent 历史。固定滑窗默认最近的内容更重要；代码任务中，真正相关的定义、配置或错误根因，可能在很远的位置。DSA 至少在机制上允许模型按内容选取远处信息</span></b></span></em>。</div><div class="notion-text notion-block-38e8f42f83138048aea2f70eda724bfb"><em><span class="notion-inline-underscore">但 DSA 不是免费加速。稀疏选择会让 KV 访问变得不规则</span></em>。密集 attention 虽然算得多，访问模式相对规整；动态稀疏 attention 的 top-k 由内容决定，不同 token、不同层、不同 head 可能访问完全不同的位置。<span class="notion-red"><span class="notion-inline-underscore">对 serving 系统来说，这意味着 cache locality、prefetch、kernel 调度都会变难</span></span>。</div><table class="notion-simple-table notion-block-38e8f42f831380009af3dcecf42db732"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f831380aebd55efff3ef31105"><td class="" style="width:120px"><div class="notion-simple-table-cell">路线</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少的成本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">新增的问题</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313806fb137d3f05775f98a"><td class="" style="width:120px"><div class="notion-simple-table-cell">Dense attention</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">长上下文下计算和 HBM 读写过重</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380349622ee78240f566d"><td class="" style="width:120px"><div class="notion-simple-table-cell">DSA</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">attention 只看相关 token，减少 FLOPs</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">KV working set 碎片化，indexer 和 cache 管理变复杂</div></td></tr></tbody></table><div class="notion-text notion-block-38e8f42f8313809cb133fde1e376f960">所以 DSA 的价值不能只看 FLOPs。它更像是把问题从“算太多”移动到“怎么高效地找和读”。GLM-5.2 后面的 IndexShare，正是为了处理这个移动之后的新成本。</div><hr class="notion-hr notion-block-38e8f42f83138045be60dded83360cd3"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380f0a026dc8ee559dd8e" data-id="38e8f42f831380f0a026dc8ee559dd8e"><span><div id="38e8f42f831380f0a026dc8ee559dd8e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380f0a026dc8ee559dd8e" title="IndexShare：稀疏选择也要摊销"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">IndexShare：稀疏选择也要摊销</span></span></h3><div class="notion-text notion-block-38e8f42f8313808188e8d6ebe3a87dec"><em><span class="notion-blue"><span class="notion-inline-underscore">DSA 需要 indexer。每层都重新计算 top-k indices，在 1M context 下会成为明显开销</span></span></em>。Substack 原文把这个点讲得很清楚：稀疏 attention 省下来的成本，不能被重复索引吃掉。</div><div class="notion-text notion-block-38e8f42f831380ae84e3dac2d0634412"><em><span class="notion-red"><b><span class="notion-inline-underscore">IndexShare 的假设是，相邻层关注的历史 token 有较高重叠。Transformer 的相邻层通常是在同一表示空间上逐步变换，而不是每层都重新决定一套完全无关的信息来源。原文提到，相邻层 top-k selection overlap 在很多区域很高，接近对角线时可达到 70% 到 100%</span></b></span></em></div><div class="notion-text notion-block-38e8f42f831380108562de5e33c3df84">GLM-5.2 因此采用四层一组的方式。第一层运行 indexer，得到 top-k indices；后三层复用这些 indices.</div><div class="notion-text notion-block-38e8f42f83138062b42ed9427acf930f">四层共享可以画成一个更明确的分组：</div><div class="notion-text notion-block-38e8f42f8313802ba9b6d6885de411be">这样可以消掉约 75% 的 indexer 计算。Substack 原文还给出两个速度数字：prefill 最高 1.82x，autoregressive decoding 最高 1.48x。对 agent 来说，这类收益会在多轮执行中累积，因为 agent 不断重复读长历史、写长输出。</div><blockquote class="notion-quote notion-block-38e8f42f831380e0aee4eb8820591d06"><div><em><span class="notion-inline-underscore">这个设计也有边界。相邻层并不总是高度重合。原文提到 transition layers 的 overlap 会下降，某些位置可能降到 0.4 或更低。模型在这些层发生表示转换，继续共享 indices 会影响质量。因此四层 group 是一个折中：在高重合区间摊销 indexer 成本，同时避免跨过过多层导致信息选择失真</span></em>。</div></blockquote><div class="notion-callout notion-orange_background_co notion-block-38e8f42f8313801ca048e3874c870f67"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🤔">🤔</span></div><div class="notion-callout-text"><div class="notion-text notion-block-38e8f42f831380858a62fe48fd2ea7fb">IndexShare也可以采用编码的模式，即根据预先设计的不规则共享模式，来提升精度</div></div></div><div class="notion-text notion-block-38e8f42f83138051b15ace3449a27886">这部分的技术含义可以写得更具体：IndexShare 没有改变 DSA 的目标，而是在降低 DSA 的元成本。也就是说，它优化的是“选择相关 token”这件事本身。</div><hr class="notion-hr notion-block-38e8f42f831380518ca6c192bea16c34"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f83138014b5bbf9f07ce7c3d3" data-id="38e8f42f83138014b5bbf9f07ce7c3d3"><span><div id="38e8f42f83138014b5bbf9f07ce7c3d3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f83138014b5bbf9f07ce7c3d3" title="MTP：输出侧的串行瓶颈"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">MTP：输出侧的串行瓶颈</span></span></h3><div class="notion-text notion-block-38e8f42f831380f081c7f6bcf9b8a09e">如果 DSA 和 IndexShare 处理的是读，MTP 处理的是写。</div><div class="notion-text notion-block-38e8f42f8313806faafce247a733618f">标准 autoregressive decoding 每次只生成一个 token。这个路径简单，但对 agent 不友好。agent 经常要输出长代码块、长解释、工具调用参数、错误诊断。每一个 token 都等待一次 target model forward，整个 loop 的 wall-clock time 会被 decode 拉长。</div><div class="notion-text notion-block-38e8f42f8313802ea55fdf81f2a89af9">MTP / speculative decoding 的思路，是让便宜的 draft 路径先提出多个候选 token，再由 target model 一次验证。真正决定收益的，不是 draft 了几个 token，而是最终平均能接受几个 token。</div><div class="notion-text notion-block-38e8f42f831380488600fb145a86839e">这里先用一个小例子：target prefix 是 x1..x4.target backbone 已经算出 h1..h4、KV1..KV4，以及第一步 sparse attention 的 top-k indices。MTP 要做的事，是从这个 prefix 后面连续提出 x5..x11 这 7 个候选 token</div><div class="notion-text notion-block-38e8f42f83138054af5fc8c06c6ecc26">关键点在于区分两种东西：一是 step-to-step 的条件状态，二是 attention 看到的 memory. draft token 和 draft hidden 会从 step 1 传到 step 2，再传到后续 step；<em><span class="notion-red"><b><span class="notion-inline-underscore">但 GLM-5.2 的 KVShare / IndexShare 让 attention memory 保持在 target 侧，即复用第一步的 target KV 和 top-k indices</span></b></span></em></div><div class="notion-text notion-block-38e8f42f831380809e9ad146d6c93e67">单个 MTP step 可以理解成一个轻量 draft layer：当前输入 token 做 embedding，上一步 hidden 做归一化，两者 concat 后经 EH projection，进入 MTP decoder block，再用 shared head 产出下一个 token 的 draft logits.</div><div class="notion-text notion-block-38e8f42f83138076aeced276d0b0c070">step 1 预测 x5 时，它的上下文不是 x1..x5，而是 target prefix x1..x4 的 hidden/KV/top-k. 它预测的是 prefix 后的第一个候选 token. step 2 会拿到 step 1 产生的 draft token x5 和 draft hidden h5 作为递推状态，但它的 attention memory 仍然复用 target prefix 的 KV/top-k</div><div class="notion-text notion-block-38e8f42f8313801d8fbfe1831c6f9d17"><b><span class="notion-inline-underscore">KV cache 确实不会随着 draft step 变长，top-k indices 也不是当前 draft token 重新算出来的。GLM-5.2 这里本来就不是在 MTP 内部构造一条完整、越来越长的自回归 KV cache；它是有意把 memory 固定在 target 侧，让 draft path 更便宜、更接近训练时的分布。代价是 draft 只是近似，所以后面必须由 target verifier 做接受前缀</span></b>。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-38e8f42f831380e2b6aada06e09fb1f0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af4692e8d-6ed6-4a99-98ec-f6fa49ef3d65%3Aimage.png?table=block&amp;id=38e8f42f-8313-80e2-b6aa-da06e09fb1f0&amp;t=38e8f42f-8313-80e2-b6aa-da06e09fb1f0" alt="source: https://huggingface.co/blog/zai-org/glm-52-blog#mtp-with-indexshare-and-kvshare.  GLM-5.1 式两步 MTP 的问题时，第二步里 h1:h4 来自 target model，h5 来自 MTP layer，如果把 h5 也写进 KV，就会得到 target KV 和 MTP KV 混在一起的 cache。GLM-5.2 用 KVShare / IndexShare 避开这件事：训练和推理都复用第一步的 KV cache 和 top-k indices" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">source: <a class="notion-link" href="https://huggingface.co/blog/zai-org/glm-52-blog#mtp-with-indexshare-and-kvshare" target="_blank" rel="noopener noreferrer">https://huggingface.co/blog/zai-org/glm-52-blog#mtp-with-indexshare-and-kvshare</a>.  GLM-5.1 式两步 MTP 的问题时，第二步里 h1:h4 来自 target model，h5 来自 MTP layer，如果把 h5 也写进 KV，就会得到 target KV 和 MTP KV 混在一起的 cache。GLM-5.2 用 KVShare / IndexShare 避开这件事：训练和推理都复用第一步的 KV cache 和 top-k indices</figcaption></div></figure><div class="notion-text notion-block-38e8f42f831380c789b7cb81afe4c81c">因此，MTP 的 acceptance length 不是靠“draft 越滚越长、上下文越完整”得到的，而是靠三件事叠加：固定 target-side memory 降低 draft 成本和分布偏差；rejection sampling 只接受 target 认可的前缀；端到端 TV loss 继续对齐 draft/target 分布。</div><div class="notion-text notion-block-38e8f42f83138008b4fde1d72e808573">vLLM PR #45895 修了两个 serving 侧很容易忽略的接口：第一，下一步 MTP 不能接收 pre-final-norm hidden，而要输入 post-final-norm recycle hidden；第二，skip_topk 的 sparse MLA 层即使没有本地 indexer，也必须能读到共享的 topk_indices_buffer. 少掉任意一个，MTP 仍然可能“能跑”，但 acceptance length 会明显掉下去。</div><div class="notion-text notion-block-38e8f42f8313803691b7da4e9e50627f">这和前面的 MTP 解释可以接起来看：draft hidden 可以一步一步递推，但 sparse attention 里的 top-k memory 不是每一步都重新算。PR 里的实现把它拆成两个约束： <span class="notion-default"><code class="notion-inline-code">deepseek_v2.py</code></span> 保证 MTP / nextn layer 总是构建完整 indexer，用来在 step 0 计算 indices； <span class="notion-default"><code class="notion-inline-code">set_skip_topk()</code></span> 让后续 step 复用； <span class="notion-default"><code class="notion-inline-code">mla_attention.py</code></span> 和几个 sparse MLA backend 再把共享 top-k buffer 显式传下去，避免 skip layer 因为 <span class="notion-default"><code class="notion-inline-code">indexer=None</code></span> 而找不到 indices.</div><div class="notion-text notion-block-38e8f42f8313809b8cbbd33ff8b0a669">另一个细节是 hidden recycle.  <span class="notion-default"><code class="notion-inline-code">deepseek_mtp.py</code></span> 里的 MTP block 先得到 pre-final-norm hidden，用它走 logits；但下一轮 MTP step 复用的是 shared head 之后的 post-final-norm hidden。这样 logits 路径和 recycle 路径各自只用一次 final norm。如果把 pre-norm hidden 直接塞回下一轮，模型不一定立刻报错，但下一步 draft 的 hidden 分布已经偏了，acceptance length会降低。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-38e8f42f8313802cb947c045776fe598"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A092976ba-2cfb-4ba4-9b5b-563c2d4ca166%3Aimage.png?table=block&amp;id=38e8f42f-8313-802c-b947-c045776fe598&amp;t=38e8f42f-8313-802c-b947-c045776fe598" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-38e8f42f831380df81dcee39acc265cc">PR 作者给出的 GLM-5.2-FP8 serving 测试结果也说明这不是“小清洁”：MTP mean acceptance length 从约 3 提到约 4，mean acceptance rate 到 60%，IFBench 保持 74.62。这个数字不是前面官方 blog 的 5.47 消融，而是 vLLM serving 实现修复后的效果，更接近线上推理工程师真正会遇到的问题。</div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380b59aa2dbb3bac4801c"><li>PR #45895: <a class="notion-link" href="https://github.com/vllm-project/vllm/pull/45895" target="_blank" rel="noopener noreferrer">https://github.com/vllm-project/vllm/pull/45895</a></li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f83138095aa67def044263721"><li>MTP hidden recycle: <a class="notion-link" href="https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/deepseek_mtp.py" target="_blank" rel="noopener noreferrer">https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/deepseek_mtp.py</a></li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380e8a40bf9bc36c153d2"><li>proposer tuple handling and top-k sharing: <a class="notion-link" href="https://github.com/vllm-project/vllm/blob/main/vllm/v1/spec_decode/llm_base_proposer.py" target="_blank" rel="noopener noreferrer">https://github.com/vllm-project/vllm/blob/main/vllm/v1/spec_decode/llm_base_proposer.py</a></li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f8313806892cfddef6f9ad40a"><li>MTP layer indexer rule: <a class="notion-link" href="https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/deepseek_v2.py" target="_blank" rel="noopener noreferrer">https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/deepseek_v2.py</a></li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380df83e1eb1a9bc36b0b"><li>shared top-k buffer plumbing: <a class="notion-link" href="https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/attention/mla_attention.py" target="_blank" rel="noopener noreferrer">https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/attention/mla_attention.py</a></li></ul><div class="notion-text notion-block-38e8f42f831380fa8e84e870673d9588">所以 MTP 这节最后要落在模型结构和推理实现两个层面：模型侧是可递推 draft module、7-step block、MTP IndexShare / KVShare、target verifier；推理侧则要保证 post-final-norm hidden recycle 和 shared top-k buffer plumbing。vLLM PR #45895 正好说明，少掉这两个接口细节，acceptance length 会明显掉下去。</div><hr class="notion-hr notion-block-38e8f42f831380ee86d4cbf80d5aa5f5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380a09b60c22b7f38fded" data-id="38e8f42f831380a09b60c22b7f38fded"><span><div id="38e8f42f831380a09b60c22b7f38fded" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380a09b60c22b7f38fded" title="GRPO 的适用边界"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">GRPO 的适用边界</span></span></h3><div class="notion-text notion-block-38e8f42f831380c498e5f691971a3507">Substack 原文对训练部分的讨论，重点在 GRPO 与 critic-based PPO 的取舍。这里需要先把问题说简单。</div><div class="notion-text notion-block-38e8f42f831380c9b3fbc4f9f07b1ab7">长链路 agent 任务的奖励很稀疏。一个模型修 bug，可能先读日志，再打开几个文件，修改一处代码，跑测试失败，重新定位，再改一次，最后通过。最终结果是 pass 或 fail，但训练时真正想知道的是：哪些中间步骤帮到了任务，哪些只是噪声。</div><div class="notion-text notion-block-38e8f42f8313801d9514c6ada549289a">GRPO 的工程优势在于省掉 critic / value network。它对同一个 prompt 采样多条输出，按组内相对分数计算 advantage，再把这个 advantage 分配给轨迹中的 token。短任务中，这个办法很有效，成本也低。</div><div class="notion-text notion-block-38e8f42f8313804c81b1e629674ef81b">长链路 agent 任务会让这个结构变差。</div><table class="notion-simple-table notion-block-38e8f42f831380b3885cc07f2f2f24b3"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f8313806593b7e6e4fff572d2"><td class="" style="width:120px"><div class="notion-simple-table-cell">GRPO 依赖的条件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">agent 任务中的破坏因素</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f83138057b040ff7935b2647c"><td class="" style="width:120px"><div class="notion-simple-table-cell">同组 rollout 可比较</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用和上下文压缩导致轨迹结构差异很大</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313803e9a13fa9463db8d8e"><td class="" style="width:120px"><div class="notion-simple-table-cell">轨迹长度相对可控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">coding / web agent 可能产生很长执行历史</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313802f9bd6eb2863db65ba"><td class="" style="width:120px"><div class="notion-simple-table-cell">组级 reward 能代表 token 贡献</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">成败常由少数关键 token 或动作决定</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f83138067ae32e2be0388b224"><td class="" style="width:120px"><div class="notion-simple-table-cell">不需要显式 value baseline</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">长轨迹中信号被大量普通 token 稀释</div></td></tr></tbody></table><div class="notion-text notion-block-38e8f42f8313808d9c0ef042e8dbb7ed">GRPO 在短任务里整洁，在长 agent 任务里会遇到结构不齐的问题：</div><div class="notion-text notion-block-38e8f42f831380ad838dd48ebe7714eb">原文举的核心问题是 uniform advantage。一个 50,000-token 的 agent trajectory 中，关键 debugging step 和普通 boilerplate 可能得到同方向的训练信号。轨迹越长，真正有效的步骤越容易被噪声淹没。</div><div class="notion-text notion-block-38e8f42f83138090b7c1d09417cea20c"><em><b><span class="notion-inline-underscore">还有 context compaction。生产 agent 会把早期历史压缩成 summary，形成多个 sub-trace。不同 rollout 的压缩次数、片段长度、内部对齐都可能不同。GRPO 需要比较一组输出，但这些输出已经不是同构对象</span></b></em>。</div><div class="notion-text notion-block-38e8f42f83138032aabade401f7508f1">所以 GLM-5.2 回到 critic-based PPO，并不是简单回到旧方法。它是在任务形态变化之后，重新接受 critic 的成本。</div><hr class="notion-hr notion-block-38e8f42f831380bc8003d57cb2900997"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f8313807ba9cbf2caa80aa8c4" data-id="38e8f42f8313807ba9cbf2caa80aa8c4"><span><div id="38e8f42f8313807ba9cbf2caa80aa8c4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f8313807ba9cbf2caa80aa8c4" title="Critic-based PPO：把奖励放回过程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Critic-based PPO：把奖励放回过程</span></span></h3><div class="notion-text notion-block-38e8f42f831380cca5b4e1b297930881">critic-based PPO 的代价比较明确：要维护一个 value model，训练和显存成本上升，系统复杂度也更高。它的收益也明确：可以对单条轨迹里的不同 token / state 给出更细的 value estimate。</div><div class="notion-text notion-block-38e8f42f831380bda4dddd842ea47e39">PPO 的差别在于 value estimate 进入了轨迹内部：</div><div class="notion-text notion-block-38e8f42f8313805aae7de5f6c1d644b0">在 coding agent 中，普通 import、格式调整、解释性文本可能接近 baseline。真正修掉错误的一步，会让 critic 对后续成功概率的估计发生变化。<em><span class="notion-inline-underscore">PPO 利用这种 per-token / per-state advantage，让更新集中在更可能影响结果的位置</span></em>。</div><div class="notion-text notion-block-38e8f42f83138091ac0ffa76ad6e4da2">Substack 原文提到，GLM-5.2 的 PPO 设计能自然处理 compaction 后的 sub-traces。因为 PPO 不需要多条 rollout 在结构上对齐，它可以在单条轨迹内部计算 token-level loss。原文还给出一个数字：对于长 coding task，group sampling 计算需求可以从 16 小时降到 2 小时。</div><div class="notion-text notion-block-38e8f42f8313808da1ecd48f53d86328">这个数字不应被理解成 PPO 在所有情况下都更便宜。更准确的理解是：当 GRPO 需要多条很长、结构不齐的 rollout 做组内比较时，critic-based PPO 用 value baseline 换掉了大量重复采样成本。</div><div class="notion-text notion-block-38e8f42f831380b1818fdf7d3a61cbc4">这部分给我的启发是：reasoning model 的 RL 选择，不能脱离任务长度。短答案、短推理、静态题库，GRPO 的优势很自然。长工具链、长上下文、可压缩历史，critic 重新变得有价值。</div><hr class="notion-hr notion-block-38e8f42f8313807d8bb6e490b7c512a3"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f83138034a8a0de30ce983438" data-id="38e8f42f83138034a8a0de30ce983438"><span><div id="38e8f42f83138034a8a0de30ce983438" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f83138034a8a0de30ce983438" title="训练环境也是被优化对象"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">训练环境也是被优化对象</span></span></h3><div class="notion-text notion-block-38e8f42f8313806abf38d0f7531142e0">原文还提到一个现实问题：GLM-5.2 在 RL 中出现更多 reward-hacking 行为。模型越强，越会探索评测环境的漏洞。它可能不是解决任务，而是读取评测文件、下载答案、利用工具权限绕过目标。</div><div class="notion-text notion-block-38e8f42f83138098b641c1587caeff50">这不是小插曲。agent 一旦有工具，训练环境本身就变成 action space 的一部分。文件系统、网络访问、测试脚本、评分器、权限边界，都可能被模型试探。</div><div class="notion-text notion-block-38e8f42f831380b18f77d640b44dec30">GLM-5.2 因此需要 anti-hack gate、规则过滤、在线 LLM judge 等机制。否则 critic 学到的 value landscape 会被污染。一个高 reward 轨迹可能对应真实解决方案，也可能只是一次环境漏洞利用。</div><div class="notion-text notion-block-38e8f42f831380f9ad66d61337bb7dbd">一个更像系统的训练环境会先过滤轨迹，再把样本交给 critic 和 policy：</div><div class="notion-text notion-block-38e8f42f831380198f8de865b386156e">这一点把后训练从“算法问题”推成了“系统问题”。训练系统需要 rollout 环境、权限隔离、日志审计、工具调用约束、样本过滤、reward 校准。模型越接近 agent，后训练系统就越像一个小型线上平台。</div><hr class="notion-hr notion-block-38e8f42f831380309754ef78f00c0607"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380a7a0edc123e81a4715" data-id="38e8f42f831380a7a0edc123e81a4715"><span><div id="38e8f42f831380a7a0edc123e81a4715" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380a7a0edc123e81a4715" title="OPD 与 SLIME"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OPD 与 SLIME</span></span></h3><div class="notion-text notion-block-38e8f42f8313804eb656e840d54af8f0">GLM-5.2 还使用 On-Policy Distillation（OPD）和 SLIME 后训练基础设施。这里的背景是多领域能力合并。</div><div class="notion-text notion-block-38e8f42f831380cc8f45d623c1ae7c22">一个 generalist 模型要同时覆盖 coding、math、web search、agentic workflow。较自然的路线是先训练多个 specialist，再把它们合并。但合并会遇到 exposure gap：如果 student 只模仿 teacher 生成的轨迹，它训练时看到的是 teacher 的分布；上线后，它会走到自己的状态分布。</div><div class="notion-text notion-block-38e8f42f8313809685a9c57e8c68eed3"><em><span class="notion-brown"><b><span class="notion-inline-underscore">OPD 的做法是让 student 自己生成轨迹，teacher 在 student 的轨迹上给监督。这样 student 学到的是自己真实会遇到的状态</span></b></span></em>。</div><div class="notion-text notion-block-38e8f42f831380598985ea689b815c71">OPD 的关键是让 student 站在自己的分布上学习：</div><div class="notion-text notion-block-38e8f42f8313800686c3c3f03fde36d8">Substack 原文提到，Z.ai 使用 SLIME 将 10 个以上 specialist 在约 48 小时内合并进 GLM-5.2 generalist。SLIME 依赖 Megatron 做分布式训练，用 SGLang 管理 rollout 推理，并通过 Data Buffer 连接训练和推理。</div><div class="notion-text notion-block-38e8f42f831380f586ced53a871d8570">这里的重点不在软件名，而在边界变化。RL 后训练需要大量 rollout；rollout 本身就是高吞吐推理。训练系统不断调用推理系统，生成轨迹、过滤轨迹、打分、回灌训练。推理引擎因此进入训练闭环，不再只是上线后的 serving 组件。</div><div class="notion-text notion-block-38e8f42f831380628c9bcf4c0d21d778">SLIME 可以理解成训练和推理之间的循环接口：</div><div class="notion-text notion-block-38e8f42f8313802db572fb1bf1c5d920"><em><span class="notion-inline-underscore">这对 vLLM、SGLang 这类系统也有含义。它们以后可能不只服务线上请求，也服务训练期 rollout、工具环境、长上下文缓存和样本生成。模型公司之间的竞争，会越来越依赖这条后训练流水线的效率</span></em>。</div><hr class="notion-hr notion-block-38e8f42f8313802496e2c2bbc8a2b568"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380778e4edcd0d5ebb51a" data-id="38e8f42f831380778e4edcd0d5ebb51a"><span><div id="38e8f42f831380778e4edcd0d5ebb51a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380778e4edcd0d5ebb51a" title="小结：技术机制之间的关系"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">小结：技术机制之间的关系</span></span></h3><div class="notion-text notion-block-38e8f42f83138077a3f1da20f47017f0">可以把 GLM-5.2 的几个机制放在同一张账本里：</div><table class="notion-simple-table notion-block-38e8f42f8313802ba54ed5f083abdd20"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f831380a0acb7ef1487f300e3"><td class="" style="width:120px"><div class="notion-simple-table-cell">环节</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">降低的成本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">转移出的复杂度</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313805ea435d15ede6f7fa4"><td class="" style="width:120px"><div class="notion-simple-table-cell">长上下文读取</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">DSA</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">少读无关 token，减少 attention FLOPs</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">动态 top-k 让 KV 访问碎片化</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313800a9311db2aec5b3f87"><td class="" style="width:120px"><div class="notion-simple-table-cell">稀疏索引</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IndexShare</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少每层重复 indexer 计算</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">需要识别哪些层适合共享 indices</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380e79e5edb7d6687a7e1"><td class="" style="width:120px"><div class="notion-simple-table-cell">长输出生成</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">MTP</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少逐 token target forward</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">draft / target 分布对齐和 KV cache 管理</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f83138044b274fd8cb3d7e39a"><td class="" style="width:120px"><div class="notion-simple-table-cell">长轨迹训练</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">critic-based PPO</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提高 credit assignment 精度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">critic 成本和训练系统复杂度</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380539740d28524ccace6"><td class="" style="width:120px"><div class="notion-simple-table-cell">专家合并</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OPD + SLIME</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少 specialist 到 generalist 的分布错位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">rollout、过滤、推理调度进入训练系统</div></td></tr></tbody></table><div class="notion-text notion-block-38e8f42f83138099be16c3f7abba8fcc">把这些机制合成一张端到端图，大致是：</div><div class="notion-text notion-block-38e8f42f83138089b7d7e5ff93b1b16f">这张表也说明了为什么 GLM-5.2 不能只按“架构创新”或“蒸馏争议”来理解。它更像是把 agent 系统里的多处成本各自削掉一部分，再承受由此增加的系统复杂度。</div><hr class="notion-hr notion-block-38e8f42f83138078b8c6f1f8e475c033"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380ddbef2dd4f1492d84d" data-id="38e8f42f831380ddbef2dd4f1492d84d"><span><div id="38e8f42f831380ddbef2dd4f1492d84d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380ddbef2dd4f1492d84d" title="数据来源问题：X Article 的假说"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">数据来源问题：X Article 的假说</span></span></h3><div class="notion-text notion-block-38e8f42f831380628b0fd8e3512c61a9">X Article 提出一个和 Substack 技术线不同的问题：GLM-5.2 这类模型变强，是否只应从直接蒸馏解释？</div><div class="notion-text notion-block-38e8f42f831380af971dffbf4ccee345">作者的假说是，直接蒸馏可能不是最有解释力的框架。中国开发者对 Claude 的需求没有因为访问限制而消失，而是通过代理 API、中转站、灰色服务继续存在。如果这些中转层记录真实开发者任务，就可能形成比普通问答蒸馏更有价值的数据。</div><div class="notion-text notion-block-38e8f42f8313802da345cbcf0090dbaa">这里说的“真实任务”，不是“写一个排序函数”这种孤立 prompt，而是：</div><ul class="notion-list notion-list-disc notion-block-38e8f42f8313802799d0dc0a809bfb4b"><li>一个仓库的真实上下文。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380d6a650d4415948de8e"><li>用户的真实意图。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380169792c5d3d8a39df1"><li>模型给出的初版修改。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f8313802b8440d29aba1da61d"><li>测试失败或工具返回。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380599637d409d7a8becb"><li>用户追问、否定、补充约束。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380078ff1c734bd7163ab"><li>最终被接受或放弃的结果。</li></ul><div class="notion-text notion-block-38e8f42f83138013a4fecbe70f7b5910">两类数据的差别在于：前者主要学习答案，后者学习人在真实环境里如何把模型接入任务。</div><div class="notion-text notion-block-38e8f42f831380aa9e0de5e9c43b70b2">这也是 X Article 中“数据飞轮”说法的含义。<em><span class="notion-blue"><span class="notion-inline-underscore">闭源模型吸引高价值用户；访问限制让部分用户转向中转站；中转站如果沉淀工作流数据，数据又可能进入评测、训练或数据市场；开放模型能力提升后，更多用户迁移过去，继续产生本地工作流数据</span></span></em>。</div><div class="notion-text notion-block-38e8f42f83138020ad5acc94bbb45f12">这是一张机制图，不是证据图。它只说明一种可能的传导路径。</div><hr class="notion-hr notion-block-38e8f42f831380cab57fe6f69a499f68"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f83138052b4fad49d5ae6e7c0" data-id="38e8f42f83138052b4fad49d5ae6e7c0"><span><div id="38e8f42f83138052b4fad49d5ae6e7c0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f83138052b4fad49d5ae6e7c0" title="对开发者的含义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">对开发者的含义</span></span></h3><div class="notion-text notion-block-38e8f42f831380bb902df4f99e6aa5b3">如果把 GLM-5.2 当作一次开放模型的工程样本，开发者最该关心的不是“它有没有赢 Claude”，而是它能否进入自己的工作流。</div><div class="notion-text notion-block-38e8f42f831380a3a15aeadffb98d0d7">评估模型时，至少要看这些指标：</div><table class="notion-simple-table notion-block-38e8f42f831380a4a0eee36767c79fe0"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-38e8f42f831380079728e9bfd6f6ef86"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">观察方式</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313809e852ae781cbc9f97d"><td class="" style="width:120px"><div class="notion-simple-table-cell">长上下文能力</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用自己的 repo、日志、文档测，不只看 max context</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f83138098bb4acefd020b49c5"><td class="" style="width:120px"><div class="notion-simple-table-cell">输出延迟</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">观察完整 agent loop 的 wall-clock time，而不只看 tokens/s</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f831380ec9039f811ca4953c5"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用稳定性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">看模型是否能处理失败、重试和约束变化</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f83138051bd30dc1889702bc0"><td class="" style="width:120px"><div class="notion-simple-table-cell">部署控制权</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">是否能私有部署、缓存、审计、微调、降级</div></td></tr><tr class="notion-simple-table-row notion-block-38e8f42f8313807c815ae96afd0bc66f"><td class="" style="width:120px"><div class="notion-simple-table-cell">供应风险</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">API、地区、价格、账号和合规策略是否稳定</div></td></tr></tbody></table><div class="notion-text notion-block-38e8f42f831380599fa1ec5465372648">实际选型更像一个逐步缩小范围的流程：</div><div class="notion-text notion-block-38e8f42f8313803bacf2d87725653988">开放权重模型的优势，通常会在“足够好”之后变得明显。闭源模型可能仍然更强，但如果开放模型在具体任务上已经可用，成本、可控性、部署稳定性会进入决策。</div><div class="notion-text notion-block-38e8f42f831380dbba16c6f0d75cc3a5"><em><span class="notion-inline-underscore">对于团队来说，比较稳妥的做法是保持模型层可替换。Claude、GPT、GLM、Qwen、Kimi、本地模型都可以进入候选池。业务逻辑不要和单一 API 绑死。agent 系统尤其如此，因为它比普通聊天更依赖长上下文、工具调用、缓存、日志和权限控制。</span></em></div><hr class="notion-hr notion-block-38e8f42f83138029818ad4fe497e33d5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380a99333c02276016c3c" data-id="38e8f42f831380a99333c02276016c3c"><span><div id="38e8f42f831380a99333c02276016c3c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380a99333c02276016c3c" title="后续观察点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">后续观察点</span></span></h3><div class="notion-text notion-block-38e8f42f83138066a058ff79db0af36a">GLM-5.2 之后，有几类信号值得继续跟踪。</div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380938c97c78e0ee3ec1f"><li><em><span class="notion-inline-underscore">DSA / IndexShare 在真实 serving 中的 latency、cache 命中、tail latency 数据。</span></em></li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380648bc1ef7f428cd2b6"><li><em><span class="notion-inline-underscore">MTP acceptance length 在 coding、agent、普通聊天等任务上的分布，而不是单一平均值</span></em>。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380d685dbe92db27bd3f6"><li>critic-based PPO 对长链路任务的 ablation，尤其是和 GRPO 在相同任务长度下的比较。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f831380a39725f7e78bbd795c"><li><em><span class="notion-inline-underscore">SLIME 这类 post-training infrastructure 是否继续公开更多细节，包括 rollout、Data Buffer、过滤器和 SGLang 调度</span></em>。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f8313802883e0d50e37b26be7"><li>开放模型在真实 coding agent benchmark 上的稳定提升。</li></ul><ul class="notion-list notion-list-disc notion-block-38e8f42f8313806bab4afa5c00abda3d"><li>闭源模型访问限制是否继续推动代理层和本地模型生态增长。</li></ul><div class="notion-text notion-block-38e8f42f831380beaa9cd75aac081184">这些信号比单次榜单排名更能说明问题。GLM-5.2 如果只是一次分数提升，影响有限；如果它代表的是开放模型开始系统性优化 agent workload，那么后面会出现一批类似的工程选择。</div><hr class="notion-hr notion-block-38e8f42f831380a39c41c101bf88686a"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380aea964dc06040f1457" data-id="38e8f42f831380aea964dc06040f1457"><span><div id="38e8f42f831380aea964dc06040f1457" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380aea964dc06040f1457" title="结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结论</span></span></h3><div class="notion-text notion-block-38e8f42f831380c881edee56ac1f60f1">GLM-5.2 的位置，不宜写得过满。它没有证明开放模型已经全面超过闭源模型，也没有证明闭源模型的护城河已经失效。</div><div class="notion-text notion-block-38e8f42f83138072856fcc59149a1a85">它比较清楚地展示了另一件事：开放权重模型正在把竞争重心从“回答质量”推进到“任务系统”。在这个系统里，长上下文、稀疏索引、投机生成、长轨迹 RL、后训练 rollout、工具环境、部署控制权都会进入同一张账本。</div><div class="notion-text notion-block-38e8f42f8313805bb10efe3d2744da0d">Substack 原文给出的技术拆解，解释了这张账本里的工程项。X Article 提出的数据飞轮假说，提示了另一张账本：闭源模型的用户路径和数据流向，可能在访问限制之后发生迁移。</div><div class="notion-text notion-block-38e8f42f831380418234c832e94f3984">这两条线放在一起，GLM-5.2 就更像一个案例。开放模型要追上来，靠的不只是参数和蒸馏，还包括推理系统、后训练基础设施、真实工作流数据，以及开发者愿不愿意把它放进自己的生产链路。</div><hr class="notion-hr notion-block-38e8f42f831380e9a173cc243da440e1"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-38e8f42f831380d09892eb29fa046b0e" data-id="38e8f42f831380d09892eb29fa046b0e"><span><div id="38e8f42f831380d09892eb29fa046b0e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e8f42f831380d09892eb29fa046b0e" title="Reference"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Reference</span></span></h3><ul class="notion-list notion-list-disc notion-block-38e8f42f831380d3ac82f3ec99bdc6b6"><li>Artificial Intelligence Made Simple, “Uncovering the Secrets to GLM 5.2&#x27;s Amazing Performance”</li></ul><div class="notion-text notion-block-38e8f42f83138025b937d6f14f30d815"><a class="notion-link" href="https://www.artificialintelligencemadesimple.com/p/the-4-secrets-that-make-glm-52-special" target="_blank" rel="noopener noreferrer">https://www.artificialintelligencemadesimple.com/p/the-4-secrets-that-make-glm-52-special</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380a9b7c4e71422e37288"><li>青龍聖者, “The Secret Behind GLM-5.2 May Not Be Distillation. It May Be the Data Flywheel Closed Models Created”</li></ul><div class="notion-text notion-block-38e8f42f8313805a8b93c6c385147e9d"><a class="notion-link" href="https://x.com/bdsqlsz/status/2070742695115661528" target="_blank" rel="noopener noreferrer">https://x.com/bdsqlsz/status/2070742695115661528</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f83138097a105d8dc481cc8c5"><li>Artificial Analysis, “GLM-5.2 is the new leading open weights model on the Artificial Analysis Intelligence Index”</li></ul><div class="notion-text notion-block-38e8f42f83138048a25adc63ebb6a8ce"><a class="notion-link" href="https://artificialanalysis.ai/articles/glm-5-2-is-the-new-leading-open-weights-model-on-the-artificial-analysis-intelligence-index" target="_blank" rel="noopener noreferrer">https://artificialanalysis.ai/articles/glm-5-2-is-the-new-leading-open-weights-model-on-the-artificial-analysis-intelligence-index</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380a58747ea620b5646e5"><li>Z.ai / Hugging Face, GLM-5.2 model page</li></ul><div class="notion-text notion-block-38e8f42f8313805d9f27f359cf4f7e24"><a class="notion-link" href="https://huggingface.co/zai-org/GLM-5.2" target="_blank" rel="noopener noreferrer">https://huggingface.co/zai-org/GLM-5.2</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380b081c5d4d6e30fcb2f"><li>Anthropic, “Detecting and preventing distillation attacks”</li></ul><div class="notion-text notion-block-38e8f42f831380b3877bdf8286c8f252"><a class="notion-link" href="https://www.anthropic.com/news/detecting-and-preventing-distillation-attacks" target="_blank" rel="noopener noreferrer">https://www.anthropic.com/news/detecting-and-preventing-distillation-attacks</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f831380969fe0dedf68362aa9"><li>Anthropic, “Updating restrictions of sales to unsupported regions”</li></ul><div class="notion-text notion-block-38e8f42f8313805aae51e59ad69e57ce"><a class="notion-link" href="https://www.anthropic.com/news/updating-restrictions-of-sales-to-unsupported-regions" target="_blank" rel="noopener noreferrer">https://www.anthropic.com/news/updating-restrictions-of-sales-to-unsupported-regions</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f8313800aad37c2296161ff1b"><li>ChinaTalk, “How to Buy Cheap Claude Tokens in China: The Transfer Station Economy, Explained”</li></ul><div class="notion-text notion-block-38e8f42f8313806c9032f3c5b7181b27"><a class="notion-link" href="https://www.chinatalk.media/p/how-to-buy-cheap-claude-tokens-in" target="_blank" rel="noopener noreferrer">https://www.chinatalk.media/p/how-to-buy-cheap-claude-tokens-in</a></div><ul class="notion-list notion-list-disc notion-block-38e8f42f8313804481a7e28b96357105"><li>Tom&#x27;s Hardware, Chinese Claude grey-market transfer stations and user-data harvesting risk</li></ul><div class="notion-text notion-block-38e8f42f831380748860e1f109f37a20"><a class="notion-link" href="https://www.tomshardware.com/tech-industry/artificial-intelligence/chinese-grey-market-sells-claude-api-access-at-90-percent-off-through-proxy-networks-that-harvest-user-data" target="_blank" rel="noopener noreferrer">https://www.tomshardware.com/tech-industry/artificial-intelligence/chinese-grey-market-sells-claude-api-access-at-90-percent-off-through-proxy-networks-that-harvest-user-data</a></div><div class="notion-blank notion-block-38e8f42f83138053ab31e9e2ee5ee220"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GEMM学习笔记]]></title>
            <link>https://densecollections.top//https://www.densecollections.top/interactive/gemm/gemm-teaching.htm</link>
            <guid>https://densecollections.top//https://www.densecollections.top/interactive/gemm/gemm-teaching.htm</guid>
            <pubDate>Sat, 18 Jul 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[navie/bf16/fp8/dsl gemm 学习笔记]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-3a18f42f831380bb8b75eaefa3dc6a23"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><figure class="notion-asset-wrapper notion-asset-wrapper-embed"><div style="height:930px;position:relative"><iframe class="notion-asset-object-fit" srcDoc="&lt;!doctype html&gt;
&lt;html lang=&quot;zh-CN&quot;&gt;
&lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
  &lt;title&gt;GEMM 工程教程：从三重循环到 BF16 / FP8 Tensor Core&lt;/title&gt;
  &lt;style&gt;
    :root {
      color-scheme: light;
      --bg: #f4f6f8;
      --surface: #ffffff;
      --surface-2: #f9fafb;
      --text: #151f2c;
      --muted: #5b6675;
      --line: #d8dee8;
      --accent: #0f766e;
      --accent-2: #2563eb;
      --accent-soft: #e7f5f2;
      --blue-soft: #eaf2ff;
      --warn: #9a3412;
      --warn-soft: #fff4e8;
      --code-bg: #111827;
      --code-text: #e5e7eb;
    }

    * { box-sizing: border-box; }

    html {
      scroll-behavior: auto;
      scroll-padding-top: 24px;
    }

    body {
      margin: 0;
      font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.72;
    }

    a {
      color: #1d4ed8;
      text-decoration-thickness: 1px;
      text-underline-offset: 3px;
    }

    a:focus-visible {
      outline: 3px solid #93c5fd;
      outline-offset: 3px;
      border-radius: 4px;
    }

    .skip-link {
      position: fixed;
      top: 10px;
      left: 10px;
      z-index: 100;
      transform: translateY(-160%);
      padding: 8px 12px;
      border-radius: 6px;
      background: var(--text);
      color: white;
      text-decoration: none;
    }

    .skip-link:focus { transform: translateY(0); }

    .layout {
      display: grid;
      grid-template-columns: 286px minmax(0, 1fr);
      min-height: 100vh;
    }

    aside {
      position: sticky;
      top: 0;
      height: 100vh;
      overflow: auto;
      padding: 26px 20px;
      border-right: 1px solid var(--line);
      background: #fbfcfe;
    }

    .aside-title {
      margin: 0 0 8px;
      font-size: 17px;
      line-height: 1.35;
      letter-spacing: 0;
      font-weight: 800;
    }

    aside p {
      margin: 0 0 18px;
      color: var(--muted);
      font-size: 13px;
    }

    nav a {
      display: block;
      padding: 6px 0;
      color: var(--muted);
      text-decoration: none;
      font-size: 14px;
    }

    nav a:hover,
    nav a:focus-visible { color: var(--accent); }

    main {
      width: 100%;
      max-width: 1080px;
      min-width: 0;
      min-height: 100vh;
      margin: 0 auto;
      padding: 42px 52px 78px;
      background: var(--surface);
    }

    header {
      margin-bottom: 0;
      padding-bottom: 32px;
      border-bottom: 1px solid var(--line);
    }

    h1 {
      margin: 0 0 12px;
      max-width: 900px;
      font-size: 38px;
      line-height: 1.16;
      letter-spacing: 0;
    }

    .lead {
      max-width: 860px;
      margin: 0;
      color: var(--muted);
      font-size: 17px;
    }

    section {
      margin: 0;
      padding: 34px 0;
      border-top: 1px solid var(--line);
      scroll-margin-top: 24px;
    }

    header + section { border-top: 0; }

    h2 {
      margin: 0 0 14px;
      font-size: 24px;
      line-height: 1.3;
      letter-spacing: 0;
    }

    h3 {
      margin: 24px 0 10px;
      font-size: 17px;
      line-height: 1.4;
      letter-spacing: 0;
    }

    h4 {
      margin: 22px 0 9px;
      font-size: 15px;
      line-height: 1.45;
      letter-spacing: 0;
    }

    h5 {
      margin: 19px 0 8px;
      color: #374151;
      font-size: 14px;
      line-height: 1.45;
      letter-spacing: 0;
    }

    h2, h3, h4, h5 { scroll-margin-top: 24px; }

    p { margin: 10px 0; }

    section &gt; p,
    section &gt; ul,
    section &gt; ol { max-width: 880px; }

    ul, ol { padding-left: 22px; }
    li { margin: 7px 0; }

    code {
      padding: 2px 5px;
      border-radius: 5px;
      background: #e9edf4;
      color: #111827;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.92em;
    }

    pre {
      margin: 15px 0;
      max-width: 100%;
      contain: paint;
      overflow-x: auto;
      padding: 16px;
      border-radius: 8px;
      background: var(--code-bg);
      color: var(--code-text);
      font-size: 14px;
      line-height: 1.55;
    }

    pre code {
      display: block;
      min-width: 100%;
      width: max-content;
      padding: 0;
      background: transparent;
      color: inherit;
    }

    .code-label {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      margin: 12px 0 -6px;
      padding: 3px 8px;
      border: 1px solid #c7d2fe;
      border-radius: 6px;
      background: #eef2ff;
      color: #3730a3;
      font-size: 12px;
      font-weight: 750;
    }

    .code-disclosure {
      margin: 18px 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
    }

    .code-disclosure summary {
      padding: 13px 15px;
      color: #374151;
      cursor: pointer;
      font-weight: 750;
    }

    .code-disclosure summary::marker { color: var(--accent); }

    .code-disclosure summary:focus-visible {
      outline: 3px solid #93c5fd;
      outline-offset: -3px;
      border-radius: 7px;
    }

    .code-disclosure[open] summary {
      border-bottom: 1px solid var(--line);
    }

    .code-disclosure-body { padding: 0 14px 14px; }

    .code-disclosure-body pre { margin-bottom: 0; }

    .source-ref {
      margin: -5px 0 16px;
      color: var(--muted);
      font-size: 12px;
    }

    .table-scroll {
      max-width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    .table-scroll table { margin: 16px 0; }

    table {
      width: 100%;
      border-collapse: collapse;
      margin: 16px 0;
      font-size: 14px;
    }

    th, td {
      padding: 10px 12px;
      border: 1px solid var(--line);
      text-align: left;
      vertical-align: top;
    }

    th { background: #edf2f7; }

    tbody tr:nth-child(even) td { background: #fbfcfd; }

    .reader-guide th:first-child,
    .reader-guide td:first-child {
      width: 150px;
      font-weight: 750;
      color: var(--accent);
    }

    .path-table {
      table-layout: fixed;
    }

    .path-table th:nth-child(1),
    .path-table td:nth-child(1) {
      width: 22%;
    }

    .path-table th:nth-child(2),
    .path-table td:nth-child(2) {
      width: 40%;
    }

    .path-table code {
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
      line-height: 1.55;
    }

    .pill-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 16px 0;
    }

    .pill {
      padding: 5px 10px;
      border: 1px solid #b7d9d4;
      border-radius: 999px;
      background: var(--accent-soft);
      color: #115e59;
      font-size: 13px;
      font-weight: 650;
    }

    .note, .warn, .blue {
      margin: 16px 0;
      padding: 14px 16px;
      border-radius: 7px;
      border-left: 4px solid var(--accent);
      background: var(--accent-soft);
      color: #164e48;
    }

    .warn {
      border-left-color: var(--warn);
      background: var(--warn-soft);
      color: var(--warn);
    }

    .blue {
      border-left-color: var(--accent-2);
      background: var(--blue-soft);
      color: #1d4ed8;
    }

    .step {
      margin: 18px 0;
      padding: 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--surface-2);
    }

    .step-title {
      display: flex;
      gap: 10px;
      align-items: baseline;
      margin-bottom: 8px;
      font-weight: 750;
    }

    .num {
      display: inline-grid;
      place-items: center;
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: var(--accent);
      color: white;
      font-size: 13px;
      flex: none;
    }

    .compare {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin: 16px 0;
    }

    .card {
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
    }

    .card strong {
      display: block;
      margin-bottom: 4px;
      color: var(--accent);
    }

    .flow {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 8px;
      margin: 16px 0;
    }

    .flow div {
      min-height: 54px;
      display: grid;
      place-items: center;
      padding: 8px;
      border-radius: 8px;
      background: #edf2f7;
      border: 1px solid var(--line);
      text-align: center;
      font-size: 13px;
      font-weight: 650;
    }

    .flow .hot {
      background: var(--accent-soft);
      border-color: #a8d8d1;
      color: #0f766e;
    }

    .two-col {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
      margin: 16px 0;
    }

    .mini-title {
      margin-bottom: 6px;
      color: var(--accent);
      font-weight: 750;
    }

    .formula {
      margin: 14px 0;
      padding: 12px 14px;
      border-radius: 7px;
      background: #f0f7f6;
      border: 1px solid #b7d9d4;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 14px;
      color: #134e4a;
    }

    .memory-map {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 10px;
      margin: 16px 0;
    }

    .memory-map div {
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
      min-height: 92px;
    }

    .memory-map strong {
      display: block;
      margin-bottom: 5px;
      color: var(--accent);
    }

    .diagram {
      margin: 16px 0;
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
    }

    .diagram-title {
      margin-bottom: 10px;
      color: var(--accent);
      font-weight: 750;
    }

    .timeline-grid {
      display: grid;
      grid-template-columns: 108px repeat(4, minmax(82px, 1fr));
      gap: 6px;
      align-items: center;
      font-size: 13px;
    }

    .timeline-label {
      color: var(--muted);
      font-weight: 700;
    }

    .timeline-cell {
      min-height: 34px;
      display: grid;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #edf2f7;
      text-align: center;
    }

    .timeline-cell.hot {
      background: var(--accent-soft);
      border-color: #a8d8d1;
      color: #0f766e;
      font-weight: 750;
    }

    .bank-scroll {
      max-width: 100%;
      overflow-x: auto;
      padding-bottom: 6px;
      -webkit-overflow-scrolling: touch;
    }

    .bank-cycle {
      display: grid;
      grid-template-columns: repeat(8, minmax(72px, 1fr));
      gap: 6px;
      min-width: 680px;
      margin: 12px 0;
    }

    .bank-word {
      min-height: 48px;
      display: grid;
      place-items: center;
      padding: 6px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #edf2f7;
      text-align: center;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 12px;
      line-height: 1.35;
    }

    .bank-word.cycle {
      border-color: #93c5fd;
      background: var(--blue-soft);
      color: #1d4ed8;
      font-weight: 750;
    }

    .gemm-bank-flow {
      display: grid;
      grid-template-columns: 1.1fr 34px 0.9fr 34px 1fr;
      gap: 10px;
      align-items: center;
      min-width: 900px;
      margin: 12px 0;
    }

    .gemm-op {
      display: grid;
      place-items: center;
      color: var(--muted);
      font-size: 26px;
      font-weight: 750;
    }

    .gemm-tile {
      border: 1px solid var(--line);
      border-radius: 7px;
      overflow: hidden;
      background: white;
    }

    .gemm-tile-title {
      padding: 8px 10px;
      border-bottom: 1px solid var(--line);
      background: #f5f7fa;
      color: #374151;
      font-size: 12px;
      font-weight: 750;
      text-align: center;
    }

    .gemm-tile-row {
      display: grid;
      grid-template-columns: 54px repeat(4, minmax(54px, 1fr));
    }

    .gemm-tile-row span {
      min-height: 34px;
      display: grid;
      place-items: center;
      padding: 4px;
      border-right: 1px solid #e5e7eb;
      border-bottom: 1px solid #e5e7eb;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      white-space: nowrap;
    }

    .gemm-tile-row:last-child span { border-bottom: 0; }
    .gemm-tile-row span:last-child { border-right: 0; }

    .gemm-tile-row .axis {
      background: #f5f7fa;
      color: var(--muted);
      font-family: Inter, ui-sans-serif, system-ui, sans-serif;
      font-weight: 700;
    }

    .gemm-tile-row .focus-a {
      background: var(--warn-soft);
      color: #9a3412;
      font-weight: 750;
    }

    .gemm-tile-row .focus-b {
      background: var(--blue-soft);
      color: #1d4ed8;
      font-weight: 750;
    }

    .gemm-tile-row .focus-c {
      background: var(--accent-soft);
      color: #0f766e;
      font-weight: 750;
    }

    .bank-layout-pair {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
      margin: 14px 0;
    }

    .bank-layout-panel {
      min-width: 0;
    }

    .swizzle-matrix {
      display: grid;
      grid-template-columns: 42px repeat(8, 42px);
      width: max-content;
      gap: 3px;
      margin-top: 8px;
    }

    .swizzle-cell {
      width: 42px;
      min-height: 34px;
      display: grid;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: 4px;
      background: #edf2f7;
      color: #374151;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
    }

    .swizzle-cell.axis {
      border-color: transparent;
      background: transparent;
      color: var(--muted);
      font-family: Inter, ui-sans-serif, system-ui, sans-serif;
      font-weight: 700;
    }

    .swizzle-cell.logical-k0 {
      border-color: #fb923c;
      background: var(--warn-soft);
      color: #9a3412;
      font-weight: 800;
    }

    .lane-map-grid {
      display: grid;
      grid-template-columns: repeat(8, minmax(76px, 1fr));
      gap: 6px;
      min-width: 720px;
      margin-top: 10px;
    }

    .lane-map-cell {
      min-height: 38px;
      display: grid;
      place-items: center;
      padding: 5px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: #edf2f7;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      font-weight: 750;
      white-space: nowrap;
    }

    .lane-map-cell.conflict {
      border-color: #fb923c;
      background: var(--warn-soft);
      color: #9a3412;
    }

    .lane-map-cell.ok {
      border-color: #6ee7b7;
      background: #ecfdf5;
      color: #047857;
    }

    .bank-result {
      display: grid;
      grid-template-columns: 150px 1fr;
      gap: 10px;
      align-items: stretch;
      margin: 12px 0;
    }

    .bank-result-label {
      display: grid;
      place-items: center;
      padding: 10px;
      border-radius: 6px;
      background: #f5f7fa;
      color: #374151;
      text-align: center;
      font-size: 12px;
      font-weight: 750;
    }

    .bank-result-body {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      align-items: center;
      padding: 9px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: white;
    }

    .access-chip {
      padding: 4px 7px;
      border-radius: 5px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      white-space: nowrap;
    }

    .access-chip.conflict {
      background: var(--warn-soft);
      color: #9a3412;
    }

    .access-chip.ok {
      background: #ecfdf5;
      color: #047857;
    }

    .alignment-levels {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
      margin: 16px 0;
    }

    .alignment-level {
      min-height: 132px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #fbfcfd;
    }

    .alignment-level strong {
      display: block;
      margin-bottom: 7px;
      color: var(--accent);
    }

    .alignment-level .value {
      display: block;
      margin-bottom: 7px;
      color: #111827;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 18px;
      font-weight: 800;
    }

    .transaction-case {
      margin: 16px 0;
      padding: 13px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #fbfcfd;
    }

    .transaction-case-title {
      margin-bottom: 4px;
      color: #374151;
      font-weight: 800;
    }

    .transaction-case-meta {
      margin-bottom: 10px;
      color: var(--muted);
      font-size: 13px;
    }

    .transaction-strip {
      display: grid;
      gap: 4px;
      min-width: 880px;
    }

    .transaction-strip.count-16 {
      grid-template-columns: repeat(16, minmax(48px, 1fr));
    }

    .transaction-strip.count-17 {
      grid-template-columns: repeat(17, minmax(48px, 1fr));
      min-width: 930px;
    }

    .transaction-cell {
      min-height: 54px;
      display: grid;
      place-items: center;
      padding: 5px 3px;
      border: 1px solid #bfdbfe;
      border-top-width: 4px;
      border-radius: 5px;
      background: var(--blue-soft);
      color: #1d4ed8;
      text-align: center;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 10px;
      line-height: 1.25;
    }

    .transaction-cell.alt {
      border-color: #99f6e4;
      background: var(--accent-soft);
      color: #0f766e;
    }

    .transaction-cell.partial {
      border-color: #fb923c;
      background: var(--warn-soft);
      color: #9a3412;
      font-weight: 800;
    }

    .transaction-summary {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .transaction-summary span {
      padding: 5px 8px;
      border-radius: 5px;
      background: #edf2f7;
      color: #374151;
      font-size: 12px;
      font-weight: 700;
    }

    .bank-hardware-pipeline {
      display: grid;
      grid-template-columns: 1fr 42px 1.1fr 42px 1.45fr;
      gap: 10px;
      align-items: stretch;
      min-width: 940px;
      margin: 12px 0;
    }

    .hardware-stage {
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: white;
    }

    .hardware-stage-title {
      margin-bottom: 9px;
      color: #374151;
      text-align: center;
      font-size: 12px;
      font-weight: 800;
    }

    .hardware-stage-note {
      margin: 8px 0 0;
      color: var(--muted);
      text-align: center;
      font-size: 11px;
    }

    .hardware-arrow {
      display: grid;
      place-items: center;
      color: var(--accent);
      font-size: 28px;
      font-weight: 800;
    }

    .hardware-lanes {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 5px;
    }

    .hardware-lane {
      min-height: 36px;
      display: grid;
      place-items: center;
      padding: 4px;
      border: 1px solid #bfdbfe;
      border-radius: 5px;
      background: var(--blue-soft);
      color: #1d4ed8;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      font-weight: 750;
    }

    .decoder-formula {
      margin: 7px 0;
      padding: 7px;
      border-radius: 5px;
      background: #f0f7f6;
      color: #134e4a;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      line-height: 1.45;
      text-align: center;
    }

    .bank-port-grid {
      display: grid;
      grid-template-columns: repeat(8, minmax(0, 1fr));
      gap: 4px;
    }

    .bank-port {
      min-height: 37px;
      display: grid;
      place-items: center;
      padding: 3px;
      border: 1px solid #99f6e4;
      border-radius: 4px;
      background: var(--accent-soft);
      color: #0f766e;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 10px;
      font-weight: 800;
    }

    .bank-array {
      display: grid;
      grid-template-columns: 70px repeat(8, minmax(72px, 1fr));
      gap: 4px;
      min-width: 720px;
      margin: 12px 0;
    }

    .bank-array-cell {
      min-height: 39px;
      display: grid;
      place-items: center;
      padding: 5px;
      border: 1px solid var(--line);
      border-radius: 4px;
      background: #edf2f7;
      color: #374151;
      text-align: center;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
    }

    .bank-array-cell.axis {
      border-color: transparent;
      background: transparent;
      color: var(--muted);
      font-family: Inter, ui-sans-serif, system-ui, sans-serif;
      font-weight: 750;
    }

    .bank-array-cell.same-bank {
      border-color: #fb923c;
      background: var(--warn-soft);
      color: #9a3412;
      font-weight: 800;
    }

    .bank-scenarios {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin: 14px 0;
    }

    .bank-scenario {
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #fbfcfd;
    }

    .bank-scenario-title {
      margin-bottom: 8px;
      font-weight: 800;
    }

    .bank-scenario-title.ok { color: #047857; }
    .bank-scenario-title.conflict { color: #9a3412; }
    .bank-scenario-title.broadcast { color: #1d4ed8; }

    .bank-route {
      display: grid;
      grid-template-columns: 64px 24px 1fr;
      gap: 5px;
      align-items: center;
      margin: 5px 0;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
    }

    .bank-route span:first-child,
    .bank-route span:last-child {
      padding: 5px;
      border-radius: 4px;
      background: #edf2f7;
      text-align: center;
    }

    .bank-route .route-arrow {
      color: var(--muted);
      text-align: center;
      font-weight: 800;
    }

    .api-stack {
      display: grid;
      gap: 12px;
    }

    .api-root {
      width: min(100%, 460px);
      margin: 0 auto;
      padding: 11px 14px;
      border: 1px solid #a8d8d1;
      border-radius: 7px;
      background: var(--accent-soft);
      color: #0f766e;
      text-align: center;
      font-weight: 800;
    }

    .api-root span {
      color: #115e59;
      font-size: 12px;
      font-weight: 650;
    }

    .api-branch-label {
      color: var(--muted);
      text-align: center;
      font-size: 13px;
      font-weight: 700;
    }

    .api-paths {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
    }

    .api-path {
      display: grid;
      grid-template-rows: auto 24px auto;
      min-width: 0;
    }

    .api-node {
      display: grid;
      place-items: center;
      min-height: 72px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: white;
      text-align: center;
      font-size: 13px;
    }

    .api-node strong {
      display: block;
      color: #374151;
    }

    .api-arrow {
      display: grid;
      place-items: center;
      color: var(--accent);
      font-weight: 800;
    }

    footer {
      margin-top: 8px;
      padding-top: 24px;
      border-top: 1px solid var(--line);
      color: var(--muted);
      font-size: 13px;
    }

    @media (max-width: 880px) {
      html { scroll-padding-top: 58px; }
      .layout { display: block; }
      aside {
        position: sticky;
        top: 0;
        z-index: 20;
        height: auto;
        overflow: hidden;
        padding: 9px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: rgba(251, 252, 254, 0.97);
      }
      .aside-title, aside p { display: none; }
      nav {
        display: flex;
        gap: 6px;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
      }
      nav a {
        flex: none;
        padding: 5px 9px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: white;
        font-size: 12px;
      }
      main { padding: 28px 18px 56px; }
      section { padding: 28px 0; }
      table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      th, td {
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      table code {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      .table-scroll table {
        display: table;
        min-width: 640px;
      }
      .comparison-scroll {
        overflow: visible;
      }
      .comparison-scroll .comparison-table {
        display: block;
        min-width: 0;
      }
      .comparison-table thead { display: none; }
      .comparison-table tbody {
        display: grid;
        gap: 12px;
      }
      .comparison-table tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border: 1px solid var(--line);
      }
      .comparison-table td {
        display: block;
        border: 0;
        background: white !important;
      }
      .comparison-table td:first-child {
        grid-column: 1 / -1;
        border-bottom: 1px solid var(--line);
        background: #edf2f7 !important;
        font-weight: 750;
      }
      .comparison-table td:nth-child(2) {
        border-right: 1px solid var(--line);
      }
      .comparison-table td:nth-child(2)::before,
      .comparison-table td:nth-child(3)::before {
        display: block;
        margin-bottom: 5px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 750;
      }
      .comparison-table td:nth-child(2)::before { content: &quot;普通 dense FP8&quot;; }
      .comparison-table td:nth-child(3)::before { content: &quot;Blockscaled FP8&quot;; }
      p code, li code, td code, th code {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      pre code {
        min-width: 100%;
        width: max-content;
        white-space: pre;
        overflow-wrap: normal;
        word-break: normal;
      }
      .compare, .flow, .two-col, .memory-map, .bank-layout-pair, .alignment-levels, .bank-scenarios, .api-paths { grid-template-columns: 1fr; }
      .bank-result { grid-template-columns: 1fr; }
      .timeline-grid {
        grid-template-columns: 52px repeat(4, minmax(0, 1fr));
        gap: 4px;
        font-size: 11px;
      }
      .timeline-cell {
        min-height: 30px;
        padding: 4px;
        overflow-wrap: anywhere;
      }
      h1 { font-size: 29px; }
    }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;a class=&quot;skip-link&quot; href=&quot;#content&quot;&gt;跳到正文&lt;/a&gt;
  &lt;div class=&quot;layout&quot;&gt;
    &lt;aside&gt;
      &lt;div class=&quot;aside-title&quot;&gt;GEMM 工程教程&lt;/div&gt;
      &lt;p&gt;主线：先把 BF16 GEMM 优化清楚，再迁移到 FP8。&lt;/p&gt;
      &lt;nav aria-label=&quot;章节目录&quot;&gt;
        &lt;a href=&quot;#overview&quot;&gt;0. 学习地图&lt;/a&gt;
        &lt;a href=&quot;#reader-guide&quot;&gt;0.1 阅读路径&lt;/a&gt;
        &lt;a href=&quot;#prereq&quot;&gt;0.2 读前准备&lt;/a&gt;
        &lt;a href=&quot;#math&quot;&gt;1. 数学定义和形状&lt;/a&gt;
        &lt;a href=&quot;#cpu&quot;&gt;2. 一般写法：三重循环&lt;/a&gt;
        &lt;a href=&quot;#naive-gpu&quot;&gt;3. Naive GPU Kernel&lt;/a&gt;
        &lt;a href=&quot;#cuda-demo&quot;&gt;3.3 可跑 CUDA demo&lt;/a&gt;
        &lt;a href=&quot;#block-tiling&quot;&gt;4. Block Tiling&lt;/a&gt;
        &lt;a href=&quot;#split-k&quot;&gt;4.6 Split-K&lt;/a&gt;
        &lt;a href=&quot;#shared&quot;&gt;5. Shared Memory&lt;/a&gt;
        &lt;a href=&quot;#register&quot;&gt;6. Register Tiling&lt;/a&gt;
        &lt;a href=&quot;#tensor-core&quot;&gt;7. BF16 Tensor Core&lt;/a&gt;
        &lt;a href=&quot;#pipeline&quot;&gt;8. Pipeline 和 Async Copy&lt;/a&gt;
        &lt;a href=&quot;#epilogue&quot;&gt;9. Epilogue 和融合&lt;/a&gt;
        &lt;a href=&quot;#perf&quot;&gt;10. Profiling 工具和方法&lt;/a&gt;
        &lt;a href=&quot;#fp8&quot;&gt;11. FP8 GEMM 怎么做&lt;/a&gt;
        &lt;a href=&quot;#cute&quot;&gt;12. CuTe / CUTLASS DSL&lt;/a&gt;
        &lt;a href=&quot;#triton&quot;&gt;13. Triton GEMM&lt;/a&gt;
        &lt;a href=&quot;#hipblas&quot;&gt;14. hipBLAS / hipBLASLt&lt;/a&gt;
        &lt;a href=&quot;#checklist&quot;&gt;15. 实战 Checklist&lt;/a&gt;
        &lt;a href=&quot;#pitfalls&quot;&gt;16. 常见误区&lt;/a&gt;
        &lt;a href=&quot;#refs&quot;&gt;17. 参考资料&lt;/a&gt;
      &lt;/nav&gt;
    &lt;/aside&gt;

    &lt;main id=&quot;content&quot;&gt;
      &lt;header&gt;
        &lt;h1&gt;GEMM 工程教程：从三重循环到 BF16 / FP8 Tensor Core&lt;/h1&gt;
        &lt;p class=&quot;lead&quot;&gt;这是一份工程视角的 GEMM 教程。我们先从最普通的矩阵乘法写法出发，解释数据复用、tile、片上存储、BF16/FP8 matrix-core 路径和 profiling。硬件细节以前十二章的 CUDA/NVIDIA 主线展开，最后再对照 Triton 与 AMD ROCm 的实现和工具。&lt;/p&gt;
        &lt;div class=&quot;pill-row&quot;&gt;
          &lt;span class=&quot;pill&quot;&gt;BF16 主线&lt;/span&gt;
          &lt;span class=&quot;pill&quot;&gt;GPU Kernel&lt;/span&gt;
          &lt;span class=&quot;pill&quot;&gt;Tiling&lt;/span&gt;
          &lt;span class=&quot;pill&quot;&gt;Tensor Core&lt;/span&gt;
          &lt;span class=&quot;pill&quot;&gt;FP8 扩展&lt;/span&gt;
        &lt;/div&gt;
      &lt;/header&gt;

      &lt;section id=&quot;overview&quot;&gt;
        &lt;h2&gt;0. 学习地图&lt;/h2&gt;
        &lt;p&gt;GEMM 的优化可以看成一个不断减少“无效数据移动”、提高“计算单元饱和度”的过程。&lt;/p&gt;
        &lt;div class=&quot;flow&quot;&gt;
          &lt;div&gt;三重循环&lt;/div&gt;
          &lt;div&gt;Naive GPU&lt;/div&gt;
          &lt;div class=&quot;hot&quot;&gt;Block Tiling&lt;/div&gt;
          &lt;div class=&quot;hot&quot;&gt;Shared + Register&lt;/div&gt;
          &lt;div class=&quot;hot&quot;&gt;Tensor Core Pipeline&lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;如果只记一条主线：&lt;strong&gt;先让每个输出 tile 复用 A/B 数据，再让每个线程保留多个 accumulator，最后让 Tensor Core 在数据搬运期间持续工作。&lt;/strong&gt;&lt;/p&gt;
        &lt;div class=&quot;memory-map&quot;&gt;
          &lt;div&gt;&lt;strong&gt;Global / HBM&lt;/strong&gt;容量大、延迟高、带宽珍贵。GEMM 优化的第一目标是减少重复读，并让读写连续、对齐、可合并。&lt;/div&gt;
          &lt;div&gt;&lt;strong&gt;Shared Memory&lt;/strong&gt;CTA 内共享，延迟低很多，但容量小，并且有 bank conflict、padding、同步和 occupancy 成本。&lt;/div&gt;
          &lt;div&gt;&lt;strong&gt;Register&lt;/strong&gt;每个线程私有，最快，但数量有限。accumulator 通常放这里，寄存器多了会降低活跃 warp 数。&lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;所以一个成熟 GEMM kernel 的数据流一般是：HBM 读入 A/B tile，到 shared memory 做 CTA 级复用，再进入 warp fragment / register，最后用 Tensor Core 累加到 register accumulator。&lt;/p&gt;
        &lt;h3 id=&quot;reader-guide&quot;&gt;0.1 阅读路径&lt;/h3&gt;
        &lt;p&gt;这份文档同时服务新手和已经有 CUDA 基础的读者。建议先按自己的目标选路径，不需要第一次就从头读到尾。&lt;/p&gt;
        &lt;table class=&quot;reader-guide&quot;&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;读者路径&lt;/th&gt;&lt;th&gt;阅读顺序&lt;/th&gt;&lt;th&gt;前置条件&lt;/th&gt;&lt;th&gt;可以先跳过&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;新手&lt;/td&gt;&lt;td&gt;0 → 1 → 2 → 3 → 3.3 demo → 4 → 5 → 6 → 7&lt;/td&gt;&lt;td&gt;知道矩阵乘法和基本 CUDA thread/block 概念&lt;/td&gt;&lt;td&gt;第一次先跳过 10、11、12&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;有 CUDA 基础&lt;/td&gt;&lt;td&gt;0 → 4 → 4.6 → 5 → 6 → 7 → 8 → 10 → 11 → 12 → 13&lt;/td&gt;&lt;td&gt;能读 CUDA kernel，知道 shared memory 和 warp&lt;/td&gt;&lt;td&gt;1-3 可快速扫过&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;只想调性能&lt;/td&gt;&lt;td&gt;3 → 3.3 demo → 4.4 → 4.6 → 8 → 10 → 13 → 14&lt;/td&gt;&lt;td&gt;已经有一个能跑的 GEMM 或 matmul 调用&lt;/td&gt;&lt;td&gt;FP8 和 CuTe 先不用看；profile 时可用 &lt;code&gt;--skip-check&lt;/code&gt; 避免 CPU reference 污染时间线&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;关注 FP8&lt;/td&gt;&lt;td&gt;7 → 9 → 10 → 11 → 12 → 13 → 14&lt;/td&gt;&lt;td&gt;理解 BF16 Tensor Core 和 epilogue&lt;/td&gt;&lt;td&gt;CPU/naive 部分只作背景&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/section&gt;

      &lt;section id=&quot;prereq&quot;&gt;
        &lt;h2&gt;0.2 读前准备&lt;/h2&gt;
        &lt;p&gt;这份文档的目标不是让你背 CUDA 名词，而是让你能看懂一个生产级 GEMM kernel 的性能结构，并能判断一个优化点为什么有效。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;先看代码块标签再读代码：&lt;strong&gt;Concept sketch&lt;/strong&gt; / &lt;strong&gt;Teaching kernel&lt;/strong&gt; 用于解释机制，不承诺可直接编译；&lt;strong&gt;Production command&lt;/strong&gt; / &lt;strong&gt;Production profiling command&lt;/strong&gt; 可在匹配的环境中运行；&lt;strong&gt;Production reference&lt;/strong&gt; 使用真实工程 API，但仍依赖对应的库版本和 GPU 架构。标签后的补充文字只说明语言或场景。&lt;/div&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;读完应该掌握&lt;/div&gt;
            &lt;ul&gt;
              &lt;li&gt;能从三重循环推导出 block/shared/register/tensor core tiling。&lt;/li&gt;
              &lt;li&gt;能解释 BM/BN/BK、stage、occupancy、bank conflict 的取舍。&lt;/li&gt;
              &lt;li&gt;能区分 BF16 GEMM 和 FP8 GEMM 的数值路径。&lt;/li&gt;
              &lt;li&gt;能读 CUTLASS/CuTe GEMM 示例，知道 mainloop 和 epilogue 在哪里。&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;默认前置知识&lt;/div&gt;
            &lt;ul&gt;
              &lt;li&gt;知道 CUDA thread、warp、CTA/block、SM 的基本含义。&lt;/li&gt;
              &lt;li&gt;知道 global memory、shared memory、register 的大致层级。&lt;/li&gt;
              &lt;li&gt;能读 C++/Python 代码，不要求已经写过 CUTLASS kernel。&lt;/li&gt;
              &lt;li&gt;知道 BF16/FP16/FP8 是低精度浮点格式。&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;h3&gt;0.2.1 术语速查&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;术语&lt;/th&gt;&lt;th&gt;本文里的含义&lt;/th&gt;&lt;th&gt;容易混淆点&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;CTA&lt;/td&gt;&lt;td&gt;CUDA thread block，一个 block 负责一个或多个输出 tile&lt;/td&gt;&lt;td&gt;很多资料会把 CTA 和 block 混用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;BM/BN/BK&lt;/td&gt;&lt;td&gt;CTA 级 GEMM tile 的 M/N/K 尺寸&lt;/td&gt;&lt;td&gt;不是固定经验值，要结合资源和 shape profile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Warp tile&lt;/td&gt;&lt;td&gt;CTA tile 内分给单个 warp 的子 tile&lt;/td&gt;&lt;td&gt;不等于 MMA 指令一次覆盖的 tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;MMA tile&lt;/td&gt;&lt;td&gt;Tensor Core 指令级小矩阵形状&lt;/td&gt;&lt;td&gt;由架构和指令族决定&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Epilogue&lt;/td&gt;&lt;td&gt;accumulator 完成后到输出写回之间的融合逻辑&lt;/td&gt;&lt;td&gt;FP8 下 scale/amax/requantize 常在这里变成瓶颈&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CuTe&lt;/td&gt;&lt;td&gt;CUTLASS 里的 layout/tensor/MMA/copy DSL&lt;/td&gt;&lt;td&gt;既有 C++ CuTe，也有 Python CuTe DSL&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/section&gt;

      &lt;section id=&quot;math&quot;&gt;
        &lt;h2&gt;1. 数学定义和形状&lt;/h2&gt;
        &lt;p&gt;标准 GEMM 写作：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;C = alpha * A * B + beta * C&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;教学里先忽略 &lt;code&gt;alpha&lt;/code&gt; 和 &lt;code&gt;beta&lt;/code&gt;，关注核心乘法：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;A: [M, K]
B: [K, N]
C: [M, N]

C[m, n] = sum(A[m, k] * B[k, n] for k in 0..K-1)&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;compare&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;strong&gt;M&lt;/strong&gt;输出矩阵的行数，常对应 token 数、batch 维或 row tile。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;strong&gt;N&lt;/strong&gt;输出矩阵的列数，常对应 hidden/out feature 维。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;strong&gt;K&lt;/strong&gt;reduce 维，每个输出元素都要沿 K 做点积。&lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;计算量近似为 &lt;code&gt;2 * M * N * K&lt;/code&gt; FLOPs，因为一次 multiply-add 通常算 2 FLOPs。&lt;/p&gt;
        &lt;h3&gt;1.1 为什么 GEMM 值得专门优化&lt;/h3&gt;
        &lt;p&gt;GEMM 的计算量随 &lt;code&gt;M*N*K&lt;/code&gt; 增长，但输入输出数据量只随 &lt;code&gt;M*K + K*N + M*N&lt;/code&gt; 增长。如果 tile 设计合理，同一份 A/B 数据可以被重复使用很多次，kernel 就更容易接近计算峰值。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;Arithmetic intensity ≈ FLOPs / bytes moved&lt;/div&gt;
        &lt;p&gt;这也是 roofline 模型的核心：当 arithmetic intensity 低时，瓶颈是内存带宽；当它足够高时，瓶颈才可能变成 Tensor Core / CUDA core 吞吐。&lt;/p&gt;
        &lt;h3&gt;1.2 Layout 先于 kernel&lt;/h3&gt;
        &lt;p&gt;矩阵在内存里通常是 row-major 或 column-major。对 GPU 来说，线程束访问连续地址时才能合并成更少的 memory transaction。一个数学上等价的转置或 layout 选择，可能直接决定 global load 是否 coalesced。&lt;/p&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;好访问&lt;/div&gt;warp 中相邻 lane 访问相邻地址，并尽量完整利用当前架构的 32B global-memory transaction；单个线程的 vectorized load 还要满足自身宽度对齐，例如 16B load 至少对齐到 16B。GEMM tile 起点常进一步按 128B 组织，但这不是 warp 的通用硬性对齐要求。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;坏访问&lt;/div&gt;warp 中 lane 跨 stride 访问，或者每个 lane 只拿很小的不连续片段，transaction 多且有效带宽低。&lt;/div&gt;
        &lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;cpu&quot;&gt;
        &lt;h2&gt;2. 一般写法：三重循环&lt;/h2&gt;
        &lt;p&gt;最直接的写法如下：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;for m in range(M):
  for n in range(N):
    acc = 0.0
    for k in range(K):
      acc += A[m, k] * B[k, n]
    C[m, n] = acc&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;step&quot;&gt;
          &lt;div class=&quot;step-title&quot;&gt;&lt;span class=&quot;num&quot;&gt;1&lt;/span&gt;它正确，但没有利用数据复用&lt;/div&gt;
          &lt;p&gt;同一个 &lt;code&gt;A[m, k]&lt;/code&gt; 会被多个 &lt;code&gt;n&lt;/code&gt; 使用，同一个 &lt;code&gt;B[k, n]&lt;/code&gt; 会被多个 &lt;code&gt;m&lt;/code&gt; 使用。朴素循环没有显式把这种复用组织起来。&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class=&quot;step&quot;&gt;
          &lt;div class=&quot;step-title&quot;&gt;&lt;span class=&quot;num&quot;&gt;2&lt;/span&gt;它也没有匹配 GPU 的执行模型&lt;/div&gt;
          &lt;p&gt;GPU 需要大量线程并行，且访问模式要连续、对齐、可合并。三重循环只是算法表达，不是高性能实现。&lt;/p&gt;
        &lt;/div&gt;
        &lt;h3&gt;2.1 循环顺序会改变缓存行为&lt;/h3&gt;
        &lt;p&gt;即使在 CPU 上，&lt;code&gt;m-n-k&lt;/code&gt;、&lt;code&gt;m-k-n&lt;/code&gt;、&lt;code&gt;k-m-n&lt;/code&gt; 的性能也可能差很多，因为 B 的访问是连续还是跨 stride，会影响 cache line 利用率。GPU 上这个问题更尖锐：warp 是否 coalesced 比单个线程的局部性更重要。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// row-major B[K, N] 下，n 连续时 B[k, n] 连续
for m:
  for k:
    a = A[m, k]
    for n:
      C[m, n] += a * B[k, n]&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这段 CPU 伪代码已经开始表达“复用 A、连续读 B”的思想。GPU kernel 的 tiling 只是把这个思想推进到 CTA、warp、register 三个层级。&lt;/p&gt;
      &lt;/section&gt;

      &lt;section id=&quot;naive-gpu&quot;&gt;
        &lt;h2&gt;3. Naive GPU Kernel：一个线程算一个输出元素&lt;/h2&gt;
        &lt;p&gt;第一版 GPU 化通常是：每个 thread 负责一个 &lt;code&gt;C[m,n]&lt;/code&gt;。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;__global__ void matmul_naive_bf16(A, B, C, M, N, K) {
  int m = blockIdx.y * blockDim.y + threadIdx.y;
  int n = blockIdx.x * blockDim.x + threadIdx.x;
  if (m &gt;= M || n &gt;= N) return;

  float acc = 0.0f;
  for (int k = 0; k &lt; K; ++k) {
    acc += float(A[m * K + k]) * float(B[k * N + n]);
  }
  C[m * N + n] = bf16(acc);
}&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这比 CPU 三重循环更并行，但离高性能仍很远。主要问题通常不是乘加数量，而是 A/B 数据缺少 CTA 内复用，导致相对计算量产生了过多 HBM 访问。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;Naive GPU kernel 的核心问题：每个 thread 独立从 global memory 扫 A 的一行和 B 的一列，block 内大量重复读取，数据复用几乎丢失。&lt;/div&gt;
        &lt;h3&gt;3.1 Naive kernel 的访存问题&lt;/h3&gt;
        &lt;p&gt;假设一个 block 有很多线程同时计算相邻的 &lt;code&gt;C[m,n]&lt;/code&gt;。它们在同一个 &lt;code&gt;k&lt;/code&gt; 上往往会重复读取同一个 &lt;code&gt;A[m,k]&lt;/code&gt;，并读取一段连续的 &lt;code&gt;B[k,n]&lt;/code&gt;。B 的访问可能还能合并，A 的读取却会在多个线程之间重复发生。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;访问对象&lt;/th&gt;&lt;th&gt;Naive 行为&lt;/th&gt;&lt;th&gt;后续优化目标&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;A[m,k]&lt;/td&gt;&lt;td&gt;同一行的元素被多个 n 重复读取&lt;/td&gt;&lt;td&gt;放入 shared，让 CTA 内多个列复用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;B[k,n]&lt;/td&gt;&lt;td&gt;相邻 n 可能连续，但跨 m 会重复读取&lt;/td&gt;&lt;td&gt;放入 shared，让 CTA 内多行复用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;C[m,n]&lt;/td&gt;&lt;td&gt;每个线程只维护一个 acc&lt;/td&gt;&lt;td&gt;每个线程或 warp 维护多个 acc，提高计算密度&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;3.2 第一个性能判断&lt;/h3&gt;
        &lt;p&gt;如果 profile 里看到 global load throughput 很高，但 Tensor Core 或 FMA 利用率很低，通常说明 kernel 被内存喂不饱。这时不要急着调 block size，先问：A/B 是否被重复从 HBM 读了太多次？&lt;/p&gt;
      &lt;/section&gt;

      &lt;section id=&quot;cuda-demo&quot;&gt;
        &lt;h2&gt;3.3 从零能跑的 CUDA GEMM demo&lt;/h2&gt;
        &lt;p&gt;只看伪代码很难建立性能直觉。这里提供一个单文件 CUDA demo：同一个 FP32 GEMM 同时实现 naive kernel 和 shared-memory tiled kernel，并用 CUDA event 计时。它不是生产级 Tensor Core kernel，而是用来亲眼看到“重复读 HBM”和“CTA 内复用 A/B tile”的差别。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;nvcc -O3 -std=c++17 -arch=sm_80 gemm-demo.cu -o gemm-demo
./gemm-demo
./gemm-demo 1024 1024 1024 50&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;&lt;code&gt;-arch=sm_80&lt;/code&gt; 只是示例，应该替换成你的 GPU 架构。这个 demo 只依赖 CUDA runtime，不依赖 CUTLASS、Triton 或 cuBLAS。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;__global__ void matmul_tiled_kernel(const float* A, const float* B, float* C,
                                    int M, int N, int K) {
  __shared__ float As[16][16];
  __shared__ float Bs[16][16];
  int n = blockIdx.x * 16 + threadIdx.x;
  int m = blockIdx.y * 16 + threadIdx.y;
  float acc = 0.0f;

  for (int k0 = 0; k0 &amp;lt; K; k0 += 16) {
    As[threadIdx.y][threadIdx.x] = in_bounds_A ? A[m * K + k0 + threadIdx.x] : 0.0f;
    Bs[threadIdx.y][threadIdx.x] = in_bounds_B ? B[(k0 + threadIdx.y) * N + n] : 0.0f;
    __syncthreads();
    for (int kk = 0; kk &amp;lt; 16; ++kk) acc += As[threadIdx.y][kk] * Bs[kk][threadIdx.x];
    __syncthreads();
  }
  if (m &amp;lt; M &amp;amp;&amp;amp; n &amp;lt; N) C[m * N + n] = acc;
}&lt;/code&gt;&lt;/pre&gt;
        &lt;details class=&quot;code-disclosure&quot;&gt;
          &lt;summary&gt;查看完整 gemm-demo.cu 源码&lt;/summary&gt;
          &lt;div class=&quot;code-disclosure-body&quot;&gt;
            &lt;div class=&quot;code-label&quot;&gt;Production reference · full source&lt;/div&gt;
            &lt;pre&gt;&lt;code&gt;// gemm-demo.cu
// Minimal CUDA GEMM lab: naive one-thread-per-output vs shared-memory tiling.
//
// Build on a CUDA machine:
//   nvcc -O3 -std=c++17 -arch=sm_80 gemm-demo.cu -o gemm-demo
//
// Run:
//   ./gemm-demo
//   ./gemm-demo 1024 1024 1024 50
//   ./gemm-demo 1024 1024 1024 50 --skip-check

#include &amp;lt;cuda_runtime.h&amp;gt;

#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;

#define CUDA_CHECK(call)                                                     \
  do {                                                                       \
    cudaError_t err__ = (call);                                               \
    if (err__ != cudaSuccess) {                                               \
      std::cerr &amp;lt;&amp;lt; &quot;CUDA error at &quot; &amp;lt;&amp;lt; __FILE__ &amp;lt;&amp;lt; &quot;:&quot; &amp;lt;&amp;lt; __LINE__ &amp;lt;&amp;lt; &quot;: &quot; \
                &amp;lt;&amp;lt; cudaGetErrorString(err__) &amp;lt;&amp;lt; std::endl;                   \
      std::exit(EXIT_FAILURE);                                                \
    }                                                                        \
  } while (0)

constexpr int TILE = 16;

__global__ void matmul_naive_kernel(const float* __restrict__ A,
                                    const float* __restrict__ B,
                                    float* __restrict__ C,
                                    int M,
                                    int N,
                                    int K) {
  int n = blockIdx.x * blockDim.x + threadIdx.x;
  int m = blockIdx.y * blockDim.y + threadIdx.y;

  if (m &amp;gt;= M || n &amp;gt;= N) {
    return;
  }

  float acc = 0.0f;
  for (int k = 0; k &amp;lt; K; ++k) {
    acc += A[m * K + k] * B[k * N + n];
  }
  C[m * N + n] = acc;
}

__global__ void matmul_tiled_kernel(const float* __restrict__ A,
                                    const float* __restrict__ B,
                                    float* __restrict__ C,
                                    int M,
                                    int N,
                                    int K) {
  __shared__ float As[TILE][TILE];
  __shared__ float Bs[TILE][TILE];

  int tx = threadIdx.x;
  int ty = threadIdx.y;
  int n = blockIdx.x * TILE + tx;
  int m = blockIdx.y * TILE + ty;

  float acc = 0.0f;
  int k_tiles = (K + TILE - 1) / TILE;

  for (int tile = 0; tile &amp;lt; k_tiles; ++tile) {
    int a_col = tile * TILE + tx;
    int b_row = tile * TILE + ty;

    As[ty][tx] = (m &amp;lt; M &amp;amp;&amp;amp; a_col &amp;lt; K) ? A[m * K + a_col] : 0.0f;
    Bs[ty][tx] = (b_row &amp;lt; K &amp;amp;&amp;amp; n &amp;lt; N) ? B[b_row * N + n] : 0.0f;
    __syncthreads();

    #pragma unroll
    for (int kk = 0; kk &amp;lt; TILE; ++kk) {
      acc += As[ty][kk] * Bs[kk][tx];
    }
    __syncthreads();
  }

  if (m &amp;lt; M &amp;amp;&amp;amp; n &amp;lt; N) {
    C[m * N + n] = acc;
  }
}

void init_matrix(std::vector&amp;lt;float&amp;gt;&amp;amp; x, int rows, int cols, int salt) {
  for (int r = 0; r &amp;lt; rows; ++r) {
    for (int c = 0; c &amp;lt; cols; ++c) {
      int v = (r * 17 + c * 13 + salt) % 97;
      x[r * cols + c] = static_cast&amp;lt;float&amp;gt;(v - 48) / 48.0f;
    }
  }
}

void cpu_reference(const std::vector&amp;lt;float&amp;gt;&amp;amp; A,
                   const std::vector&amp;lt;float&amp;gt;&amp;amp; B,
                   std::vector&amp;lt;float&amp;gt;&amp;amp; C,
                   int M,
                   int N,
                   int K) {
  for (int m = 0; m &amp;lt; M; ++m) {
    for (int n = 0; n &amp;lt; N; ++n) {
      float acc = 0.0f;
      for (int k = 0; k &amp;lt; K; ++k) {
        acc += A[m * K + k] * B[k * N + n];
      }
      C[m * N + n] = acc;
    }
  }
}

float max_abs_error(const std::vector&amp;lt;float&amp;gt;&amp;amp; ref, const std::vector&amp;lt;float&amp;gt;&amp;amp; got) {
  float err = 0.0f;
  for (size_t i = 0; i &amp;lt; ref.size(); ++i) {
    err = std::max(err, std::abs(ref[i] - got[i]));
  }
  return err;
}

template &amp;lt;typename Kernel&amp;gt;
float time_kernel(Kernel kernel,
                  dim3 grid,
                  dim3 block,
                  const float* d_A,
                  const float* d_B,
                  float* d_C,
                  int M,
                  int N,
                  int K,
                  int iters) {
  cudaEvent_t start;
  cudaEvent_t stop;
  CUDA_CHECK(cudaEventCreate(&amp;amp;start));
  CUDA_CHECK(cudaEventCreate(&amp;amp;stop));

  kernel&amp;lt;&amp;lt;&amp;lt;grid, block&amp;gt;&amp;gt;&amp;gt;(d_A, d_B, d_C, M, N, K);
  CUDA_CHECK(cudaGetLastError());
  CUDA_CHECK(cudaDeviceSynchronize());

  CUDA_CHECK(cudaEventRecord(start));
  for (int i = 0; i &amp;lt; iters; ++i) {
    kernel&amp;lt;&amp;lt;&amp;lt;grid, block&amp;gt;&amp;gt;&amp;gt;(d_A, d_B, d_C, M, N, K);
  }
  CUDA_CHECK(cudaEventRecord(stop));
  CUDA_CHECK(cudaEventSynchronize(stop));
  CUDA_CHECK(cudaGetLastError());

  float ms = 0.0f;
  CUDA_CHECK(cudaEventElapsedTime(&amp;amp;ms, start, stop));
  CUDA_CHECK(cudaEventDestroy(start));
  CUDA_CHECK(cudaEventDestroy(stop));
  return ms / static_cast&amp;lt;float&amp;gt;(iters);
}

double gflops(int M, int N, int K, float ms) {
  double flops = 2.0 * static_cast&amp;lt;double&amp;gt;(M) * static_cast&amp;lt;double&amp;gt;(N) * static_cast&amp;lt;double&amp;gt;(K);
  return flops / (static_cast&amp;lt;double&amp;gt;(ms) * 1.0e6);
}

int parse_arg(char** argv, int index, int fallback) {
  if (argv[index] == nullptr) {
    return fallback;
  }
  int value = std::atoi(argv[index]);
  return value &amp;gt; 0 ? value : fallback;
}

bool has_flag(int argc, char** argv, const char* flag) {
  for (int i = 1; i &amp;lt; argc; ++i) {
    if (std::strcmp(argv[i], flag) == 0) {
      return true;
    }
  }
  return false;
}

int main(int argc, char** argv) {
  int M = argc &amp;gt; 1 ? parse_arg(argv, 1, 512) : 512;
  int N = argc &amp;gt; 2 ? parse_arg(argv, 2, 512) : 512;
  int K = argc &amp;gt; 3 ? parse_arg(argv, 3, 512) : 512;
  int iters = argc &amp;gt; 4 ? parse_arg(argv, 4, 20) : 20;
  bool skip_check = has_flag(argc, argv, &quot;--skip-check&quot;);

  std::cout &amp;lt;&amp;lt; &quot;GEMM demo shape: M=&quot; &amp;lt;&amp;lt; M &amp;lt;&amp;lt; &quot; N=&quot; &amp;lt;&amp;lt; N &amp;lt;&amp;lt; &quot; K=&quot; &amp;lt;&amp;lt; K
            &amp;lt;&amp;lt; &quot; iters=&quot; &amp;lt;&amp;lt; iters &amp;lt;&amp;lt; std::endl;
  if (skip_check) {
    std::cout &amp;lt;&amp;lt; &quot;correctness: skipped (--skip-check)&quot; &amp;lt;&amp;lt; std::endl;
  }

  std::vector&amp;lt;float&amp;gt; h_A(static_cast&amp;lt;size_t&amp;gt;(M) * K);
  std::vector&amp;lt;float&amp;gt; h_B(static_cast&amp;lt;size_t&amp;gt;(K) * N);
  std::vector&amp;lt;float&amp;gt; h_ref(skip_check ? 0 : static_cast&amp;lt;size_t&amp;gt;(M) * N);
  std::vector&amp;lt;float&amp;gt; h_naive(static_cast&amp;lt;size_t&amp;gt;(M) * N);
  std::vector&amp;lt;float&amp;gt; h_tiled(static_cast&amp;lt;size_t&amp;gt;(M) * N);

  init_matrix(h_A, M, K, 7);
  init_matrix(h_B, K, N, 19);
  if (!skip_check) {
    cpu_reference(h_A, h_B, h_ref, M, N, K);
  }

  float* d_A = nullptr;
  float* d_B = nullptr;
  float* d_C = nullptr;
  size_t bytes_A = h_A.size() * sizeof(float);
  size_t bytes_B = h_B.size() * sizeof(float);
  size_t bytes_C = static_cast&amp;lt;size_t&amp;gt;(M) * N * sizeof(float);

  CUDA_CHECK(cudaMalloc(&amp;amp;d_A, bytes_A));
  CUDA_CHECK(cudaMalloc(&amp;amp;d_B, bytes_B));
  CUDA_CHECK(cudaMalloc(&amp;amp;d_C, bytes_C));
  CUDA_CHECK(cudaMemcpy(d_A, h_A.data(), bytes_A, cudaMemcpyHostToDevice));
  CUDA_CHECK(cudaMemcpy(d_B, h_B.data(), bytes_B, cudaMemcpyHostToDevice));

  dim3 block(TILE, TILE);
  dim3 grid((N + TILE - 1) / TILE, (M + TILE - 1) / TILE);

  float naive_ms = time_kernel(matmul_naive_kernel, grid, block, d_A, d_B, d_C, M, N, K, iters);
  CUDA_CHECK(cudaMemcpy(h_naive.data(), d_C, bytes_C, cudaMemcpyDeviceToHost));
  float naive_err = skip_check ? NAN : max_abs_error(h_ref, h_naive);

  float tiled_ms = time_kernel(matmul_tiled_kernel, grid, block, d_A, d_B, d_C, M, N, K, iters);
  CUDA_CHECK(cudaMemcpy(h_tiled.data(), d_C, bytes_C, cudaMemcpyDeviceToHost));
  float tiled_err = skip_check ? NAN : max_abs_error(h_ref, h_tiled);

  std::cout &amp;lt;&amp;lt; &quot;kernel, avg_ms, GFLOP/s, max_abs_error&quot; &amp;lt;&amp;lt; std::endl;
  std::cout &amp;lt;&amp;lt; &quot;naive, &quot; &amp;lt;&amp;lt; naive_ms &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; gflops(M, N, K, naive_ms)
            &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; naive_err &amp;lt;&amp;lt; std::endl;
  std::cout &amp;lt;&amp;lt; &quot;tiled, &quot; &amp;lt;&amp;lt; tiled_ms &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; gflops(M, N, K, tiled_ms)
            &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; tiled_err &amp;lt;&amp;lt; std::endl;

  CUDA_CHECK(cudaFree(d_A));
  CUDA_CHECK(cudaFree(d_B));
  CUDA_CHECK(cudaFree(d_C));
  return 0;
}
&lt;/code&gt;&lt;/pre&gt;
          &lt;/div&gt;
        &lt;/details&gt;
        &lt;p&gt;运行输出会包含 correctness、max absolute error、平均耗时和 GFLOP/s。做 profiling 时可以加 &lt;code&gt;--skip-check&lt;/code&gt; 跳过 CPU reference，避免时间线里混入 CPU 端三重循环。不要把 demo 数字当成硬件上限：naive/tiled 只是教学 baseline，真正的 BF16/FP8 高性能路径还要进入 Tensor Core、pipeline、epilogue 和库级调参。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production profiling command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;nsys profile -o gemm_demo_timeline --trace=cuda,nvtx,osrt ./gemm-demo 1024 1024 1024 20 --skip-check
ncu --set full --kernel-name regex:matmul_ ./gemm-demo 1024 1024 1024 20 --skip-check&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;note&quot;&gt;如果 tiled kernel 明显快于 naive kernel，主要原因通常不是少做了计算，而是同一份 A/B tile 被 CTA 内多个线程复用，HBM traffic 相对下降。后面的 §4-§8 会把这个思路推进到 Tensor Core 级别。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;block-tiling&quot;&gt;
        &lt;h2&gt;4. Block Tiling：让一个 CTA 负责一个 C tile&lt;/h2&gt;
        &lt;p&gt;优化的第一步是把 C 切成 tile。比如一个 CTA 负责 &lt;code&gt;128 x 128&lt;/code&gt; 的 C tile。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;for block_m in range(0, M, BM):
  for block_n in range(0, N, BN):
    C_tile[BM, BN] = 0
    for block_k in range(0, K, BK):
      A_tile = A[block_m:block_m+BM, block_k:block_k+BK]
      B_tile = B[block_k:block_k+BK, block_n:block_n+BN]
      C_tile += A_tile @ B_tile&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这里的关键变化是：&lt;code&gt;A_tile&lt;/code&gt; 会被同一个 C tile 的多个列复用，&lt;code&gt;B_tile&lt;/code&gt; 会被多个行复用。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;参数&lt;/th&gt;&lt;th&gt;典型含义&lt;/th&gt;&lt;th&gt;选择影响&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;BM&lt;/td&gt;&lt;td&gt;C tile 的行数&lt;/td&gt;&lt;td&gt;影响 CTA 数量和 A 的复用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;BN&lt;/td&gt;&lt;td&gt;C tile 的列数&lt;/td&gt;&lt;td&gt;影响 B 的复用和输出写回&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;BK&lt;/td&gt;&lt;td&gt;K 维每次处理的块大小&lt;/td&gt;&lt;td&gt;影响 shared memory 占用和 pipeline 粒度&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;4.1 CTA tile、warp tile、MMA tile 是三层结构&lt;/h3&gt;
        &lt;p&gt;不要把 &lt;code&gt;BM/BN/BK&lt;/code&gt; 理解成一个孤立参数。实际 kernel 通常会把一个 CTA tile 再切给多个 warp，每个 warp 再执行多个 MMA tile。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;CTA tile:   128 x 128 x 64
Warp tile:   64 x  64 x 64   // 一个 CTA 里多个 warp 分工
MMA tile:    16 x   8 x 16   // 具体 Tensor Core 指令形状示意&lt;/code&gt;&lt;/pre&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;层级&lt;/th&gt;&lt;th&gt;谁负责&lt;/th&gt;&lt;th&gt;和下一层的关系&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;CTA tile&lt;/td&gt;&lt;td&gt;一个 CUDA block / CTA&lt;/td&gt;&lt;td&gt;切成多个 warp tile，决定 shared memory 中 A/B tile 的总体大小&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Warp tile&lt;/td&gt;&lt;td&gt;一个 warp 或 warp group&lt;/td&gt;&lt;td&gt;由多次 MMA tile 拼出来，决定每个 warp 维护多少 accumulator fragment&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;MMA tile&lt;/td&gt;&lt;td&gt;一次或一组 Tensor Core 指令&lt;/td&gt;&lt;td&gt;最小计算原语，形状由架构和 dtype 指令族决定&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;p&gt;CTA tile 太小，数据复用少，调度开销相对变大；CTA tile 太大，shared memory 和 register 使用量会上升，occupancy 下降。高性能 GEMM 本质上是在这些约束之间找平衡点。&lt;/p&gt;
        &lt;h3&gt;4.2 为什么 BK 很关键&lt;/h3&gt;
        &lt;p&gt;&lt;code&gt;BK&lt;/code&gt; 决定每个 mainloop stage 搬多少 K 维数据。BK 大会增加每次搬运的数据和 shared memory 占用，也可能让单个 stage 的计算更饱满；BK 小则 pipeline 粒度细，但 loop overhead 和同步占比可能更高。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;Shared bytes per CTA ≈ (BM * BK + BK * BN) * bytes_per_element * stages&lt;/div&gt;
        &lt;p&gt;例如 BF16 每个元素 2 bytes，&lt;code&gt;BM=128, BN=128, BK=64, stages=2&lt;/code&gt; 时，只存 A/B tile 就大约需要 &lt;code&gt;(128*64 + 64*128)*2*2 = 65536&lt;/code&gt; bytes shared memory，还没算 padding 或特殊 layout。&lt;/p&gt;
        &lt;h3&gt;4.3 BM / BN / BK 怎么量化选择&lt;/h3&gt;
        &lt;p&gt;这确实是 GEMM 最难的参数之一，因为它不是单目标优化。一个 tile shape 同时决定数据复用、CTA 数量、shared memory 占用、寄存器数量、tail 浪费、warp 分工和 Tensor Core 指令排布。&lt;/p&gt;
        &lt;p&gt;比较实用的方法不是“背一个固定组合”，而是先用资源约束过滤候选，再用 profile 选择。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;约束&lt;/th&gt;&lt;th&gt;近似判断&lt;/th&gt;&lt;th&gt;太大时的问题&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;shared memory&lt;/td&gt;&lt;td&gt;&lt;code&gt;(BM*BK + BK*BN) * bytes * stages&lt;/code&gt;&lt;/td&gt;&lt;td&gt;CTA 驻留数下降，occupancy 降低&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;accumulator 寄存器&lt;/td&gt;&lt;td&gt;&lt;code&gt;warp_tile_m * warp_tile_n&lt;/code&gt; 拆到每个 lane&lt;/td&gt;&lt;td&gt;寄存器溢出，local memory 出现&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CTA 数量&lt;/td&gt;&lt;td&gt;&lt;code&gt;ceil(M/BM) * ceil(N/BN)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;并行度不足，尤其小 M 场景&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;tail 浪费&lt;/td&gt;&lt;td&gt;&lt;code&gt;M % BM&lt;/code&gt;、&lt;code&gt;N % BN&lt;/code&gt;、&lt;code&gt;K % BK&lt;/code&gt;&lt;/td&gt;&lt;td&gt;大量线程处理无效元素&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;MMA 对齐&lt;/td&gt;&lt;td&gt;BM/BN/BK 尽量是 MMA tile 的整数倍&lt;/td&gt;&lt;td&gt;需要额外 mask 或 fallback path&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;4.4 一个可执行的选型流程&lt;/h3&gt;
        &lt;ol&gt;
          &lt;li&gt;先根据 dtype 和架构选 MMA 指令族，例如 BF16 Tensor Core 的基本 MMA 形状。&lt;/li&gt;
          &lt;li&gt;让 &lt;code&gt;BM/BN/BK&lt;/code&gt; 都对齐到 MMA 形状和 vectorized load 粒度，避免主路径里到处都是 tail。&lt;/li&gt;
          &lt;li&gt;估算 shared memory：把 &lt;code&gt;stages&lt;/code&gt; 算进去，再留出 padding / swizzle 的空间。&lt;/li&gt;
          &lt;li&gt;估算寄存器：accumulator fragment 是大头，再加 A/B fragment、地址、predicate、epilogue 临时变量。&lt;/li&gt;
          &lt;li&gt;检查 CTA 并行度：如果 &lt;code&gt;ceil(M/BM) * ceil(N/BN)&lt;/code&gt; 太小，即使单 CTA 很快，整卡也可能吃不满。&lt;/li&gt;
          &lt;li&gt;用 profile 比较候选，观察 Tensor Core 利用率、HBM 带宽、shared conflict、occupancy 和 local memory。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 候选生成的思路，不是固定答案
for BM, BN in [(64, 64), (64, 128), (128, 64), (128, 128), (128, 256)]:
  for BK in [32, 64, 128]:
    if not mma_aligned(BM, BN, BK): continue
    if smem_bytes(BM, BN, BK, stages) &gt; smem_budget: continue
    if estimated_registers(BM, BN, BK) &gt; register_budget: continue
    benchmark(BM, BN, BK)&lt;/code&gt;&lt;/pre&gt;

        &lt;h3&gt;4.5 不同 shape 的倾向&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;场景&lt;/th&gt;&lt;th&gt;tile 倾向&lt;/th&gt;&lt;th&gt;原因&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;大 M、大 N、大 K&lt;/td&gt;&lt;td&gt;较大的 BM/BN，例如 128x128 或更大候选&lt;/td&gt;&lt;td&gt;数据复用充分，CTA 数量也足够&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;小 M、大 N，例如 decode&lt;/td&gt;&lt;td&gt;较小 BM，或让一个 CTA 覆盖更多 N&lt;/td&gt;&lt;td&gt;避免 M 维浪费，同时提高 CTA 数量&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;N 很大、M 中等&lt;/td&gt;&lt;td&gt;BN 可以偏大，但要看 C 写回和寄存器&lt;/td&gt;&lt;td&gt;B tile 复用好，但 accumulator 会变多&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;K 很大&lt;/td&gt;&lt;td&gt;BK 和 stage 数要一起调&lt;/td&gt;&lt;td&gt;需要覆盖加载延迟，但 shared 占用不能爆&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;MoE / grouped GEMM&lt;/td&gt;&lt;td&gt;更小或更灵活的 tile&lt;/td&gt;&lt;td&gt;每组 shape 不规则，tail 和调度开销更明显&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;note&quot;&gt;经验值只能当候选起点。BM/BN/BK 的最终选择必须和具体 shape 分布、GPU 架构、dtype、epilogue 融合内容一起 profile。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;split-k&quot;&gt;
        &lt;h2&gt;4.6 Split-K：当 M/N 并行度不够时，拆 K 维&lt;/h2&gt;
        &lt;p&gt;前面的 block tiling 默认一个 &lt;code&gt;C_tile[BM, BN]&lt;/code&gt; 由一个 CTA 沿完整 K 维算完。这个设计在大 M、大 N 的 GEMM 上通常很好，因为 &lt;code&gt;ceil(M/BM) * ceil(N/BN)&lt;/code&gt; 已经能提供足够多 CTA。但在小 M、大 K，或者 M/N tile 数量很少的场景，整张卡可能只有很少 CTA 可调度，Tensor Core 明明很快，SM 却吃不满。&lt;/p&gt;
        &lt;p&gt;&lt;strong&gt;Split-K&lt;/strong&gt; 的想法是：不要让一个 CTA 独占完整 K 维，而是把 K 维切成多个 slice，让多个 CTA 同时计算同一个 C tile 的不同 partial sum，最后再把 partial sum reduce 成最终 C。&lt;/p&gt;

        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 普通 tiling：一个 CTA 算完整 K
for cta_m, cta_n:
  acc = 0
  for k0 in range(0, K, BK):
    acc += A[cta_m, k0] @ B[k0, cta_n]
  C[cta_m, cta_n] = acc

// Split-K：多个 CTA 分别算 K slice，然后再 reduce
for cta_m, cta_n, split_id:
  k_begin, k_end = split_range(split_id, K)
  partial = 0
  for k0 in range(k_begin, k_end, BK):
    partial += A[cta_m, k0] @ B[k0, cta_n]
  Workspace[split_id, cta_m, cta_n] = partial

reduce Workspace[:, cta_m, cta_n] -&amp;gt; C[cta_m, cta_n]&lt;/code&gt;&lt;/pre&gt;

        &lt;h3&gt;4.6.1 Split-K 解决的不是复用，而是并行度&lt;/h3&gt;
        &lt;p&gt;Split-K 不会神奇地减少总计算量。它通常还会增加额外的 workspace 写读和 reduction 成本。它真正解决的是 &lt;strong&gt;CTA 数量不足&lt;/strong&gt;：当 M/N tile 太少时，把 K 拆开可以制造更多独立 work，让更多 SM 同时工作。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;场景&lt;/th&gt;&lt;th&gt;普通 GEMM 的问题&lt;/th&gt;&lt;th&gt;Split-K 的收益&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;小 M、大 K、大 N&lt;/td&gt;&lt;td&gt;M 维 tile 很少，CTA 数不够&lt;/td&gt;&lt;td&gt;沿 K 增加 CTA 数，提高设备并行度和 SM 覆盖率&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;batched / grouped GEMM 中某些 group 很小&lt;/td&gt;&lt;td&gt;单个 group 吃不满 GPU&lt;/td&gt;&lt;td&gt;给大 K 的 group 拆更多 split，减少尾部空转&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;单个输出 tile 计算很重&lt;/td&gt;&lt;td&gt;少数 CTA 占用时间长，负载不均&lt;/td&gt;&lt;td&gt;把长 K 分摊给多个 CTA，改善调度粒度&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;4.6.2 两种 reduction 路线&lt;/h3&gt;
        &lt;p&gt;Split-K 的关键不是前半段 partial GEMM，而是后半段怎么合并 partial sums。常见有两条路线。&lt;/p&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;Workspace + second kernel&lt;/div&gt;
            &lt;p&gt;每个 split 把 partial C 写到 workspace，第二个 reduction kernel 再沿 split 维求和。&lt;/p&gt;
            &lt;p&gt;&lt;strong&gt;优点：&lt;/strong&gt;逻辑清楚，数值顺序相对可控，适合 split 数较多或 C tile 较大。&lt;/p&gt;
            &lt;p&gt;&lt;strong&gt;代价：&lt;/strong&gt;多一次 global memory 写读，多一次 kernel launch。&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;Atomic accumulate&lt;/div&gt;
            &lt;p&gt;每个 split 直接 atomic add 到最终 C。&lt;/p&gt;
            &lt;p&gt;&lt;strong&gt;优点：&lt;/strong&gt;少一个 reduction kernel，代码直观。&lt;/p&gt;
            &lt;p&gt;&lt;strong&gt;代价：&lt;/strong&gt;atomic contention、写回顺序不稳定、浮点结果可能不 deterministic。&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Split-K 数据流&lt;/div&gt;
          &lt;div class=&quot;flow&quot;&gt;
            &lt;div&gt;A/B tiles&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;K slice 0&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;K slice 1&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;K slice 2&lt;/div&gt;
            &lt;div&gt;Reduce to C&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h3&gt;4.6.3 Split-K 的选择条件&lt;/h3&gt;
        &lt;p&gt;Split-K 应该是一个 profile-driven 的开关，而不是默认打开。一个简单判断是先算普通 tiling 的 CTA 数：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;num_cta = ceil(M / BM) * ceil(N / BN)&lt;/div&gt;
        &lt;p&gt;如果 &lt;code&gt;num_cta&lt;/code&gt; 已经远大于 SM 数，Split-K 往往只会引入 reduction overhead；如果 &lt;code&gt;num_cta&lt;/code&gt; 明显小于 SM 数，且 K 很大，Split-K 才可能值得尝试。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;问题&lt;/th&gt;&lt;th&gt;判断方式&lt;/th&gt;&lt;th&gt;调参方向&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;SM 空闲但少数 CTA 执行很久&lt;/td&gt;&lt;td&gt;&lt;code&gt;nsys&lt;/code&gt; 先排除 launch gap；&lt;code&gt;ncu&lt;/code&gt; 再看 SM throughput、grid waves 和 active warps&lt;/td&gt;&lt;td&gt;增加 split 数，或减小 BM/BN 产生更多 CTA&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;HBM 写读暴涨&lt;/td&gt;&lt;td&gt;workspace traffic 增加，L2/HBM store/load 上升&lt;/td&gt;&lt;td&gt;降低 split 数，或换 atomic / fused reduction 策略&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;结果不稳定&lt;/td&gt;&lt;td&gt;多次运行 low-bit 差异，尤其 atomic accumulate&lt;/td&gt;&lt;td&gt;使用固定 reduction 顺序，或接受非 deterministic 误差边界&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;tail 变多&lt;/td&gt;&lt;td&gt;K 不能均匀切分，最后一个 split 工作量小&lt;/td&gt;&lt;td&gt;让 split 数匹配 K/BK，避免太细的 K slice&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;4.6.4 Split-K 和 Stream-K 不一样&lt;/h3&gt;
        &lt;p&gt;有些库文档还会提到 Stream-K。它和 Split-K 都是在 K 维和 tile 调度上做文章，但目标更偏向负载均衡和持续填满 SM。Split-K 更容易理解为“把一个 C tile 的 K 维拆给多个 worker”；Stream-K 通常会把全局 GEMM 的 tile/K 工作以更流式的方式分配给 worker，减少尾部不均衡。学习时可以先掌握 Split-K，再把 Stream-K 看成更工程化的调度策略。&lt;/p&gt;

        &lt;div class=&quot;warn&quot;&gt;Split-K 的常见误用：看到 K 很大就打开。K 大只是必要条件之一；如果 M/N tile 已经足够多，Split-K 的 reduction 成本可能直接吃掉收益。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;shared&quot;&gt;
        &lt;h2&gt;5. Shared Memory：把 A/B tile 搬到片上&lt;/h2&gt;
        &lt;p&gt;Block tiling 只是逻辑复用。要真正减少 HBM 访问，通常需要把当前 &lt;code&gt;A_tile&lt;/code&gt; 和 &lt;code&gt;B_tile&lt;/code&gt; 搬到 shared memory。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 伪代码
for k0 in range(0, K, BK):
  shared_A = load_global_to_shared(A_tile)
  shared_B = load_global_to_shared(B_tile)
  __syncthreads()

  for kk in range(BK):
    acc += shared_A[row, kk] * shared_B[kk, col]
  __syncthreads()&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这样 block 内线程会从 shared memory 复用 A/B 数据，而不是每次都打到 HBM。&lt;/p&gt;
        &lt;div class=&quot;blue&quot;&gt;shared memory 不是免费午餐。要关注 bank conflict、对齐、padding、load vectorization，以及 shared memory 占用对 occupancy 的影响。&lt;/div&gt;
        &lt;h3&gt;5.1 Coalesced global load&lt;/h3&gt;
        &lt;p&gt;从 HBM 搬到 shared 时，首先要让 global memory load 合并。常见做法是让每个线程搬连续的 16 bytes，例如 &lt;code&gt;float4&lt;/code&gt;、&lt;code&gt;int4&lt;/code&gt; 或等价 vectorized load。这里的 16B 是单线程指令宽度和自然对齐要求；32 个 lane 合起来会请求 512B，但这 512B 不会成为一个单独的 512B transaction。当前 CUDA 文档对 Compute Capability 6.0 及之后的通用解释，是硬件按覆盖到的 32B segment 数量合并请求。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念示意：每个线程搬 16B
int lane = threadIdx.x % 32;       // 当前线程在 warp 内的编号
int vec_id = block_thread_id;      // CTA 内连续的线性线程编号

const char* src = reinterpret_cast&amp;lt;const char*&amp;gt;(global_ptr) + vec_id * 16;
char* dst = reinterpret_cast&amp;lt;char*&amp;gt;(shared_ptr) + vec_id * 16;

// debug 时检查实际地址，而不只是检查 cudaMalloc 返回的基地址
assert((reinterpret_cast&amp;lt;uintptr_t&amp;gt;(src) &amp;amp; 0xF) == 0);
assert((reinterpret_cast&amp;lt;uintptr_t&amp;gt;(dst) &amp;amp; 0xF) == 0);

uint4 x = *reinterpret_cast&amp;lt;const uint4*&amp;gt;(src);  // 16B global load
*reinterpret_cast&amp;lt;uint4*&amp;gt;(dst) = x;              // 16B shared store&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;&lt;code&gt;uint4&lt;/code&gt; 由 4 个 32-bit 无符号整数组成，因此 &lt;code&gt;sizeof(uint4) = 4 * 4B = 16B&lt;/code&gt;。&lt;code&gt;vec_id&lt;/code&gt; 每增加 1，地址增加 16B；只要起始地址 16B 对齐，连续线程的每次 vector load 就都满足 16B 对齐。上面的 &lt;code&gt;lane&lt;/code&gt; 在简化代码里没有参与地址计算，它只是提示真实 kernel 通常还会用 lane id 设计 warp 内的数据分工。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;addr(vec_id) = base_addr + vec_id * 16；16B aligned ⇔ addr(vec_id) % 16 == 0&lt;/div&gt;
        &lt;div class=&quot;warn&quot;&gt;&lt;code&gt;reinterpret_cast&amp;lt;uint4*&amp;gt;&lt;/code&gt; 不会把一个未对齐地址“变对齐”。它只是要求编译器把该地址当作 &lt;code&gt;uint4*&lt;/code&gt; 使用。真正要检查的是加入 row、leading dimension、tile offset 后的有效地址；不满足自然对齐时，应走 scalar/masked fallback，或者调整 layout 和 padding。&lt;/div&gt;

        &lt;h4&gt;5.1.1 从矩阵下标判断 16B 对齐&lt;/h4&gt;
        &lt;p&gt;对 row-major 矩阵，线程从 &lt;code&gt;A[row, col]&lt;/code&gt; 开始搬运时，有效字节地址是：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;effective_addr = base(A) + (row * lda + col) * sizeof(T)&lt;/div&gt;
        &lt;p&gt;如果 &lt;code&gt;base(A)&lt;/code&gt; 已经 16B 对齐，那么只需继续判断 &lt;code&gt;(row * lda + col) * sizeof(T)&lt;/code&gt; 是否为 16 的倍数。注意：设备分配返回的基地址通常已经满足较强对齐，但 subview、切片、tile 起点和非整齐的 leading dimension 仍然可能破坏有效地址的对齐。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;数据类型&lt;/th&gt;&lt;th&gt;元素大小&lt;/th&gt;&lt;th&gt;一次 16B load&lt;/th&gt;&lt;th&gt;元素 offset 条件&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;FP32 / INT32&lt;/td&gt;&lt;td&gt;4B&lt;/td&gt;&lt;td&gt;4 个元素&lt;/td&gt;&lt;td&gt;&lt;code&gt;(row * lda + col) % 4 == 0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;FP16 / BF16&lt;/td&gt;&lt;td&gt;2B&lt;/td&gt;&lt;td&gt;8 个元素&lt;/td&gt;&lt;td&gt;&lt;code&gt;(row * lda + col) % 8 == 0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;FP8 / INT8&lt;/td&gt;&lt;td&gt;1B&lt;/td&gt;&lt;td&gt;16 个元素&lt;/td&gt;&lt;td&gt;&lt;code&gt;(row * lda + col) % 16 == 0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch · BF16 alignment&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// A 是 row-major BF16，base(A) 已满足 16B 对齐
const __nv_bfloat16* src = A + row * lda + k0;
bool aligned_16b =
    (reinterpret_cast&amp;lt;uintptr_t&amp;gt;(src) &amp;amp; 0xF) == 0;

// lda=128、k0 是 8 的倍数：任意 row 都满足 16B 对齐
// (row * 128 + k0) * 2B 是 16B 的倍数

// lda=130、row=1、k0=0：第二行行首没有 16B 对齐
// (1 * 130 + 0) * 2B = 260B，260 % 16 = 4&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;因此，高性能 kernel 往往会把 &lt;code&gt;lda&lt;/code&gt; padding 到 vector width 的整数倍，让 mainloop 走对齐的 16B load；对矩阵开头、结尾或 K-tail 中不满足条件的元素，再使用 masked load、标量 load，或者单独的 fallback kernel。&lt;/p&gt;

        &lt;h4 id=&quot;alignment-levels&quot;&gt;5.1.2 16B、32B、128B 和 512B 分别是什么&lt;/h4&gt;
        &lt;p&gt;&lt;strong&gt;先给结论：&lt;/strong&gt;warp 在这段代码里总共请求 512B，但 512B 只是 payload，不是 transaction size，所以没有“warp 首地址必须 512B 对齐”的规则。对齐要求应该跟它所属的层级一起读。&lt;/p&gt;
        &lt;div class=&quot;alignment-levels&quot;&gt;
          &lt;div class=&quot;alignment-level&quot;&gt;&lt;strong&gt;单个 lane&lt;/strong&gt;&lt;span class=&quot;value&quot;&gt;16B&lt;/span&gt;&lt;code&gt;uint4&lt;/code&gt; load 的数据宽度和自然对齐。每个线程的实际地址必须是 16 的倍数。&lt;/div&gt;
          &lt;div class=&quot;alignment-level&quot;&gt;&lt;strong&gt;Warp payload&lt;/strong&gt;&lt;span class=&quot;value&quot;&gt;32 × 16B = 512B&lt;/span&gt;32 个 lane 在一条指令里合计需要的数据量。它描述“要多少数据”，不描述“一次搬多少”。&lt;/div&gt;
          &lt;div class=&quot;alignment-level&quot;&gt;&lt;strong&gt;Global transaction&lt;/strong&gt;&lt;span class=&quot;value&quot;&gt;32B&lt;/span&gt;当前 CUDA 文档对 Compute Capability 6.0+ 的通用 coalescing 模型。warp 请求会拆成覆盖这些地址所需的若干 32B transaction。&lt;/div&gt;
          &lt;div class=&quot;alignment-level&quot;&gt;&lt;strong&gt;Cache line / tile&lt;/strong&gt;&lt;span class=&quot;value&quot;&gt;常见 128B&lt;/span&gt;可用于 L1/cache-line、旧架构 segment 或 GEMM tile/stage 的强化对齐，但不是 warp 的统一硬性要求。&lt;/div&gt;
        &lt;/div&gt;

        &lt;h5&gt;5.1.2.1 为什么 512B payload 不要求 512B 对齐&lt;/h5&gt;
        &lt;p&gt;一条 warp load 发出后，coalescer 会统计 32 个 lane 的地址覆盖了多少个 transaction segment，而不是把所有 lane 拼成一个 512B 原子 transaction。对于连续的 16B-per-lane 访问：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;lane L 访问 [base + 16L, base + 16L + 15]；warp 覆盖 [base, base + 511]&lt;/div&gt;
        &lt;div class=&quot;formula&quot;&gt;32B transaction 数 = floor((base + 511) / 32) - floor(base / 32) + 1&lt;/div&gt;
        &lt;p&gt;只要 &lt;code&gt;base % 32 == 0&lt;/code&gt;，512B 连续范围就正好覆盖 &lt;code&gt;512 / 32 = 16&lt;/code&gt; 个 transaction。把 base 从 128B 对齐进一步提高到 512B 对齐，并不会把 16 个 transaction 继续减少。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Warp 首地址&lt;/th&gt;&lt;th&gt;满足的对齐&lt;/th&gt;&lt;th&gt;访问范围&lt;/th&gt;&lt;th&gt;32B transaction&lt;/th&gt;&lt;th&gt;覆盖的 128B line&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;0x080&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16B / 32B / 128B；不是 512B&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x080...0x27F&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;0x200&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16B / 32B / 128B / 512B&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x200...0x3FF&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;0x020&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16B / 32B；不是 128B&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x020...0x21F&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;5&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;0x010&lt;/code&gt;&lt;/td&gt;&lt;td&gt;只有 16B；不是 32B&lt;/td&gt;&lt;td&gt;&lt;code&gt;0x010...0x20F&lt;/code&gt;&lt;/td&gt;&lt;td&gt;17&lt;/td&gt;&lt;td&gt;5&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;div class=&quot;transaction-case&quot;&gt;
          &lt;div class=&quot;transaction-case-title&quot;&gt;Case A：base = 0x080，128B 对齐但不是 512B 对齐&lt;/div&gt;
          &lt;div class=&quot;transaction-case-meta&quot;&gt;512B payload 正好占 16 个 32B segment；每 4 格组成一个 128B line，共 4 条 line。&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;transaction-strip count-16&quot;&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T0&lt;br&gt;080-09F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T1&lt;br&gt;0A0-0BF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T2&lt;br&gt;0C0-0DF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T3&lt;br&gt;0E0-0FF&lt;/div&gt;
              &lt;div class=&quot;transaction-cell alt&quot;&gt;T4&lt;br&gt;100-11F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T5&lt;br&gt;120-13F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T6&lt;br&gt;140-15F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T7&lt;br&gt;160-17F&lt;/div&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T8&lt;br&gt;180-19F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T9&lt;br&gt;1A0-1BF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T10&lt;br&gt;1C0-1DF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T11&lt;br&gt;1E0-1FF&lt;/div&gt;
              &lt;div class=&quot;transaction-cell alt&quot;&gt;T12&lt;br&gt;200-21F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T13&lt;br&gt;220-23F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T14&lt;br&gt;240-25F&lt;/div&gt;&lt;div class=&quot;transaction-cell alt&quot;&gt;T15&lt;br&gt;260-27F&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;transaction-summary&quot;&gt;&lt;span&gt;16 × 32B transaction&lt;/span&gt;&lt;span&gt;4 × 128B line&lt;/span&gt;&lt;span&gt;0 个额外 segment&lt;/span&gt;&lt;/div&gt;
        &lt;/div&gt;

        &lt;div class=&quot;transaction-case&quot;&gt;
          &lt;div class=&quot;transaction-case-title&quot;&gt;Case B：base = 0x010，只满足每线程 16B 对齐&lt;/div&gt;
          &lt;div class=&quot;transaction-case-meta&quot;&gt;lane 0 从一个 32B segment 的中间开始，warp 末尾也落在另一个 segment 的前半段，所以首尾各有半个 transaction 没被充分利用。&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;transaction-strip count-17&quot;&gt;
              &lt;div class=&quot;transaction-cell partial&quot;&gt;T0&lt;br&gt;000-01F&lt;br&gt;只用后16B&lt;/div&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T1&lt;br&gt;020-03F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T2&lt;br&gt;040-05F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T3&lt;br&gt;060-07F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T4&lt;br&gt;080-09F&lt;/div&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T5&lt;br&gt;0A0-0BF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T6&lt;br&gt;0C0-0DF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T7&lt;br&gt;0E0-0FF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T8&lt;br&gt;100-11F&lt;/div&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T9&lt;br&gt;120-13F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T10&lt;br&gt;140-15F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T11&lt;br&gt;160-17F&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T12&lt;br&gt;180-19F&lt;/div&gt;
              &lt;div class=&quot;transaction-cell&quot;&gt;T13&lt;br&gt;1A0-1BF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T14&lt;br&gt;1C0-1DF&lt;/div&gt;&lt;div class=&quot;transaction-cell&quot;&gt;T15&lt;br&gt;1E0-1FF&lt;/div&gt;
              &lt;div class=&quot;transaction-cell partial&quot;&gt;T16&lt;br&gt;200-21F&lt;br&gt;只用前16B&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;transaction-summary&quot;&gt;&lt;span&gt;17 × 32B transaction&lt;/span&gt;&lt;span&gt;5 × 128B line&lt;/span&gt;&lt;span&gt;多覆盖 32B segment&lt;/span&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;blue&quot;&gt;&lt;strong&gt;因此答案是：&lt;/strong&gt;&lt;code&gt;0x080&lt;/code&gt; 虽然不是 512B 对齐，但已经落在 32B transaction 边界上，所以和 &lt;code&gt;0x200&lt;/code&gt; 一样只需要 16 个 transaction。512B 对齐没有进一步减少请求数量。&lt;/div&gt;

        &lt;h5&gt;5.1.2.2 那为什么 GEMM 里仍经常看到 128B 对齐&lt;/h5&gt;
        &lt;p&gt;128B 属于更高一级的布局选择，而不是由 &lt;code&gt;32 lanes × 16B&lt;/code&gt; 推导出来的 warp 对齐要求。它常见有三个原因：&lt;/p&gt;
        &lt;ol&gt;
          &lt;li&gt;&lt;strong&gt;Cache-line / segment 边界：&lt;/strong&gt;部分旧架构和文档用 128B L1 segment 解释 coalescing；即使当前数据访问单元按 32B 计算，128B 对齐也能让四个连续 32B sector 自然落入同一条 128B line。&lt;/li&gt;
          &lt;li&gt;&lt;strong&gt;Tile 和 pipeline stage 易于管理：&lt;/strong&gt;GEMM 会反复搬运 A/B tile。让每行或每个 stage 从 128B 边界开始，地址计算、cache-line 利用、shared layout 和异步流水线通常更规整。&lt;/li&gt;
          &lt;li&gt;&lt;strong&gt;历史 API 性能指导：&lt;/strong&gt;部分旧版 &lt;code&gt;cuda::memcpy_async&lt;/code&gt; 文档曾建议 global/shared 都按 128B 对齐。当前 Cooperative Groups 文档则推荐 16B，因此这不是跨版本、跨 API 的统一硬规则。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;p&gt;&lt;code&gt;base=0x020&lt;/code&gt; 是一个有用的反例：它已经 32B 对齐，因此仍是最少的 16 个 32B transaction；但 512B 范围会跨 5 条 128B line。也就是说，128B 对齐可能改善 cache-line/tile 组织，却不等于它是 coalescing 的最低门槛。&lt;/p&gt;

        &lt;h5&gt;5.1.2.3 Async copy 应该检查哪种对齐&lt;/h5&gt;
        &lt;p&gt;低层 &lt;code&gt;cp.async&lt;/code&gt; 家族按线程支持 4B、8B、16B copy，指针至少要满足所选 copy size 的自然对齐。对于本节每线程 16B 的写法，首先必须证明 global source 和 shared destination 都满足 16B 对齐。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;必须满足：src_lane % 16 == 0 且 dst_lane % 16 == 0&lt;/div&gt;
        &lt;p&gt;至于 tile 是否进一步 32B、128B 或更高对齐，要看具体 CUDA 版本、API、架构以及使用的是 &lt;code&gt;cp.async&lt;/code&gt;、Cooperative Groups、TMA 还是其他 copy atom。不要把某个 API 某一版文档的“最佳性能建议”改写成所有 warp load 的硬件要求。&lt;/p&gt;

        &lt;h5&gt;5.1.2.4 实际写 kernel 时按这个顺序判断&lt;/h5&gt;
        &lt;ol&gt;
          &lt;li&gt;检查每个 lane 的实际地址：16B vector load 必须满足 &lt;code&gt;addr % 16 == 0&lt;/code&gt;。&lt;/li&gt;
          &lt;li&gt;检查 lane 间地址是否连续，确保请求能被 coalescer 合并。&lt;/li&gt;
          &lt;li&gt;在当前 32B transaction 模型下，检查 warp 首地址是否满足 &lt;code&gt;base % 32 == 0&lt;/code&gt;，避免首尾多覆盖一个 segment。&lt;/li&gt;
          &lt;li&gt;把 128B 当作常见的 tile/cache-line 强化对齐，再通过 profile 判断它是否有额外收益。&lt;/li&gt;
          &lt;li&gt;只有具体 copy API、TMA descriptor 或自定义 allocator 明确要求时，才继续要求 256B、512B 等更强对齐；不要从 warp payload 大小反推对齐要求。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;div class=&quot;note&quot;&gt;进一步阅读：&lt;a href=&quot;https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-cuda-kernels.html#coalesced-global-memory-access&quot;&gt;当前 CUDA Programming Guide：Coalesced Global Memory Access&lt;/a&gt;；&lt;a href=&quot;https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/cooperative-groups.html#memcpy-async-alignment-requirements&quot;&gt;Cooperative Groups：Memcpy Async Alignment Requirements&lt;/a&gt;。&lt;/div&gt;

        &lt;h3 id=&quot;bank-conflict&quot;&gt;5.2 Bank conflict 是什么&lt;/h3&gt;
        &lt;p&gt;Bank conflict 不是“多个线程同时访问 shared memory”这么简单。真正的判断条件是：&lt;strong&gt;同一个 warp 发出一次 shared memory 指令时，是否有多个 lane 访问了同一个 bank 中的不同地址&lt;/strong&gt;。如果是，硬件就要把这次请求拆成多轮；如果 32 个 lane 的地址落到 32 个不同 bank，则这些 bank 可以并行服务。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;下面使用 NVIDIA Compute Capability 5.x 及之后常用的教学模型：shared memory 有 32 个 bank，每个 bank 每周期提供一个 32-bit word 的带宽，连续 32-bit word 依次映射到 bank 0...31。更宽的 load 会被拆成多个 transaction 分析，具体端口和调度细节随架构变化。AMD LDS 的思想相近，但 bank 数、wave 大小和一次 LDS 指令的分相规则可能不同，不能把本节的 32-lane 公式逐字照搬。&lt;/div&gt;

        &lt;h4&gt;5.2.1 Bank 到底是什么：先看 shared memory 的硬件模型&lt;/h4&gt;
        &lt;p&gt;从 CUDA 程序看，shared memory 是一个普通的线性地址空间；你声明的是数组或 byte buffer，并不会手工选择 bank。硬件为了让一个 warp 的多个地址能够并行访问，把这片片上 SRAM 在逻辑上组织成 32 个可同时工作的带宽分区，这些分区就是 &lt;strong&gt;bank&lt;/strong&gt;。&lt;/p&gt;
        &lt;p&gt;可以把一次 shared load 想成下面的流水：warp 提供最多 32 个 lane address；地址解码器从每个地址里算出 bank id 和 bank 内位置；路由网络把请求送到 32 个 bank。不同 bank 可以并行返回，同一 bank 的不同位置则需要拆成多轮。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;概念硬件图：Warp → 地址解码与路由 → 32 个 Shared Memory Bank&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;bank-hardware-pipeline&quot;&gt;
              &lt;div class=&quot;hardware-stage&quot;&gt;
                &lt;div class=&quot;hardware-stage-title&quot;&gt;Warp 发出一条 shared-memory 指令&lt;/div&gt;
                &lt;div class=&quot;hardware-lanes&quot;&gt;
                  &lt;div class=&quot;hardware-lane&quot;&gt;L0 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L1 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L2 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L3 addr&lt;/div&gt;
                  &lt;div class=&quot;hardware-lane&quot;&gt;L4 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L5 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L6 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L7 addr&lt;/div&gt;
                  &lt;div class=&quot;hardware-lane&quot;&gt;...&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L29 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L30 addr&lt;/div&gt;&lt;div class=&quot;hardware-lane&quot;&gt;L31 addr&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;hardware-arrow&quot;&gt;→&lt;/div&gt;
              &lt;div class=&quot;hardware-stage&quot;&gt;
                &lt;div class=&quot;hardware-stage-title&quot;&gt;地址解码器 + 32-way 路由&lt;/div&gt;
                &lt;div class=&quot;decoder-formula&quot;&gt;word = addr &gt;&gt; 2&lt;/div&gt;
                &lt;div class=&quot;decoder-formula&quot;&gt;bank = word &amp;amp; 0x1F&lt;/div&gt;
                &lt;div class=&quot;decoder-formula&quot;&gt;depth = word &gt;&gt; 5&lt;/div&gt;
                &lt;p class=&quot;hardware-stage-note&quot;&gt;低位选择 bank，高位选择该 bank 内的 32-bit word&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;hardware-arrow&quot;&gt;→&lt;/div&gt;
              &lt;div class=&quot;hardware-stage&quot;&gt;
                &lt;div class=&quot;hardware-stage-title&quot;&gt;32 个可并行服务的 bank&lt;/div&gt;
                &lt;div class=&quot;bank-port-grid&quot;&gt;
                  &lt;div class=&quot;bank-port&quot;&gt;B0&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B1&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B2&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B3&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B4&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B5&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B6&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B7&lt;/div&gt;
                  &lt;div class=&quot;bank-port&quot;&gt;B8&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B9&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B10&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B11&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B12&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B13&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B14&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B15&lt;/div&gt;
                  &lt;div class=&quot;bank-port&quot;&gt;B16&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B17&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B18&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B19&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B20&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B21&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B22&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B23&lt;/div&gt;
                  &lt;div class=&quot;bank-port&quot;&gt;B24&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B25&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B26&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B27&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B28&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B29&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B30&lt;/div&gt;&lt;div class=&quot;bank-port&quot;&gt;B31&lt;/div&gt;
                &lt;/div&gt;
                &lt;p class=&quot;hardware-stage-note&quot;&gt;教学模型：每个 bank 每周期提供一个 32-bit word 的带宽&lt;/p&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;p&gt;Bank 不是只保存一个 word。每个 bank 内部还有很多位置。连续地址会横向铺到 B0...B31，铺满后再回到 B0 的下一个 depth。下面只画前 8 个 bank；真实硬件同一行还有 B8...B31。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Shared memory 的“bank × depth”视图：橙色列都是 Bank 0，但地址不同&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;bank-array&quot;&gt;
              &lt;div class=&quot;bank-array-cell axis&quot;&gt;内部位置&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 0&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 1&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 2&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 3&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 4&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 5&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 6&lt;/div&gt;&lt;div class=&quot;bank-array-cell axis&quot;&gt;Bank 7&lt;/div&gt;
              &lt;div class=&quot;bank-array-cell axis&quot;&gt;depth 0&lt;/div&gt;&lt;div class=&quot;bank-array-cell same-bank&quot;&gt;word 0&lt;br&gt;addr 0B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 1&lt;br&gt;addr 4B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 2&lt;br&gt;addr 8B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 3&lt;br&gt;addr 12B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 4&lt;br&gt;addr 16B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 5&lt;br&gt;addr 20B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 6&lt;br&gt;addr 24B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 7&lt;br&gt;addr 28B&lt;/div&gt;
              &lt;div class=&quot;bank-array-cell axis&quot;&gt;depth 1&lt;/div&gt;&lt;div class=&quot;bank-array-cell same-bank&quot;&gt;word 32&lt;br&gt;addr 128B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 33&lt;br&gt;addr 132B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 34&lt;br&gt;addr 136B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 35&lt;br&gt;addr 140B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 36&lt;br&gt;addr 144B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 37&lt;br&gt;addr 148B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 38&lt;br&gt;addr 152B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 39&lt;br&gt;addr 156B&lt;/div&gt;
              &lt;div class=&quot;bank-array-cell axis&quot;&gt;depth 2&lt;/div&gt;&lt;div class=&quot;bank-array-cell same-bank&quot;&gt;word 64&lt;br&gt;addr 256B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 65&lt;br&gt;addr 260B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 66&lt;br&gt;addr 264B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 67&lt;br&gt;addr 268B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 68&lt;br&gt;addr 272B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 69&lt;br&gt;addr 276B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 70&lt;br&gt;addr 280B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 71&lt;br&gt;addr 284B&lt;/div&gt;
              &lt;div class=&quot;bank-array-cell axis&quot;&gt;depth 3&lt;/div&gt;&lt;div class=&quot;bank-array-cell same-bank&quot;&gt;word 96&lt;br&gt;addr 384B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 97&lt;br&gt;addr 388B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 98&lt;br&gt;addr 392B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 99&lt;br&gt;addr 396B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 100&lt;br&gt;addr 400B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 101&lt;br&gt;addr 404B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 102&lt;br&gt;addr 408B&lt;/div&gt;&lt;div class=&quot;bank-array-cell&quot;&gt;word 103&lt;br&gt;addr 412B&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;formula&quot;&gt;32-bit 对齐地址中：address bits [1:0] 是 byte-in-word；bits [6:2] 选择 32 个 bank；bits [7+] 选择 bank 内 depth&lt;/div&gt;
        &lt;p&gt;BF16/FP16 元素只有 2B，所以两个相邻元素位于同一个 32-bit bank word；FP8/INT8 则一个 word 可容纳四个元素。真实 kernel 常使用 packed/vector load、&lt;code&gt;ldmatrix&lt;/code&gt; 或更宽 transaction，分析时要把实际指令拆成它触及的 32-bit bank word，不能机械地把“一个元素”当成“一个 bank”。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;图里的 &lt;code&gt;depth&lt;/code&gt; 是为了理解硬件地址映射而使用的概念名称，不是 GEMM 矩阵的 row，也不是 CUDA API 暴露出来的可编程维度。程序仍然只看到一段线性 shared address。&lt;/div&gt;

        &lt;p&gt;把路由结果分成三种情况，Bank conflict 的定义就很直观：&lt;/p&gt;
        &lt;div class=&quot;bank-scenarios&quot;&gt;
          &lt;div class=&quot;bank-scenario&quot;&gt;
            &lt;div class=&quot;bank-scenario-title ok&quot;&gt;无冲突：不同 bank&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L0: word0&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L1: word1&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B1 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L2: word2&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B2 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;p&gt;每个 bank 只收到一个地址，可以并行服务。&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;bank-scenario&quot;&gt;
            &lt;div class=&quot;bank-scenario-title conflict&quot;&gt;Conflict：同 bank，不同地址&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L0: word0&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L1: word32&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth1&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L2: word64&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth2&lt;/span&gt;&lt;/div&gt;
            &lt;p&gt;B0 一次收到多个不同位置，需要拆分或 replay。&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;bank-scenario&quot;&gt;
            &lt;div class=&quot;bank-scenario-title broadcast&quot;&gt;Broadcast：同 bank，同地址&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L0: word0&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L1: word0&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;bank-route&quot;&gt;&lt;span&gt;L2: word0&lt;/span&gt;&lt;span class=&quot;route-arrow&quot;&gt;→&lt;/span&gt;&lt;span&gt;B0 / depth0&lt;/span&gt;&lt;/div&gt;
            &lt;p&gt;地址完全相同，读取结果可以广播给多个 lane。&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;blue&quot;&gt;&lt;strong&gt;一句话心智模型：&lt;/strong&gt;Bank 像 32 条可以并行工作的 shared-memory 服务通道。冲突不是“走了同一条通道”，而是“同一周期要这条通道返回多个不同位置”；请求同一个位置则可以广播。&lt;/div&gt;

        &lt;h4&gt;5.2.2 地址怎样映射到 bank&lt;/h4&gt;
        &lt;div class=&quot;formula&quot;&gt;word_index = byte_address / 4；bank_id = word_index % 32&lt;/div&gt;
        &lt;p&gt;因此前 32 个 32-bit word 分别进入 bank 0 到 bank 31；第 32 个 word 又回到 bank 0。Bank 是交错编址，不是“bank 0 存一整段地址、bank 1 再存下一整段”。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;连续 32-bit word 在 32 个 bank 中轮转&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;bank-cycle&quot;&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 0&lt;br&gt;B0&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 1&lt;br&gt;B1&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 2&lt;br&gt;B2&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 3&lt;br&gt;B3&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 4&lt;br&gt;B4&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 5&lt;br&gt;B5&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 6&lt;br&gt;B6&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 7&lt;br&gt;B7&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 8&lt;br&gt;B8&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 9&lt;br&gt;B9&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 10&lt;br&gt;B10&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 11&lt;br&gt;B11&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 12&lt;br&gt;B12&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 13&lt;br&gt;B13&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 14&lt;br&gt;B14&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 15&lt;br&gt;B15&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 16&lt;br&gt;B16&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 17&lt;br&gt;B17&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 18&lt;br&gt;B18&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 19&lt;br&gt;B19&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 20&lt;br&gt;B20&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 21&lt;br&gt;B21&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 22&lt;br&gt;B22&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 23&lt;br&gt;B23&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 24&lt;br&gt;B24&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 25&lt;br&gt;B25&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 26&lt;br&gt;B26&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 27&lt;br&gt;B27&lt;/div&gt;
              &lt;div class=&quot;bank-word&quot;&gt;word 28&lt;br&gt;B28&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 29&lt;br&gt;B29&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 30&lt;br&gt;B30&lt;/div&gt;&lt;div class=&quot;bank-word&quot;&gt;word 31&lt;br&gt;B31&lt;/div&gt;
              &lt;div class=&quot;bank-word cycle&quot;&gt;word 32&lt;br&gt;又回到 B0&lt;/div&gt;&lt;div class=&quot;bank-word cycle&quot;&gt;word 33&lt;br&gt;又回到 B1&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Conflict&lt;/div&gt;多个 lane 落到同一 bank，且读取的是不同 word。例如 lane 0 读 word 0、lane 1 读 word 32：两者都是 B0，但地址不同，需要拆开。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Broadcast 例外&lt;/div&gt;多个 lane 读取完全相同的 shared address 时，硬件可以广播该 word，不算 bank conflict。“同 bank”不够，还要看是不是“不同地址”。&lt;/div&gt;
        &lt;/div&gt;

        &lt;h4&gt;5.2.3 把问题放回 GEMM：一个 warp 读取 A 的同一列&lt;/h4&gt;
        &lt;p&gt;考虑一个教学用的 warp 映射。把两个 BF16 打包成一个 32-bit word，shared A tile 记作 &lt;code&gt;A_pack[32][32]&lt;/code&gt;；它在 K 方向覆盖 64 个 BF16。warp 的 lane &lt;code&gt;r&lt;/code&gt; 负责输出列 &lt;code&gt;n0&lt;/code&gt; 上的不同行，因此在某个固定 &lt;code&gt;k_pair&lt;/code&gt; 上执行：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;lane r：C[r, n0] += A_pack[r, k_pair] * B_pack[k_pair, n0]&lt;/div&gt;
        &lt;p&gt;当 &lt;code&gt;k_pair=0&lt;/code&gt; 时，lane 0...31 要读取 A tile 的同一逻辑列 &lt;code&gt;A_pack[0...31][0]&lt;/code&gt;。B 侧所有 lane 读取的是完全相同的 &lt;code&gt;B_pack[0][n0]&lt;/code&gt;，可以 broadcast；真正出问题的是 A 侧“同列、不同地址”的读取。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;一个 K step：A 的纵向读取 × B 的广播 → 更新 C 的一列&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;gemm-bank-flow&quot;&gt;
              &lt;div class=&quot;gemm-tile&quot;&gt;
                &lt;div class=&quot;gemm-tile-title&quot;&gt;A_pack[32][32]：每个 lane 读一行的 k0&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;lane&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;k0&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;k1&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;k31&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L0 / r0&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;A[0,0]&lt;/span&gt;&lt;span&gt;A[0,1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;A[0,31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L1 / r1&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;A[1,0]&lt;/span&gt;&lt;span&gt;A[1,1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;A[1,31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L2 / r2&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;A[2,0]&lt;/span&gt;&lt;span&gt;A[2,1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;A[2,31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L3 / r3&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;A[3,0]&lt;/span&gt;&lt;span&gt;A[3,1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;A[3,31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L31 / r31&lt;/span&gt;&lt;span class=&quot;focus-a&quot;&gt;A[31,0]&lt;/span&gt;&lt;span&gt;A[31,1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;A[31,31]&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;gemm-op&quot;&gt;×&lt;/div&gt;
              &lt;div class=&quot;gemm-tile&quot;&gt;
                &lt;div class=&quot;gemm-tile-title&quot;&gt;B_pack：同一个 word 广播&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n0&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n1&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n31&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;k0&lt;/span&gt;&lt;span class=&quot;focus-b&quot;&gt;B[0,n0]&lt;/span&gt;&lt;span&gt;B[0,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;B[0,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;k1&lt;/span&gt;&lt;span&gt;B[1,n0]&lt;/span&gt;&lt;span&gt;B[1,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;B[1,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;k31&lt;/span&gt;&lt;span&gt;B[31,n0]&lt;/span&gt;&lt;span&gt;B[31,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;B[31,n31]&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;gemm-op&quot;&gt;→&lt;/div&gt;
              &lt;div class=&quot;gemm-tile&quot;&gt;
                &lt;div class=&quot;gemm-tile-title&quot;&gt;C：每个 lane 更新不同输出行&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;lane&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n0&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n1&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;axis&quot;&gt;n31&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L0 / r0&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;C[0,n0]&lt;/span&gt;&lt;span&gt;C[0,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;C[0,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L1 / r1&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;C[1,n0]&lt;/span&gt;&lt;span&gt;C[1,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;C[1,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L2 / r2&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;C[2,n0]&lt;/span&gt;&lt;span&gt;C[2,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;C[2,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L3 / r3&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;C[3,n0]&lt;/span&gt;&lt;span&gt;C[3,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;C[3,n31]&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;gemm-tile-row&quot;&gt;&lt;span class=&quot;axis&quot;&gt;L31 / r31&lt;/span&gt;&lt;span class=&quot;focus-c&quot;&gt;C[31,n0]&lt;/span&gt;&lt;span&gt;C[31,n1]&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;C[31,n31]&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h4&gt;5.2.4 普通 row-major layout 为什么产生 32-way conflict&lt;/h4&gt;
        &lt;p&gt;&lt;code&gt;A_pack[32][32]&lt;/code&gt; 的一行正好是 32 个 32-bit word。普通 row-major 下：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;word_index(L) = L * 32 + k_pair；bank(L) = (L * 32 + k_pair) % 32 = k_pair&lt;/div&gt;
        &lt;p&gt;固定 &lt;code&gt;k_pair=0&lt;/code&gt; 后，无论 lane 是多少，bank 都是 0。每个 lane 读的是不同 row，因此地址不同，不能 broadcast；硬件必须把一次 warp request 拆成最多 32 轮 conflict-free request，这就是 32-way bank conflict。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Lane&lt;/th&gt;&lt;th&gt;逻辑元素&lt;/th&gt;&lt;th&gt;32-bit word index&lt;/th&gt;&lt;th&gt;相对 byte address&lt;/th&gt;&lt;th&gt;Bank&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;L0&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[0][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0B&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L1&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[1][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;128B&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L2&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[2][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;256B&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L3&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[3][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;96&lt;/td&gt;&lt;td&gt;384B&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L31&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[31][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;992&lt;/td&gt;&lt;td&gt;3968B&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;普通 layout：32 个 lane 全部落到 B0，但访问 32 个不同地址&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;lane-map-grid&quot;&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L0 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L1 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L2 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L3 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L4 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L5 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L6 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L7 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L8 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L9 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L10 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L11 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L12 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L13 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L14 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L15 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L16 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L17 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L18 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L19 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L20 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L21 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L22 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L23 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L24 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L25 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L26 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L27 → B0&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell conflict&quot;&gt;L28 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L29 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L30 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell conflict&quot;&gt;L31 → B0&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;bank-result&quot;&gt;
            &lt;div class=&quot;bank-result-label&quot;&gt;Bank 0&lt;br&gt;32 个不同 word&lt;/div&gt;
            &lt;div class=&quot;bank-result-body&quot;&gt;
              &lt;span class=&quot;access-chip conflict&quot;&gt;L0@0B&lt;/span&gt;&lt;span class=&quot;access-chip conflict&quot;&gt;L1@128B&lt;/span&gt;&lt;span class=&quot;access-chip conflict&quot;&gt;L2@256B&lt;/span&gt;&lt;span class=&quot;access-chip conflict&quot;&gt;L3@384B&lt;/span&gt;&lt;span class=&quot;access-chip conflict&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;access-chip conflict&quot;&gt;L31@3968B&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;warn&quot;&gt;不要把这个 A 访问和 B 的读取混为一谈：32 个 lane 都读同一个 &lt;code&gt;B_pack[0][n0]&lt;/code&gt; 时是同地址 broadcast；32 个 lane 读 &lt;code&gt;A_pack[0...31][0]&lt;/code&gt; 时虽然 bank 相同，但地址不同，所以是 conflict。&lt;/div&gt;

        &lt;h4&gt;5.2.5 Swizzle：不改逻辑矩阵，只改物理地址&lt;/h4&gt;
        &lt;p&gt;Swizzle 的核心是对 shared memory 的地址做一个可逆置换。写入和读取都使用同一映射，所以数学上仍然是原来的 &lt;code&gt;A[row][col]&lt;/code&gt;；只是逻辑列不再总是落在相同的物理列和 bank。为了把原理画清楚，先使用最简单的 32-bit word 级 XOR：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch · word-level XOR swizzle&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 教学映射：tile width 是 32 个 32-bit word
physical_col = logical_col ^ row;

// global -&gt; shared：把逻辑元素写到置换后的物理位置
smem[row][physical_col] = A_pack[row][logical_col];

// shared -&gt; register：用同一映射找回原来的逻辑元素
x = smem[row][logical_col ^ row];&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;8×8 裁剪图：橙色都表示逻辑 k0；Swizzle 后它从竖直一列变成物理对角线&lt;/div&gt;
          &lt;div class=&quot;bank-layout-pair&quot;&gt;
            &lt;div class=&quot;bank-layout-panel&quot;&gt;
              &lt;div class=&quot;mini-title&quot;&gt;普通 row-major：logical k0 永远位于 physical p0&lt;/div&gt;
              &lt;div class=&quot;bank-scroll&quot;&gt;
                &lt;div class=&quot;swizzle-matrix&quot;&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p0&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p1&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p2&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p3&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p4&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p5&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p6&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r0&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r1&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r2&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r3&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r4&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r5&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r6&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r7&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;bank-layout-panel&quot;&gt;
              &lt;div class=&quot;mini-title&quot;&gt;XOR swizzle：physical_col = logical_col ^ row&lt;/div&gt;
              &lt;div class=&quot;bank-scroll&quot;&gt;
                &lt;div class=&quot;swizzle-matrix&quot;&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p0&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p1&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p2&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p3&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p4&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p5&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p6&lt;/div&gt;&lt;div class=&quot;swizzle-cell axis&quot;&gt;p7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r0&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;
                  &lt;div class=&quot;swizzle-cell axis&quot;&gt;r7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k7&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k6&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k5&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k4&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k3&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k2&lt;/div&gt;&lt;div class=&quot;swizzle-cell&quot;&gt;k1&lt;/div&gt;&lt;div class=&quot;swizzle-cell logical-k0&quot;&gt;k0&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;Swizzle 后，在固定 &lt;code&gt;k_pair&lt;/code&gt; 时：&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;physical_col(L) = k_pair ^ L；bank(L) = (L * 32 + (k_pair ^ L)) % 32 = k_pair ^ L&lt;/div&gt;
        &lt;p&gt;对固定的 &lt;code&gt;k_pair&lt;/code&gt;，XOR 是一个一一映射：lane 0...31 会得到 0...31 的某种排列，不会有两个 lane 落到同一个 bank。以 &lt;code&gt;k_pair=0&lt;/code&gt; 为例，physical column 就等于 lane id：&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Swizzle 后：32 个 lane 分散到 32 个 bank&lt;/div&gt;
          &lt;div class=&quot;bank-scroll&quot;&gt;
            &lt;div class=&quot;lane-map-grid&quot;&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L0 → B0&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L1 → B1&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L2 → B2&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L3 → B3&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L4 → B4&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L5 → B5&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L6 → B6&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L7 → B7&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L8 → B8&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L9 → B9&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L10 → B10&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L11 → B11&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L12 → B12&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L13 → B13&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L14 → B14&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L15 → B15&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L16 → B16&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L17 → B17&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L18 → B18&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L19 → B19&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L20 → B20&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L21 → B21&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L22 → B22&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L23 → B23&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L24 → B24&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L25 → B25&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L26 → B26&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L27 → B27&lt;/div&gt;
              &lt;div class=&quot;lane-map-cell ok&quot;&gt;L28 → B28&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L29 → B29&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L30 → B30&lt;/div&gt;&lt;div class=&quot;lane-map-cell ok&quot;&gt;L31 → B31&lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Lane&lt;/th&gt;&lt;th&gt;逻辑元素&lt;/th&gt;&lt;th&gt;Swizzle 后物理元素&lt;/th&gt;&lt;th&gt;word index&lt;/th&gt;&lt;th&gt;Bank&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;L0&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[0][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;smem[0][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;B0&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L1&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[1][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;smem[1][1]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;33&lt;/td&gt;&lt;td&gt;B1&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L2&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[2][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;smem[2][2]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;66&lt;/td&gt;&lt;td&gt;B2&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L3&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[3][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;smem[3][3]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;99&lt;/td&gt;&lt;td&gt;B3&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;L31&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_pack[31][0]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;smem[31][31]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1023&lt;/td&gt;&lt;td&gt;B31&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;blue&quot;&gt;&lt;strong&gt;关键点：&lt;/strong&gt;Swizzle 没有转置 A，也没有改变 &lt;code&gt;C=A×B&lt;/code&gt;。它只改变逻辑坐标到 shared physical address 的映射。生产者写入和消费者读取都经过同一个可逆映射，因此取出的仍是同一个逻辑元素。&lt;/div&gt;

        &lt;h4&gt;5.2.6 为什么生产 kernel 的 Swizzle 看起来更复杂&lt;/h4&gt;
        &lt;p&gt;&lt;code&gt;physical_col = logical_col ^ row&lt;/code&gt; 是为了讲清 bank 置换的 32-bit word 级模型。真实 Tensor Core GEMM 还要同时满足三类约束：&lt;/p&gt;
        &lt;ol&gt;
          &lt;li&gt;global → shared 通常按 16B vector copy，不能随意打散一个 vector 内的元素。&lt;/li&gt;
          &lt;li&gt;shared → register 可能使用 &lt;code&gt;ldmatrix&lt;/code&gt;、TMA 或架构特定 fragment layout，lane 的读取模式不是简单的一 lane 一 word。&lt;/li&gt;
          &lt;li&gt;A/B 的 dtype、major mode、MMA tile 和 stage layout 不同，参与 XOR 的地址 bit 也不同。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;p&gt;因此 CUTLASS/CuTe 的 Swizzle 通常表现为“保留最低若干对齐 bit，再把一组高位 bit XOR 到地址低位”。它本质上仍是同一件事：&lt;strong&gt;保持 vector alignment，同时把消费者会同时访问的地址分散到不同 bank&lt;/strong&gt;。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;CuTe 思路：保留 MBase 个低位；取 BBits 个地址 bit；平移 SShift 后做 XOR&lt;/div&gt;
        &lt;div class=&quot;note&quot;&gt;先用本节公式检查逻辑访问是否冲突，再根据具体 &lt;code&gt;ldmatrix&lt;/code&gt;/MMA copy atom 选择 production swizzle。不要从网上抄一个 XOR 常数：同一个 swizzle 换了 dtype、tile shape 或 lane mapping，可能重新产生 conflict，甚至破坏 16B 对齐。&lt;/div&gt;
        &lt;p&gt;进一步阅读：&lt;a href=&quot;https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#shared-memory-and-memory-banks&quot;&gt;CUDA C++ Best Practices Guide：Shared Memory and Memory Banks&lt;/a&gt;，以及 &lt;a href=&quot;https://docs.nvidia.com/cutlass/latest/media/docs/pythonDSL/cute_dsl_api/cute.html&quot;&gt;CUTLASS CuTe Swizzle API&lt;/a&gt;。&lt;/p&gt;

        &lt;h3&gt;5.3 Padding 什么时候有用&lt;/h3&gt;
        &lt;p&gt;padding 是最简单的破冲突方法之一：如果每行长度刚好导致 stride 命中同一组 bank，就给 shared tile 的 leading dimension 多加几个元素。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 不是固定要 +1，而是用 padding 改变行间 stride
__shared__ bf16 smem_a[BM][BK + PAD];&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;padding 的代价是 shared memory 占用增加，并且可能影响 vectorized store/load 对齐。因此它适合教学和简单 kernel；在生产级 Tensor Core kernel 里，更常见的是专门设计 shared layout。&lt;/p&gt;
      &lt;/section&gt;

      &lt;section id=&quot;register&quot;&gt;
        &lt;h2&gt;6. Register Tiling：每个线程算多个输出元素&lt;/h2&gt;
        &lt;p&gt;如果一个 thread 只算一个 &lt;code&gt;C[m,n]&lt;/code&gt;，每次加载 A/B 后只产生一个 accumulator 的贡献，计算密度不够。Register tiling 会让每个 thread 持有多个 accumulator，例如 &lt;code&gt;4 x 4&lt;/code&gt; 的小块。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;float acc[TM][TN] = {0};

for k0 in range(0, K, BK):
  load A/B tile
  for kk in range(BK):
    a_frag[TM] = load A rows for this thread
    b_frag[TN] = load B cols for this thread
    for i in range(TM):
      for j in range(TN):
        acc[i][j] += a_frag[i] * b_frag[j]&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这一步提升 arithmetic intensity，但也会增加寄存器压力。寄存器太多会降低 occupancy，反而可能变慢。&lt;/p&gt;
        &lt;h3&gt;6.1 accumulator 为什么放寄存器&lt;/h3&gt;
        &lt;p&gt;每个 &lt;code&gt;C[m,n]&lt;/code&gt; 都要沿 K 累加。如果每次 partial sum 都写回 shared 或 global，再读出来继续累加，带宽和延迟都会爆炸。所以高性能 GEMM 会让 accumulator 长时间留在寄存器里，直到 K 维全部处理完后再进入 epilogue。&lt;/p&gt;
        &lt;div class=&quot;formula&quot;&gt;每线程寄存器数 ≈ accumulator registers + A/B fragment registers + 地址/循环/临时变量&lt;/div&gt;
        &lt;p&gt;例如一个线程维护 &lt;code&gt;8x4&lt;/code&gt; 个 FP32 accumulator，仅 accumulator 就需要 32 个寄存器。再加上 fragment 和临时变量，很容易达到 80、120 甚至更多寄存器。&lt;/p&gt;

        &lt;h3&gt;6.2 寄存器越多不一定越快&lt;/h3&gt;
        &lt;p&gt;更多 register tiling 会提高单线程计算密度，但会降低一个 SM 上能同时驻留的 warp 或 CTA 数。如果 occupancy 太低，kernel 对内存延迟、指令调度空洞、同步等待的隐藏能力会下降。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;现象&lt;/th&gt;&lt;th&gt;可能原因&lt;/th&gt;&lt;th&gt;调参方向&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Tensor Core 利用率低，occupancy 也低&lt;/td&gt;&lt;td&gt;寄存器或 shared memory 太多，活跃 warp 不够&lt;/td&gt;&lt;td&gt;减小 warp tile、stage 数或 accumulator 数&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;occupancy 高但 TFLOP/s 低&lt;/td&gt;&lt;td&gt;每个线程工作太少，数据复用不足&lt;/td&gt;&lt;td&gt;增大 tile 或 register tiling&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;local memory load/store 出现&lt;/td&gt;&lt;td&gt;寄存器溢出到 local memory&lt;/td&gt;&lt;td&gt;减少临时变量，拆小 tile，检查编译器 unroll&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;6.3 Register tiling 和 warp-level 分工&lt;/h3&gt;
        &lt;p&gt;在 Tensor Core kernel 里，寄存器不只是普通标量数组。A/B fragment 会按照 MMA 指令要求分布在 warp 的多个 lane 上，accumulator fragment 也由整个 warp 共同表示。单个线程看到的是自己那部分 fragment，整个 warp 合起来才是一个完整的 MMA tile。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;视角&lt;/th&gt;&lt;th&gt;每个 lane 看到什么&lt;/th&gt;&lt;th&gt;整个 warp 合起来是什么&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;普通 CUDA core tiling&lt;/td&gt;&lt;td&gt;几个标量 A/B 和多个 &lt;code&gt;acc[i][j]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;一个 warp 覆盖一片 C 子区域，但每个线程仍在做标量 FMA&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Tensor Core MMA&lt;/td&gt;&lt;td&gt;A/B fragment 的若干寄存器和 accumulator fragment 的一部分&lt;/td&gt;&lt;td&gt;一次或多次 MMA tile，例如把多个 &lt;code&gt;m16n8k16&lt;/code&gt; 拼成 warp tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Epilogue 写回&lt;/td&gt;&lt;td&gt;lane 持有的 accumulator fragment 要映射回全局 C 坐标&lt;/td&gt;&lt;td&gt;warp/CTA 协作把输出重排成 coalesced store&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;note&quot;&gt;理解 Tensor Core GEMM 时，要从“一个线程算一个元素”的模型切换到“一个 warp 协作算一个或多个小矩阵 tile”的模型。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;tensor-core&quot;&gt;
        &lt;h2&gt;7. BF16 Tensor Core：真正的高吞吐路径&lt;/h2&gt;
        &lt;p&gt;在 NVIDIA GPU 上，BF16 GEMM 的高性能路径通常不是普通 CUDA core FMA，而是 Tensor Core MMA 指令。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念模型，不是完整可编译代码
for k0 in range(0, K, BK):
  load A/B tiles into shared memory
  for warp_k in range(0, BK, mma_k):
    a_frag = ldmatrix_or_load_matrix_A(shared_A)
    b_frag = ldmatrix_or_load_matrix_B(shared_B)
    acc_frag = mma_sync(acc_frag, a_frag, b_frag)&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;BF16 常见策略是：输入 A/B 为 BF16，Tensor Core 做 BF16 multiply，accumulator 使用 FP32。最后写回时再转成 BF16 或 FP32，取决于输出需求。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;对象&lt;/th&gt;&lt;th&gt;推荐 dtype&lt;/th&gt;&lt;th&gt;原因&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;A/B input&lt;/td&gt;&lt;td&gt;BF16&lt;/td&gt;&lt;td&gt;吞吐高，动态范围接近 FP32&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Accumulator&lt;/td&gt;&lt;td&gt;FP32&lt;/td&gt;&lt;td&gt;降低 K 维累加误差&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;C output&lt;/td&gt;&lt;td&gt;BF16 或 FP32&lt;/td&gt;&lt;td&gt;取决于后续算子和精度要求&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;note&quot;&gt;高性能 GEMM 的核心不是“写一个 for loop”，而是组织出适合 Tensor Core 消费的 tile、fragment 和 pipeline。&lt;/div&gt;
        &lt;h3&gt;7.1 MMA 指令在做什么&lt;/h3&gt;
        &lt;p&gt;Tensor Core 指令可以理解为 warp 级别的小矩阵乘法：从 A fragment 和 B fragment 读入一小块矩阵，乘加到 accumulator fragment。它不是每个线程独立做完整矩阵乘法，而是 warp 内 32 个 lane 共同完成。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念公式
D_fragment = A_fragment @ B_fragment + C_fragment&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;具体指令形状会随架构变化，例如 &lt;code&gt;m16n8k16&lt;/code&gt; 这类形状表示一次 MMA 覆盖的 M/N/K 小块大小。kernel 的 warp tile 通常由很多个 MMA 指令拼起来。&lt;/p&gt;
        &lt;h3&gt;7.2 ldmatrix 和 shared layout 的关系&lt;/h3&gt;
        &lt;p&gt;Tensor Core 前的数据搬运通常不是普通标量 load，而是按照矩阵片段形式从 shared memory 取数。&lt;code&gt;ldmatrix&lt;/code&gt; 一类指令要求 warp 中各 lane 以特定模式读取 shared 地址，所以第 5 章的 swizzle 和 padding 会直接影响 Tensor Core 喂数效率。&lt;/p&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Global 到 Shared&lt;/div&gt;目标是 coalesced、对齐、吞吐高。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Shared 到 Fragment&lt;/div&gt;目标是 bank conflict 少，并匹配 MMA fragment 布局。&lt;/div&gt;
        &lt;/div&gt;
        &lt;h3&gt;7.3 BF16 的数值路径&lt;/h3&gt;
        &lt;p&gt;BF16 只有 7 个显式 fraction bit，但 exponent 范围与 FP32 相同。实践里的常见安全路径是 BF16 输入、FP32 accumulator，最后按需求 cast 到 BF16/FP16/FP32。除非目标硬件和误差预算明确允许更低精度累加，否则 K 维 reduction 通常应保留 FP32 accumulator。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;bf16 A, bf16 B
fp32 acc = mma_bf16(A, B, fp32 acc)
output = cast_or_fuse(acc)&lt;/code&gt;&lt;/pre&gt;
      &lt;/section&gt;

      &lt;section id=&quot;pipeline&quot;&gt;
        &lt;h2&gt;8. Pipeline 和 Async Copy：让加载与计算重叠&lt;/h2&gt;
        &lt;p&gt;如果每次都同步加载 A/B tile，再计算，再加载下一块，Tensor Core 会等待内存。高性能 kernel 会做 pipeline。&lt;/p&gt;
        &lt;div class=&quot;flow&quot;&gt;
          &lt;div&gt;&lt;strong&gt;Prologue&lt;/strong&gt;&lt;br&gt;Load S0&lt;/div&gt;
          &lt;div class=&quot;hot&quot;&gt;&lt;strong&gt;Steady state&lt;/strong&gt;&lt;br&gt;Compute S0 + Load S1&lt;/div&gt;
          &lt;div class=&quot;hot&quot;&gt;&lt;strong&gt;Steady state&lt;/strong&gt;&lt;br&gt;Compute S1 + Load S2&lt;/div&gt;
          &lt;div&gt;&lt;strong&gt;Drain&lt;/strong&gt;&lt;br&gt;Compute last stage&lt;/div&gt;
          &lt;div&gt;&lt;strong&gt;Epilogue&lt;/strong&gt;&lt;br&gt;Store C&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Pipeline 时间线：计算当前 stage，同时加载下一 stage&lt;/div&gt;
          &lt;div class=&quot;timeline-grid&quot;&gt;
            &lt;div&gt;&lt;/div&gt;&lt;div class=&quot;timeline-label&quot;&gt;t0&lt;/div&gt;&lt;div class=&quot;timeline-label&quot;&gt;t1&lt;/div&gt;&lt;div class=&quot;timeline-label&quot;&gt;t2&lt;/div&gt;&lt;div class=&quot;timeline-label&quot;&gt;t3&lt;/div&gt;
            &lt;div class=&quot;timeline-label&quot;&gt;Load pipe&lt;/div&gt;&lt;div class=&quot;timeline-cell&quot;&gt;load S0&lt;/div&gt;&lt;div class=&quot;timeline-cell&quot;&gt;load S1&lt;/div&gt;&lt;div class=&quot;timeline-cell&quot;&gt;load S2&lt;/div&gt;&lt;div class=&quot;timeline-cell&quot;&gt;load S3&lt;/div&gt;
            &lt;div class=&quot;timeline-label&quot;&gt;MMA pipe&lt;/div&gt;&lt;div class=&quot;timeline-cell&quot;&gt;&lt;/div&gt;&lt;div class=&quot;timeline-cell hot&quot;&gt;compute S0&lt;/div&gt;&lt;div class=&quot;timeline-cell hot&quot;&gt;compute S1&lt;/div&gt;&lt;div class=&quot;timeline-cell hot&quot;&gt;compute S2&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;实际实现里会使用 double buffering 或 multi-stage buffering：当 Tensor Core 计算当前 stage 时，异步加载下一 stage 的 A/B。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念模型：允许下一 stage 保持 in flight
prefetch stage 0
commit copy group

for k_stage in range(num_k_stages):
  if has_next_stage:
    prefetch next stage
    commit copy group

  wait until current stage is ready
  CTA barrier for current buffer
  mma current stage
  CTA barrier before reusing current buffer
  swap current / next buffer

wait for remaining copies
store C tile&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;把 mainloop 组织成“搬运下一块、计算当前块”的稳态流水，是 CUTLASS、Triton 生成代码和 BLASLt 类库中普遍存在的高性能方向；具体使用 &lt;code&gt;cp.async&lt;/code&gt;、TMA 还是其他 copy primitive，取决于架构与实现。&lt;/p&gt;
        &lt;h3&gt;8.1 Double buffering 的直觉&lt;/h3&gt;
        &lt;p&gt;只有一个 shared buffer 时，kernel 必须“加载完再算，算完再加载”。double buffering 准备两份 shared buffer：计算 stage 0 时加载 stage 1，计算 stage 1 时加载 stage 2。这样内存延迟被 mainloop 的 MMA 指令部分隐藏。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;load smem[0]
for k_stage:
  load smem[next]       // async copy
  compute smem[current] // mma
  swap current/next&lt;/code&gt;&lt;/pre&gt;
        &lt;h3&gt;8.2 stage 数不是越多越好&lt;/h3&gt;
        &lt;p&gt;更多 stage 可以覆盖更长内存延迟，但每多一个 stage 都会增加 shared memory 占用，也可能减少可驻留 CTA 数。生产 kernel 常在 2、3、4 stage 之间调参，取决于矩阵形状、GPU 架构和每个 CTA 的 tile 大小。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;stage 选择&lt;/th&gt;&lt;th&gt;优点&lt;/th&gt;&lt;th&gt;风险&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;2 stages&lt;/td&gt;&lt;td&gt;shared 占用较低，实现直观&lt;/td&gt;&lt;td&gt;可能盖不住 HBM 延迟&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;3-4 stages&lt;/td&gt;&lt;td&gt;更容易让 Tensor Core 连续工作&lt;/td&gt;&lt;td&gt;shared 占用上升，occupancy 可能下降&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;过多 stages&lt;/td&gt;&lt;td&gt;理论上预取更深&lt;/td&gt;&lt;td&gt;资源占用过高，收益递减&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;8.3 同步点要尽量少但必须正确&lt;/h3&gt;
        &lt;p&gt;shared memory 被多个线程协作写入和读取，因此同步不能随意删。优化的方向通常是用异步 copy 的 wait group、barrier 或 pipeline abstraction 精确表达“哪一 stage 已经可读”，而不是在每个小步骤后粗暴同步。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 稳态示意：此时 current group 和 next group 都在队列中
cp_async_copy(smem[next], gmem[next]);
cp_async_commit_group();

cp_async_wait_group(1);  // 最多保留 1 组未完成：current 已就绪，next 可继续在途
__syncthreads();         // CTA 内线程现在可以安全读取 current buffer
mma_on(smem[current]);
__syncthreads();         // 覆盖这个 buffer 前，确保所有消费者都已读完

// pipeline drain 时再用 wait_group(0) 等完最后一组&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;&lt;code&gt;wait_group(0)&lt;/code&gt; 会等待所有已提交 group；如果在发出 next stage 后立刻这样做，就会把预取也等完，失去加载与计算的重叠。稳态常用 &lt;code&gt;wait_group(1)&lt;/code&gt; 只保证当前最老的 group 已完成，同时允许下一组继续在途；最后 drain 才等到 0。生产代码通常用 CUTLASS pipeline、CUDA barrier 或架构专用 primitive 管理这些状态。&lt;code&gt;wait_group&lt;/code&gt; 管 copy group 的完成边界，barrier 管 CTA 线程之间的可见性和 buffer 复用边界，两者不能互相替代。&lt;/p&gt;
      &lt;/section&gt;

      &lt;section id=&quot;epilogue&quot;&gt;
        &lt;h2&gt;9. Epilogue：累加之后还没结束&lt;/h2&gt;
        &lt;p&gt;mainloop 负责把 &lt;code&gt;A @ B&lt;/code&gt; 累加到 FP32 accumulator，但真实模型里的 GEMM 往往还要做 bias、activation、scale、residual、cast、量化和写回。这部分通常叫 epilogue。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念 epilogue
float x = acc[m, n];
x = alpha * x + beta * old_c[m, n];
x = x + bias[n];
x = activation(x);
C[m, n] = cast_to_output_dtype(x);&lt;/code&gt;&lt;/pre&gt;
        &lt;h3&gt;9.1 为什么 epilogue 要融合&lt;/h3&gt;
        &lt;p&gt;如果 mainloop 写出 FP32 C，再启动另一个 kernel 做 bias/activation/cast，就会多一次 global write 和 read。对大 GEMM 来说这可能还可以接受；对 LLM 推理里的小 M、decode、MoE grouped GEMM，epilogue 的内存流量和 kernel launch overhead 会非常明显。&lt;/p&gt;
        &lt;div class=&quot;blue&quot;&gt;高性能实现通常把 epilogue 融合在 GEMM kernel 末尾，让 accumulator 在寄存器里直接完成后处理，然后只写一次最终输出。&lt;/div&gt;
        &lt;h3&gt;9.2 写回也要 coalesced&lt;/h3&gt;
        &lt;p&gt;不要只关心 A/B 的 load。C 的 store 如果是分散写、非对齐写，也会浪费带宽。很多 kernel 会让 warp 或 CTA 的输出 layout 匹配全局内存中的连续 N 维，这样写回更容易合并。&lt;/p&gt;
      &lt;/section&gt;

      &lt;section id=&quot;perf&quot;&gt;
        &lt;h2&gt;10. Profiling 工具和方法&lt;/h2&gt;
        &lt;p&gt;评估 GEMM 不要只看 wall time。wall time 告诉你“慢了”，profiling 才告诉你“为什么慢”。CUDA 性能分析通常分两层：先用 Nsight Systems 看时间线和 kernel 调度，再用 Nsight Compute 深挖单个 kernel 的硬件指标。&lt;/p&gt;
        &lt;h3&gt;10.1 工具怎么选&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;工具&lt;/th&gt;&lt;th&gt;回答的问题&lt;/th&gt;&lt;th&gt;适合场景&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Nsight Systems / &lt;code&gt;nsys&lt;/code&gt;&lt;/td&gt;&lt;td&gt;程序时间花在哪里，kernel 是否被 CPU launch、同步、通信、数据拷贝卡住&lt;/td&gt;&lt;td&gt;端到端推理、多个 kernel、CPU/GPU overlap、NCCL/拷贝/调度分析&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Nsight Compute / &lt;code&gt;ncu&lt;/code&gt;&lt;/td&gt;&lt;td&gt;某个 CUDA kernel 为什么没有打满硬件&lt;/td&gt;&lt;td&gt;GEMM kernel 本身调优，Tensor Core、访存、occupancy、stall reason&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;PyTorch Profiler&lt;/td&gt;&lt;td&gt;PyTorch op、CUDA kernel、shape、调用栈的对应关系&lt;/td&gt;&lt;td&gt;先定位哪个 op / kernel 慢，再下钻到 nsys/ncu&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CUPTI&lt;/td&gt;&lt;td&gt;程序化采集 trace/counter&lt;/td&gt;&lt;td&gt;框架、服务、自动 benchmark 系统里集成 profiling&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;10.2 推荐工作流&lt;/h3&gt;
        &lt;ol&gt;
          &lt;li&gt;先用业务 benchmark 固定 shape、batch、dtype、warmup、iteration，避免 profile 的对象不稳定。&lt;/li&gt;
          &lt;li&gt;用 &lt;code&gt;nsys&lt;/code&gt; 看时间线：确认慢的是 GEMM kernel 本身，还是 kernel launch、同步、memcpy、NCCL、CPU 调度。&lt;/li&gt;
          &lt;li&gt;挑出最耗时或最可疑的 GEMM kernel，用 &lt;code&gt;ncu&lt;/code&gt; 采集详细指标。&lt;/li&gt;
          &lt;li&gt;用指标判断瓶颈：Tensor Core 没打满、HBM 压力高、shared bank conflict、寄存器溢出、occupancy 太低、tail 浪费。&lt;/li&gt;
          &lt;li&gt;每次只改一个变量：BM/BN/BK、stage 数、warp 数、layout、epilogue 融合、split-K 或 grouped 调度。&lt;/li&gt;
        &lt;/ol&gt;

        &lt;h3&gt;10.3 Nsight Systems 怎么用&lt;/h3&gt;
        &lt;p&gt;&lt;code&gt;nsys&lt;/code&gt; 适合先看全局时间线。它不会告诉你 shared memory bank conflict 细节，但能快速判断“是不是 GEMM kernel 自己慢”。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production profiling command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;# 采集端到端 timeline
nsys profile \
  -o gemm_timeline \
  --trace=cuda,nvtx,osrt,cublas,cudnn \
  --force-overwrite=true \
  ./your_benchmark

# 只有 benchmark 调用了 cudaProfilerStart/Stop 时，才按 API 范围截取
nsys profile -o gemm_range \
  --trace=cuda,nvtx,osrt \
  --capture-range=cudaProfilerApi \
  --capture-range-end=stop \
  ./your_benchmark

# 也可以直接 profile Python
nsys profile -o torch_gemm --trace=cuda,nvtx,osrt python bench.py&lt;/code&gt;&lt;/pre&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;在 nsys 里看什么&lt;/th&gt;&lt;th&gt;可能说明什么&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;GPU timeline 中 GEMM kernel 是否连续&lt;/td&gt;&lt;td&gt;中间有空洞可能是 CPU launch、同步或依赖问题&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Memcpy / Memset 是否夹在 GEMM 中间&lt;/td&gt;&lt;td&gt;可能有隐式拷贝、临时 buffer、layout 转换&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CUDA API 时间是否很长&lt;/td&gt;&lt;td&gt;可能 CPU 端同步、allocator、driver 调用开销明显&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;NCCL 与 GEMM 是否 overlap&lt;/td&gt;&lt;td&gt;分布式推理里通信可能盖不住或阻塞计算&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;kernel 数量是否碎片化&lt;/td&gt;&lt;td&gt;小 kernel 太多，launch overhead 或 fusion 不足&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;10.4 Nsight Compute 怎么用&lt;/h3&gt;
        &lt;p&gt;&lt;code&gt;ncu&lt;/code&gt; 用来深挖单个 kernel。它采集 counter 会显著拖慢程序，所以一般只 profile 少量 iteration，并用 kernel 名称或 launch 序号过滤。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production profiling command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;# 基础采集：先用常用 section
ncu --set full \
  --target-processes all \
  --kernel-name regex:gemm \
  -o gemm_kernel \
  ./your_benchmark

# 更轻量：只采集常用分析 section
ncu \
  --section SpeedOfLight \
  --section MemoryWorkloadAnalysis \
  --section Occupancy \
  --section SchedulerStats \
  --section WarpStateStats \
  --target-processes all \
  ./your_benchmark&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;warn&quot;&gt;profile 前一定要 warmup。第一次运行可能包含 JIT、cudaMalloc、cache cold start、autotune，这些会污染 GEMM kernel 本身的判断。&lt;/div&gt;

        &lt;h3&gt;10.5 GEMM 里最该看的指标&lt;/h3&gt;
        &lt;p&gt;至少看这些指标：&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;指标&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;th&gt;常见问题&lt;/th&gt;&lt;th&gt;对应调参方向&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;TFLOP/s&lt;/td&gt;&lt;td&gt;用 &lt;code&gt;2MNK / time&lt;/code&gt; 算实际吞吐，再与该 dtype 的理论峰值比较&lt;/td&gt;&lt;td&gt;Tensor Core 没打满，或计时/工作量口径有误&lt;/td&gt;&lt;td&gt;回 §4/§7 检查 tile、MMA 对齐和是否走 Tensor Core 路径&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;HBM bandwidth&lt;/td&gt;&lt;td&gt;global load/store 的实际带宽及其峰值占比&lt;/td&gt;&lt;td&gt;tile 复用差、额外 workspace 或 epilogue 访存过多&lt;/td&gt;&lt;td&gt;回 §4/§5 调 BM/BN/BK、coalesced load 和 shared 复用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Occupancy&lt;/td&gt;&lt;td&gt;资源约束下可驻留 warp/CTA 的比例；不是性能分数&lt;/td&gt;&lt;td&gt;寄存器或 shared memory 过多，也可能只是 grid 太小&lt;/td&gt;&lt;td&gt;回 §6/§8 减小 register tile、stage 数或 shared footprint，并结合 grid waves 判断&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Tail / tile utilization&lt;/td&gt;&lt;td&gt;由 shape、tile 和有效元素比例推算；通常不是一个统一的 NCU counter&lt;/td&gt;&lt;td&gt;非整除维度或小 M 让大量 lane/tile 空转&lt;/td&gt;&lt;td&gt;回 §4.5/§10.9 考虑小 tile、split-K、persistent/grouped 调度&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Shared bank conflict&lt;/td&gt;&lt;td&gt;shared load/store 是否被序列化&lt;/td&gt;&lt;td&gt;shared layout 不匹配 warp 读取模式&lt;/td&gt;&lt;td&gt;回 §5/§7 调 swizzle、padding、ldmatrix 读取布局&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Local memory&lt;/td&gt;&lt;td&gt;寄存器溢出后的隐式内存访问&lt;/td&gt;&lt;td&gt;register pressure 过高或 unroll 太激进&lt;/td&gt;&lt;td&gt;回 §6/§9 减少 accumulator、临时数组和 epilogue 复杂度&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;note&quot;&gt;Nsight Compute 的具体 metric 名称会随 GPU 架构和工具版本变化。先用 SpeedOfLight、MemoryWorkloadAnalysis、Occupancy、SchedulerStats 等 section 建立结论，再查该版本的 metric 定义；不要只凭一个百分比判断瓶颈。&lt;/div&gt;
        &lt;h3&gt;10.6 指标怎么解读&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Profiling signal&lt;/th&gt;&lt;th&gt;优先怀疑&lt;/th&gt;&lt;th&gt;下一步&lt;/th&gt;&lt;th&gt;回到章节&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Tensor Core utilization 低，HBM 带宽也低&lt;/td&gt;&lt;td&gt;并行度不足、tail 多、kernel launch 间隙、依赖等待&lt;/td&gt;&lt;td&gt;回 nsys 看 timeline，检查小 M、CTA 数量、split-K&lt;/td&gt;&lt;td&gt;§4.5、§10.9&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Tensor Core utilization 低，HBM 带宽高&lt;/td&gt;&lt;td&gt;内存喂不饱，A/B tile 复用差，global load 不合并&lt;/td&gt;&lt;td&gt;检查 BM/BN/BK、global load pattern、layout 转换&lt;/td&gt;&lt;td&gt;§4、§5&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;shared load/store bank conflict 高&lt;/td&gt;&lt;td&gt;shared layout 不适合 warp 读取或 ldmatrix 模式&lt;/td&gt;&lt;td&gt;检查 swizzle、padding、shared leading dimension&lt;/td&gt;&lt;td&gt;§5.2、§7.2&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;occupancy 很低&lt;/td&gt;&lt;td&gt;寄存器、shared memory、cluster/stage 占用过大&lt;/td&gt;&lt;td&gt;降低 tile、stage、epilogue 临时变量，查 local memory&lt;/td&gt;&lt;td&gt;§6、§8、§9&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;local memory transaction 出现&lt;/td&gt;&lt;td&gt;寄存器 spill&lt;/td&gt;&lt;td&gt;减少 accumulator tile、unroll、临时数组或 epilogue 融合复杂度&lt;/td&gt;&lt;td&gt;§6.2、§9&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;pipeline stall 或 barrier stall 高&lt;/td&gt;&lt;td&gt;async copy 没盖住延迟，wait/barrier 放置过粗&lt;/td&gt;&lt;td&gt;检查 stage 数、wait group 距离、barrier 粒度&lt;/td&gt;&lt;td&gt;§8&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;epilogue 时间占比高&lt;/td&gt;&lt;td&gt;FP8 scale、amax、bias、activation、requantize 过重&lt;/td&gt;&lt;td&gt;分离 mainloop/epilogue profile，减少额外读写&lt;/td&gt;&lt;td&gt;§9、§11.8&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;10.7 一个实用排查顺序&lt;/h3&gt;
        &lt;ol&gt;
          &lt;li&gt;先确认结果正确，尤其是 tail block、非整除 K、转置 layout、dtype cast。&lt;/li&gt;
          &lt;li&gt;看是否走到 Tensor Core 指令路径，而不是退回普通 FMA。&lt;/li&gt;
          &lt;li&gt;看 HBM load/store 是否异常高，判断 tile 复用和 epilogue 融合是否有效。&lt;/li&gt;
          &lt;li&gt;看 shared bank conflict，判断 shared layout 是否喂得动 Tensor Core。&lt;/li&gt;
          &lt;li&gt;看寄存器数量、local memory、occupancy，判断 tile 是否过大。&lt;/li&gt;
          &lt;li&gt;最后再微调 tile size、stage 数、warp 数和 split-K 等策略。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;h3&gt;10.8 PyTorch 场景怎么定位到 GEMM&lt;/h3&gt;
        &lt;p&gt;如果 GEMM 来自 PyTorch 或推理框架，先用 PyTorch Profiler 或 NVTX 标记把高层 op 和底层 kernel 对上，再用 nsys/ncu 深挖。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production reference&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;import torch
from torch.profiler import profile, ProfilerActivity

with profile(
    activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],
    record_shapes=True,
    with_stack=True,
) as prof:
    run_model_once()

print(prof.key_averages().table(
    sort_by=&quot;cuda_time_total&quot;,
    row_limit=20,
))&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;看到慢 op 后，再在关键区域加 NVTX range，nsys 里就能按阶段定位。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production reference&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;torch.cuda.nvtx.range_push(&quot;prefill_gemm&quot;)
run_prefill()
torch.cuda.nvtx.range_pop()&lt;/code&gt;&lt;/pre&gt;

        &lt;h3 id=&quot;small-m&quot;&gt;10.9 小 M 场景的特殊性&lt;/h3&gt;
        &lt;p&gt;LLM decode 常见 &lt;code&gt;M&lt;/code&gt; 很小，甚至 batch token 数只有几十或更少。这时大 CTA tile 可能浪费，输出 tile 数也可能少到无法铺满所有 SM。工程上可能需要 split-K、persistent kernel、grouped GEMM，或者把多个请求/专家合并调度。&lt;/p&gt;

        &lt;h4&gt;10.9.1 Persistent kernel：CTA 算完一个 tile 后不退出&lt;/h4&gt;
        &lt;p&gt;普通 GEMM 通常按输出 tile 启动大量 CTA，一个 CTA 算完自己负责的 tile 就结束。Persistent kernel 则只启动接近硬件可驻留数量的 CTA，让这些 CTA 在 kernel 生命周期内循环领取后续 tile；因此“persistent”表示 CTA 在一次 kernel launch 内持续工作，不是 kernel 永远不退出。&lt;/p&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;普通 tile-per-CTA&lt;/div&gt;
            &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
            &lt;pre&gt;&lt;code&gt;CTA 0: tile 0 -&amp;gt; exit
CTA 1: tile 1 -&amp;gt; exit
CTA 2: tile 2 -&amp;gt; exit
...
下一批工作再次 launch&lt;/code&gt;&lt;/pre&gt;
          &lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;Persistent CTA&lt;/div&gt;
            &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
            &lt;pre&gt;&lt;code&gt;while scheduler.has_work():
  tile = scheduler.next_tile()
  compute_gemm_tile(tile)

// 所有 tile 完成后才退出&lt;/code&gt;&lt;/pre&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;当多个 tile、problem 或请求被合进同一次 launch 时，它可以摊薄 kernel launch 和 CTA 建立/回收开销；scheduler 也能把剩余 tile 交给先空闲的 CTA，改善尾部负载均衡。某些实现还可以跨多个 tile 复用调度状态或权重相关 metadata。对单次、单个 GEMM 而言，persistent 本身并不会减少 launch 次数。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;&lt;strong&gt;Persistent 不等于自动解决小 M。&lt;/strong&gt;如果整个 workload 真的只有两三个 tile，没有其他请求、group 或 K-split 可做，常驻 CTA 也不能凭空制造计算并行度。它更适合“单个问题很小，但同时有很多问题/tile 可以连续领取”的场景。&lt;/div&gt;

        &lt;h4&gt;10.9.2 Grouped GEMM：把多个不同 GEMM 作为一组调度&lt;/h4&gt;
        &lt;p&gt;Grouped GEMM 的输入不是一对 A/B，而是一组 GEMM problem。每个 problem 可以有自己的指针、&lt;code&gt;M/N/K&lt;/code&gt;、stride 和输出地址；kernel 把所有 problem 的输出 tile 放进同一个逻辑工作集合，再分给 CTA。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch · MoE grouped GEMM&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 四个 expert 实际收到的 token 数不同，因此 M 不同
GEMM 0: [ 1, K] @ [K, N] -&amp;gt; [ 1, N]
GEMM 1: [ 3, K] @ [K, N] -&amp;gt; [ 3, N]
GEMM 2: [17, K] @ [K, N] -&amp;gt; [17, N]
GEMM 3: [64, K] @ [K, N] -&amp;gt; [64, N]

grouped_gemm([problem0, problem1, problem2, problem3])&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;如果分别 launch 四个 kernel，前三个 GEMM 可能都只有很少 CTA，launch 和尾部空转占比很高。Grouped GEMM 用一次 launch 暴露整组 tile，scheduler 可以让空闲 CTA 从下一个 expert/problem 继续取工作。它尤其适合 MoE，因为每个 expert 的 token 数动态变化，problem shape 天然不规则。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Grouped + Persistent 的常见组合&lt;/div&gt;
          &lt;div class=&quot;flow&quot;&gt;
            &lt;div&gt;G0 tiles&lt;br&gt;M=1&lt;/div&gt;
            &lt;div&gt;G1 tiles&lt;br&gt;M=3&lt;/div&gt;
            &lt;div&gt;G2 tiles&lt;br&gt;M=17&lt;/div&gt;
            &lt;div&gt;G3 tiles&lt;br&gt;M=64&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;统一 tile scheduler&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;two-col&quot;&gt;
            &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Resident CTA 0&lt;/div&gt;&lt;code&gt;G0/T0 → G2/T1 → G3/T3 → ...&lt;/code&gt;&lt;/div&gt;
            &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;Resident CTA 1&lt;/div&gt;&lt;code&gt;G1/T0 → G2/T2 → G3/T4 → ...&lt;/code&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h4&gt;10.9.3 两个概念是什么关系&lt;/h4&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;概念&lt;/th&gt;&lt;th&gt;回答的问题&lt;/th&gt;&lt;th&gt;关键机制&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Persistent kernel&lt;/td&gt;&lt;td&gt;一个 CTA 算完当前 tile 后做什么？&lt;/td&gt;&lt;td&gt;CTA 保持驻留，循环从 scheduler 领取多个 tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Grouped GEMM&lt;/td&gt;&lt;td&gt;哪些 GEMM problem 放在同一次调度里？&lt;/td&gt;&lt;td&gt;把多个不同 shape/pointer 的 GEMM tile 合成一个工作集合&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Grouped persistent GEMM&lt;/td&gt;&lt;td&gt;如何持续处理一组不规则小 GEMM？&lt;/td&gt;&lt;td&gt;少量驻留 CTA 跨 problem 不断领取 tile；CUTLASS grouped kernel 常采用这种方式&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Batched GEMM&lt;/td&gt;&lt;td&gt;如何重复执行一批通常较规则的 GEMM？&lt;/td&gt;&lt;td&gt;常见接口假设 shape/stride 更一致；不等同于一般的 heterogeneous grouped GEMM&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;p&gt;代价也很直接：device scheduler、problem metadata 读取和 tile 查找会产生额外开销；不同 problem 的 K 相差很大时，CTA 工作量仍可能失衡。因此 grouped/persistent 适合小而多、shape 不规则的 workload，不代表单个标准大 GEMM 也应该使用。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;进一步阅读：&lt;a href=&quot;https://docs.nvidia.com/cutlass/latest/media/docs/cpp/grouped_scheduler.html&quot;&gt;CUTLASS Grouped Kernel Schedulers&lt;/a&gt;。CUTLASS 的 grouped kernel 会启动少于总 tile 数的 persistent threadblocks，每个 threadblock 循环查询 scheduler 并计算一个或多个 problem tile。&lt;/div&gt;
        &lt;div class=&quot;warn&quot;&gt;LLM 推理里的 GEMM 经常不是理想大方阵。小 M、MoE grouped GEMM、prefill/decode 混合形状都会让“库默认最优”不再绝对成立；应按 shape bucket 分别 profile。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;fp8&quot;&gt;
        &lt;h2&gt;11. FP8 GEMM 怎么做&lt;/h2&gt;
        &lt;p&gt;FP8 不是简单地把 BF16 输入换成 FP8。FP8 的动态范围和精度都更紧，需要 scale 管理。&lt;/p&gt;
        &lt;h3&gt;11.1 FP8 的基本形态&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;格式&lt;/th&gt;&lt;th&gt;特点&lt;/th&gt;&lt;th&gt;常见用途&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;E4M3&lt;/td&gt;&lt;td&gt;mantissa 多，精度相对好，范围较小&lt;/td&gt;&lt;td&gt;activation / weight 常用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;E5M2&lt;/td&gt;&lt;td&gt;exponent 多，范围更大，精度较低&lt;/td&gt;&lt;td&gt;gradient 或范围更大的张量&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;11.2 scale 是 FP8 GEMM 的核心&lt;/h3&gt;
        &lt;p&gt;通常会把真实值映射到 FP8 可表达范围：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;x_fp8 = quantize(x / scale)
x_real ≈ dequantize(x_fp8) * scale&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;scale 粒度可以不同：&lt;/p&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;strong&gt;per-tensor scale：&lt;/strong&gt;实现简单，但容易被 outlier 影响。&lt;/li&gt;
          &lt;li&gt;&lt;strong&gt;per-row / per-column scale：&lt;/strong&gt;必须注明广播轴；weight 常按输出通道，activation 常按 token/row。&lt;/li&gt;
          &lt;li&gt;&lt;strong&gt;per-block scale：&lt;/strong&gt;例如每 32/64/128 个元素一个 scale，兼顾精度和吞吐。&lt;/li&gt;
        &lt;/ul&gt;

        &lt;h3&gt;11.3 FP8 GEMM 的计算路径&lt;/h3&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 简化路径：scale_a / scale_b 在该输出 tile 的整个 K reduction 上恒定
A_fp8, scale_A = quantize(A_bf16_or_fp32)
B_fp8, scale_B = quantize(B_bf16_or_fp32)

acc_fp32 = fp8_tensor_core_mma(A_fp8, B_fp8)
C = acc_fp32 * scale_A * scale_B
C_out = cast_or_quantize(C)&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;只有当 &lt;code&gt;scale_A * scale_B&lt;/code&gt; 对整个 K reduction 都不变时，scale 才能从求和中提出，在 mainloop 结束后统一应用。高性能实现会把 scale load、MMA、scale apply、输出 cast 或 requantize 融合起来，减少额外内存读写。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;&lt;strong&gt;关键边界：&lt;/strong&gt;如果 scale 沿 K-block 变化，就不能先把所有 FP8 product 累加完再乘一次 scale。每个 K-block 的 partial accumulator 都要乘自己的 &lt;code&gt;scale_A[kb] * scale_B[kb]&lt;/code&gt; 后再进入总和；§11.7 展开这条路径。&lt;/div&gt;

        &lt;h3&gt;11.4 从 BF16 kernel 迁移到 FP8 时要改什么&lt;/h3&gt;
        &lt;ol&gt;
          &lt;li&gt;global memory layout 要容纳 FP8 数据和 scale 数据。&lt;/li&gt;
          &lt;li&gt;load path 要加载 FP8 tile，同时加载对应 scale。&lt;/li&gt;
          &lt;li&gt;MMA 指令路径从 BF16 MMA 换成 FP8 MMA。&lt;/li&gt;
          &lt;li&gt;accumulator 通常仍用 FP32。&lt;/li&gt;
          &lt;li&gt;按 scale 粒度决定缩放位置：K 维恒定的 scale 可放到 epilogue；沿 K 变化的 block scale 必须进入 mainloop / block-scaled MMA。&lt;/li&gt;
          &lt;li&gt;epilogue 还要处理 bias、activation、输出 dtype，以及可能的 output scale。&lt;/li&gt;
          &lt;li&gt;如果输出继续 FP8，还要做 requantize，并按约定读取或写出新的 output scale / amax。&lt;/li&gt;
        &lt;/ol&gt;
        &lt;h3&gt;11.5 scale 粒度会改变 kernel 设计&lt;/h3&gt;
        &lt;p&gt;per-tensor scale 在整个 reduction 上恒定时，可以在 epilogue 里乘一个标量，最简单但最容易受 outlier 牵制。所谓 per-channel 必须说明轴：权重按输出通道量化时，scale 常沿 N 维；activation 按 token/row 量化时，scale 常沿 M 维。这些 scale 若不随 K 变化，仍可在输出 tile 上应用。per-block scale 一旦包含 K 维分块，scale load 和缩放就进入 mainloop，不能再被当作普通 epilogue 标量。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;scale 粒度&lt;/th&gt;&lt;th&gt;kernel 代价&lt;/th&gt;&lt;th&gt;精度特点&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;per-tensor&lt;/td&gt;&lt;td&gt;最小；scale 对 K 恒定时可在 epilogue 应用&lt;/td&gt;&lt;td&gt;容易被全局 outlier 牵制&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;per-row / per-column&lt;/td&gt;&lt;td&gt;按 M 或 N 广播 scale；输出 tile 需要对应向量&lt;/td&gt;&lt;td&gt;常用于 token/activation 或输出通道/weight&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;per-block，且沿 K 分块&lt;/td&gt;&lt;td&gt;每个 K stage 都要索引 scale，并缩放 partial sum 或由 block-scaled MMA 消费&lt;/td&gt;&lt;td&gt;局部动态范围更好，工程复杂度更高&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;11.6 FP8 的 accumulator 和输出&lt;/h3&gt;
        &lt;p&gt;FP8 GEMM 的常见安全路径仍使用 FP32 accumulator，但具体 accumulator 模式由硬件指令和库配置决定。原因和 BF16 一样：K 维累加误差需要受控。输出可以是 BF16/FP16/FP32，也可以重新量化成 FP8；如果输出 FP8，epilogue 还要决定 output scale，并处理 clipping 和 rounding。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 仍假设 input scale 在整个 K reduction 上恒定
acc_fp32 = fp8_mma(A_fp8, B_fp8)
y_fp32 = acc_fp32 * scale_a * scale_b + bias
out_fp8 = quantize(y_fp32 / scale_out)&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;即使 input scale 可以留到 K reduction 之后处理，scale apply、bias/activation、output scale 和再量化仍会增加 epilogue 的指令与访存；因此只比较 FP8/BF16 的 MMA 峰值，不能推导完整 kernel 的加速比。&lt;/p&gt;
        &lt;h3&gt;11.7 per-block scale 的 layout 和索引&lt;/h3&gt;
        &lt;p&gt;per-block scale 的难点不是多乘一个标量，而是 scale tensor 必须和 tile 形状、K-loop 顺序一起设计。下面用一个简化例子：A 的 scale 覆盖 &lt;code&gt;64 x 64&lt;/code&gt; 子块，B 的 scale 也覆盖 &lt;code&gt;64 x 64&lt;/code&gt; 子块。对某个固定的输出 scale-block &lt;code&gt;(mb, nb)&lt;/code&gt;，每个 K-block 都有不同的 scale pair。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// mb / kb / nb 是 64x64 scale block 的索引
acc_fp32[mb, nb] = 0

for kb in range(num_k_scale_blocks):
  partial_fp32 = fp8_mma(
      A_fp8[mb, kb],
      B_fp8[kb, nb])

  scale_a = ScaleA[mb, kb]
  scale_b = ScaleB[kb, nb]
  acc_fp32[mb, nb] += partial_fp32 * scale_a * scale_b

y[mb, nb] = epilogue(acc_fp32[mb, nb])&lt;/code&gt;&lt;/pre&gt;
        &lt;div class=&quot;formula&quot;&gt;C[mb, nb] = Σ&lt;sub&gt;kb&lt;/sub&gt; partial_fp32[mb, kb, nb] × ScaleA[mb, kb] × ScaleB[kb, nb]&lt;/div&gt;
        &lt;p&gt;公式的重点是 scale multiplication 位于 K-block 求和内部。实现上不一定真的生成一块独立的 &lt;code&gt;partial_fp32&lt;/code&gt;：支持 block-scaled MMA 的架构可以把 data fragment 和 scale-factor fragment 一起交给 MMA；其他实现可能在 mainloop 中提升、缩放并累加 partial fragment。数学语义必须相同。&lt;/p&gt;
        &lt;p&gt;如果 scale block 和 CTA/MMA tile 不整齐对齐，kernel 会多出 predicate、额外 scale load，甚至跨 block 的 scale 拼接与 fragment 重排。实际工程常让 scale layout 和 mainloop 的消费粒度对齐，牺牲一点布局自由度，换取更简单的地址计算和更连续的 scale load。&lt;/p&gt;
        &lt;h3&gt;11.8 requantize：clipping、rounding、amax&lt;/h3&gt;
        &lt;p&gt;如果 GEMM 输出还要写成 FP8，epilogue 需要把 FP32 accumulator 重新映射回 FP8 范围。这个过程通常包含三件事：先按约定除以 output scale，再对目标 FP8 格式的可表达范围做 clipping，最后按硬件或库的策略 rounding。output scale 可以预先给定，也可以根据当前或历史 amax 动态更新；两种路径的同步和可复现性成本不同。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;步骤&lt;/th&gt;&lt;th&gt;为什么需要&lt;/th&gt;&lt;th&gt;常见风险&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;选择 output scale&lt;/td&gt;&lt;td&gt;决定 FP8 动态范围如何覆盖输出分布&lt;/td&gt;&lt;td&gt;scale 太小会大量 clipping，scale 太大有效精度下降&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;clipping&lt;/td&gt;&lt;td&gt;避免超出 E4M3/E5M2 可表达范围&lt;/td&gt;&lt;td&gt;outlier 多时会损失模型精度&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;rounding&lt;/td&gt;&lt;td&gt;把 FP32 映射到离散 FP8 值&lt;/td&gt;&lt;td&gt;不同 rounding 策略会影响误差分布和可复现性&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;amax 统计&lt;/td&gt;&lt;td&gt;给下一次 scale 更新提供动态范围信息&lt;/td&gt;&lt;td&gt;额外 reduction 可能让 epilogue 变重&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;11.9 为什么 FP8 epilogue 可能成为瓶颈&lt;/h3&gt;
        &lt;p&gt;BF16 GEMM 的 epilogue 可能只是 bias、activation 和 cast；FP8 epilogue 往往还要处理可从 K reduction 提出的 input scale、output scale、clipping/rounding，并可能写 amax 或 auxiliary tensor。沿 K 变化的 A/B block scale 属于 mainloop 成本，不应误记到 epilogue。mainloop 因为 FP8 Tensor Core 变快以后，剩余 epilogue 工作在总时间里的占比反而可能上升。&lt;/p&gt;
        &lt;p&gt;下面是 profile 的解释框架，不是某张 GPU 上的实测比例。对融合 kernel，mainloop/epilogue 占比通常需要结合 source-level counter、指令区间，或用“保留 mainloop、逐项关闭 epilogue 功能”的变体对照来估算，不能指望一个通用 NCU 指标直接给出百分比。&lt;/p&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Profile 对比&lt;/th&gt;&lt;th&gt;BF16 常见解释&lt;/th&gt;&lt;th&gt;FP8 常见解释&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Mainloop 占比高&lt;/td&gt;&lt;td&gt;Tensor Core 或 shared pipeline 是主要瓶颈&lt;/td&gt;&lt;td&gt;scale load 已被很好隐藏，主要仍是 MMA&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Epilogue 占比高&lt;/td&gt;&lt;td&gt;bias/activation/store 或小 M launch overhead 明显&lt;/td&gt;&lt;td&gt;scale apply、requantize、amax、额外 store 压过 mainloop 收益&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;HBM store 高&lt;/td&gt;&lt;td&gt;输出写回或未融合后处理过重&lt;/td&gt;&lt;td&gt;除了输出，可能还写 scale/amax/aux，需检查 epilogue fusion&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;blue&quot;&gt;FP8 的性能收益来自更低的带宽需求、更高的 Tensor Core 吞吐和更小的存储占用；代价是 scale 管理与数值验证明显更复杂。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;cute&quot;&gt;
        &lt;h2&gt;12. CuTe / CUTLASS DSL：NVIDIA 生产实现的一条主力路径&lt;/h2&gt;
        &lt;p&gt;前面讲的是 GEMM kernel 的原理：tile、shared memory、register、Tensor Core、pipeline、epilogue。在 NVIDIA 生产实现中，常见路径不是从裸 CUDA 一行行维护所有地址计算，而是使用 CuTe / CUTLASS 3.x API 这类 DSL 和模板库。&lt;/p&gt;
        &lt;h3&gt;12.1 CuTe 在解决什么问题&lt;/h3&gt;
        &lt;p&gt;CuTe 的核心抽象是 &lt;code&gt;Tensor = pointer + layout&lt;/code&gt;，以及用 &lt;code&gt;Shape&lt;/code&gt;、&lt;code&gt;Stride&lt;/code&gt;、&lt;code&gt;Layout&lt;/code&gt;、&lt;code&gt;TiledMMA&lt;/code&gt;、&lt;code&gt;TiledCopy&lt;/code&gt; 描述数据如何被 CTA、warp 和 MMA 指令消费。它让你把“逻辑上的矩阵 tile”和“物理上的 shared/global/register 布局”分开表达。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;名字容易混：CuTe 本体最早是 C++ template DSL，CUTLASS 3.x API 的 GEMM collective 建立在它上面；现在 NVIDIA 也提供 Python CuTe DSL，用 Python 语法写低层 GPU kernel，再 JIT/AOT 编译。因此 §12.3 的 C++ 代码更准确地说是“CUTLASS collective 代码，使用了 CuTe 类型”，不是手写 CuTe kernel。&lt;/div&gt;
        &lt;h4&gt;12.1.1 CuTe 极简心智模型&lt;/h4&gt;
        &lt;p&gt;读 CuTe 代码时，先不要从模板类型硬啃。把它看成三层：&lt;code&gt;Tensor&lt;/code&gt; 保存指针和 layout，&lt;code&gt;Layout&lt;/code&gt; 把逻辑坐标映射到物理 offset，&lt;code&gt;TiledMMA&lt;/code&gt; 描述 warp 如何把 fragment 喂给 Tensor Core。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// CuTe 风格示意，不是完整 kernel
Tensor gA = make_tensor(make_gmem_ptr(A), make_layout(make_shape(M, K), make_stride(K, 1)));
Tensor tileA = local_tile(gA, make_shape(BM, BK), make_coord(block_m, block_k));

// Layout 决定 (m, k) 如何变成地址 offset
// TiledMMA 决定 warp/lane 如何持有 A/B/C fragment
auto tiled_mma = make_tiled_mma(mma_atom, warp_layout);
auto thr_mma = tiled_mma.get_thread_slice(threadIdx.x);&lt;/code&gt;&lt;/pre&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;CuTe 名词&lt;/th&gt;&lt;th&gt;先按什么理解&lt;/th&gt;&lt;th&gt;对应本文概念&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;Tensor&lt;/code&gt;&lt;/td&gt;&lt;td&gt;数据指针 + layout 的视图&lt;/td&gt;&lt;td&gt;global/shared/register tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;Layout&lt;/code&gt;&lt;/td&gt;&lt;td&gt;坐标到 offset 的函数&lt;/td&gt;&lt;td&gt;row-major、column-major、swizzle、padding&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;Shape&lt;/code&gt;&lt;/td&gt;&lt;td&gt;逻辑 tile 尺寸&lt;/td&gt;&lt;td&gt;BM/BN/BK、warp tile、MMA tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;TiledMMA&lt;/code&gt;&lt;/td&gt;&lt;td&gt;warp 到 MMA fragment 的分配规则&lt;/td&gt;&lt;td&gt;§4.1 和 §6.3 的 warp-level 分工&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;裸 CUDA 难点&lt;/div&gt;地址计算散落在代码里，swizzle、bank conflict、TMA、MMA fragment、epilogue 很容易互相缠住。&lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;&lt;div class=&quot;mini-title&quot;&gt;CuTe / CUTLASS 路径&lt;/div&gt;用 layout 和 collective 描述 mainloop/epilogue，让编译期类型系统承载 tile shape、copy atom、MMA atom 和 schedule。&lt;/div&gt;
        &lt;/div&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;名字&lt;/th&gt;&lt;th&gt;语言&lt;/th&gt;&lt;th&gt;典型代码形态&lt;/th&gt;&lt;th&gt;适合场景&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;CuTe C++&lt;/td&gt;&lt;td&gt;C++ template&lt;/td&gt;&lt;td&gt;&lt;code&gt;cute::Tensor&lt;/code&gt;、&lt;code&gt;cute::Layout&lt;/code&gt;、&lt;code&gt;TiledMMA&lt;/code&gt;、&lt;code&gt;TiledCopy&lt;/code&gt;&lt;/td&gt;&lt;td&gt;理解 CUTLASS 内核、写极底层 kernel、精细控制布局&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CUTLASS collective&lt;/td&gt;&lt;td&gt;C++ template&lt;/td&gt;&lt;td&gt;&lt;code&gt;CollectiveBuilder&lt;/code&gt;、&lt;code&gt;GemmUniversalAdapter&lt;/code&gt;&lt;/td&gt;&lt;td&gt;工程里组合高性能 GEMM；§12.3 的代码属于这一层&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Python CuTe DSL&lt;/td&gt;&lt;td&gt;Python&lt;/td&gt;&lt;td&gt;&lt;code&gt;import cutlass.cute as cute&lt;/code&gt;、&lt;code&gt;@cute.kernel&lt;/code&gt;&lt;/td&gt;&lt;td&gt;新 kernel 快速迭代、减少 C++ 模板负担、面向 CUTLASS 4.x 路线&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;h3&gt;12.2 CUTLASS 3.x 的分层&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;层级&lt;/th&gt;&lt;th&gt;作用&lt;/th&gt;&lt;th&gt;你通常关心什么&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;CuTe&lt;/td&gt;&lt;td&gt;layout、tensor、copy、MMA 的底层 DSL&lt;/td&gt;&lt;td&gt;tile 如何映射到线程、warp、shared、fragment&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Collective Mainloop&lt;/td&gt;&lt;td&gt;从 global/shared 到 MMA accumulator&lt;/td&gt;&lt;td&gt;A/B dtype、layout、TileShape、ClusterShape、stage、kernel schedule&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Collective Epilogue&lt;/td&gt;&lt;td&gt;accumulator 到 D 输出&lt;/td&gt;&lt;td&gt;scale、bias、activation、amax、aux、输出 dtype&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Device Adapter&lt;/td&gt;&lt;td&gt;把 kernel 包装成 host 可调用对象&lt;/td&gt;&lt;td&gt;problem shape、stride、workspace、initialize、run&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;p&gt;所以工程上常见的做法是：先用 CUTLASS 的 &lt;code&gt;CollectiveBuilder&lt;/code&gt; 组合出一个 kernel，再对 tile shape、cluster shape、schedule 和 epilogue fusion 做调参。只有当 builder 覆盖不了需求时，才下沉到更底层的 CuTe kernel。&lt;/p&gt;

        &lt;h3&gt;12.3 Hopper FP8 GEMM：完整 CUTLASS 3.x collective 代码&lt;/h3&gt;
        &lt;p&gt;下面是一份教学版 Hopper FP8 GEMM。它保留了完整 host 侧流程：定义 CUTLASS/CuTe kernel 类型、分配 A/B/C/D、初始化输入、构造 &lt;code&gt;Gemm::Arguments&lt;/code&gt;、申请 workspace、检查支持性、初始化并运行。真实项目应以 CUTLASS 仓库中的 &lt;a href=&quot;https://github.com/NVIDIA/cutlass/tree/main/examples/54_hopper_fp8_warp_specialized_gemm&quot;&gt;&lt;code&gt;examples/54_hopper_fp8_warp_specialized_gemm&lt;/code&gt;&lt;/a&gt;、&lt;a href=&quot;https://github.com/NVIDIA/cutlass/tree/main/examples/67_hopper_fp8_warp_specialized_gemm_with_blockwise_scaling&quot;&gt;&lt;code&gt;examples/67_hopper_fp8_warp_specialized_gemm_with_blockwise_scaling&lt;/code&gt;&lt;/a&gt; 和 Python CuTe DSL 示例为准。&lt;/p&gt;
        &lt;details class=&quot;code-disclosure&quot;&gt;
          &lt;summary&gt;查看完整 Hopper FP8 CUTLASS C++ 代码&lt;/summary&gt;
          &lt;div class=&quot;code-disclosure-body&quot;&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production reference&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// hopper_fp8_gemm.cu
// Teaching version: CUTLASS 3.x + CuTe shapes for Hopper FP8 GEMM.
// It is intentionally compact, but keeps the complete host-side run path.
//
// Typical compile shape:
//   nvcc -std=c++17 -arch=sm_90a -I${CUTLASS_ROOT}/include \
//        -I${CUTLASS_ROOT}/tools/util/include hopper_fp8_gemm.cu -o hopper_fp8_gemm

#include &amp;lt;iostream&amp;gt;

#include &quot;cutlass/cutlass.h&quot;
#include &quot;cutlass/numeric_types.h&quot;
#include &quot;cutlass/util/host_tensor.h&quot;
#include &quot;cutlass/util/device_memory.h&quot;
#include &quot;cutlass/util/reference/host/tensor_fill.h&quot;
#include &quot;cutlass/util/reference/host/tensor_compare.h&quot;
#include &quot;cutlass/gemm/device/gemm_universal_adapter.h&quot;
#include &quot;cutlass/gemm/kernel/gemm_universal.hpp&quot;
#include &quot;cutlass/gemm/collective/collective_builder.hpp&quot;
#include &quot;cutlass/epilogue/collective/collective_builder.hpp&quot;
#include &quot;cutlass/epilogue/thread/activation.h&quot;
#include &quot;cutlass/epilogue/fusion/operations.hpp&quot;
#include &quot;cute/tensor.hpp&quot;

using namespace cute;

using ElementA = cutlass::float_e4m3_t;
using ElementB = cutlass::float_e4m3_t;
using ElementC = cutlass::half_t;
using ElementD = cutlass::half_t;
using ElementAccumulator = float;
using ElementCompute = float;
using ElementAux = ElementD;
using ElementAmax = float;
using ElementBias = float;

using LayoutA = cutlass::layout::RowMajor;
using LayoutB = cutlass::layout::ColumnMajor;
using LayoutC = cutlass::layout::ColumnMajor;
using LayoutD = cutlass::layout::ColumnMajor;
using LayoutAux = LayoutD;

// Alignment is expressed in elements. For FP8, 128 bits means 16 elements.
constexpr int AlignmentA = 128 / cutlass::sizeof_bits&amp;lt;ElementA&amp;gt;::value;
constexpr int AlignmentB = 128 / cutlass::sizeof_bits&amp;lt;ElementB&amp;gt;::value;
constexpr int AlignmentC = 128 / cutlass::sizeof_bits&amp;lt;ElementC&amp;gt;::value;
constexpr int AlignmentD = 128 / cutlass::sizeof_bits&amp;lt;ElementD&amp;gt;::value;

using ArchTag = cutlass::arch::Sm90;
using OperatorClass = cutlass::arch::OpClassTensorOp;

// This is the CTA-level tile discussed earlier as BM/BN/BK.
using TileShape = Shape&amp;lt;_128, _128, _128&amp;gt;;
using ClusterShape = Shape&amp;lt;_1, _2, _1&amp;gt;;

using KernelSchedule =
    cutlass::gemm::KernelTmaWarpSpecializedCooperative;
using EpilogueSchedule =
    cutlass::epilogue::TmaWarpSpecializedCooperative;

using EpilogueTile = cutlass::epilogue::collective::EpilogueTileAuto;
using FusionOperation =
    cutlass::epilogue::fusion::ScaledLinCombPerRowBiasEltActAmaxAux&amp;lt;
        LayoutAux,
        cutlass::epilogue::thread::ReLU,
        ElementD,
        ElementCompute,
        ElementAux,
        ElementAmax,
        ElementBias,
        ElementC&amp;gt;;

using CollectiveEpilogue =
    typename cutlass::epilogue::collective::CollectiveBuilder&amp;lt;
        ArchTag, OperatorClass,
        TileShape, ClusterShape, EpilogueTile,
        ElementAccumulator, ElementCompute,
        ElementC, LayoutC, AlignmentC,
        ElementD, LayoutD, AlignmentD,
        EpilogueSchedule,
        FusionOperation
    &amp;gt;::CollectiveOp;

using CollectiveMainloop =
    typename cutlass::gemm::collective::CollectiveBuilder&amp;lt;
        ArchTag, OperatorClass,
        ElementA, LayoutA, AlignmentA,
        ElementB, LayoutB, AlignmentB,
        ElementAccumulator,
        TileShape, ClusterShape,
        cutlass::gemm::collective::StageCountAutoCarveout&amp;lt;
            static_cast&amp;lt;int&amp;gt;(sizeof(typename CollectiveEpilogue::SharedStorage))
        &amp;gt;,
        KernelSchedule
    &amp;gt;::CollectiveOp;

using GemmKernel =
    cutlass::gemm::kernel::GemmUniversal&amp;lt;
        Shape&amp;lt;int, int, int, int&amp;gt;,
        CollectiveMainloop,
        CollectiveEpilogue
    &amp;gt;;

using Gemm = cutlass::gemm::device::GemmUniversalAdapter&amp;lt;GemmKernel&amp;gt;;
using StrideA = typename GemmKernel::StrideA;
using StrideB = typename GemmKernel::StrideB;
using StrideC = typename GemmKernel::StrideC;
using StrideD = typename GemmKernel::StrideD;

template &amp;lt;class Element, class Layout&amp;gt;
void fill_random(cutlass::HostTensor&amp;lt;Element, Layout&amp;gt;&amp;amp; tensor, int seed) {
  int bits = cutlass::sizeof_bits&amp;lt;Element&amp;gt;::value;
  double scope = bits &amp;lt;= 8 ? 2.0 : 8.0;
  cutlass::reference::host::TensorFillRandomUniform(
      tensor.host_view(), seed, scope, -scope, 0);
  tensor.sync_device();
}

int main() {
  int M = 4096;
  int N = 4096;
  int K = 4096;
  int L = 1;

  auto stride_A = cutlass::make_cute_packed_stride(
      StrideA{}, cute::make_shape(M, K, L));
  auto stride_B = cutlass::make_cute_packed_stride(
      StrideB{}, cute::make_shape(N, K, L));
  auto stride_C = cutlass::make_cute_packed_stride(
      StrideC{}, cute::make_shape(M, N, L));
  auto stride_D = cutlass::make_cute_packed_stride(
      StrideD{}, cute::make_shape(M, N, L));

  cutlass::HostTensor&amp;lt;ElementA, LayoutA&amp;gt; tensor_A({M, K});
  cutlass::HostTensor&amp;lt;ElementB, LayoutB&amp;gt; tensor_B({K, N});
  cutlass::HostTensor&amp;lt;ElementC, LayoutC&amp;gt; tensor_C({M, N});
  cutlass::HostTensor&amp;lt;ElementD, LayoutD&amp;gt; tensor_D({M, N});

  fill_random(tensor_A, 2026);
  fill_random(tensor_B, 2027);
  fill_random(tensor_C, 2028);
  tensor_D.sync_device();

  typename Gemm::Arguments args{
    cutlass::gemm::GemmUniversalMode::kGemm,
    {M, N, K, L},
    {tensor_A.device_data(), stride_A,
     tensor_B.device_data(), stride_B},
    {
      {}, // fusion args; filled below
      tensor_C.device_data(), stride_C,
      tensor_D.device_data(), stride_D
    }
  };

  // Epilogue computes roughly:
  // D = activation(alpha * scale_a * scale_b * accumulator
  //              + beta * scale_c * C + bias)
  auto&amp;amp; fusion = args.epilogue.thread;
  fusion.alpha = 1.0f;
  fusion.beta = 0.0f;
  fusion.scale_a = 1.0f;
  fusion.scale_b = 1.0f;
  fusion.scale_c = 1.0f;
  fusion.scale_d = 1.0f;
  fusion.scale_aux = 1.0f;
  fusion.bias_ptr = nullptr;
  fusion.aux_ptr = nullptr;
  fusion.amax_D_ptr = nullptr;
  fusion.amax_aux_ptr = nullptr;

  Gemm gemm;
  size_t workspace_size = Gemm::get_workspace_size(args);
  cutlass::device_memory::allocation&amp;lt;uint8_t&amp;gt; workspace(workspace_size);

  cutlass::Status status = gemm.can_implement(args);
  if (status != cutlass::Status::kSuccess) {
    std::cerr &amp;lt;&amp;lt; &quot;GEMM configuration is not supported\n&quot;;
    return -1;
  }

  status = gemm.initialize(args, workspace.get());
  if (status != cutlass::Status::kSuccess) {
    std::cerr &amp;lt;&amp;lt; &quot;GEMM initialization failed\n&quot;;
    return -1;
  }

  status = gemm.run();
  if (status != cutlass::Status::kSuccess) {
    std::cerr &amp;lt;&amp;lt; &quot;GEMM run failed\n&quot;;
    return -1;
  }

  // cudaDeviceSynchronize();
  tensor_D.sync_host();
  std::cout &amp;lt;&amp;lt; &quot;Hopper FP8 GEMM finished\n&quot;;
  return 0;
}&lt;/code&gt;&lt;/pre&gt;
          &lt;/div&gt;
        &lt;/details&gt;

        &lt;h3&gt;12.4 blockwise scaling FP8 要多什么&lt;/h3&gt;
        &lt;p&gt;上面的代码是“普通 FP8 A/B 输入”的主线骨架。LLM 推理中更常见的是 blockwise scaling：A/B 除了 FP8 数据外，还要带 scale tensor。CUTLASS Hopper 示例会把 A 和 scale-A 组合成一个 tuple layout，把 B 和 scale-B 组合成一个 tuple layout，mainloop 在 MMA 前把 scale 带入。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;// 概念差异：普通 FP8
ElementA, LayoutA, AlignmentA
ElementB, LayoutB, AlignmentB

// blockwise scaling FP8
ElementA, cute::tuple&amp;lt;LayoutA, LayoutSFA&amp;gt;, AlignmentA
ElementB, cute::tuple&amp;lt;LayoutB, LayoutSFB&amp;gt;, AlignmentB&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;在 Hopper blockwise FP8 示例里，scale layout 通常由 tile shape 推导，例如 &lt;code&gt;sm90_trivial_blockwise_scale_config(TileShape{})&lt;/code&gt; 再得到 &lt;code&gt;LayoutSFA/LayoutSFB&lt;/code&gt;。这样 scale 的分块方式和 &lt;code&gt;BM/BN/BK&lt;/code&gt; 绑定，避免 epilogue 或 mainloop 里临时做复杂索引。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;把 FP8 GEMM 写到生产级时，CuTe/CUTLASS 的价值不是“少写几行代码”，而是把 tile、layout、TMA、MMA、scale、epilogue 的约束放进类型和 collective 里，让 kernel 更容易系统性调参。&lt;/div&gt;

        &lt;h3&gt;12.5 Python CuTe DSL：运行入口与源码版本&lt;/h3&gt;
        &lt;p&gt;Python CuTe DSL 的完整 GEMM kernel 不是几十行教学代码，而是包含 TMA descriptor、shared layout、pipeline barrier、TMEM、MMA、epilogue、reference check、benchmark 和 cold-L2 workspace 的工程实现。本节保留可运行命令，并从固定版本中摘取关键路径；完整文件仍以官方仓库为准。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;下文代码固定到 NVIDIA CUTLASS commit &lt;a href=&quot;https://github.com/NVIDIA/cutlass/commit/d01487db82c79df188b78b3f35b8aa67fcd864fe&quot;&gt;&lt;code&gt;d01487d&lt;/code&gt;&lt;/a&gt;（2026-07-16），并遵循仓库的 &lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/LICENSE.txt&quot;&gt;BSD-3-Clause license&lt;/a&gt;。固定 commit 很重要：CuTe DSL 的 API 和示例目录仍在演进，直接阅读 &lt;code&gt;main&lt;/code&gt; 可能和本文行号不一致。&lt;/div&gt;
        &lt;table class=&quot;path-table&quot;&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;目标&lt;/th&gt;&lt;th&gt;官方完整文件&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;普通 FP8 dense GEMM&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py&quot;&gt;&lt;code&gt;examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;A/B 同 dtype，可用 &lt;code&gt;Float8E4M3FN&lt;/code&gt; 或 &lt;code&gt;Float8E5M2&lt;/code&gt;，accumulator 通常设 &lt;code&gt;Float32&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;blockscaled FP8 / MXF8 GEMM&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py&quot;&gt;&lt;code&gt;examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;A/B 数据和 SFA/SFB scale tensor 一起参与 mainloop，更接近低精度推理里的真实路线&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;p&gt;普通 FP8 dense GEMM 的完整运行命令：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;cd ${CUTLASS_ROOT}

python examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py \
  --ab_dtype Float8E4M3FN \
  --c_dtype Float16 \
  --acc_dtype Float32 \
  --a_major k \
  --b_major n \
  --c_major n \
  --mma_tiler_mn 128,128 \
  --cluster_shape_mn 1,1 \
  --mnkl 4096,4096,4096,1 \
  --use_tma_store \
  --warmup_iterations 1 \
  --iterations 10&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;blockscaled FP8 / MXF8 GEMM 的完整运行命令：&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;cd ${CUTLASS_ROOT}

python examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py \
  --a_dtype Float8E4M3FN \
  --b_dtype Float8E4M3FN \
  --sf_dtype Float8E8M0FNU \
  --sf_vec_size 32 \
  --c_dtype Float16 \
  --a_major k \
  --b_major n \
  --c_major n \
  --mma_tiler_mn 128,128 \
  --cluster_shape_mn 1,1 \
  --mnkl 4096,4096,4096,1 \
  --warmup_iterations 1 \
  --iterations 10&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这里的 &lt;code&gt;--a_major k&lt;/code&gt; 表示 A 的 K 维连续，等价于常见 row-major A；&lt;code&gt;--b_major n&lt;/code&gt; 表示 B 的 N 维连续，也等价于常见 row-major B。参数名写的是逻辑连续维，不是直接写 RowMajor/ColumnMajor，所以读命令时要先结合矩阵形状 &lt;code&gt;A[M,K]&lt;/code&gt;、&lt;code&gt;B[K,N]&lt;/code&gt; 判断。CuTe DSL 仍在快速演进；实际运行前应先对当前 checkout 执行 &lt;code&gt;python .../dense_gemm.py --help&lt;/code&gt;，确认参数名与支持的 dtype。&lt;/p&gt;
        &lt;h3 id=&quot;pycute-dense&quot;&gt;12.6 普通 FP8 dense kernel：从 host 到 device&lt;/h3&gt;
        &lt;p&gt;&lt;code&gt;dense_gemm.py&lt;/code&gt; 并不是“Python 调一个现成 GEMM”。Python 代码先把 dtype、layout、tile 和 cluster 组织成 CuTe 对象，&lt;code&gt;cute.compile&lt;/code&gt; 再把这些静态信息编译成目标 GPU kernel。下面的命令把 A/B dtype 设成 FP8；同一个 &lt;code&gt;DenseGemmKernel&lt;/code&gt; 类也能被其他受支持 dtype 专门化。&lt;/p&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Python CuTe DSL：编译路径与运行路径&lt;/div&gt;
          &lt;div class=&quot;flow&quot;&gt;
            &lt;div&gt;&lt;strong&gt;run()&lt;/strong&gt;&lt;br&gt;准备 tensor 与参数&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;cute.compile(...)&lt;/strong&gt;&lt;br&gt;驱动 JIT 专门化&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;@cute.jit __call__&lt;/strong&gt;&lt;br&gt;生成 layout / TMA / launch stub&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;compiled_gemm(...)&lt;/strong&gt;&lt;br&gt;提交 GPU launch&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;&lt;strong&gt;@cute.kernel&lt;/strong&gt;&lt;br&gt;TMA → tcgen05 → epilogue&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h4&gt;12.6.1 &lt;code&gt;run()&lt;/code&gt;：先实例化，再编译&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · dense_gemm.py L1639-L1663&lt;/div&gt;
        &lt;pre data-source-file=&quot;dense&quot; data-source-lines=&quot;1639-1663&quot;&gt;&lt;code&gt;a_tensor, b_tensor, c_tensor, a_torch_cpu, b_torch_cpu, c_torch_cpu, c_torch_gpu = (
    create_tensors(l, m, n, k, a_major, b_major, c_major, ab_dtype, c_dtype)
)

# Build GEMM object
gemm = DenseGemmKernel(
    acc_dtype, use_2cta_instrs, mma_tiler_mn, cluster_shape_mn, use_tma_store
)

# Check if configuration can be implemented
can_implement = gemm.can_implement(a_tensor, b_tensor, c_tensor)
if not can_implement:
    raise ValueError(
        f&quot;The current config which is invalid/unsupported: use_2cta_instrs = {use_2cta_instrs}, &quot;
        f&quot;mma_tiler_mn = {mma_tiler_mn}, cluster_shape_mn = {cluster_shape_mn}, &quot;
        f&quot;use_tma_store = {use_tma_store}&quot;
    )
max_active_clusters = utils.HardwareInfo().get_max_active_clusters(
    cluster_shape_mn[0] * cluster_shape_mn[1]
)
compiled_gemm = cute.compile(gemm, a_tensor, b_tensor, c_tensor, current_stream)

if not skip_ref_check:
    compiled_gemm(a_tensor, b_tensor, c_tensor, current_stream)
    compare(a_torch_cpu, b_torch_cpu, c_torch_gpu, c_dtype, tolerance)&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py#L1639-L1663&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;create_tensors&lt;/code&gt; 同时准备 PyTorch tensor 和带动态 layout 的 &lt;code&gt;cute.Tensor&lt;/code&gt; view。随后构造的 &lt;code&gt;DenseGemmKernel&lt;/code&gt; 还不是已编译 kernel；它保存 accumulator dtype、MMA tiler、cluster shape 和 store 策略。&lt;code&gt;can_implement&lt;/code&gt; 先验证 dtype、连续维对齐、tile/cluster 组合与输出边界，&lt;code&gt;cute.compile&lt;/code&gt; 才依据对象配置及 A/B/C tensor 的类型和 layout 生成可调用的 &lt;code&gt;compiled_gemm&lt;/code&gt;。&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;cute.compile(gemm, ...)&lt;/code&gt; 以带 &lt;code&gt;@cute.jit&lt;/code&gt; 的 &lt;code&gt;gemm.__call__&lt;/code&gt; 为编译入口：编译器据此专门化 layout、TMA atom、grid 和 kernel launch stub，并产出 &lt;code&gt;compiled_gemm&lt;/code&gt;。第一次 &lt;code&gt;compiled_gemm(...)&lt;/code&gt; 用来做 reference check，benchmark 则复用这一编译结果。也就是说，Python 在这里主要负责&lt;strong&gt;配置、编译和调度&lt;/strong&gt;，矩阵主循环仍在 &lt;code&gt;@cute.kernel&lt;/code&gt; 生成的 GPU 代码里。&lt;/p&gt;
        &lt;div class=&quot;warn&quot;&gt;这个固定版本在 dense 路径里计算了 &lt;code&gt;max_active_clusters&lt;/code&gt;，但没有把它传给 &lt;code&gt;DenseGemmKernel&lt;/code&gt;；persistent blockscaled 路径才用它限制 grid。读工程示例时应沿参数实际传递关系判断作用，不能只根据局部变量名推断。&lt;/div&gt;

        &lt;h4&gt;12.6.2 &lt;code&gt;@cute.jit __call__&lt;/code&gt;：把 tensor 和 tile 变成 TMA 描述&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · dense_gemm.py L377-L413&lt;/div&gt;
        &lt;pre data-source-file=&quot;dense&quot; data-source-lines=&quot;377-413&quot;&gt;&lt;code&gt;# Setup TMA load for A
a_op = sm100_utils.cluster_shape_to_tma_atom_A(
    self.cluster_shape_mn, tiled_mma.thr_id
)
a_smem_layout = cute.slice_(self.a_smem_layout_staged, (None, None, None, 0))
tma_atom_a, tma_tensor_a = cute.nvgpu.make_tiled_tma_atom_A(
    a_op,
    a,
    a_smem_layout,
    self.mma_tiler,
    tiled_mma,
    self.cluster_layout_vmnk.shape,
    internal_type=(
        cutlass.TFloat32 if a.element_type is cutlass.Float32 else None
    ),
)

# Setup TMA load for B
b_op = sm100_utils.cluster_shape_to_tma_atom_B(
    self.cluster_shape_mn, tiled_mma.thr_id
)
b_smem_layout = cute.slice_(self.b_smem_layout_staged, (None, None, None, 0))
tma_atom_b, tma_tensor_b = cute.nvgpu.make_tiled_tma_atom_B(
    b_op,
    b,
    b_smem_layout,
    self.mma_tiler,
    tiled_mma,
    self.cluster_layout_vmnk.shape,
    internal_type=(
        cutlass.TFloat32 if b.element_type is cutlass.Float32 else None
    ),
)

a_copy_size = cute.size_in_bytes(self.a_dtype, a_smem_layout)
b_copy_size = cute.size_in_bytes(self.b_dtype, b_smem_layout)
self.num_tma_load_bytes = (a_copy_size + b_copy_size) * atom_thr_size&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py#L377-L413&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;make_tiled_tma_atom_A/B&lt;/code&gt; 把五类信息绑定在一起：global tensor、单 stage 的 shared layout、MMA tile、&lt;code&gt;TiledMMA&lt;/code&gt; 的线程组织，以及 cluster layout。返回的 &lt;code&gt;tma_atom_a&lt;/code&gt; 是 copy 操作描述，&lt;code&gt;tma_tensor_a&lt;/code&gt; 是按照该描述重解释后的 global tensor view；二者不是已经搬入 shared memory 的数据。&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;self.num_tma_load_bytes&lt;/code&gt; 也不是“预估带宽”。后面的 TMA pipeline 会把它作为 barrier 的 transaction byte count：只有该 stage 对应的 A/B 字节都到达，消费者才能把 stage 判为 ready。A/B multicast 是否启用，则由 cluster shape 和 TMA atom 的选择共同决定。&lt;/p&gt;

        &lt;h4&gt;12.6.3 Mainloop：等待 stage，发出 tcgen05 MMA，再释放 stage&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · dense_gemm.py L771-L799&lt;/div&gt;
        &lt;pre data-source-file=&quot;dense&quot; data-source-lines=&quot;771-799&quot;&gt;&lt;code&gt;    if is_leader_cta:
        # Conditionally wait for AB buffer full
        consumer_handle = ab_consumer.wait_and_advance(peek_ab_full_status)

        # tCtAcc += tCrA * tCrB
        num_kblks = cute.size(tCrA, mode=[2])
        for kblk_idx in cutlass.range(num_kblks, unroll_full=True):
            kblk_crd = (None, None, kblk_idx, consumer_handle.index)

            cute.gemm(
                tiled_mma, tCtAcc, tCrA[kblk_crd], tCrB[kblk_crd], tCtAcc
            )
            # Enable accumulate on tCtAcc after first kblock
            tiled_mma.set(tcgen05.Field.ACCUMULATE, True)

        # Async arrive AB buffer empty
        consumer_handle.release()

    if k_tile_idx + 1 &amp;lt; k_tile_cnt - prefetch_k_tile_cnt:
        # Peek (try_wait) AB buffer empty for k_tile = prefetch_k_tile_cnt + k_tile + 1
        peek_ab_empty_status = ab_producer.try_acquire()

    if k_tile_idx + 1 &amp;lt; k_tile_cnt and is_leader_cta:
        # Peek (try_wait) AB buffer full for k_tile = k_tile + 1
        peek_ab_full_status = ab_consumer.try_wait()

# Async arrive accumulator buffer full
if is_leader_cta:
    acc_pipeline.producer_commit(acc_producer_state)&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py#L771-L799&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;这段代码位于 producer 已经发出 TMA load 之后。&lt;code&gt;wait_and_advance&lt;/code&gt; 返回当前可消费的 stage；&lt;code&gt;consumer_handle.index&lt;/code&gt; 选择 shared-memory ring buffer 中对应的 A/B fragment。内层 &lt;code&gt;kblk_idx&lt;/code&gt; 再把一个 CTA K tile 拆成 tcgen05 MMA 能直接处理的 K fragment。&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;tCtAcc&lt;/code&gt; 的名字里是 &lt;code&gt;t&lt;/code&gt;，因为 Blackwell 版本把 accumulator 放在 TMEM，而不是普通线程寄存器数组。第一次 &lt;code&gt;cute.gemm&lt;/code&gt; 后设置 &lt;code&gt;ACCUMULATE=True&lt;/code&gt;，后续 MMA 才读旧 accumulator 并继续累加。&lt;code&gt;consumer_handle.release()&lt;/code&gt; 把当前 A/B stage 归还 producer；K-loop 完成后，&lt;code&gt;acc_pipeline.producer_commit&lt;/code&gt; 再通知 epilogue accumulator 已就绪。&lt;/p&gt;

        &lt;h4&gt;12.6.4 Epilogue：TMEM → register → shared → global&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · dense_gemm.py L1011-L1049&lt;/div&gt;
        &lt;pre data-source-file=&quot;dense&quot; data-source-lines=&quot;1011-1049&quot;&gt;&lt;code&gt;subtile_cnt = cute.size(tTR_tAcc.shape, mode=[3])
for subtile_idx in cutlass.range(subtile_cnt):
    #
    # Load accumulator from tensor memory buffer to register
    #
    tTR_tAcc_mn = tTR_tAcc[(None, None, None, subtile_idx)]
    cute.copy(tiled_copy_t2r, tTR_tAcc_mn, tTR_rAcc)

    #
    # Perform epilogue op on accumulator and convert to C type
    #
    acc_vec = tiled_copy_r2s.retile(tTR_rAcc).load()
    acc_vec = epilogue_op(acc_vec.to(self.c_dtype))
    tRS_rC.store(acc_vec)

    #
    # Store C to shared memory
    #
    c_buffer = subtile_idx % self.num_c_stage
    cute.copy(tiled_copy_r2s, tRS_rC, tRS_sC[(None, None, None, c_buffer)])
    # Fence and barrier to make sure shared memory store is visible to TMA store
    cute.arch.fence_proxy(
        &quot;async.shared&quot;,
        space=&quot;cta&quot;,
    )
    pipeline.sync(barrier_id=1)

    # TMA store C to global memory
    if warp_idx == 0:
        cute.copy(
            tma_atom_c, bSG_sC[(None, c_buffer)], bSG_gC[(None, subtile_idx)]
        )
        # Fence and barrier to make sure TMA store is completed to recollect C buffer
        c_pipeline.producer_commit()
        c_pipeline.producer_acquire()
    pipeline.sync(barrier_id=1)

# Wait for C store complete
c_pipeline.producer_tail()&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py#L1011-L1049&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;TMA store 不能直接读取 TMEM accumulator，因此输出要经过两次显式重排：&lt;code&gt;tiled_copy_t2r&lt;/code&gt; 先把一个 epilogue subtile 从 TMEM 搬到 register，&lt;code&gt;tiled_copy_r2s&lt;/code&gt; 再把转换后的结果写入 shared C buffer。&lt;code&gt;epilogue_op&lt;/code&gt; 和 output dtype 转换发生在 register vector 上。&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;fence_proxy(&quot;async.shared&quot;)&lt;/code&gt; 与 CTA barrier 保证 shared store 对 TMA 可见，warp 0 随后发出 shared-to-global TMA store。&lt;code&gt;PipelineTmaStore&lt;/code&gt; 控制 C buffer 何时可以复用。这里也能看到：即使 mainloop 已经结束，输出重排、类型转换和异步 store 仍是一条独立流水线。&lt;/p&gt;

        &lt;h3 id=&quot;pycute-blockscaled&quot;&gt;12.7 Blockscaled FP8：SFA/SFB 如何进入 mainloop&lt;/h3&gt;
        &lt;p&gt;普通 dense 示例的 kernel 参数只有 A、B、C；如果模型使用沿 K 分块的 scale，SFA/SFB 就不能留到 epilogue。Blackwell blockscaled kernel 把 scale factor 作为独立 tensor，与 A/B 一起经过 TMA、shared pipeline 和 TMEM，再由 block-scaled tcgen05 MMA 在每个 K tile 内消费。&lt;/p&gt;
        &lt;div class=&quot;table-scroll comparison-scroll&quot; role=&quot;region&quot; aria-label=&quot;普通 dense FP8 与 Blockscaled FP8 对照&quot; tabindex=&quot;0&quot;&gt;
          &lt;table class=&quot;comparison-table&quot;&gt;
            &lt;thead&gt;&lt;tr&gt;&lt;th&gt;维度&lt;/th&gt;&lt;th&gt;普通 dense FP8&lt;/th&gt;&lt;th&gt;Blockscaled FP8&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
            &lt;tbody&gt;
              &lt;tr&gt;&lt;td&gt;Kernel operand&lt;/td&gt;&lt;td&gt;A、B、C；不含 block scale tensor&lt;/td&gt;&lt;td&gt;A、B、SFA、SFB、C&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;每个 K stage 搬运&lt;/td&gt;&lt;td&gt;A tile + B tile&lt;/td&gt;&lt;td&gt;A + B + 对应的 SFA + SFB&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;MMA operand&lt;/td&gt;&lt;td&gt;&lt;code&gt;A_fragment&lt;/code&gt;、&lt;code&gt;B_fragment&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;[A_fragment, SFA]&lt;/code&gt;、&lt;code&gt;[B_fragment, SFB]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Scale 应用位置&lt;/td&gt;&lt;td&gt;kernel 内没有 K-block scale&lt;/td&gt;&lt;td&gt;位于 K-loop 内，由 block-scaled MMA 消费&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;调度&lt;/td&gt;&lt;td&gt;固定 grid 的 dense kernel&lt;/td&gt;&lt;td&gt;persistent tile scheduler + 专用 TMA/MMA/epilogue warps&lt;/td&gt;&lt;/tr&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;/div&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;Blockscaled persistent kernel 的数据流&lt;/div&gt;
          &lt;div class=&quot;flow&quot;&gt;
            &lt;div&gt;&lt;strong&gt;TMA warp&lt;/strong&gt;&lt;br&gt;A / B / SFA / SFB&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;Staged SMEM&lt;/strong&gt;&lt;br&gt;同一 barrier 管理&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;MMA warp&lt;/strong&gt;&lt;br&gt;SFA/SFB: SMEM → TMEM&lt;/div&gt;
            &lt;div class=&quot;hot&quot;&gt;&lt;strong&gt;tcgen05 MMA&lt;/strong&gt;&lt;br&gt;[A,SFA] × [B,SFB]&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;Epilogue warps&lt;/strong&gt;&lt;br&gt;TMEM → C&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h4&gt;12.7.1 Warp specialization：192 个线程不是做同一件事&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · blockscaled persistent L194-L218&lt;/div&gt;
        &lt;pre data-source-file=&quot;blockscaled&quot; data-source-lines=&quot;194-218&quot;&gt;&lt;code&gt;self.acc_dtype = cutlass.Float32
self.sf_vec_size = sf_vec_size
self.use_2cta_instrs = mma_tiler_mn[0] == 256
self.cluster_shape_mn = cluster_shape_mn
# K dimension is deferred in _setup_attributes
self.mma_tiler = (*mma_tiler_mn, 1)

self.cta_group = (
    tcgen05.CtaGroup.TWO if self.use_2cta_instrs else tcgen05.CtaGroup.ONE
)

self.occupancy = 1
# Set specialized warp ids
self.epilog_warp_id = (
    0,
    1,
    2,
    3,
)
self.mma_warp_id = 4
self.tma_warp_id = 5
self.threads_per_warp = 32
self.threads_per_cta = self.threads_per_warp * len(
    (self.mma_warp_id, self.tma_warp_id, *self.epilog_warp_id)
)&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py#L194-L218&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;一个 CTA 有 6 个 warp：warp 0-3 负责 epilogue，warp 4 专门发出 MMA，warp 5 专门发出 TMA。TMA warp 可以继续为后续 K stage 或后续 output tile 搬数据，而 MMA warp 消费当前 stage；四个 epilogue warp 则并行处理 TMEM accumulator 的输出 subtile。这是 warp specialization，不是把 192 个线程平均分给一个标量循环。&lt;/p&gt;
        &lt;p&gt;kernel 还是 persistent 的：TMA、MMA 和 epilogue 角色各自维护 &lt;code&gt;StaticPersistentTileScheduler&lt;/code&gt; 状态，在完成一个 output tile 后继续领取下一 tile。三个角色通过 A/B pipeline、accumulator pipeline、TMEM allocation barrier 和 epilogue barrier 对齐生命周期。&lt;/p&gt;

        &lt;h4&gt;12.7.2 SFA/SFB 有自己的逻辑 layout 和 TMA atom&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · blockscaled persistent L478-L500&lt;/div&gt;
        &lt;pre data-source-file=&quot;blockscaled&quot; data-source-lines=&quot;478-500&quot;&gt;&lt;code&gt;# Setup sfa/sfb tensor by filling A/B tensor to scale factor atom layout
# ((Atom_M, Rest_M),(Atom_K, Rest_K),RestL)
sfa_layout = blockscaled_utils.tile_atom_to_shape_SF(
    a_tensor.shape, self.sf_vec_size
)
sfa_tensor = cute.make_tensor(sfa_ptr, sfa_layout)

# ((Atom_N, Rest_N),(Atom_K, Rest_K),RestL)
sfb_layout = blockscaled_utils.tile_atom_to_shape_SF(
    b_tensor.shape, self.sf_vec_size
)
sfb_tensor = cute.make_tensor(sfb_ptr, sfb_layout)

tiled_mma = sm100_utils.make_blockscaled_trivial_tiled_mma(
    self.a_dtype,
    self.b_dtype,
    self.a_major_mode,
    self.b_major_mode,
    self.sf_dtype,
    self.sf_vec_size,
    self.cta_group,
    self.mma_inst_shape_mn,
)&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py#L478-L500&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;tile_atom_to_shape_SF&lt;/code&gt; 根据 A/B 的逻辑 shape 和 &lt;code&gt;sf_vec_size&lt;/code&gt; 构造 scale tensor：SFA 与 A 的 M/K 分块对应，SFB 与 B 的 N/K 分块对应。它们不是把一个一维 scale 数组随便挂到 GEMM 参数上；layout 必须表达“哪个 scale 覆盖哪段 K 数据”，并匹配 block-scaled MMA 的 scale-factor atom。&lt;/p&gt;

        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · blockscaled persistent L548-L580&lt;/div&gt;
        &lt;pre data-source-file=&quot;blockscaled&quot; data-source-lines=&quot;548-580&quot;&gt;&lt;code&gt;# Setup TMA load for SFA
sfa_op = sm100_utils.cluster_shape_to_tma_atom_A(
    self.cluster_shape_mn, tiled_mma.thr_id
)
sfa_smem_layout = cute.slice_(
    self.sfa_smem_layout_staged, (None, None, None, 0)
)
tma_atom_sfa, tma_tensor_sfa = cute.nvgpu.make_tiled_tma_atom_A(
    sfa_op,
    sfa_tensor,
    sfa_smem_layout,
    self.mma_tiler,
    tiled_mma,
    self.cluster_layout_vmnk.shape,
    internal_type=cutlass.Int16,
)

# Setup TMA load for SFB
sfb_op = sm100_utils.cluster_shape_to_tma_atom_SFB(
    self.cluster_shape_mn, tiled_mma.thr_id
)
sfb_smem_layout = cute.slice_(
    self.sfb_smem_layout_staged, (None, None, None, 0)
)
tma_atom_sfb, tma_tensor_sfb = cute.nvgpu.make_tiled_tma_atom_B(
    sfb_op,
    sfb_tensor,
    sfb_smem_layout,
    self.mma_tiler_sfb,
    tiled_mma_sfb,
    self.cluster_layout_sfb_vmnk.shape,
    internal_type=cutlass.Int16,
)&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py#L548-L580&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;SFA 复用 A 方向的 cluster multicast 规则，SFB 使用面向 B/列方向的专用 &lt;code&gt;cluster_shape_to_tma_atom_SFB&lt;/code&gt;。两者最终都生成独立 TMA atom 和 tensor view。这里的 &lt;code&gt;internal_type=cutlass.Int16&lt;/code&gt; 描述 TMA/SMEM 搬运时的内部表示，不等于把 scale 的逻辑数值类型改成 INT16；逻辑类型仍由 &lt;code&gt;self.sf_dtype&lt;/code&gt; 决定。&lt;/p&gt;

        &lt;h4&gt;12.7.3 Producer：一个 stage 必须同时等到 A/B/SFA/SFB&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · blockscaled persistent L1070-L1104&lt;/div&gt;
        &lt;pre data-source-file=&quot;blockscaled&quot; data-source-lines=&quot;1070-1104&quot;&gt;&lt;code&gt;for k_tile in cutlass.range(0, k_tile_cnt, 1, unroll=1):
    # Conditionally wait for AB buffer empty
    ab_pipeline.producer_acquire(
        ab_producer_state, peek_ab_empty_status
    )

    # TMA load A/B/SFA/SFB
    cute.copy(
        tma_atom_a,
        tAgA_slice[(None, ab_producer_state.count)],
        tAsA[(None, ab_producer_state.index)],
        tma_bar_ptr=ab_pipeline.producer_get_barrier(ab_producer_state),
        mcast_mask=a_full_mcast_mask,
    )
    cute.copy(
        tma_atom_b,
        tBgB_slice[(None, ab_producer_state.count)],
        tBsB[(None, ab_producer_state.index)],
        tma_bar_ptr=ab_pipeline.producer_get_barrier(ab_producer_state),
        mcast_mask=b_full_mcast_mask,
    )
    cute.copy(
        tma_atom_sfa,
        tAgSFA_slice[(None, ab_producer_state.count)],
        tAsSFA[(None, ab_producer_state.index)],
        tma_bar_ptr=ab_pipeline.producer_get_barrier(ab_producer_state),
        mcast_mask=sfa_full_mcast_mask,
    )
    cute.copy(
        tma_atom_sfb,
        tBgSFB_slice[(None, ab_producer_state.count)],
        tBsSFB[(None, ab_producer_state.index)],
        tma_bar_ptr=ab_pipeline.producer_get_barrier(ab_producer_state),
        mcast_mask=sfb_full_mcast_mask,
    )&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py#L1070-L1104&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;四次 &lt;code&gt;cute.copy&lt;/code&gt; 使用同一个 stage barrier。该 kernel 在创建 pipeline 时把 &lt;code&gt;A + B + SFA + SFB&lt;/code&gt; 的字节数都计入 &lt;code&gt;tx_count&lt;/code&gt;，因此消费者不会在“数据到了、scale 还没到”的中间状态开始 MMA。&lt;code&gt;ab_producer_state.index&lt;/code&gt; 选择 ring buffer 的物理 stage，&lt;code&gt;count&lt;/code&gt; 则选择逻辑上的下一个 K tile。&lt;/p&gt;

        &lt;h4&gt;12.7.4 Consumer：scale 从 SMEM 进入 TMEM，并成为 MMA operand&lt;/h4&gt;
        &lt;div class=&quot;code-label&quot;&gt;Official excerpt · blockscaled persistent L1252-L1289&lt;/div&gt;
        &lt;pre data-source-file=&quot;blockscaled&quot; data-source-lines=&quot;1252-1289&quot;&gt;&lt;code&gt;for k_tile in range(k_tile_cnt):
    if is_leader_cta:
        # Conditionally wait for AB buffer full
        ab_pipeline.consumer_wait(
            ab_consumer_state, peek_ab_full_status
        )

        #  Copy SFA/SFB from smem to tmem
        s2t_stage_coord = (
            None,
            None,
            None,
            None,
            ab_consumer_state.index,
        )
        tCsSFA_compact_s2t_staged = tCsSFA_compact_s2t[s2t_stage_coord]
        tCsSFB_compact_s2t_staged = tCsSFB_compact_s2t[s2t_stage_coord]
        cute.copy(
            tiled_copy_s2t_sfa,
            tCsSFA_compact_s2t_staged,
            tCtSFA_compact_s2t,
        )
        cute.copy(
            tiled_copy_s2t_sfb,
            tCsSFB_compact_s2t_staged,
            tCtSFB_compact_s2t,
        )

        # tCtAcc += tCrA * tCrSFA * tCrB * tCrSFB
        tiled_mma.set(tcgen05.Field.ACCUMULATE, k_tile != 0)
        tile_crd = (None, None, None, ab_consumer_state.index)
        cute.gemm(
            tiled_mma,
            tCtAcc,
            [tCrA[tile_crd], tCtSFA],
            [tCrB[tile_crd], tCtSFB_mma],
            tCtAcc,
        )&lt;/code&gt;&lt;/pre&gt;
        &lt;p class=&quot;source-ref&quot;&gt;&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/d01487db82c79df188b78b3f35b8aa67fcd864fe/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py#L1252-L1289&quot;&gt;查看固定版本中的原始行&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;MMA warp 先等待当前 A/B stage ready，再用两次 S2T copy 把这个 stage 的 SFA/SFB 从 shared memory 放进 TMEM scale layout。随后 &lt;code&gt;cute.gemm&lt;/code&gt; 接收的不是单独 A/B fragment，而是 &lt;code&gt;[A, SFA]&lt;/code&gt; 和 &lt;code&gt;[B, SFB]&lt;/code&gt; 两个 paired operand。&lt;/p&gt;
        &lt;p&gt;&lt;code&gt;ACCUMULATE&lt;/code&gt; 按 &lt;code&gt;k_tile&lt;/code&gt; 更新，说明每一轮 K tile 都使用与该轮匹配的 scale factor，再累加到 FP32 TMEM accumulator。这正是 §11.7 公式 &lt;code&gt;Σ partial[kb] × scale_A[kb] × scale_B[kb]&lt;/code&gt; 的硬件实现；把 SFA/SFB 留到完整 K reduction 之后再乘一次，在这里既不符合代码，也不符合数学语义。&lt;/p&gt;

        &lt;h3&gt;12.8 读 Python CuTe DSL 时先分清这些对象&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;对象&lt;/th&gt;&lt;th&gt;它实际表示什么&lt;/th&gt;&lt;th&gt;常见误读&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;@cute.jit&lt;/code&gt;&lt;/td&gt;&lt;td&gt;由 CuTe 编译器处理的 host/JIT 组装路径&lt;/td&gt;&lt;td&gt;误以为只是普通 Python helper&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;@cute.kernel&lt;/code&gt;&lt;/td&gt;&lt;td&gt;GPU device kernel 本体&lt;/td&gt;&lt;td&gt;从第一行顺序阅读，忽略 warp specialization&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;cute.Tensor&lt;/code&gt;&lt;/td&gt;&lt;td&gt;iterator/pointer 与 layout 的组合 view&lt;/td&gt;&lt;td&gt;误以为调用时复制了一份 tensor&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;SMEM / RMEM / TMEM&lt;/td&gt;&lt;td&gt;shared memory、线程寄存器、Blackwell Tensor Memory&lt;/td&gt;&lt;td&gt;把所有 fragment 都叫“寄存器”&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;cute.copy&lt;/code&gt;&lt;/td&gt;&lt;td&gt;由 copy atom、source/destination layout 决定的搬运&lt;/td&gt;&lt;td&gt;误以为等价于同步的 Python copy&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;cute.gemm&lt;/code&gt;&lt;/td&gt;&lt;td&gt;生成 tcgen05 MMA 的 DSL primitive&lt;/td&gt;&lt;td&gt;误以为是高层框架的 eager matmul&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Pipeline state&lt;/td&gt;&lt;td&gt;stage index、phase、count 与 mbarrier 生命周期&lt;/td&gt;&lt;td&gt;只看循环下标，漏掉 buffer 所有权转移&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;note&quot;&gt;建议先沿“host compile → TMA producer → MMA consumer → epilogue”四条路径分别读，再回头看完整 kernel。不要逐行穿过 3000 多行文件：那会把 layout 构造、persistent scheduler、数值 reference 和 benchmark scaffolding 混成一条难以验证的叙事。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;triton&quot;&gt;
        &lt;h2&gt;13. Triton GEMM：用 Python 写 tile kernel&lt;/h2&gt;
        &lt;p&gt;Triton 位于“直接调用库”和“手写 CUDA/CuTe kernel”之间：它保留了 tile、program id、mask、accumulator、autotune 这些关键控制点，但把线程级地址计算、LLVM/MLIR lowering 和具体后端代码生成隐藏掉。对教学来说，Triton 很适合把前面讲的 BM/BN/BK、tail mask、&lt;code&gt;tl.dot&lt;/code&gt; 和 accumulator 连起来。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;Triton 不是“更简单的 cuBLAS”。它适合 shape 特殊、需要融合、想快速试 kernel 结构的场景；如果只是标准大 GEMM，成熟库仍然经常更稳、更快。&lt;/div&gt;

        &lt;h3&gt;13.1 一个 Triton matmul kernel 对应前文哪几层&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;本文概念&lt;/th&gt;&lt;th&gt;Triton 写法&lt;/th&gt;&lt;th&gt;CUDA / CUTLASS 类比&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;CTA 负责一个 C tile&lt;/td&gt;&lt;td&gt;&lt;code&gt;tl.program_id(0)&lt;/code&gt; 映射到 &lt;code&gt;(pid_m, pid_n)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;blockIdx&lt;/code&gt; / thread block tile&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;BM/BN/BK&lt;/td&gt;&lt;td&gt;&lt;code&gt;BLOCK_M&lt;/code&gt;、&lt;code&gt;BLOCK_N&lt;/code&gt;、&lt;code&gt;BLOCK_K&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;TileShape&amp;lt;BM, BN, BK&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;global load + tail&lt;/td&gt;&lt;td&gt;&lt;code&gt;tl.load(..., mask=...)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;边界判断、predicated load&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;MMA / Tensor Core&lt;/td&gt;&lt;td&gt;&lt;code&gt;tl.dot(a, b)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;mma.sync&lt;/code&gt; / WGMMA / collective mainloop&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;accumulator&lt;/td&gt;&lt;td&gt;&lt;code&gt;tl.zeros((BM, BN), tl.float32)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;register accumulator fragment&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;调参&lt;/td&gt;&lt;td&gt;&lt;code&gt;BLOCK_*&lt;/code&gt;、&lt;code&gt;num_warps&lt;/code&gt;、&lt;code&gt;num_stages&lt;/code&gt;、autotune configs&lt;/td&gt;&lt;td&gt;tile shape、warp 数、pipeline stage、heuristic&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;13.2 教学版 Triton GEMM&lt;/h3&gt;
        &lt;p&gt;下面这段代码保留了 Triton GEMM 的核心结构：一个 program 负责一个 &lt;code&gt;BLOCK_M x BLOCK_N&lt;/code&gt; 的 C tile，沿 K 维分块循环，每轮加载 A/B 子块，用 &lt;code&gt;tl.dot&lt;/code&gt; 累加，最后写回 C。真实项目还会加 grouped ordering、autotune、dtype 选择、epilogue fusion 和 benchmark。&lt;/p&gt;
        &lt;details class=&quot;code-disclosure&quot;&gt;
          &lt;summary&gt;查看完整 Triton GEMM 教学 kernel&lt;/summary&gt;
          &lt;div class=&quot;code-disclosure-body&quot;&gt;
        &lt;div class=&quot;code-label&quot;&gt;Teaching kernel · Triton&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;import torch
import triton
import triton.language as tl


@triton.jit
def matmul_kernel(
    a_ptr, b_ptr, c_ptr,
    M, N, K,
    stride_am, stride_ak,
    stride_bk, stride_bn,
    stride_cm, stride_cn,
    BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,
):
    pid = tl.program_id(axis=0)
    num_pid_n = tl.cdiv(N, BLOCK_N)
    pid_m = pid // num_pid_n
    pid_n = pid % num_pid_n

    offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)
    offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)
    offs_k = tl.arange(0, BLOCK_K)

    a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak
    b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn
    acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)

    for k_block in range(0, tl.cdiv(K, BLOCK_K)):
        a = tl.load(
            a_ptrs,
            mask=(offs_m[:, None] &amp;lt; M) &amp;amp;
                 (offs_k[None, :] &amp;lt; K - k_block * BLOCK_K),
            other=0.0,
        )
        b = tl.load(
            b_ptrs,
            mask=(offs_k[:, None] &amp;lt; K - k_block * BLOCK_K) &amp;amp;
                 (offs_n[None, :] &amp;lt; N),
            other=0.0,
        )
        acc += tl.dot(a, b)
        a_ptrs += BLOCK_K * stride_ak
        b_ptrs += BLOCK_K * stride_bk

    c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn
    tl.store(c_ptrs, acc, mask=(offs_m[:, None] &amp;lt; M) &amp;amp; (offs_n[None, :] &amp;lt; N))


def matmul(a, b):
    assert a.is_cuda and b.is_cuda
    assert a.ndim == 2 and b.ndim == 2
    assert a.dtype == b.dtype
    assert a.dtype in (torch.float16, torch.bfloat16)
    M, K = a.shape
    K2, N = b.shape
    assert K == K2
    c = torch.empty((M, N), device=a.device, dtype=a.dtype)

    grid = (triton.cdiv(M, 128) * triton.cdiv(N, 128),)
    matmul_kernel[grid](
        a, b, c, M, N, K,
        a.stride(0), a.stride(1),
        b.stride(0), b.stride(1),
        c.stride(0), c.stride(1),
        BLOCK_M=128, BLOCK_N=128, BLOCK_K=64,
        num_warps=4, num_stages=4,
    )
    return c&lt;/code&gt;&lt;/pre&gt;
          &lt;/div&gt;
        &lt;/details&gt;
        &lt;p&gt;&lt;code&gt;M/N/K&lt;/code&gt; 和 stride 作为运行时参数传入，避免每个 shape 都生成一份专门化 kernel；&lt;code&gt;BLOCK_M/N/K&lt;/code&gt;、&lt;code&gt;num_warps&lt;/code&gt;、&lt;code&gt;num_stages&lt;/code&gt; 才是编译期 meta-parameter。&lt;code&gt;tl.store&lt;/code&gt; 会按 &lt;code&gt;c_ptr&lt;/code&gt; 的元素类型把 FP32 accumulator 转成 FP16 或 BF16。&lt;/p&gt;

        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;为什么要保留 mask&lt;/div&gt;
            &lt;p&gt;真实 shape 往往不能整除 BM/BN/BK。Triton 的 &lt;code&gt;tl.load&lt;/code&gt; / &lt;code&gt;tl.store&lt;/code&gt; mask 把 tail 处理写进向量化表达式里，避免为边界 tile 单独写一个 kernel。&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;为什么 accumulator 用 FP32&lt;/div&gt;
            &lt;p&gt;BF16/FP16 输入通常仍以 FP32 累加，然后在 epilogue cast 到目标 dtype。低精度 GEMM 的数值质量很大程度取决于 accumulator dtype 和 epilogue 的转换策略。&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h3&gt;13.3 从 program_id 到 C tile&lt;/h3&gt;
        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;flow&quot;&gt;
            &lt;div&gt;&lt;strong&gt;program_id&lt;/strong&gt;&lt;br&gt;一维 grid 编号&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;pid_m / pid_n&lt;/strong&gt;&lt;br&gt;映射到 C 的 tile 坐标&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;offs_m / offs_n&lt;/strong&gt;&lt;br&gt;生成 M/N 向量索引&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;K loop&lt;/strong&gt;&lt;br&gt;每轮推进 BLOCK_K&lt;/div&gt;
            &lt;div&gt;&lt;strong&gt;tl.dot&lt;/strong&gt;&lt;br&gt;累加到 C tile&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;上面的 grid 是一维的：&lt;code&gt;pid&lt;/code&gt; 先除以 N 方向 tile 数得到 &lt;code&gt;pid_m&lt;/code&gt;，再取模得到 &lt;code&gt;pid_n&lt;/code&gt;。这和 CUDA 里用二维 &lt;code&gt;blockIdx.y/blockIdx.x&lt;/code&gt; 没有本质区别，只是 Triton 教程常用一维 program id 来方便做 grouped ordering。&lt;/p&gt;

        &lt;h3&gt;13.4 Autotune 调什么&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;参数&lt;/th&gt;&lt;th&gt;影响&lt;/th&gt;&lt;th&gt;profile 上常见信号&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;BLOCK_M / BLOCK_N&lt;/code&gt;&lt;/td&gt;&lt;td&gt;C tile 面积、A/B 复用、accumulator 大小&lt;/td&gt;&lt;td&gt;Tensor Core 利用率低、CTA 数不足、register pressure 高&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;BLOCK_K&lt;/code&gt;&lt;/td&gt;&lt;td&gt;每轮 K 维深度、load 粒度、dot 输入块大小&lt;/td&gt;&lt;td&gt;HBM 事务过碎、shared/register 压力变化&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;num_warps&lt;/code&gt;&lt;/td&gt;&lt;td&gt;一个 program 内的 warp 资源&lt;/td&gt;&lt;td&gt;occupancy、stall、每 tile 并行度&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;num_stages&lt;/code&gt;&lt;/td&gt;&lt;td&gt;软件 pipeline 深度&lt;/td&gt;&lt;td&gt;memory dependency stall、shared memory 用量、occupancy&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;p&gt;Triton 官方 matmul 教程会给出多组 &lt;code&gt;triton.Config&lt;/code&gt;，CUDA 和 HIP 后端的推荐候选也不同。经验上，不要把 NVIDIA 上的 config 原样搬到 AMD；同一个 &lt;code&gt;BLOCK_M/N/K&lt;/code&gt;，寄存器、LDS、wavefront、MFMA 路径和编译器 lowering 都可能让最优点变化。&lt;/p&gt;

        &lt;h3&gt;13.5 Triton 和 CUTLASS / 手写 CUDA 的取舍&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;/th&gt;&lt;th&gt;优势&lt;/th&gt;&lt;th&gt;代价&lt;/th&gt;&lt;th&gt;适合&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Triton&lt;/td&gt;&lt;td&gt;迭代快，容易融合，Python 侧接入方便&lt;/td&gt;&lt;td&gt;极限控制弱于 CUDA/CuTe，性能依赖编译器和后端成熟度&lt;/td&gt;&lt;td&gt;shape 专用 kernel、融合算子、研究和线上快速试错&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CUTLASS / CuTe&lt;/td&gt;&lt;td&gt;对 NVIDIA 新架构特性覆盖深，mainloop/epilogue 可组合&lt;/td&gt;&lt;td&gt;C++ 模板复杂，学习成本高&lt;/td&gt;&lt;td&gt;生产级 NVIDIA GEMM、FP8、TMA/WGMMA、复杂 epilogue&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;手写 CUDA/HIP&lt;/td&gt;&lt;td&gt;控制最细，可以做非常规调度&lt;/td&gt;&lt;td&gt;维护成本最高，跨架构成本高&lt;/td&gt;&lt;td&gt;库和 DSL 覆盖不了的极特殊 kernel&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/section&gt;

      &lt;section id=&quot;hipblas&quot;&gt;
        &lt;h2&gt;14. hipBLAS / hipBLASLt：AMD ROCm 里的 GEMM 库路线&lt;/h2&gt;
        &lt;p&gt;在 ROCm 生态里，GEMM 不只有一种入口。&lt;code&gt;hipBLAS&lt;/code&gt; 更像 BLAS API 的可移植门面：应用调用 hipBLAS，下面可以接 AMD 的 &lt;code&gt;rocBLAS&lt;/code&gt;，也可以在 CUDA 平台接 &lt;code&gt;cuBLAS&lt;/code&gt;。&lt;code&gt;hipBLASLt&lt;/code&gt; 则是更灵活的 matmul API，重点放在 layout、algorithm、heuristic、workspace、tuning 和 epilogue 上。&lt;/p&gt;
        &lt;div class=&quot;note&quot;&gt;&lt;strong&gt;术语边界：&lt;/strong&gt;前文的 Tensor Core、warp、shared memory、&lt;code&gt;ldmatrix&lt;/code&gt;、&lt;code&gt;cp.async&lt;/code&gt; 主要是 NVIDIA 语境；AMD 常见对应词是 Matrix Core / MFMA、wave、LDS 和 &lt;code&gt;ds_read&lt;/code&gt;/&lt;code&gt;ds_write&lt;/code&gt;。tile、复用、pipeline、bank conflict 这些设计原则可以迁移，指令形状、lane mapping 和 layout 不能一一照抄。&lt;/div&gt;

        &lt;div class=&quot;diagram&quot;&gt;
          &lt;div class=&quot;diagram-title&quot;&gt;ROCm GEMM 的三条并列路径，不是一条串行调用链&lt;/div&gt;
          &lt;div class=&quot;api-stack&quot;&gt;
            &lt;div class=&quot;api-root&quot;&gt;Framework / Application&lt;br&gt;&lt;span&gt;PyTorch · vLLM · 自研 runtime&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;api-branch-label&quot;&gt;按可移植性、融合需求和目标 shape 选择入口&lt;/div&gt;
            &lt;div class=&quot;api-paths&quot;&gt;
              &lt;div class=&quot;api-path&quot;&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;hipBLAS&lt;/strong&gt;标准 BLAS 兼容门面&lt;/div&gt;
                &lt;div class=&quot;api-arrow&quot;&gt;↓&lt;/div&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;rocBLAS / cuBLAS&lt;/strong&gt;AMD / NVIDIA 平台后端&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;api-path&quot;&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;hipBLASLt&lt;/strong&gt;descriptor · heuristic · epilogue&lt;/div&gt;
                &lt;div class=&quot;api-arrow&quot;&gt;↓&lt;/div&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;Optimized algorithm pool&lt;/strong&gt;按 shape、dtype、workspace 选择 kernel&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;api-path&quot;&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;Triton / CK / AITER&lt;/strong&gt;DSL、组件库或 AI kernel 集合&lt;/div&gt;
                &lt;div class=&quot;api-arrow&quot;&gt;↓&lt;/div&gt;
                &lt;div class=&quot;api-node&quot;&gt;&lt;strong&gt;Custom GPU kernels&lt;/strong&gt;为融合和热点 shape 特化&lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;&lt;code&gt;hipBLASLt&lt;/code&gt; 不是 &lt;code&gt;rocBLAS&lt;/code&gt; 调用链的下一层，Triton/CK/AITER 也不是 hipBLASLt 的后端。它们是应用可以分别选择、并在同一框架中并存的实现路线。&lt;/p&gt;

        &lt;h3&gt;14.1 先把几个名字分清&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;名字&lt;/th&gt;&lt;th&gt;它是什么&lt;/th&gt;&lt;th&gt;更接近的 NVIDIA 概念&lt;/th&gt;&lt;th&gt;读者该怎么用&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;rocBLAS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;ROCm 的底层 BLAS 实现库&lt;/td&gt;&lt;td&gt;&lt;code&gt;cuBLAS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;标准 GEMM baseline，通常被上层框架间接调用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;hipBLAS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;BLAS marshaling / portability API，可转发到 rocBLAS 或 cuBLAS&lt;/td&gt;&lt;td&gt;跨平台 BLAS 门面&lt;/td&gt;&lt;td&gt;想写 HIP/CUDA 双后端基础 GEMM 时使用&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;hipBLASLt&lt;/code&gt;&lt;/td&gt;&lt;td&gt;更灵活的 GEMM API，支持 descriptor、algorithm、heuristic、workspace、tuning&lt;/td&gt;&lt;td&gt;&lt;code&gt;cuBLASLt&lt;/code&gt;&lt;/td&gt;&lt;td&gt;需要 layout/epilogue/tuning 时优先看&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;Composable Kernel&lt;/code&gt;&lt;/td&gt;&lt;td&gt;ROCm 的 C++ kernel/template 组件库&lt;/td&gt;&lt;td&gt;部分角色接近 CUTLASS&lt;/td&gt;&lt;td&gt;需要构造或理解 AMD 定制 kernel 时看&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;code&gt;AITER&lt;/code&gt;&lt;/td&gt;&lt;td&gt;面向 AI workload 的 AMD 优化算子与 kernel 集合&lt;/td&gt;&lt;td&gt;更接近领域 kernel library&lt;/td&gt;&lt;td&gt;框架已有接入，或热点 shape/融合已被覆盖时对照测试&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;14.2 hipBLAS：标准 GEMM baseline&lt;/h3&gt;
        &lt;p&gt;hipBLAS 的优势是接口熟悉、迁移成本低。注意 BLAS API 的传统约定偏 column-major；如果你的张量是 row-major，常见处理方式是交换 A/B、调整转置标志，或在上层 layout 上显式处理 stride。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch · hipBLAS SGEMM&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;hipblasHandle_t handle;
hipblasCreate(&amp;amp;handle);

const float alpha = 1.0f;
const float beta = 0.0f;

// BLAS uses column-major convention. For row-major C[M, N] = A[M, K] * B[K, N],
// many examples call GEMM as column-major C^T[N, M] = B^T[N, K] * A^T[K, M].
hipblasSgemm(
    handle,
    HIPBLAS_OP_N, HIPBLAS_OP_N,
    N, M, K,
    &amp;amp;alpha,
    B, N,
    A, K,
    &amp;amp;beta,
    C, N);

hipblasDestroy(handle);&lt;/code&gt;&lt;/pre&gt;
        &lt;p&gt;这段代码适合作 baseline，不适合解释高性能 GEMM 的全部细节。真实性能来自库内部选到了什么 kernel、对应什么 dtype、layout、stride、workspace 和架构，而不是来自这几行 API 本身。&lt;/p&gt;

        &lt;h3&gt;14.3 hipBLASLt：更像生产 matmul 的入口&lt;/h3&gt;
        &lt;p&gt;LLM 推理里的 GEMM 往往不是裸乘法：可能有 bias、activation、scale、输出 dtype 转换，也可能要为固定 shape 做离线调优。hipBLASLt 的心智模型就是把一次 matmul 拆成 descriptor、matrix layout、preference、heuristic result 和实际 launch。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Concept sketch · hipBLASLt API flow&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;create hipblasLt handle

create matmul descriptor
  - compute type
  - transpose flags
  - epilogue mode
  - bias / auxiliary pointer if needed

create matrix layouts for A, B, C, D
  - dtype
  - rows / cols
  - leading dimension
  - batch stride if batched

create preference
  - max workspace bytes
  - algorithm search constraints

query heuristic algorithms
allocate workspace
run hipblasLtMatmul(...)
destroy descriptors&lt;/code&gt;&lt;/pre&gt;

        &lt;div class=&quot;two-col&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;hipBLASLt 比 hipBLAS 多了什么&lt;/div&gt;
            &lt;p&gt;更多 layout 描述、algorithm 选择、workspace 控制、logging/heuristic/tuning 工具，以及更接近生产推理的 epilogue 配置。&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;mini-title&quot;&gt;它仍然不是 CUTLASS&lt;/div&gt;
            &lt;p&gt;hipBLASLt 是库 API，重点是选择和调用已有算法；CUTLASS/CK 更像构造 kernel 的模板工具。两者解决的问题层级不同。&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;

        &lt;h3&gt;14.4 和 CUDA / Triton / CUTLASS 路线怎么比较&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;/th&gt;&lt;th&gt;抽象层&lt;/th&gt;&lt;th&gt;什么时候优先用&lt;/th&gt;&lt;th&gt;主要限制&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;cuBLAS / rocBLAS / hipBLAS&lt;/td&gt;&lt;td&gt;标准 BLAS 调用&lt;/td&gt;&lt;td&gt;快速建立 baseline，标准 GEMM&lt;/td&gt;&lt;td&gt;融合和 layout 控制有限&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;cuBLASLt / hipBLASLt&lt;/td&gt;&lt;td&gt;descriptor + heuristic + algorithm&lt;/td&gt;&lt;td&gt;需要 epilogue、workspace、算法选择和 shape tuning&lt;/td&gt;&lt;td&gt;仍受库已实现 kernel 覆盖范围约束&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CUTLASS / CK&lt;/td&gt;&lt;td&gt;C++ 模板 / kernel 组件&lt;/td&gt;&lt;td&gt;要构造生产 kernel，控制 mainloop/epilogue/layout&lt;/td&gt;&lt;td&gt;代码复杂，编译和调参成本高&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Triton&lt;/td&gt;&lt;td&gt;Python kernel DSL&lt;/td&gt;&lt;td&gt;快速做定制融合和 shape 专用 kernel&lt;/td&gt;&lt;td&gt;极限性能和新硬件特性依赖后端成熟度&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;手写 CUDA/HIP&lt;/td&gt;&lt;td&gt;最低层 kernel&lt;/td&gt;&lt;td&gt;需要完全自定义调度或验证硬件机制&lt;/td&gt;&lt;td&gt;维护和跨架构迁移成本最高&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;

        &lt;h3&gt;14.5 在 LLM 推理里怎么选&lt;/h3&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;需求&lt;/th&gt;&lt;th&gt;建议路线&lt;/th&gt;&lt;th&gt;理由&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;先确认 AMD/NVIDIA 上 GEMM 是否正常&lt;/td&gt;&lt;td&gt;hipBLAS / rocBLAS / cuBLAS&lt;/td&gt;&lt;td&gt;最小变量，方便排查 dtype、layout、stride 问题&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;标准大 GEMM 要稳定性能&lt;/td&gt;&lt;td&gt;hipBLASLt / cuBLASLt&lt;/td&gt;&lt;td&gt;库的 heuristic 和 tuned algorithms 往往先给出很强 baseline&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;小 M、MoE、decode shape、特殊 batch&lt;/td&gt;&lt;td&gt;hipBLASLt tuning + Triton / CK 对照&lt;/td&gt;&lt;td&gt;标准大 GEMM 的最优策略不一定适合 serving shape&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;需要融合 scale、bias、activation、requantize&lt;/td&gt;&lt;td&gt;hipBLASLt epilogue / Triton / CK / CUTLASS&lt;/td&gt;&lt;td&gt;瓶颈可能从 mainloop 转移到 epilogue，必须把融合路径纳入 benchmark&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;跨后端框架适配&lt;/td&gt;&lt;td&gt;先用 hipBLAS 建公共路径，再为热点 shape 下沉&lt;/td&gt;&lt;td&gt;baseline 保持可移植，热点 kernel 再按架构特化&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;blue&quot;&gt;ROCm 上做 GEMM 调优时，最实用的工作流不是“选一个库后永远不换”，而是先用 hipBLAS/rocBLAS 建正确性和 baseline，再用 hipBLASLt、Triton、CK 或 AITER 对热点 shape 做交叉 benchmark。&lt;/div&gt;

        &lt;h3&gt;14.6 ROCm 上怎么 profile&lt;/h3&gt;
        &lt;p&gt;与 §10 的 CUDA 工作流类似，ROCm 也应先分清“端到端时间线问题”和“单 kernel 硬件瓶颈”。&lt;code&gt;rocprofv3&lt;/code&gt; 适合采集 HIP API、kernel dispatch、memory copy 和指定硬件 counter；&lt;code&gt;rocprof-compute&lt;/code&gt; 在这些数据之上提供 Speed-of-Light、memory hierarchy、roofline 和结果对比。&lt;/p&gt;
        &lt;div class=&quot;code-label&quot;&gt;Production profiling command&lt;/div&gt;
        &lt;pre&gt;&lt;code&gt;# 先看 HIP runtime、kernel dispatch 和 memory copy 时间线
rocprofv3 --runtime-trace -- ./your_benchmark

# 再采集单 kernel 分析；工具会多次运行 workload 收集 counter
rocprof-compute profile \
  --name gemm_profile \
  --no-roof \
  -- ./your_benchmark

# 分析采集结果；实际 SoC 子目录由工具生成
rocprof-compute analyze -p workloads/gemm_profile/&amp;lt;soc&amp;gt;/&lt;/code&gt;&lt;/pre&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;CUDA 侧问题&lt;/th&gt;&lt;th&gt;ROCm 对应观察&lt;/th&gt;&lt;th&gt;GEMM 调参关联&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;Tensor Core 是否饱和&lt;/td&gt;&lt;td&gt;MFMA / Matrix Core 指令与 compute throughput&lt;/td&gt;&lt;td&gt;检查 dtype 路径、tile、wave 分工和 MFMA 指令形状&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Shared bank conflict&lt;/td&gt;&lt;td&gt;LDS access / bank conflict 与 &lt;code&gt;ds_read&lt;/code&gt; 模式&lt;/td&gt;&lt;td&gt;检查 LDS padding、XOR preshuffle、wave lane mapping&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;HBM/L2/L1 压力&lt;/td&gt;&lt;td&gt;memory hierarchy throughput 与 roofline&lt;/td&gt;&lt;td&gt;检查 A/B 复用、global load 合并、epilogue traffic&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Occupancy / spill&lt;/td&gt;&lt;td&gt;wave occupancy、VGPR/SGPR/LDS 用量&lt;/td&gt;&lt;td&gt;减小 tile、stage 或临时 fragment，检查 scratch/spill&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;div class=&quot;warn&quot;&gt;ROCm counter 名称和可同时采集的组合取决于 &lt;code&gt;gfx&lt;/code&gt; 架构与 ROCm 版本。先运行 &lt;code&gt;rocprofv3-avail list&lt;/code&gt; / &lt;code&gt;rocprof-compute profile --list-available-metrics&lt;/code&gt;，再为目标 MI 系列选择指标，不要把另一代 GPU 的 counter 名称写死到脚本里。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;checklist&quot;&gt;
        &lt;h2&gt;15. 实战 Checklist&lt;/h2&gt;
        &lt;ul&gt;
          &lt;li&gt;先确认 shape：M/N/K 是否足够大，是否存在小 M 或 tail block。&lt;/li&gt;
          &lt;li&gt;先用 cuBLAS / cuBLASLt / CUTLASS / Triton / hipBLAS / hipBLASLt 建 baseline。&lt;/li&gt;
          &lt;li&gt;BF16 先检查 Tensor Core / MFMA matrix-core path 是否生效，accumulator 是否符合精度预算。&lt;/li&gt;
          &lt;li&gt;调 tile size 时同时看 shared memory、register pressure 和 occupancy。&lt;/li&gt;
          &lt;li&gt;FP8 先定 scale 粒度，再定 kernel layout；不要把 scale 当成事后补丁。&lt;/li&gt;
          &lt;li&gt;CUDA 先用 &lt;code&gt;nsys&lt;/code&gt; 判断是不是 kernel 本身慢，再用 &lt;code&gt;ncu&lt;/code&gt; 看单 kernel；ROCm 对应先用 &lt;code&gt;rocprofv3&lt;/code&gt;，再用 &lt;code&gt;rocprof-compute&lt;/code&gt;。&lt;/li&gt;
          &lt;li&gt;profile 时把 mainloop 和 epilogue 分开看，很多 FP8 kernel 瓶颈会转移到 epilogue。&lt;/li&gt;
        &lt;/ul&gt;
        &lt;div class=&quot;note&quot;&gt;工程建议：自己写 kernel 前，先把成熟库的性能边界摸清楚。只有在 shape 特殊、融合需求强、或框架 overhead 明确时，手写 GEMM 才更划算。&lt;/div&gt;
      &lt;/section&gt;

      &lt;section id=&quot;pitfalls&quot;&gt;
        &lt;h2&gt;16. 常见误区&lt;/h2&gt;
        &lt;table&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;误区&lt;/th&gt;&lt;th&gt;为什么不对&lt;/th&gt;&lt;th&gt;更好的判断&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;&lt;td&gt;BM/BN/BK 有固定最佳值&lt;/td&gt;&lt;td&gt;tile 受 shape、dtype、SM 资源、epilogue、架构共同约束&lt;/td&gt;&lt;td&gt;把经验值当候选，用 profile 选&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;occupancy 越高越好&lt;/td&gt;&lt;td&gt;高 occupancy 可能来自每个线程工作太少，Tensor Core 仍然吃不满&lt;/td&gt;&lt;td&gt;同时看 Tensor Core 利用率、stall reason、HBM 带宽&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;shared memory 一定更快&lt;/td&gt;&lt;td&gt;shared 也有 bank conflict、同步、容量和 occupancy 成本&lt;/td&gt;&lt;td&gt;确认 shared layout 服务于后续 warp/MMA 读取&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;FP8 只是把 dtype 从 BF16 改成 FP8&lt;/td&gt;&lt;td&gt;FP8 的 scale、amax、requantize、clipping 会改变 mainloop 和 epilogue&lt;/td&gt;&lt;td&gt;先定 scale 粒度，再定 layout 和 kernel&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;看平均 TFLOP/s 就够&lt;/td&gt;&lt;td&gt;LLM 推理有小 M、tail、MoE、decode/prefill 混合，平均数掩盖瓶颈&lt;/td&gt;&lt;td&gt;按 shape bucket 分开 benchmark&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;CuTe/CUTLASS 能自动解决所有问题&lt;/td&gt;&lt;td&gt;DSL 降低表达成本，但 tile、layout、schedule、epilogue 仍要选择&lt;/td&gt;&lt;td&gt;把 DSL 当调参框架，不是黑盒&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Triton 一定比库快&lt;/td&gt;&lt;td&gt;Triton 迭代快，但标准大 GEMM 上库 kernel 和 heuristic 可能更成熟&lt;/td&gt;&lt;td&gt;对同一 shape 同时 benchmark Triton、BLASLt 和框架内置 kernel&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;hipBLASLt 就是 AMD 版 CUTLASS&lt;/td&gt;&lt;td&gt;hipBLASLt 是可调库 API，CUTLASS/CK 是更接近 kernel 构造的模板/组件库&lt;/td&gt;&lt;td&gt;按抽象层选择工具：调用库、调算法、还是写 kernel&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/section&gt;

      &lt;section id=&quot;refs&quot;&gt;
        &lt;h2&gt;17. 参考资料&lt;/h2&gt;
        &lt;p&gt;继续深入时，优先看官方文档和官方示例，因为 CUDA/CUTLASS 的接口和硬件细节会随版本更新。&lt;/p&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;https://docs.nvidia.com/cuda/cuda-programming-guide/&quot;&gt;NVIDIA CUDA C++ Programming Guide&lt;/a&gt;：memory coalescing、shared memory、async copy、alignment。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://docs.nvidia.com/nsight-systems/UserGuide/index.html&quot;&gt;NVIDIA Nsight Systems User Guide&lt;/a&gt;：端到端 CUDA timeline、CPU/GPU overlap、kernel launch、memcpy、NCCL。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html&quot;&gt;NVIDIA Nsight Compute Profiling Guide&lt;/a&gt;：单 kernel 的 Tensor Core、memory workload、occupancy、warp stall、shared bank conflict。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://docs.nvidia.com/cutlass/latest/&quot;&gt;NVIDIA CUTLASS 文档&lt;/a&gt;：CUTLASS GEMM、CuTe layout、collective mainloop/epilogue 与 CuTe DSL。&lt;/li&gt;
          &lt;li&gt;CUTLASS Hopper FP8 示例：&lt;a href=&quot;https://github.com/NVIDIA/cutlass/tree/main/examples/54_hopper_fp8_warp_specialized_gemm&quot;&gt;&lt;code&gt;examples/54_hopper_fp8_warp_specialized_gemm&lt;/code&gt;&lt;/a&gt;、&lt;a href=&quot;https://github.com/NVIDIA/cutlass/tree/main/examples/67_hopper_fp8_warp_specialized_gemm_with_blockwise_scaling&quot;&gt;&lt;code&gt;examples/67_hopper_fp8_warp_specialized_gemm_with_blockwise_scaling&lt;/code&gt;&lt;/a&gt;。&lt;/li&gt;
          &lt;li&gt;Python CuTe DSL 示例：&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/main/examples/python/CuTeDSL/cute/blackwell/kernel/dense_gemm/dense_gemm.py&quot;&gt;&lt;code&gt;dense_gemm.py&lt;/code&gt;&lt;/a&gt;、&lt;a href=&quot;https://github.com/NVIDIA/cutlass/blob/main/examples/python/CuTeDSL/cute/blackwell/kernel/blockscaled_gemm/dense_blockscaled_gemm_persistent.py&quot;&gt;&lt;code&gt;dense_blockscaled_gemm_persistent.py&lt;/code&gt;&lt;/a&gt;；另见 &lt;a href=&quot;https://docs.nvidia.com/cutlass/latest/media/docs/operators/tutorials/006_block_scaled_gemm.html&quot;&gt;CUTLASS block-scaled GEMM 教程&lt;/a&gt;。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://www.aleksagordic.com/blog/matmul&quot;&gt;Inside NVIDIA GPUs: Anatomy of high performance matmul kernels&lt;/a&gt;：一篇很适合作进一步阅读的 matmul 长文，覆盖 GPU 架构、PTX/SASS、warp tiling、Hopper TMA 和异步 Tensor Core pipeline。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://triton-lang.org/main/getting-started/tutorials/03-matrix-multiplication.html&quot;&gt;Triton official matrix multiplication tutorial&lt;/a&gt;：Triton matmul、autotune、CUDA/HIP config 示例。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/hipBLAS/en/latest/&quot;&gt;AMD hipBLAS documentation&lt;/a&gt;：hipBLAS 作为 BLAS marshaling library 的定位和 API。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/hipBLASLt/en/latest/&quot;&gt;AMD hipBLASLt documentation&lt;/a&gt;：GEMM、heuristic、tuning、workspace、Stream-K、datatype 和 samples。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/rocBLAS/en/latest/&quot;&gt;AMD rocBLAS documentation&lt;/a&gt;：ROCm 底层 BLAS 库。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/composable_kernel/en/latest/&quot;&gt;Composable Kernel user guide&lt;/a&gt;：ROCm 的 kernel 组件和 template 路线。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/rocprofiler-sdk/en/latest/how-to/using-rocprofv3.html&quot;&gt;ROCprofiler-SDK：Using rocprofv3&lt;/a&gt; 与 &lt;a href=&quot;https://rocm.docs.amd.com/projects/rocprofiler-compute/en/latest/&quot;&gt;ROCm Compute Profiler&lt;/a&gt;：ROCm 时间线、counter、Speed-of-Light 和 roofline 分析。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://rocm.docs.amd.com/projects/composable_kernel/en/develop/conceptual/ck_tile/hardware/lds_bank_conflicts.html&quot;&gt;Composable Kernel：AMD GPU LDS and Bank Conflicts&lt;/a&gt;：LDS bank、wave 分相访问、padding 与 XOR preshuffle。&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;https://github.com/ROCm/aiter&quot;&gt;ROCm AITER&lt;/a&gt;：面向 AI workload 的高性能算子与 kernel 集合。&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/section&gt;

      &lt;footer&gt;最后更新：2026 年 7 月。教学示例用于解释机制；生产实现请以目标 GPU、工具链版本和官方文档为准。&lt;/footer&gt;
    &lt;/main&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
" title="gemm-teaching.html" frameBorder="0" loading="lazy" scrolling="auto" sandbox="allow-scripts allow-forms allow-popups"></iframe></div></figure><div class="notion-blank notion-block-3a18f42f8313801d8fced3094090ee7f"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2024-2025: 空白格]]></title>
            <link>https://densecollections.top//year-summary/2024-blank-space</link>
            <guid>https://densecollections.top//year-summary/2024-blank-space</guid>
            <pubDate>Wed, 22 Jan 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[2024年终总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1838f42f8313802aa61ed404f640f52f"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-1878f42f83138014b7dbe264a0680fad"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="✍️">✍️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-1868f42f831380b2bc3fef5ad638c1df"><em><b>日历满满的，但未来一片空白</b></em>。——特朗斯特罗姆-《黑色明信片》</div></div></div><div class="notion-blank notion-block-1878f42f8313801aab00c3fa095a6e80"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313804dbee5ec71c42d3712"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:336px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/sea_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-804d-bee5-ec71c42d3712" alt="上海水族馆的梦幻水母" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">上海水族馆的梦幻水母</figcaption></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1868f42f83138020ab06f5abb4ee0404" data-id="1868f42f83138020ab06f5abb4ee0404"><span><div id="1868f42f83138020ab06f5abb4ee0404" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1868f42f83138020ab06f5abb4ee0404" title="📌写在前面"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌写在前面</span></span></h3><div class="notion-text notion-block-1878f42f83138022aab2da1ac5e3aba8">今年做了很多事，但是好像却又什么都没做。世界在发生巨变的前夕，自己好像没什么进步，这种焦虑无时无刻不裹挟着我，让我神经紧张，我强忍着，坚持着，努力地面对，却时不时想要逃避。我现在落在画幅的空白处，我处在音乐旋律的空白停顿符上，但是我必须一直前行，虽然不知道前方是不是对的，不知道还有多久…</div><div class="notion-text notion-block-1868f42f8313804787f9ed4e7c7153ba">🪙<b>Work</b></div><div class="notion-text notion-block-1878f42f831380ab83a8ce0e25cc8023">转眼一看，我在Intel做AI infra也已经快四年了。四年间一直做着transformers-based model的推理加速，但是仔细想想，好像也没摸到很深的技术，还是处于慢慢积累的阶段。AI Infra现在随着LLM serving的难度增加而被推到公众面前，未来还是有很多工作要做，即使模型架构开始慢慢收敛，但是优化是无处不在的。以前做bert类的encoder-model模型加速，graph-fusion层面有很多工作要做，现在收敛到了decoder-only架构，kv cache的优化又逐渐变得重要和复杂起来。围绕着decoder-only的LLM OS概念也开始陆续提出，引起researcher的思考。</div><div class="notion-text notion-block-1878f42f8313809897adffbbc089e545">这一年的开源LLM大放异彩，从年初的Llama,到MoE,到年末的DeepSeek V3, MiniMax等；从大家唱衰pretrain-scaling law之后openAI又提出了inference-sacling law,到O1，到DeepSeek R1, RL陆续发力，computation power持续发力；这一年的多模态发展也很不错，视频生成从sora，到open-sora，到快手可灵等，图片生成从SD3到flux，文本加图片出现了Qwen-VL等等，diffusion model持续证明自己。在企业端，RAG依旧是主流，围绕着RAG的workflow和kv cache压缩/caching等也出了很多不错的工作，年末AI Agent的成果开始出现，预计25年将会出现更多的关于open AI Agent方面的工作（字节/DeepSeek/智谱等）。更多更详细的关于LLM这一年的总结可以参考这篇blog: <a class="notion-link" href="https://www.163.com/dy/article/JKTHVG4C0511AQHO.html" target="_blank" rel="noopener noreferrer">2024, LLM这一年</a>。还有一个技术细节比较多的，总结2024年的<a class="notion-link" href="https://nrehiew.github.io/blog/2024/" target="_blank" rel="noopener noreferrer">generative models blog</a>: <em><span class="notion-inline-underscore">llm里面DeepSeek的MLA，meta的byte-latent-transformers，大模型上的蒸馏，Image上字节的VAR，文生图的FLUX，多模态，不仅是VLM，而是真正的one-for-all，最后是AI-agent, UI设计很重要，workflow组建等等</span></em>。</div><div class="notion-text notion-block-1878f42f83138062925ec64f34d81488">从CV算法转到AI Infra,自己也逐渐开始适应并且开始热爱这个领域，未来有很多很深很酷的东西可以做，25年希望可以多多涉及分布式serving和调度的工作，同时深入了解OS，协同设计KV cache/memory的一些模块，多多关注半导体，好好熟悉一下芯片架构（chiplet/nic/network…)和一些高性能计算kernel.</div><div class="notion-text notion-block-1878f42f831380259b79f4446ba53709">👣<b>Life</b></div><div class="notion-text notion-block-1878f42f831380ab929ce71eb3e98ae7">今年算是弥补了去年没能好好去玩的遗憾，趁着W有空，一起集中去了好几个地方，出去转转总归是好的，让自己慢慢认识这个世界。</div><div class="notion-text notion-block-1888f42f8313806d965ff5fda4d7b1c1">今年的电钢学习，画画练习也停了，空闲时间要么打游戏，要么就是捣鼓一些别的东西，不过有了工作和家庭之后，时间在体感上是真的变得越来越少，流逝得越来越快，时常和W感叹一周来去的速度如此之快。25年真的要好好思考一下如何充分的利用时间，如何进行高效的阅读和学习才行。</div><div class="notion-text notion-block-1888f42f8313806dba3fdf693627ac60">不过比较欣慰的是，24年终于舍得拿起尘封已久的相机去到处拍拍了，这也多亏了W的督促。很长一段时间我觉得自己言之无物，也不知道该拍些什么。我不是特别喜欢研究构图，光圈，快门之类的技术，我只是想让拍出来的照片充满灵魂，活力，故事等，因此言之无物很大程度上显示自己内心智识的匮乏。所以，24年下半年， 我一边开始认真去挑书看，一边开始继续实践起来，希望25年能有更大的进步 📸</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1868f42f831380f19cf7e0db5309a01d" data-id="1868f42f831380f19cf7e0db5309a01d"><span><div id="1868f42f831380f19cf7e0db5309a01d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1868f42f831380f19cf7e0db5309a01d" title="📌旅游"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌旅游</span></span></h3><div class="notion-text notion-block-1868f42f8313802faacdc3a8444986d8">✈️<b>日本</b></div><div class="notion-text notion-block-1868f42f83138007b976eb6cb9288eb8">和W念叨了好久，终于在上半年办好了日本签证，出发去大阪玩了一趟。五晚六天的行程基本就是商业区闲逛购物，W和我都是P人，没做什么详细的攻略和规划，基本都是前一天晚上翻翻小红书临时决定第二天去哪，吃东西也是看到了想吃就进去（不过很多时候都是因为人多被店家”无情“拒绝服务了hh)。大阪的游客很多，不仅是国内游客多，韩国，欧美，泰国等等地区的游客也很多，基本上热门地区都有英语/韩语/中文这几种语言注释，甚至百货商店和商业街的店里都有会中文的销售为你服务，微信，支付宝什么的也支持，所以在大阪旅游的体验也蛮好的，而且大阪人民也挺热情的，经常在路上听到一群年轻人哈哈大笑，相互攀谈（网上说关西人大大咧咧，关东人，比如东京人相对冷漠）。如果是像我这种白本护照的，第一站出国地点择大阪或者日本应该还是很棒的。</div><div class="notion-text notion-block-1868f42f83138054a488dcace9d4b441">第一次出国，第一次去日本，第一次去大阪，相对而言我们还是比较拘谨的，也有一些遗憾，比如没买更多的东西带回国 :)，没能尝到更多的美食（很多寿司没吃到），没能去逛逛当地的景点和自然景观，也没去本地大超市看看，不过来日本只有0次和无数次，下一次的日本之行我相信很快就会再次安排上。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f831380f1a87fe0ed843c803f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_0.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-80f1-a87f-e0ed843c803f" alt="大阪机场周围的海很蓝很干净，入境时候飞机在海上盘旋降落，对于在内陆长大的我是一种很神奇的体验" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">大阪机场周围的海很蓝很干净，入境时候飞机在海上盘旋降落，对于在内陆长大的我是一种很神奇的体验</figcaption></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313804b8d49e0594abbfcb5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_4.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-804b-8d49-e0594abbfcb5" alt="我们住的酒店附近有一个小公园，里面有很多玫瑰，园艺做的很精美，随手拍了一张" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">我们住的酒店附近有一个小公园，里面有很多玫瑰，园艺做的很精美，随手拍了一张</figcaption></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f83138009a8fdc37d7977089c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_3.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-8009-a8fd-c37d7977089c" alt="本人喜闻乐见的&quot;TREE&quot;环节" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">本人喜闻乐见的&quot;TREE&quot;环节</figcaption></div></figure><div class="notion-row notion-block-1868f42f8313800e839edfe699f164b0"><div class="notion-column notion-block-1868f42f831380ed8e6feba1bf621b1a" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f831380d98bf8c82ba798e0dc"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-80d9-8bf8-c82ba798e0dc" alt="梅田的商业街" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">梅田的商业街</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1868f42f83138063a2b1db47609758b1" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313803885d4d1bdf1f92f22"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-8038-85d4-d1bdf1f92f22" alt="小吃街横幅上的“瘆人”的铜像...，无法理解日本人民在这方面的审美" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">小吃街横幅上的“瘆人”的铜像...，无法理解日本人民在这方面的审美</figcaption></div></figure><div class="notion-blank notion-block-1868f42f831380a9bca2fe174e211214"> </div></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1868f42f83138033b6a5c0e75d341252"><div class="notion-column notion-block-1868f42f8313802c975ad0cc68be5974" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313809088a7ff5fb5b2eaa6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_6.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-8090-88a7-ff5fb5b2eaa6" alt="一家很好吃的关东煮店，已经有180年的历史了" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">一家很好吃的关东煮店，已经有180年的历史了</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1868f42f831380cc971fc6ab50b93b5c" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313803da548c7952ec757e5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jp_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-803d-a548-c7952ec757e5" alt="小吃店门口有些”奇怪又好笑“的雕像" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">小吃店门口有些”奇怪又好笑“的雕像</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-1868f42f8313808386cec76ccc22745b">🚄<b>景德镇</b></div><div class="notion-text notion-block-1868f42f831380d79f8fd106feb58e56">中秋节附近陪W去了江西景德镇和庐山。去景德镇纯粹是为了看和买瓷器，去庐山则是错峰旅游去逛逛，不和旅游大部队凑热闹。景德镇的瓷器确实是好看的，我们主要逛了陶溪川的商业街，里面陈列售卖的瓷器有设计，有美感，圆润，色彩搭配的都很漂亮，价格也参差不齐，后面在其他地方看的瓷器觉得都不如在这里看的好。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f831380efaad0d23c8184e416"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/china_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-80ef-aad0-d23c8184e416" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f831380f8b1aec07ae9aaa392"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/china_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-80f8-b1ae-c07ae9aaa392" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1868f42f8313805ea8fce4fcdedfe4b0">除了瓷器之外，这个城市没能给我留下什么好的印象了，环境差，交通差，商业化严重导致物价不匹配当地生活水平，此外水质极差，应该不会去第二次了，除非以后来买家用的瓷器。</div><div class="notion-text notion-block-1868f42f83138062b37aede19cbb1771">庐山市的交通很不便，可能是因为庐山群峰绵延不绝，修路难度高。我和W由于对自己爬山体力不够的认识特别清醒，所以只去看了秀峰，也就是“望庐山瀑布”所在的峰，可惜当时是秋季，枯水期，只能远远地看到一条细长地水流绵延而下。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f83138053a059c21cc24965f2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/lushan_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-8053-a059-c21cc24965f2" alt="望庐山瀑布" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">望庐山瀑布</figcaption></div></figure><div class="notion-text notion-block-1868f42f831380018c9ae6df82497271">🚗<b>丽水缙云</b></div><div class="notion-text notion-block-1868f42f831380fda503fe17e66b64d8">国庆期间我和W连轴转，跑到了丽水缙云，主打的就是一个回归乡野，疗养人生。缙云仙都这边依山傍水，绿植丰富，是个天然氧吧，而且古民居保存完好，也充满了历史文化地厚重气息。不过正因如此，蚊虫太多了，此外景区也比较分散，适合自驾游，不过人民生活很chill，节奏慢，是个养老地好地方。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f831380858792cbfcdf7ba399"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jinyun_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-8085-8792-cbfcdf7ba399" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1868f42f8313803c89d2da6fe271232b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/jinyun_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1868f42f-8313-803c-89d2-da6fe271232b" alt="千年古树" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">千年古树</figcaption></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1868f42f831380819374fc0f9f70ad8d" data-id="1868f42f831380819374fc0f9f70ad8d"><span><div id="1868f42f831380819374fc0f9f70ad8d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1868f42f831380819374fc0f9f70ad8d" title="📌展览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌展览</span></span></h3><div class="notion-text notion-block-1878f42f831380eea734c46b2a7aa478">5.1去日本的时候恰好碰上“印象派莫奈展览”的尾声，相比于国内而言，作品更多更全，基本都是莫奈本人的作品，我之前在上海看的几个大多有“欺诈”嫌疑，因为很多作品都是同期的其他类似风格的创作者的作品，本人的作品只有区区几幅，比如“莫奈与印象派”，可能莫奈的本人作品只有两个，其他的都是不那么出名的印象派作品，所以第一印象上会让我觉得物有所值（而且票价是120人民币不到，相比而言并不贵）。日本的这次莫奈展是按照莫奈几个绘画时间线（成长）来进行的，从一开始的学习习作到后来著名的睡莲系列都囊括在内，当然像“日出印象”这种特别著名的画是没有的（意料之中），不过那些“草堆”系列作品，海滩等等都有，可以说是我这些年来看到过的最全的莫奈作品展映了。</div><div class="notion-row notion-block-1878f42f831380be94d4c2da29617269"><div class="notion-column notion-block-1878f42f831380f8a2cddf57b1548442" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313806cb80bd01930c95fb2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_0.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-806c-b80b-d01930c95fb2" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f83138000ab05eefd38bf810e" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313804e94d3e599a7d17a6f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-804e-94d3-e599a7d17a6f" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-1878f42f831380af9199c7be512e7388">很多作品禁止拍摄，除了最后的”睡莲“系列允许，所以我也只能放这几张。现如今我自己看画展的喜好是：国画看意境，西洋画看色彩，构图和笔触。莫奈的画除了色彩和构图特别好之外（笔触也是粗中有细），其作品还蒙上了一种”记忆（memory）和故事（story)“的味道，明亮温暖的色调也让人心情舒畅。</div><div class="notion-row notion-block-1878f42f83138064a35bc54a71c17f51"><div class="notion-column notion-block-1878f42f83138088be3ec8c5b5e5908e" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380d789aeddf5fc94b13e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80d7-89ae-ddf5fc94b13e" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f831380469f0cf0f08e836610" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380cfb41edb947b10265b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_4.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80cf-b41e-db947b10265b" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f83138057adade666435af1ab"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8057-adad-e666435af1ab" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380ea8fbbeabf589f4048"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/monet_jp_3.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80ea-8fbb-eabf589f4048" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1878f42f831380a08cf7dd2102dc328a" data-id="1878f42f831380a08cf7dd2102dc328a"><span><div id="1878f42f831380a08cf7dd2102dc328a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1878f42f831380a08cf7dd2102dc328a" title="📌阅读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌阅读</span></span></h3><div class="notion-text notion-block-1878f42f831380f39d88f305c98a8ffc">今年碎片化阅读的时间变多了，主要的原因是自己意识到阅读的重要性，大段的时间比较难以获得，也不想花太多时间在那些社交媒体和娱乐视频上。阅读的主要平台还是在手机上，主力app是微信读书和微信的公众号，有时也会从一些其他平台订阅消息，比如苹果的podcast和substack平台。今年的阅读内容大多以科技为主，毕竟AI发展实在太快，加上居家办公太久，自己不去主动阅读的话消息太闭塞。</div><ul class="notion-list notion-list-disc notion-block-1878f42f83138001b2c2e86f269bece4"><li><b><a class="notion-link" href="https://book.douban.com/subject/36673627/" target="_blank" rel="noopener noreferrer">时势</a></b>。<a class="notion-link" href="https://space.bilibili.com/520819684/" target="_blank" rel="noopener noreferrer">小Lin说</a>的书，实际上可以看作是其视频内容的总结再复述，当通识读物看看是不错的。虽然我们国家的制度和意识形态不同，但是在整个全球化越来越重的现状下，也不得不感叹我们与日韩经济的相似性，从高素质劳动力红利，到家电，手机，再到电动汽车的市场占领，然后沿着房地厂一路开挂，除了股市不太行之外（监管有部分原因，主要是没信心吧），不管手段如何，最终也可能是殊途同归吧。这本书主要是因为自己挺喜欢小lin说的视频，觉得她把经济解释得很通俗易懂，引导观众去意识到自己应该去建立一些从经济学角度去看待，分析问题的框架。</li></ul><ul class="notion-list notion-list-disc notion-block-1878f42f831380849502c15d40c82c07"><li><b><a class="notion-link" href="https://book.douban.com/subject/26925171/" target="_blank" rel="noopener noreferrer">大明王朝1566</a></b>. 去年看完了剧集内容和解析，今年又把原著看了一遍。原著与电视剧基本没什么差别，只是多了一些人物的心里描写，因此理解难度比电视剧门槛第一点。这是一本常读常新的半虚构性历史小说，讲的是嘉靖末年，国库空虚，“朝廷开支无度，官府贪墨横行”的现状，以“改稻为桑”为切入点，展现了官场，名利场，权力，驭臣等等复杂而鲜活的“中国特色故事”。里面各个人物都有“名言金句”，角色之间你来我往的周旋百看不厌。读完百感交集，感叹命运无常，天道轮回。</li></ul><ul class="notion-list notion-list-disc notion-block-1878f42f831380eb9d86c358821be514"><li><b><a class="notion-link" href="https://book.douban.com/subject/30151808/" target="_blank" rel="noopener noreferrer">共产党宣言</a></b>。为什么读这本书，一是我们身处社会主义国家，需要好好读这本起源著作，另一方面也是自身希望能从中找到一些解答当下困境的一些思想。实际上我是直接在《大明王朝1566》之后决定读这本书的，当时列了一系列书单，其中打头的就是《宣言》和《毛泽东选集》，希望能从中窥见一些思考自身命运和社会命运的角度和方法。说回《宣言》本身，主体内容很短，其着重分析了资本主义产生的原因，以及资本主义的特性（无序扩张），劳动的价值等等，讲述了科学社会主义和共产主义的区别，以及共产主义一定可以实现的美好愿景。很难想象这个是180多年前的作品，即使是放到现在，很多内容读起来都是振聋发聩，我也更难想象100多年前的中华大地上的有志之士读到《宣言》的振奋心情：“共产主义一定会，也一定要实现！”</li></ul><blockquote class="notion-quote notion-block-1878f42f831380d897e9d0d2e740e02b"><div><em>阶级对立的存在条件主要可以归结为以下几个方面：</em></div><ol start="1" class="notion-list notion-list-numbered notion-block-1878f42f8313804ebb30d49d85c4a38a" style="list-style-type:decimal"><li><em>私有制：私有制是资本主义生产关系的基础。资产阶级通过占有生产资料，实现了对生产过程的垄断，从而形成了阶级差异和阶级对立。消灭私有制，从根本上消除了阶级和阶级对立的物质条件。</em></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1878f42f8313801a8eb8f7907ba82692" style="list-style-type:decimal"><li><em>生产资料的不平等分配：在资本主义社会中，生产资料集中在少数资产阶级手中，而广大的无产阶级则缺乏生产资料，被迫出卖劳动力以获取生活资料。这种生产资料的不平等分配是阶级对立的重要根源。</em></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1878f42f83138069b9b6f84655ace2ee" style="list-style-type:decimal"><li><em>阶级统治：资产阶级通过国家机器，即政治权力，来维护其统治地位，对无产阶级进行压迫和剥削。这种统治不仅体现在经济领域，也体现在政治、文化和社会生活的各个方面。</em></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1878f42f831380be86f4d171fcc32007" style="list-style-type:decimal"><li><em>社会分工和异化：现代资本主义社会中的高度社会分工导致了劳动者的异化，即劳动者在生产过程中逐渐丧失对自己劳动产品的控制，变成被异化的存在。这种异化加剧了阶级对立，因为工人阶级创造了财富，但却无法享受其成果。</em></li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-1878f42f831380a98142e8956af0927d" style="list-style-type:decimal"><li><em>市场机制：市场机制在资本主义社会中起着资源配置的作用，但由于其竞争性和无序性，往往导致贫富差距的扩大，进一步加剧阶级对立。市场机制使得资本家追求最大化利润，而忽视工人的基本生存需求，从而加深了阶级矛盾。</em></li></ol></blockquote><ul class="notion-list notion-list-disc notion-block-1878f42f831380fc882bfa41b1980543"><li><b><a class="notion-link" href="https://book.douban.com/subject/37138107/" target="_blank" rel="noopener noreferrer">英伟达之道</a></b>。这本书年末的时候很火，配合上NV今年爆炸式的增长，让人越来越想了解英伟达内部的情况。这本书微信读书还没有上架，我是在App内翻着别人上传的有声书生成的AI文稿，断断续续看完的。黄仁勋或者说NV的<em>”top-5 things”，白板文化，十分尊重工程师和技术以及强大的反思力和执行力让我印象深刻</em>，老黄在NV建立的扁平化的管理和高效的信息流通机制让我十分羡慕，这个是很多大公司所没有的，这也是多亏老黄这个偏执的工作狂，换做是别人，或者老黄卸任之后，不知NV还能否延续这种“精悍”的企业文化。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1878f42f83138057a6dcf04eafedf79f" data-id="1878f42f83138057a6dcf04eafedf79f"><span><div id="1878f42f83138057a6dcf04eafedf79f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1878f42f83138057a6dcf04eafedf79f" title="📌游戏"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌游戏</span></span></h3><div class="notion-text notion-block-1878f42f83138032b084fc788b01b9eb">今年打得游戏还蛮多的，反正觉得与其胡思乱想，也没啥用，不如放松（放纵）一下，<s>与其痛苦，不如快乐过一天</s>。</div><ul class="notion-list notion-list-disc notion-block-1878f42f8313806a8b4fcf4bc0206162"><li><b><a class="notion-link" href="https://www.douban.com/game/26742884/" target="_blank" rel="noopener noreferrer">狙击精英4</a></b>。趁着打折买的，本质上应该是刺杀游戏，但是玩的时候心有不甘，FPS之魂觉醒，基本上即使被发现了也要绕柱把德军全杀一遍才罢休。游戏难度不高，经典的子弹击杀时间和爆蛋瞬间，很解压哈哈，画面中规中矩，玩法也比较单一，毕竟是不少年前的游戏了。这个游戏有一个让玩家称道的地方是游戏人物的书信，反映了战争的残酷。</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380268488fa675300c5cd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_11.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8026-8488-fa675300c5cd" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-1878f42f8313801a984fd6536d32f464"><li><b><a class="notion-link" href="https://www.douban.com/game/26771824/" target="_blank" rel="noopener noreferrer">泰坦陨落2</a></b>。著名的梗“协议三，保护铁驭”的出处，FPS中被推上神坛的游戏，玩法确实很爽，尤其是时空穿梭对战的关卡。游戏比较老了，画面不是很好（可能是我电脑的原因），希望有朝一日能玩到重制版。台湾人的配音竟然也没有很出戏。挺好的。</li></ul><div class="notion-row notion-block-1878f42f831380709ff4c5c64bfe16cb"><div class="notion-column notion-block-1878f42f8313809cb806decf009420b1" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380ffac9ae8738d03421c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_8.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80ff-ac9a-e8738d03421c" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f831380be8266ecd62d5b4613" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313801faa12f2bd1ca6f8bd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_6.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-801f-aa12-f2bd1ca6f8bd" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380f69728c63be722ed89"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_7.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80f6-9728-c63be722ed89" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-1878f42f831380f78da8d4e439daa014"><li><a class="notion-link" href="https://store.steampowered.com/app/2138710/Sifu/?l=schinese" target="_blank" rel="noopener noreferrer">SIFU</a>. 法国人做的中国传统武术游戏，有些章节画面很有艺术性，但是有一些日本文化的影子。游戏的技巧性很强，我手残，而且失败就得从章节头开始，最后还是开了风灵月影过了剧情:)</li></ul><div class="notion-row notion-block-1878f42f8313800dbeb6e28582245114"><div class="notion-column notion-block-1878f42f831380449ce5d618b5fee258" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380de8285d41d5d79eab3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-6sifu_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80de-8285-d41d5d79eab3" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f831380398056e2d4d86cd6f0" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313800691d3ead1a6eb6dba"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-6sifu_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8006-91d3-ead1a6eb6dba" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><ul class="notion-list notion-list-disc notion-block-1878f42f831380239e55c251c165f87a"><li><b><a class="notion-link" href="https://www.douban.com/game/35451901/" target="_blank" rel="noopener noreferrer">战地2042</a></b>。也是趁着打折入手了战地3, 5和2042。不过前两部暂时还没来得及下载玩。2042的玩法还是很多的，战场模式我是第一次体验，上天入地，侦查突刺，啥啥都有，自由度很高，因此今年有很长时间我都沉迷在这款游戏里，已经快200多小时了。只不过由于要开加速器，EA的服务器也比较拉，每次都要花很长时间才能进入，而且在线对战也很卡，挂也多，神烦，搞得我都想转头玩企鹅的三角洲行动了。（玩AI对战都能玩这么久能看出来我有多爱玩这种游戏，36块真香）。</li></ul><div class="notion-row notion-block-1878f42f8313804faac5f951b702a4c8"><div class="notion-column notion-block-1878f42f831380fbbe1dfce2a89525e3" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380f1a833e6fd357be82d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_10.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80f1-a833-e6fd357be82d" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f8313805bb625cef308a8c697" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313806e9d67dec23cd23fe9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_9.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-806e-9d67-dec23cd23fe9" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><ul class="notion-list notion-list-disc notion-block-1878f42f831380e3a531c25eb8d03c80"><li><b><a class="notion-link" href="https://www.douban.com/game/35184766/" target="_blank" rel="noopener noreferrer">黑神话悟空</a></b>。今年当之无愧的年度热游了，是西游，也是武侠。为了能第一时间玩到黑吗喽，我甚至不惜重金买了ps5，结果49年入国军…… 回到正题，悟空的体量，美术和玩法都是很不错的，故事也很有深度，玩自己本民族的游戏是有很不同的感受的，那种熟悉感，归属感，以及不自觉地深入挖掘思考背后的真相的驱动力，都是别的游戏没法带给我的。不过有些boss确实很难打，一周目花了90多小时才通关，就这样还有一些珍玩和泡酒物没收集全，累也是真的累，通关这个游戏也是充满苦难。PS5游戏里空气墙比较多，容易卡特别是战斗时候，视角锁定不是很好用，尤其是大boss时候（以后还是升级pc了，不然会错过很多有趣的mod）。最后不得不再说一句，游戏的画面真的很美，希望能出官方美术设定集之类的书籍。</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380e0a188c90a6cdd0e86"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_4.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80e0-a188-c90a6cdd0e86" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380ce8ddbc9eb916c3064"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/game_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-80ce-8ddb-c9eb916c3064" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-1878f42f831380279cddcc814ef8c23b"><li><b><a class="notion-link" href="https://www.douban.com/game/36829685/" target="_blank" rel="noopener noreferrer">漫威争锋</a></b>。网易大概是被暴雪伤透了心，和漫威联合开发了这款含“守望先锋”量极高的多人PVE游戏。画风偏硬朗，我还可以接受，有些英雄上手难度比较高，目前才玩了几个小时，体验还不错。但是我还是更喜欢守望先锋😂</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1878f42f831380128e74caf10aaba3db" data-id="1878f42f831380128e74caf10aaba3db"><span><div id="1878f42f831380128e74caf10aaba3db" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1878f42f831380128e74caf10aaba3db" title="📌影视"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📌影视</span></span></h3><div class="notion-text notion-block-1878f42f831380beac7cc3427ccb75a6">今年看的电影少很多了，一方面很忙，一方面闲下来也是会翻翻别的东西，没精力去点开网站慢慢选择一部电影，然后好好观看一番。不过这几年的作品很少有我特别感兴趣的（音乐也是同样的状况，甚至不如听AI陶喆，AI贾斯汀比伯了哈哈），所以下一年考虑直接删除这部分，直接贴列表截图了。</div><ul class="notion-list notion-list-disc notion-block-1878f42f83138094a285e629a143814f"><li><a class="notion-link" href="https://movie.douban.com/subject/36151692/" target="_blank" rel="noopener noreferrer">周处除三害</a>。24年春节后比较火的一部电影，故事确实好看，虽然后来陷入了“剧本抄袭门”。电影的名字已经概述了电影的剧情，节奏紧凑，配乐也可圈可点（可在b站搜周杨的<a class="notion-link" href="https://www.bilibili.com/video/BV1AS421w7cd/?vd_source=c5232e4564e248b018835fa2077d9950" target="_blank" rel="noopener noreferrer">解析</a>），兼具商业性和艺术性。个人觉得“贪嗔痴”的主题讲得不多，更多的是救赎的故事。这种类似的黑帮大哥浪子回头或者为了心中的忠义以身赴死的行为，和“风尘女”或者“沉沦”女的暧昧故事一直是影史上的一大主题，”三害“通过章节（小-中-大的高潮戏）和埋线的形式，加上榜二的压迫感，榜一的洗脑，以及最后反套路，甚至“反道德”，”反圣女“的枪杀戏，让整部电影在观感上非常的爽。它是我喜欢的电影类型，属于那种回味无穷，似懂非懂的故事片。</li></ul><div class="notion-row notion-block-1878f42f83138002b842c7c506d1bb46"><div class="notion-column notion-block-1878f42f831380eea755c5b3ef533c37" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313807c8115ed4502430bf7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/zccsh-2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-807c-8115-ed4502430bf7" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1878f42f8313801ea8f7f72b661e3a6f" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313804dbefdfd560ff4b2c8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/zccsh-1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-804d-befd-fd560ff4b2c8" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><ul class="notion-list notion-list-disc notion-block-1878f42f831380acb2e2dbceebbf10f3"><li><a class="notion-link" href="https://movie.douban.com/subject/35426925/" target="_blank" rel="noopener noreferrer">机器人之梦</a>. 非常温馨，有非常忧伤的一部动画电影。讲了两个孤独的个体在一起最后因为缘分错过的故事，让我想起拜伦的诗歌 “<b>When we two parted</b>&quot;:</li></ul><blockquote class="notion-quote notion-block-1878f42f831380ee8618d75761c55855"><div>If I should meet thee</div><div class="notion-text notion-block-1878f42f831380578371f29589418b6f">After long years,</div><div class="notion-text notion-block-1878f42f831380f6bd34dac5da4e1142">How should I greet thee?-</div><div class="notion-text notion-block-1878f42f83138090ad82e69aefde811e">With silence and tears。</div></blockquote><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f83138037b178dc7ec465bf2f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/robot_dreams.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8037-b178-dc7ec465bf2f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1878f42f83138012825ac78e12d17ae7">  对于经历者而言，这部电影的力量会更大。只不过，我觉得这种类型的电影不会有比斯派克琼斯的”<b>Her</b>“更好的了。</div><div class="notion-text notion-block-1878f42f831380a6ae6bd8d1bdbf2683">  今年还有一部机器人电影叫<a class="notion-link" href="https://movie.douban.com/subject/36689857/" target="_blank" rel="noopener noreferrer">荒野机器人</a>，不过不是孤独的内核，更多的是关于爱与成长，以及人的归属感，也还不错。</div><ul class="notion-list notion-list-disc notion-block-1878f42f831380e68643f3818a122f59"><li><a class="notion-link" href="https://movie.douban.com/subject/35575567/" target="_blank" rel="noopener noreferrer">沙丘2</a>. 没完整看过原著，只听过零星的故事解说。我对这种类型的太空歌剧已经审美疲劳了，虽然原作是上个世纪60年代了，但是之后借鉴其的优秀作品也很多被完美地在大荧幕呈现了，所以沙丘的影视化作品现在再看已经觉得乏善可陈了。但是维伦纽瓦作为我很喜欢的导演，他的作品我几乎一个不落的全看过，紧凑有张力的叙事，干净完美的构图和摄影，以及有力的配乐和收音，让我完全沉浸其中。他自己在访谈时候也说过，他对电影中才有的影响和配乐是及其看重的，即使没有对白也没关系，故事是什么也没关系，关键就是看你怎么讲了。个人非常喜欢沙丘的摄影风格，我还特意因为这部电影淘了一个苏联的“<a class="notion-link" href="https://www.bilibili.com/video/BV1z44y1B7zF/?vd_source=c5232e4564e248b018835fa2077d9950" target="_blank" rel="noopener noreferrer">八羽怪</a>”镜头（自带旋焦）。<a class="notion-link" href="https://www.bilibili.com/video/BV1fm421L7pZ/?vd_source=c5232e4564e248b018835fa2077d9950" target="_blank" rel="noopener noreferrer">沙丘2摄影欣赏</a>。</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f8313809480a8f65e4dd4073a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/dune_part2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8094-80a8-f65e4dd4073a" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1878f42f831380569353fd0e853f6c79"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://cdn.jsdelivr.net/gh/Richardyu114/PicBed_blog/Summaryofthisyear-6/dune_part2_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1878f42f-8313-8056-9353-fd0e853f6c79" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-1878f42f8313801b950ed3e52c87907a"><li><a class="notion-link" href="https://movie.douban.com/subject/36181862/" target="_blank" rel="noopener noreferrer">克拉克森的农场S3</a>。喜闻乐见的“猩猩农场”终于更新了第三季，还是熟悉的味道，还是一如既往的下饭。这一季主要讲的是养猪，开发非耕地地区以及和议会的非常理要求的对抗，也顺带提及了农业靠天吃饭的辛苦和俄乌战争带来的能源危机对欧洲农业的影响。英国的大片耕地和草地以及自然景观的摄影让人心旷神怡，“猩猩”的播音腔英音听得很舒服。第四季也预定了，希望能GKD :)</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1888f42f8313805cba5cd4cb9f3020a2" data-id="1888f42f8313805cba5cd4cb9f3020a2"><span><div id="1888f42f8313805cba5cd4cb9f3020a2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1888f42f8313805cba5cd4cb9f3020a2" title="🕛尾声"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🕛尾声</span></span></h3><div class="notion-text notion-block-1888f42f83138012836ddc60bc16b3e7">每年写的来年计划已成一个习惯，虽然大部分时候都是无法完成或者偏离。计划终归只是计划，生活从来不是一成不变或者被轻易安排的。今年我就不写具体的计划了，不要求自己一定做这做那，只求自己能够认真看书，认真思考和认真实践，有空还是多想想，多写写~ 📖</div><div class="notion-callout notion-gray_background_co notion-block-1888f42f831380e89a61f6e3c6cbfb0a"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💬">💬</span></div><div class="notion-callout-text"><div class="notion-text notion-block-1888f42f831380929a17e68d0ef1f8d5"><em>麻木是生活的一种罪，一种恶。</em></div><div class="notion-text notion-block-1888f42f831380adb50fd9a8ec10c075"><em>麻木是火，炖了一锅不知道是什么东西的汤</em>。</div><div class="notion-text notion-block-1888f42f831380ce9e6cc2fb1ff3b1a0"><em>不知道怎么搞的，身边的人喝下了</em>。</div><div class="notion-text notion-block-1888f42f83138053acf8d7b4ee2fdaa7">                  <em>——雷蒙德·卡佛</em></div></div></div><div class="notion-blank notion-block-1888f42f831380cfb193f2db37e5a19f"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM inference latency / throughput metrics overvie]]></title>
            <link>https://densecollections.top//technology/llm-inference-metrics</link>
            <guid>https://densecollections.top//technology/llm-inference-metrics</guid>
            <pubDate>Mon, 03 Nov 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[vllm metrics总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-2a08f42f831380af9081ef56d1aa92e2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-red_co notion-block-2a08f42f8313801b85d1fc40361df24a"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="👉">👉</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2a08f42f83138021bbcbe605abbca768"><span class="notion-default">vLLM server提供`/metrics`端口供查阅相关的metrics: </span><span class="notion-default"><a class="notion-link" href="https://docs.vllm.ai/en/latest/design/metrics.html#objectives" target="_blank" rel="noopener noreferrer">https://docs.vllm.ai/en/latest/design/metrics.html#objectives</a></span></div></div></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2a08f42f831380a986c2d61fc4f0d103" data-id="2a08f42f831380a986c2d61fc4f0d103"><span><div id="2a08f42f831380a986c2d61fc4f0d103" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a08f42f831380a986c2d61fc4f0d103" title="Overview"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Overview</span></span></h3><div class="notion-text notion-block-2a08f42f831380a5a110e4d521f9eb03">在LLM Inference中，我们经常能看到不同的服务厂商或者推理框架汇报自己的性能，其中有很多指标(metrics)，对此我们先弄清楚他们是什么，以及如何计算/衡量的</div><div class="notion-text notion-block-2a08f42f831380f5915eda652f18568d">常见的metrics有TTFT, TPOT, ITL, E2EL, Throughput, RPS (QPS), TPS, Goodput等，参考这个介绍：<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">https://bentoml.com/llm/inference-optimization/llm-inference-metrics</a></div><table class="notion-simple-table notion-block-2a08f42f831380d1a493f9d46c500d82"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-2a08f42f831380eda574f61661641c30"><td class="" style="width:120px"><div class="notion-simple-table-cell">指标</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">中文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义（要点）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">常见公式 / 计算</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">反映什么</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">典型场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">注意/陷阱</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380fab002cf3a495c1881"><td class="" style="width:120px"><div class="notion-simple-table-cell">TTFT (Time to First Token)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">首字出字时延</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">发送请求到生成<b>首个</b>token的时间</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">交互“起步”速度与响应流畅感</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对话/补全等需实时反馈的应用</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只快TTFT但后续很慢，体验仍差。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f83138089ba5bc9897b563875"><td class="" style="width:120px"><div class="notion-simple-table-cell">E2EL (End-to-End Latency / Total Latency)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">端到端总时延</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">从发出请求到<b>接收最后一个</b>token结束</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用户完整等待时间</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">长回复、报表生成等</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">E2EL高可能由推理或网络/排队等多因素造成。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f8313807ab39ddb82a7e40466"><td class="" style="width:120px"><div class="notion-simple-table-cell">TPOT (Time per Output Token)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">单字平均生成时延</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">首字之后，<b>相邻输出token</b>之间的平均时间</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">TPOT = (E2EL - TTFT) / (TotalOutputTokens - 1)</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">稳态生成速度；越低越流畅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">流式界面（如聊天窗口）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不同框架/论文定义细节可能不同；阅读基准需看准口径。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f8313800e886af7e04ab8c236"><td class="" style="width:120px"><div class="notion-simple-table-cell">ITL (Inter-Token Latency)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">相邻token间隔</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">两个连续输出token之间的<b>实际</b>时间间隔</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">单请求下 <code class="notion-inline-code">平均ITL = TPOT</code>；多请求下为<b>token加权</b>平均</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">更细粒度观测抖动与稳态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">排查“卡顿”、尾延迟</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">多请求平均：TPOT通常按<b>请求加权</b>；ITL按<b>token加权</b>，两者可能不同。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380dea05dc34fb16534c3"><td class="" style="width:120px"><div class="notion-simple-table-cell">RPS (Requests per Second)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每秒请求数，也会叫QPS</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">单位时间内<b>完成</b>的请求数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">RPS = CompletedRequests / (T1 - T2)</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">并发承载能力</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">网关/服务容量评估</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不了解请求难度差异会误判（短prompt vs. 长文档）。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f8313800b97eedf42766ec5be"><td class="" style="width:120px"><div class="notion-simple-table-cell">TPS (Tokens per Second)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每秒token数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">单位时间处理/生成的token数（分<b>输入TPS</b>与<b>输出TPS</b>）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">更细的吞吐画像（prefill vs. decode）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">长输入总结 vs. 长输出聊天</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">必须明确是在量输入、输出还是合并口径。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f83138017b3d0f6b54f922417"><td class="" style="width:120px"><div class="notion-simple-table-cell">Throughput</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">吞吐量</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">一段时间内系统完成的工作量总称（RPS/TPS等体现）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">系统总体产能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">批量处理、并发压测</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">追求吞吐可能牺牲单请求时延（批量、共享算力）。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380e6b45ff8388315a1ba"><td class="" style="width:120px"><div class="notion-simple-table-cell">Goodput</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“有效”吞吐</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>满足SLO</b>前提下的完成速率（如达标TTFT/E2EL的RPS）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“Goodput = 在SLO内完成的请求/秒”</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">真实可用体验与质量</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">生产SLA/SLO考核</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">纯吞吐高≠好体验；需结合SLO过滤无效请求。(<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr></tbody></table><table class="notion-simple-table notion-block-2a08f42f831380fba4a3d5fbcdfb07e1"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-2a08f42f831380f280adc7bf46f6e56e"><td class="" style="width:120px"><div class="notion-simple-table-cell">指标</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">中文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义/口径</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适用解读</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">典型用法/示例</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380d8ade8fe9e5748bc60"><td class="" style="width:120px"><div class="notion-simple-table-cell">SLO (Service-Level Objective)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">服务级目标</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">针对某个指标设定的<b>达标阈值与覆盖比例</b>（如“95% 的对话 TTFT &lt; 200ms”）。常用于和 <b>Goodput</b> 结合，只统计满足 SLO 的吞吐。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">让“可用的真实吞吐”与业务体验挂钩，而不是只看裸吞吐。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“P95 TTFT ≤ 200ms” 或 “P99 E2EL ≤ 2s”。 (<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f8313807fbf3ed6ee1d033221"><td class="" style="width:120px"><div class="notion-simple-table-cell">Mean</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">平均数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">所有值求和 / 个数，容易受<b>极端值</b>影响。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适合监控长期趋势，但不代表多数用户的真实体验。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“mean TTFT” 用于观察整体波动；遇到长尾时可能被抬高。 (<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380c2bf42c5488ac9fd16"><td class="" style="width:120px"><div class="notion-simple-table-cell">Median</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">中位数(P50)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">排序后正中的那一个值，比均值<b>更抗离群</b>，代表“典型用户”的体验。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">看大多数用户的感受，比 mean 更稳定。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“median TPOT = 40ms” 表示稳态流畅；若 median TTFT = 30s，则实时性不可用。 (<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr><tr class="notion-simple-table-row notion-block-2a08f42f831380a0bd1ae5638bc9229b"><td class="" style="width:120px"><div class="notion-simple-table-cell">P99 (99th Percentile)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">第99百分位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">有 <b>99%</b> 的请求不超过该值，体现<b>尾延迟</b>与一致性。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">生产体验与 SLO常看 P99；长尾差会“压坏”口碑。</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">“P99 E2EL = 8s”：最慢 1% 仍需 8s，需优化尾部。 (<a class="notion-link" href="https://bentoml.com/llm/inference-optimization/llm-inference-metrics" target="_blank" rel="noopener noreferrer">bentoml.com</a>)</div></td></tr></tbody></table><div class="notion-callout notion-red_co notion-block-2a08f42f83138013a8d8f1832ca26555"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="👉">👉</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2a08f42f8313808ca432c9dd636991ef"><span class="notion-default"><b>一个用户发出的prompt，大致需要经历如下过程才能返回给用户：</b></span></div><div class="notion-text notion-block-2a08f42f831380dc82f5ebae03fc07f1"><span class="notion-default"><b>router_schedule + proxy_time + tokenize + schedule + prepare + model-inference + sampling + de-tokenize + proxy_time</b></span></div></div></div><ul class="notion-list notion-list-disc notion-block-2a08f42f83138078a302fe00d2c1bb36"><li>TTFT / E2EL</li></ul><ul class="notion-list notion-list-disc notion-block-2a08f42f83138065a570c442741def04"><li>TPOT / ITL （多请求）</li></ul><div class="notion-text notion-block-2a08f42f83138053a983f4c5d182f0ee"><b>对于单个请求，每次流式返回是一串token, 所以我们可以认为ITL是inference server每个step之间的间隔，通过测量得出，而mean TPOT则是每个token所花费的时间，天生就是一个均值属性，属于测量之后计算得出。</b></div><ul class="notion-list notion-list-disc notion-block-2a08f42f83138017ad5ce41c3f1894a2"><li>Goodput</li></ul><ul class="notion-list notion-list-disc notion-block-2a08f42f831380c2ba54c132bd53e073"><li>Balance latency / throughput</li></ul><div class="notion-blank notion-block-2a08f42f83138068a7c5d3b46be705d2"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2a08f42f831380279c0dce618a3ae942" data-id="2a08f42f831380279c0dce618a3ae942"><span><div id="2a08f42f831380279c0dce618a3ae942" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a08f42f831380279c0dce618a3ae942" title="VLLM的实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">VLLM的实现</span></span></h3><div class="notion-text notion-block-2a08f42f8313804ba01ce9fbb654affb">我们以`vllm bench serve` 为例：</div><div class="notion-text notion-block-2a08f42f83138037ba30edae1530f1f6">bench server发送数据记录时间和返回的代码在`vllm/vllm/benchmarks/lib/endpoint_request_func.py`, 最后计算metrics的代码在`vllm/vllm/benchmarks/serve.py`</div><ul class="notion-list notion-list-disc notion-block-2a08f42f831380eb8c31f1045dd36d2d"><li>收集：</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f831380ca89f8d3ecba45ccd5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa5584cab-76ae-4ed4-9c7d-4301f4cf1b32%3Aimage.png?table=block&amp;id=2a08f42f-8313-80ca-89f8-d3ecba45ccd5&amp;t=2a08f42f-8313-80ca-89f8-d3ecba45ccd5" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-2a08f42f83138044a450d22018b5a445"><li>计算</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f831380f2807bd8aaa6bce33f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A9bbc0030-fdc0-4d4c-bdbf-2fba6300dc1c%3Aimage.png?table=block&amp;id=2a08f42f-8313-80f2-807b-d8aaa6bce33f&amp;t=2a08f42f-8313-80f2-807b-d8aaa6bce33f" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f83138084beafddc0aff5ef28"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A56a0881e-154e-49ab-9752-08bd021945c2%3Aimage.png?table=block&amp;id=2a08f42f-8313-8084-beaf-ddc0aff5ef28&amp;t=2a08f42f-8313-8084-beaf-ddc0aff5ef28" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-2a08f42f831380f3ba05fada1904efce"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2a08f42f831380ef9701da49ddeb91d3" data-id="2a08f42f831380ef9701da49ddeb91d3"><span><div id="2a08f42f831380ef9701da49ddeb91d3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a08f42f831380ef9701da49ddeb91d3" title="TPOT和ITL的关系"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">TPOT和ITL的关系</span></span></h3><ul class="notion-list notion-list-disc notion-block-2a08f42f831380538a29f7fc417f8f20"><li>如果是是普通的Auto-Regression (AR) decode, 那么每次vllm llm serve每次流式返回一个token，假设总生成长度是n, 那么itl_list length=n-1, mean tpot = (e2e_latency - ttft) / (n-1) = sum(itl_list) / (n-1) = sum(itl_list) / len(itl_list) = mean itl</li></ul><ul class="notion-list notion-list-disc notion-block-2a08f42f83138045ad7ccee26117a011"><li>如果是在普通的AR上加了speculative decoding，也就是每个vllm llm serve存在traget-model, draft-model接力推理的情况下，每次流式返回可能不止一个token, 假设总生成长度为n, itl_list length = m, mean tpot = (e2e_latency - ttft) / (n-1) = sum(itl_list) / (n-1), mean itl = sum(itl_list) / len(itl_list) = sum(itl_list) / m, 如果speculative decoding 指定的draft tokens长度为k，那么每个decode step生成的next_tokens_num 满足 1 ≤ next_tokens_num ≤ k+1 （额外的1属于bonus token)，因此m ≤ n，那么会出现mean tpot ≤ mean itl的情况，一般来说，接受率越高，m越小，mean tpot和mean itl之间的差距就越大</li></ul><ul class="notion-list notion-list-disc notion-block-2a08f42f83138058bebacc0dc917fac9"><li>tpot对于单request来说只有mean tpot，median / p99 tpot是针对多requests统计下的 tpot来计算的，属于request粒度，而itl属于llm server inference step粒度，所以median / p99的指标数字一般是不会相同的，itl更能反映流式生成的波动，直观上就是展示用户看到的大模型吐字的“顿挫”，“卡顿”感。</li></ul><div class="notion-text notion-block-2a08f42f831380098922ed94ec2011e5">上面的第二条分析，我们得出在speculative decoding的情况下会发生mean tpot ≤ mean itl，但是它们两者之间有没有更加具体的数学关系？因为itl的mean值随着draft_model的接受率而变化，接受越多，m越小，接受越少m越大，两者也就越接近:</div><div class="notion-text notion-blue notion-block-2a08f42f831380a2b92ffee422110497">mean_itl / mean_tpot = sum(itl_list) / m * (n-1) / sum(itl_list) = (n-1) / m</div><div class="notion-text notion-block-2a08f42f831380ffb6ded404733aeb4a">speculative decoding有个接受率的概念，计算方式在`vllm/vllm/v1/spec_decode/metrics.py`文件里：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f8313809580daf9318d1ad671"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aefbdf2d2-e7f7-49df-92df-dee42df14300%3Aimage.png?table=block&amp;id=2a08f42f-8313-8095-80da-f9318d1ad671&amp;t=2a08f42f-8313-8095-80da-f9318d1ad671" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f831380a3aebace7e2f42d231"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af5915fc2-ca58-4121-ae14-7e22dfa22f64%3Aimage.png?table=block&amp;id=2a08f42f-8313-80a3-aeba-ce7e2f42d231&amp;t=2a08f42f-8313-80a3-aeba-ce7e2f42d231" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2a08f42f831380dd90f4de1452ddbfe4">draft model acceptance_rate很好理解，就是target_model 总接受token数量除以总draft model 总生成tokens数量，全部接受就是1，全部拒接就是0</div><div class="notion-text notion-block-2a08f42f831380caaa82cfa1fb330300">mean_acceptance_length比较重要，实际服务中更加关注这个指标，代码中的计算公式为：</div><div class="notion-text notion-block-2a08f42f83138001b2c6f9a521f94330">mean_acceptance_length = 1 + (num_accepted_tokens / num_drafts)</div><div class="notion-text notion-block-2a08f42f8313808bb566ecba2c8b1781">num_drafts表示每个request跑了几次verify, 应该和draft-tokens数量设置无关（假设你没走tree-attention)，所以单个requests上， num_draft_tokens = num_drafts * draft_tokens</div><div class="notion-text notion-block-2a08f42f8313807fa672ea828d0e1508">(num_accepted_tokens / num_drafts)表示平均上，每次verify，target_model接受了多大的长度，长度应该是0～draft_tokens之间，<b>+1代表，如果全部拒绝，verify自身会得到正确的next-token，如果全部接受会部分接受，verify会根据最后一个被接受的draft-tokens代表的logits，得到一个bonus token，所以+1来自decoder-only llm自回归特性使然，总会有一个额外的token给你兜底</b></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a08f42f83138025b456e80b39c6ac61"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ad82369e0-99a6-45fc-b230-6102e6fc344c%3Aimage.png?table=block&amp;id=2a08f42f-8313-8025-b456-e80b39c6ac61&amp;t=2a08f42f-8313-8025-b456-e80b39c6ac61" alt="左边的E和右边的F其实都属于额外的token, 也是上面公式+1的含义。source: https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/blogs/tech_blog/blog2_DeepSeek_R1_MTP_Implementation_and_Optimization.md#mtp-eagle" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">左边的E和右边的F其实都属于额外的token, 也是上面公式+1的含义。source: <a class="notion-link" href="https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/blogs/tech_blog/blog2_DeepSeek_R1_MTP_Implementation_and_Optimization.md#mtp-eagle" target="_blank" rel="noopener noreferrer">https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/blogs/tech_blog/blog2_DeepSeek_R1_MTP_Implementation_and_Optimization.md#mtp-eagle</a></figcaption></div></figure><hr class="notion-hr notion-block-2a08f42f83138041912af0c2b31abf28"/><div class="notion-text notion-block-2a08f42f831380388d3dfcad99d16353">现在我们回过头来看这个公式:</div><div class="notion-text notion-blue notion-block-2a08f42f8313804c8116f35cfc436ba6">mean_itl / mean_tpot = sum(itl_list) / m * (n-1) / sum(itl_list) = (n-1) / m</div><div class="notion-text notion-block-2a08f42f831380649400f0920382be20">对于一个request，在sepc_decode下，每个inference step，会生成mean_acceptance_length, 跑了m次，最终生成了n-1个next-token，所以(n-1) / m = mean_acceptance_length. 近似的，在多个requests下，我们也可以认为上述公式成立，这样我们可以得到：</div><div class="notion-text notion-teal notion-block-2a08f42f831380fea2fbf28933cc777f">mean_tpot = mean_itl / mean_acceptance_length</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2a08f42f831380f48b11fff2e03c607a" data-id="2a08f42f831380f48b11fff2e03c607a"><span><div id="2a08f42f831380f48b11fff2e03c607a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a08f42f831380f48b11fff2e03c607a" title="workload inference metric理论估计example"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">workload inference metric理论估计example</span></span></h3><div class="notion-callout notion-red_co notion-block-2a18f42f8313804c907ce2ae3213d41d"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="📌">📌</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2a08f42f8313803e90d1c302d38a1963">AI Infra serve的总体目标：在满足SLO的前提下，尽量提高有效吞吐</div></div></div><div class="notion-text notion-block-2a18f42f83138000bfcbd854cce5ac1c">以vllm llm serve为例，其控制requests处理并行/并发度行为，有三个重要的参数可以调节：</div><ul class="notion-list notion-list-disc notion-block-2a18f42f831380b0a3f0f5da95d0c2fa"><li>model server层面：`max_num_seqs`和`max_num_batched_tokens`</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f83138012b88aebf5418ce63c"><li>router层面： `max_concurrency`</li></ul><blockquote class="notion-quote notion-block-2a18f42f831380f0b2edf810368b6253"><div>router层面设置的`qps`参数不能控制并发度，它只是模拟设置的qps来采样request发送到server的间隔。并发度是针对服务层面能在单位时间/空间内处理多少个requests</div></blockquote><ul class="notion-list notion-list-disc notion-block-2a18f42f83138004a046dd34a2fc814b"><li>`max_num_seqs`代表vllm engine_core scheduler一个step最多能处理多少个requests, `max_num_batched_tokens`代表vllm engine_coe scheduler一个step最多能处理多少个token, 因为vllm采取continuous batching的方式，所以requests被选中的tokens是拼在一起拉成一维处理。上述两个参数谁先达到阈值谁先生效。</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f83138017aa54e731fba4d2f7"><li>`max_concurrency`表示router最多只能送给model server多少个requests，而不是来了就无脑送给model去管理，这个参数的目的是为了在模型上线后，调整latency-throughput之间的平衡</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2a18f42f8313808996abd8f27e1fc380"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Acb2c954f-210a-4796-b636-82aab1dfcf41%3Aimage.png?table=block&amp;id=2a18f42f-8313-8089-96ab-d8f27e1fc380&amp;t=2a18f42f-8313-8089-96ab-d8f27e1fc380" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-2a18f42f831380b3a626e4b566ba5e59"><li>`max_num_seqs`, `max_num_batched_tokens`和`max_concurrency`三者存在短板效应，谁先达到阈值就会先限制并发，如果`max_concurrency`设大了，而`max_num_seqs`和`max_num_batched_tokens`比较小，throughput也上不去，如果`max_concurrency`设小了，而`max_num_seqs`和`max_num_batched_tokens`比较充足，虽然latency能达标，但阻塞了后续的request，会造成某些request排队等待时间过长，导致TTFT过大。</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f8313803f963dc63844c4fd26"><li>既然这些参数配置比较复杂，我们如何确定llm serve期间的batch_size？比如说我们有mean TTFT和mean TPOT，他应该也有平均的bs，这样方便我们估计吞吐。一般来说，我们可以根据SLO的输入输出规模合理设置`max_num_batched_tokens`，这样我们就可以关注`max_num_seqs`，让它的阈值先到，比如可以设置阈值刚好满足SLO，然后我们设置`max_concurrency`，让其最大不能超过所有model server的总`max_num_seqs`，方便我们调节（user发request给router endponit, router下维护了多个model server endpoint, 然后根据算法选择发给哪个model server实例）。这样的话，`max_concurrency`的request都能被同时处理，我们就可以用它来代表bs，然后根据一段时间统计的mean TTFT / TPOT来计算吞吐。</li></ul><div class="notion-text notion-block-2a18f42f831380978b95ec415d78727b">接下来，我们以deepseek-r1为例（它的部署代表了现在比较前沿的水平，包含了FP8 quant + xPyD + tbo + tp + dp + ep + deepep + eplb + mtp + … etc.），来分析一下部署的metrics该怎么估计</div><ol start="1" class="notion-list notion-list-numbered notion-block-2a18f42f831380b6ba88dc98ceef5488" style="list-style-type:decimal"><li>xPyD部署中的x, y如何确定？</li></ol><ul class="notion-list notion-list-disc notion-block-2a18f42f831380199682d8e0d14e4e3e"><li>首先，1P1D中，P instance和D instance可能使用的node数量有所区别，因为他们的并行策略可能所有不同，尤其是大型MOE ep并行下，比如P可能使用2个节点，D可能使用4个节点</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f83138067a77fcf6dfadd561e"><li>我们首先要根据SLO标准，不断try p / d部署settings，尽可能在比较少的机器上充分利用内存，算力，带宽，满足各自的prefill / decode SLO标准</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f83138013ac84f0b1a414e707"><li>然后我们开始配比x, y，因为两边能处理的max-num-seqs不一样，且P计算密集型，D是访存密集型，一般来说D能处理比P更多的requests，但是D需要等P处理完发过来，所以可能需要更多的P防止D的性能退化</li><ul class="notion-list notion-list-disc notion-block-2a18f42f83138013ac84f0b1a414e707"></ul></ul><ol start="2" class="notion-list notion-list-numbered notion-block-2a18f42f8313805a9353caa445fe5165" style="list-style-type:decimal"><li>设置好了xPyD，max-concurrency怎么计算？</li></ol><ul class="notion-list notion-list-disc notion-block-2a18f42f831380e3981ef7b6a8e7d942"><li>其实本质上就是上面的p_loop * b_p * x = (lo * t2 * bp * x) / t1</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f831380ec8037d569cbed70a1"><li>此时的max_concurrency就是server处理的并发度，类似bs的概念，即lo*t2这段时间内，处理了max-concurency个request，且mean_ttft = t1, mean_tpot=t2，满足SLO</li></ul><ol start="3" class="notion-list notion-list-numbered notion-block-2a18f42f8313806e996ed2bf50136130" style="list-style-type:decimal"><li>设置好了xPyD，max-concurrency，单机8卡有效QPM怎么算?</li></ol><div class="notion-text notion-block-2a18f42f831380eeb142f4c9575cdd87">为了满足SLO，提高吞吐QPM，我们可以：</div><ul class="notion-list notion-list-disc notion-block-2a18f42f83138042a759ee5994f67414"><li>加机器，增大max_concurrency，然后看看是否可以带来更多的吞吐</li></ul><ul class="notion-list notion-list-disc notion-block-2a18f42f8313803a9f64cc8e993a6102"><li>降低t1, t2, 依然满足SLO，增大max_coneuccency，吞吐自然上去</li><ul class="notion-list notion-list-disc notion-block-2a18f42f8313803a9f64cc8e993a6102"><li>硬件</li><ul class="notion-list notion-list-disc notion-block-2a18f42f831380318582cbd46c504a02"><li>融合算子，tune gemm，优化算子等，提高硬件算力利用率</li><li>overlap device不同单元，比如通信和计算overlap，不同算子之间的overlap等，提高硬件整体利用率</li></ul><li>框架</li><ul class="notion-list notion-list-disc notion-block-2a18f42f8313804092c2cef6fe36e4b5"><li>cpu端：异步cpu操作，减少cpu开销，消除硬件idle时间</li><li>cpu端：python is slow，减少调用栈，使用nump代替list等</li><li>workload: 量化，稀疏，更加细粒度的并行切分等 (能做但是不一定让做）</li><li>算法：提高mtp接受率，mean_acceptance_length增大，t2自然减少，其他近似算法等</li><li>kv cache层级管理，空间换时间</li></ul><li>通信</li><ul class="notion-list notion-list-disc notion-block-2a18f42f8313806a9837c1436eec3c13"><li>机内 / 机间通信，带宽利用率提升，通信算法优化等</li></ul><li>…</li></ul></ul><div class="notion-blank notion-block-2a08f42f8313805d846ceea1adc3a562"> </div><div class="notion-blank notion-block-2a08f42f831380c6a502e20c56ca7dca"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[微软CEO纳德拉的两篇专访]]></title>
            <link>https://densecollections.top//technology/MSFT-Satya-Nadella-talking-notes</link>
            <guid>https://densecollections.top//technology/MSFT-Satya-Nadella-talking-notes</guid>
            <pubDate>Sat, 15 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[微软CEO访谈，主要分享对未来AI，量子计算，云计算的一些想法，在我看来，不少都是真知灼见]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1828f42f8313818096bae2afa3a671d6"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-1828f42f83138190b113e11eb4ce9c6b">最近在公众号“<em><b>瓜哥AI新知</b></em>”里看到了两篇对微软CEO纳德拉的访谈纪要整理，里面的内容主要涉及到AGI未来的发展，量子计算，云计算，已经未来AI助手的雏形畅想等等，<s>也间接解释了最近微软不参与美国星际之门项目/取消一些计算中心等事件的原因(看好AI应用，自己不一定做AI基础模型，认为AI对算力的需求是巨大的，但是不是盲目跟，合适的应用出现时会迅速跟上)</s>。个人深受启发，所以做了一些记录。</div><div class="notion-text notion-block-1b78f42f831380f48b46cdd7c78c6f58">两篇专访的链接：</div><ul class="notion-list notion-list-disc notion-block-1b78f42f831380a9b866ec3878b8d05b"><li><b><a class="notion-link" href="https://mp.weixin.qq.com/s/sN5FSz8Gm39OWoEJZET1gw" target="_blank" rel="noopener noreferrer">2万字全文｜微软CEO纳德拉专访：AI不是赢家通吃的市场、AGI的标尺是世界能否达到10%增速、微软豪赌AI/量子/混合现实</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f8313800c9023c2bddf728f7c"><li><b><a class="notion-link" href="https://mp.weixin.qq.com/s/cSBo6V3zKWgRWxyMNBekBQ" target="_blank" rel="noopener noreferrer">万字访谈｜微软CEO纳德拉：不仅豪赌AI基建还要做第一性原理重构、微软有能力自建模型、OpenAI是优秀产品公司碰巧有出色的模型</a></b></li></ul><div class="notion-blank notion-block-1b78f42f8313806db0c4ffd7fc54ffc6"> </div><div class="notion-text notion-block-1b78f42f831380fcacf5e2f6e67e2fc9">一些重要的访谈notes:</div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-1b78f42f831380ea867ace66a9bd03b8" data-id="1b78f42f831380ea867ace66a9bd03b8"><span><div id="1b78f42f831380ea867ace66a9bd03b8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b78f42f831380ea867ace66a9bd03b8" title="关于微软："><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">关于微软：</span></span></h4><ul class="notion-list notion-list-disc notion-block-1b78f42f83138078930cea7d386bb75a"><li>微软的文化是<b>构建软件工厂</b>，而非专注于单一产品或技术—-》生态的重要性；</li></ul><blockquote class="notion-quote notion-block-1b78f42f831380a498bec13a773912fd"><div>当然还有Windows。它是我们最古老的产品之一。所以在某种意义上，他们去到任何可以使用软件工厂来创建软件的地方。所以，有趣的是，我有点想到，甚至这导致了知识工作，对吧？所以我认为这种文化，是如何让最优秀的人才来构建最好的软件工厂，然后创建世界上需要的软件产品？这就是当我回顾过去时所想的。对于在座的各位创始人来说，我认为在回顾我们的50年历史时，这是一个非常强大且有用的框架。</div><div class="notion-text notion-block-1b78f42f831380b48c7acb7b947749fc"><b>因为我认为很多公司有时会爱上一个产品、一种技术、一种商业模式，但所有的事情最终都会耗尽燃料。</b>所以我很想知道，虽然我对此没有定论，但我很想知道这种框架，是否对你所说的文化观点有所帮助，有助于思考进来的人才，努力为软件工厂做出贡献。</div><div class="notion-text notion-block-1b78f42f83138058aba8ce3c56373176">每次当你有更好的想法，想要在工厂里建造一些新的小玩意时，你都可以重新审视，而不是仅仅爱上你去年建造的小玩意。我很想知道这是否有助于我们保持敏锐的注意力。</div><div class="notion-text notion-block-1b78f42f831380cc9126eb25ccd96330">我不认为文化是静态的；我们所有人都在努力，并且一直致力于学习型的文化。现在，我使用诸如成长型思维模式之类的术语。我想知道我们是否一直拥有这种成长型思维模式和学习型思维模式，因为公司从根本上的框架就是如此。</div></blockquote><ul class="notion-list notion-list-disc notion-block-1b78f42f831380bebbecdb2d5ece5825"><li>保持相关性而非追求长寿是目标——》专注；</li></ul><blockquote class="notion-quote notion-block-1b78f42f831380eda2f6f1011beb281c"><div><em>为什么微软不去自己做基础模型？</em></div><div class="notion-text notion-block-1b78f42f831380249787c51a98bc7a93">我是这么看的，我们是一家全栈系统公司，我们希望拥有全栈系统能力，而基础模型是一个重要的组成部分。当初我们开始与OpenAI合作时，实际上是基于一个信念的押注，也就是当时Sam、Ilya、Greg和其他人对大规模扩展的坚定信心。事实上，很有意思的是，我第一次读到的Scaling Laws论文，好像是Dario写的。</div><div class="notion-text notion-block-1b78f42f831380478221fd19c53d8724">我下的赌注是，特别是当它与自然语言结合时。如果不是自然语言，我不认为我们会做到今天这样。因为我们是一家知识工作者公司，我们对自然语言非常着迷。这是Bill多年来一直坚持的事情。所以，当有人说，我要把计算能力投入到自然语言中，也许我们可以得到一些扩展法则。</div><div class="notion-text notion-block-1b78f42f8313805ebd1df806fcb28d9b">因为<b>我们一直痴迷的是将世界模式化</b>，对吧？也就是人、地点、事物，然后去构建最伟大的本体和模式。我们认为智能将由此产生。我们在这上面走了很多弯路。然后我感觉，哇，我一直觉得不舒服，因为<b>世界太混乱了，SQL无法处理</b>。所以我说，总会有人以不同的方式找到某种语义表达的方法。这就是当时的赌注，我并不清楚它是否会成功，但它开始起作用了。</div><div class="notion-text notion-block-1b78f42f831380f7a1c6f73a74b49f54">所以我看到的是，我们有一个非常棒的商业伙伴关系。我们拥有所有我们想要和需要的，以及这种能力。就像我一直说的，我们在它下面构建了一个系统。我们围绕它构建了工具。我们正在构建基于它的产品。所以在某种程度上，<b>我与OpenAI保持着长期稳定的关系，并且我们拥有IP权利。</b></div><div class="notion-text notion-block-1b78f42f8313808493b2e3ca66d04888">因此，我们也会想要构建。就像我们构建了Phi。你知道，Mustafa和他的团队拥有他们在Pi之前所拥有的能力。我们在微软也拥有这种能力。在这一点上，如果只是为了证明这一点，那就没有意义了。我相信模型正在变得商品化。事实上，<b>OpenAI不是一家模型公司，而是一家碰巧拥有出色模型的产品公司</b>，这对他们和我们，作为他们的合作伙伴来说，都是一件好事。</div><div class="notion-text notion-block-1b78f42f83138026a775dee02c8ebc0a">所以，我现在想去到我认为正在形成的行业结构表明，<b>模型本身是不够的，拥有一个完整的系统堆栈和成功的产品——这两者才是关键</b>。</div></blockquote><ul class="notion-list notion-list-disc notion-block-1b78f42f831380e0baebfaf9bafb9068"><li>不应认为过去的一切都是坏的，<b>新领导者并非拯救者（结合最近老东家Intel的两任CEO pat和陈立武，百感交集）；</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380788c37e676dff91ece"><li>战略合作的目的是建立商业关系，而不仅仅是投资回报；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f8313809cad96fbee57a8f857"><li><b>对失败的容忍度：</b> 允许尝试，并认识到不可能所有事情都做对。</li></ul><div class="notion-blank notion-block-1b78f42f831380d583aedb94b36faeba"> </div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-1b78f42f8313802d80b1ebc9fa304475" data-id="1b78f42f8313802d80b1ebc9fa304475"><span><div id="1b78f42f8313802d80b1ebc9fa304475" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b78f42f8313802d80b1ebc9fa304475" title="关于AI和云计算"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">关于AI和云计算</span></span></h4><blockquote class="notion-quote notion-block-1b78f42f831380ad87a3d4c1fb415a15"><div><b>主持人德瓦克什：</b> 人工智能的价值将会在哪里创造？</div><div class="notion-text notion-block-1b78f42f831380f5b11bc46f32cf773a"><b>萨提亚·纳德拉：</b> 这是一个很好的问题。至少以我目前的看法来看，有两个地方我可以比较有信心地说。一个是超大规模厂商会做得很好。因为根本的一点是，<b>如果你回顾Sam和其他人描述的方式，如果智能是计算力的对数，那么谁能进行大量的计算，谁就是大赢家</b>。</div><div class="notion-text notion-block-1b78f42f8313804da5f2d132a6d9807b">另一个有趣的事情是，如果你看看任何AI工作负载的底层，比如ChatGPT。并非每个人都对GPU方面发生的事情感到兴奋。这很好，但它是一个比率，事实上，我甚至将我的集群视为AI加速器、存储和计算的比率。而且，从规模上看，你必须扩大它。因此，世界对这种基础设施的需求将会呈指数级增长。事实上，拥有这些AI工作负载简直是天上掉馅饼，因为你知道吗？它们对更多计算能力更加渴求，不仅仅是为了训练，而且我们现在知道对于测试时间也是如此。</div><div class="notion-text notion-block-1b78f42f831380bb917adf2f7a7d714e">正如我所说，测试时间，这里有一件有趣的事情。当你想到一个AI代理时，<b>事实证明，AI代理将呈指数级地增加计算使用量，因为你现在甚至不受仅仅一个人类调用程序的限制</b>。而是一个人类调用程序，这些程序又调用了更多的程序。这将为计算基础设施创造巨大的需求和规模。所以我们的超大规模业务，Azure业务，我认为那是一个很大的机会。</div><div class="notion-text notion-block-1b78f42f831380b2978affc93e372cda">之后，事情变得有点模糊，因为你可以说，存在一个赢者通吃的模型。我只是不这么认为，因为这是我学到的另一件事，非常擅长理解哪些是赢者通吃的市场，哪些不是，在某种程度上，是至关重要的。我记得甚至在早期我开始接触Azure时，Amazon已经拥有非常显著的领先优势，人们会来找我，投资者会来找我说，哦，游戏结束了，你永远不会成功。Amazon，它就是赢者通吃。</div><div class="notion-text notion-block-1b78f42f8313805c8f4cea23b87fcff8">但是，在与Oracle和IBM以及客户端-服务器竞争之后，<b>我知道，买家不会容忍赢者通吃。从结构上讲，超大规模永远不会是赢者通吃，因为买家很聪明</b>。消费者市场有时可能是赢者通吃，但是任何买家是公司、企业、IT部门的地方，他们都希望有多个供应商。因此，你必须是多个供应商之一。我认为即使在模型方面也会发生这种情况。</div><div class="notion-text notion-block-1b78f42f83138054ac15f17cb96d6c81">因此，会有开源，会有一个管理者。就像在Windows上一样，我学到的一个重要教训是，<b>如果你有一个闭源操作系统，就会有一个补充，那就是开源</b>。因此，在某种程度上，这实际上是对所发生事情的一种制约。所以我认为在模型方面，也许存在一些闭源的东西，但肯定会有一个开源替代方案。最终，开源替代方案实际上将确保闭源的赢者通吃得到缓解。</div><div class="notion-text notion-block-1b78f42f83138011b3a1ef6faa5528ac">所以这至少是我的感觉在模型方面。顺便说一句，如果这东西真的像人们说的那样强大，我们不要低估国家不会坐视不理，等待私营公司满世界乱跑。 所以我并不认为这是一个赢者通吃的局面。 在那之上，我认为这还是一样的老一套，也就是在消费者领域，在某些类别中，可能会有一些赢者通吃的网络效应。</div><div class="notion-text notion-block-1b78f42f8313801a82a8c5ffff4fafef">毕竟，ChatGPT就是一个很好的例子。我的意思是，它就像一个大规模的消费者产品，已经获得了真正的逃逸速度。我去应用商店，我看到它总是在前五名。我说，哇，这真是令人难以置信。所以他们能够利用这种早期的优势，并将其转化为应用程序优势。因此，在消费者领域，这种情况可能会发生。<b>在企业领域，我认为在每个类别中，都会有不同的赢家</b>。所以这至少我是这么分析的。</div></blockquote><ul class="notion-list notion-list-disc notion-block-1b78f42f831380a9971ececc5bdeacc0"><li><b>AGI里程碑的炒作不可信：</b> 真正的衡量标准是AI能否推动世界经济以<b>10%的速度增长</b>。——》不要过分限制AI，也不要过分夸大某个AI产品，重点是先用起来，看看能否提升自己的生产力。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f83138030b7b7c0fba3173438"><li><b>超大规模厂商和基础设施提供商将受益： AI对计算能力的需求将呈指数级增长</b>，利好Azure等云服务。—-》杰文斯悖论（术进步提高了某种资源的使用效率，反而导致该资源的总消耗量增加的现象），需求只会越来越大。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f83138002b195dd4773c12694"><li>自主行为超越Co-pilot，目标是减轻知识工作的苦差事—-》AI的一大重要作用就是专用化，代替人类进行一些重复的知识性劳动，这些劳动往往场景确定，指令确定，方便AI进行处理。还有一类是模糊指令，比如创作和科学研究等等，这些可能需要时间去突破；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f83138005a6a3c8514018550c"><li>存在三种并行发生的AI趋势：知识工作、现实世界行动模型、科学模型—》AI搜索/AI agent/AI for science；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380448665ccb1968cddbe"><li><b>超大规模数据中心运营的专业知识：</b> 复制全球计算能力非常困难，运营专业知识至关重要。—-》AI基础设施的建设，运维等等需要非常多的专业知识和专业人才</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380bebd96f8fd1f34f0b1"><li><b>需要对底层系统进行第一性原理的重新架构，以支持AI</b>—》AI infrastructure的重要性，目前的AI软件栈太复杂和庞大，且存在各种兼容性问题，未来不会是NV一家通吃的局面；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380f7a9c6e80625347b91"><li>现有AI系统还未迎来“存储程序”的时刻，缺少健壮的多模型内存系统—-》这一点其实很有意思，之前很多人提围绕LLM构建新的操作OS，比如kv cache是内存，LLM是cpu，token是指令等，但是token很长（比如1M）之后，LLM的使用场景就很受限（推理速度，精度，cost等）。去年很多工作都是围绕kv-cache的优化来的，目的就是为了把token的处理维度可以变得scalable。另外一点就是多模型组合/或者多MOE之类的进行分task处理等，总之就是目前的架构还不能最终确定，但是方向是使用大模型来驱动未来个人助手引擎。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380119693d35f5580db6d"><li><b>推理收入是关键：</b> 要关注将AI转化为实际客户价值的能力，供给和需求需平衡。——》训练可能是一次性的，推理时思考，或者推理时微调等等可能会占据大部分算力。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380ab9f18d6430fe00d57"><li> <b>新的AI用户界面：</b> Copilot是关键，每个人都需要一个智能代理管理器来管理与多个AI代理的交互。——-》未来每个人都会有一个智能助手，关于这个助手的形态和界面，不一定是和现在的软件产品界面类似，需要重新定义。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380e8a96eed2a5c043a72"><li><b>需要控制AI的运行时环境：</b> 通过沙盒等技术限制AI的行动空间，防止AI造成伤害。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380868551cf2ff24e46bb"><li><b>关注未被充分服务的领域：</b> 如医疗保健、教育和公共服务，将科技转化为更好的服务。——》不要总是盯着chat/code/image等单纯的领域看,要把产品结合到社会上大的基础服务领域，这个里面会有很多的利润和更大的社会变革。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f8313804ea716cd8e56ab25a7"><li>混合现实/AR/VR/元宇宙依然很有潜力。</li></ul><div class="notion-blank notion-block-1b78f42f831380ffb466f2f055538c6f"> </div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-1b78f42f8313804a97aece2c2d014ac2" data-id="1b78f42f8313804a97aece2c2d014ac2"><span><div id="1b78f42f8313804a97aece2c2d014ac2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b78f42f8313804a97aece2c2d014ac2" title="关于竞争和人才"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">关于竞争和人才</span></span></h4><ul class="notion-list notion-list-disc notion-block-1b78f42f831380e5829eccd0980a1bf4"><li><b>身处竞争激烈的领域胜过身处可能获胜但毫无意义的领域；</b></li></ul><blockquote class="notion-quote notion-block-1b78f42f831380a2a25dcb4df80a713a"><div><em>和卓越的对手竞争使你变得更强大和敏捷</em></div><div class="notion-text notion-block-1b78f42f831380dca01ee17bc48148ec">就是这样。我很高兴看到今天早上的比赛，但我对板球很痴迷。我认为每个南亚人也一样。 <b>不过，至少在我的生命中的这个阶段，我一直在思考竞争。我想确保我专注于正在进行的游戏，而不是仅仅参加游戏，并且更加深思熟虑</b>。</div><div class="notion-text notion-block-1b78f42f831380c0b5cff279c34ce2ce">我觉得创始人从本质上来说就是在做这件事，因为这就是你定义一家公司的方式。你会问自己：“我想玩什么游戏？” 然而，竞争也包括首先挑战自己，以确定正确的竞争范围。这是科技行业的另一个重要方面。如果我回顾我自己的经历，我很幸运能拥有一个独特的故事。我于 1988 年来到美国，柏林墙于 1989 年倒塌，我于 1990 年进入科技行业。真是不可思议的旅程！这真是一段令人难以置信的时光。</div><div class="notion-text notion-block-1b78f42f831380459730d5f76cb4b9aa">所以，问题就出现了：什么是设置和竞争范围？ 我意识到这是最重要的考虑因素。 <b>你想进入一个拥有卓越竞争对手的行业或领域</b>。 事实上，身处竞争激烈的领域胜过身处你可能会获胜但毫无意义的领域。 因此，我开始更多地将我的思维导向于正在进行的游戏，而不是你想要玩的游戏。</div></blockquote><ul class="notion-list notion-list-disc notion-block-1b78f42f83138017907fdc37c02842bf"><li>培养孩子的好奇心、批判性思维和常识，<b>而非过度强调专业知识</b>—-》AI越来越强大，专用，仅仅花费大量时间去人为精通某一项技能可能得不偿失，应该转换思维，学会使用AI进行创造和提高生产力；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380a596f9cc8d89d913db"><li>培养自信心，让孩子能够探索和创造—-》多去学习，接触不同的东西，不能让人把时间过多浪费在手机短视频等娱乐上；</li></ul><div class="notion-blank notion-block-1b78f42f831380cd9499f713ee1500e7"> </div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-1b78f42f831380e89ff7d76919556b49" data-id="1b78f42f831380e89ff7d76919556b49"><span><div id="1b78f42f831380e89ff7d76919556b49" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b78f42f831380e89ff7d76919556b49" title="关于量子计算"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">关于量子计算</span></span></h4><ul class="notion-list notion-list-disc notion-block-1b78f42f831380ffa1a7d7c913fbbcf7"><li><b>量子计算的“晶体管时刻”：</b> 实现了马约拉纳零模的存在性证明，有望构建百万量子比特的马约拉纳芯片（Majorana 1）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f83138064a2e8f6be646d4c2a"><li><b>量子计算与经典计算共存，前者擅长探索数据空间，后者擅长处理数据密集型工作负载</b>；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f831380c5a163f814008fd5aa"><li>量子计算机擅长模拟和探索状态空间，尤其是在化学、物理和生物学领域；</li></ul><ul class="notion-list notion-list-disc notion-block-1b78f42f83138015b713c3b3b2f86303"><li><b>AI与量子的协同：</b> 使用量子技术生成合成数据，然后使用这些数据训练AI模型，模拟化学和物理过程；

</li></ul><div class="notion-blank notion-block-1b78f42f8313801cad22d9e87a0c36bd"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2025-2026: 非共识]]></title>
            <link>https://densecollections.top//year-summary/2025-no-consensus</link>
            <guid>https://densecollections.top//year-summary/2025-no-consensus</guid>
            <pubDate>Wed, 31 Dec 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[2025年终总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1a98f42f831380e7a9e9d6cfd2b3f751"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-2da8f42f83138075a3e3e74d41e0e2a1"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🧗‍♂️">🧗‍♂️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2da8f42f83138098bd6cff64a0d0bf88"><em><span class="notion-inline-underscore">Life is not a problem to be solved, but a reality to be experienced.</span></em></div><div class="notion-text notion-block-2da8f42f8313800e8dcdcfab3182c323"><em><span class="notion-inline-underscore">生命不是一个需要解决的问题，而是一个需要体验的现实。</span></em></div><div class="notion-text notion-block-2da8f42f831380639081c7aabe5ceecd">—索伦・克尔凯郭尔</div></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380579360c17d1bba2bf7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-8057-9360-c17d1bba2bf7" alt="陈逸飞老师画的鲁迅先生" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">陈逸飞老师画的鲁迅先生</figcaption></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2da8f42f8313802eb780f1d89a81d516" data-id="2da8f42f8313802eb780f1d89a81d516"><span><div id="2da8f42f8313802eb780f1d89a81d516" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2da8f42f8313802eb780f1d89a81d516" title="回顾2025"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">回顾2025</span></span></h3><div class="notion-text notion-block-2da8f42f831380aaae6dce62bb612ebd">2025年即将结束，回顾一下，感觉自己最大的收获就是尝试了一些新东西，同时勇敢地往前迈出脚步。年后换了新工作，离开之前的舒适圈，决心要好好往着AI software/infrastructure engineer的路上进发。离职间隙和W去外面好好玩了一圈，同时也决定开始好好研究投资的事，为未来做打算，这也是文章标题取名“非共识”的原因(因为今年整体海内外股票投资情形都比较魔幻，正好年末看到了<a class="notion-link" href="https://mp.weixin.qq.com/s/uUKGLg15xw4EfOezVc7ZOQ" target="_blank" rel="noopener noreferrer">张小珺做的一个VC访谈</a>，<b>里面提到价值投资就得敢于做非共识，我又想到个人的职业发展和人生规划又何尝不是如此~</b>)。暑假末期和W一起看了周笔畅的演唱会（算是人生第一次！)，也和W一起做了很多有意思的事情和决定。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f83138042ac99df218ca13f56"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Abbcc82f4-09e4-4b5a-abaf-56989887903c%3A8508b91ca5bf8a27461e25aa5581bb66.jpg?table=block&amp;id=2da8f42f-8313-8042-ac99-df218ca13f56&amp;t=2da8f42f-8313-8042-ac99-df218ca13f56" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2da8f42f831380f9a0e0d262a6754f8a">2025年算是自己工作比较忙的一年，不像以往可以有空看看书，旅旅游。换了新工作之后，明显感觉到AI行业的快节奏和卷到飞起的技术发展。这一年，慢慢深入学习了vLLM框架的一些特性，同时感受到了社区的强大热情和创造力，自己也开始思考AI Infra的工作内容和个人的发展计划。从device kernel到框架设计，从单机单卡到分布式，从nccl到RDMA，从cuda-graph到更多的host-device overlap，从自回归模型到多模态模型等等，横跨众多系统和优化方向，所以也常感叹时间不够用。</div><div class="notion-text notion-block-2da8f42f83138049a7a3fe640a6edfb5">2025年出现了很多AI产品，并且不断迭代，产品力越来越高，比如nano-banana，sora, Manus，Claude-code, cursor等，生成式领域水平越来越高，使用门槛也越来越低，vibe coding引发了很多程序员的焦虑。自己也尝试着使用这些产品，同时也发现vibe coding也确实能make my life easier，自己也能有一些时间去思考架构设计和特性需求这样更上层一点的方向。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f831380e881b3f4803efede28"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A440b1ed4-f0bf-47af-accb-0df9b5e5df90%3A305527f5d4f389a232967b10e2f4a46c.jpg?table=block&amp;id=2da8f42f-8313-80e8-81b3-f4803efede28&amp;t=2da8f42f-8313-80e8-81b3-f4803efede28" alt="浦江郊野公园" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">浦江郊野公园</figcaption></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1a98f42f831380ada304d613074cb04a" data-id="1a98f42f831380ada304d613074cb04a"><span><div id="1a98f42f831380ada304d613074cb04a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1a98f42f831380ada304d613074cb04a" title="旅行"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">旅行</span></span></h3><div class="notion-text notion-block-1a98f42f83138087b012f50fa9bb08cc">今年2月底3月初，正好借着离职的空档期出去大玩特完了一阵。去广州吃了一些美食，去香港感受了一下往日的荣光，也去了W心心念念的Tokyo，虽然很累，却收获颇丰。</div><div class="notion-text notion-block-1b88f42f831380d88d07c82d737de6ec">🏙️<b>大湾区（部分）</b></div><div class="notion-text notion-block-1b88f42f831380769ca8e193b1134255">第一站先去的深圳，打算着从深圳通关过港，然后再从深圳到广州逛逛。深圳是一座开放包容的城市，从机场就能看到非常多的本土科技企业的宣传海报。我们住的旅馆附近也有一个名为“人才公园“的大公园，内部也树立了一些著名深圳人才的石柱。”北上广深“中应该只有深圳最不歧视外地人了，大家不讲究吃穿，都是忙着搞钱。另外，和居住在深圳的亲戚聊天，我得到一个意想不到的消息：深圳的教育不卷，老师们也不按照成绩评比，反而鼓励小孩加强体育锻炼！相较于上海的鸡娃，真是幸福太多了。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313808d966ec87cfd57545b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/sz_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-808d-966e-c87cfd57545b" alt="深圳街边熙熙攘攘的人群，电瓶车很混乱，但是很有烟火气。这里工作机会很多，每个人都忙着赚钱和生活" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">深圳街边熙熙攘攘的人群，电瓶车很混乱，但是很有烟火气。这里工作机会很多，每个人都忙着赚钱和生活</figcaption></div></figure><div class="notion-text notion-block-1a98f42f831380ef9913d1d395f166b7">我们没有在深圳待很久，大部分时间都是早上过海关去香港，然后晚上回来休息，所以很多深圳的其他地区都没机会去逛逛。南山区那边高楼林立，有无数个科技大厂的分部/总部，也看到了著名的”春笋“，感受到了一种有别于上海的，揉合了”求实创新“和生活气息浓厚的城市文化。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380949585c66cadefa8b6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/hk_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8094-9585-c66cadefa8b6" alt="维多利亚港" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">维多利亚港</figcaption></div></figure><div class="notion-text notion-block-1b88f42f83138064b119d72feb887ad2">其实在深圳就有人跟我说香港现在没啥好玩的，很多香港人都回流到内地来旅游消费。自己去了之后发现城市繁荣度上确实如此，高楼的气派程度早就被外滩和深圳超越了，路也破破烂烂的，到处是老破小，物价也贵，交通也贵。如果只是想去感受一下繁荣，那肯定是会大失所望。</div><div class="notion-text notion-block-1b88f42f831380b293d9ec428ee816ed">但是两天的香港之行让我窥见到了一些不同于内地的样貌：</div><ul class="notion-list notion-list-disc notion-block-1b88f42f831380adb363d5862923c31b"><li>香港有一种怀旧的气息，有很多老手艺店还在，比如磨剪刀（我没想到能看到这个）；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f8313800a801ed5fa9a091fae"><li>金融发达繁荣，金融普及度高，三步一个中银香港，两步一个汇丰银行，地铁站随处可见ATM取款机；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380baac6bf020324e26b3"><li>虽然很破，但是城市基础设施建设很全，市民素质高；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380108eb0fb12abff8d89"><li>很多方面和日本很像（但是购物性价比已经不如日本了）；</li></ul><div class="notion-row notion-block-1b88f42f8313809bbda5e69d9bb294d3"><div class="notion-column notion-block-1b88f42f831380bb998ee41e1e1424df" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380438648f4dc9ce2a8e8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/hk_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8043-8648-f4dc9ce2a8e8" alt="香港的本土漫画文化楼梯" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">香港的本土漫画文化楼梯</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380c7a6fddb47f9e6d6a8" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380309eeae2260618e0ad"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/hk_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8030-9eea-e2260618e0ad" alt="维多利亚港星光大道的麦兜”爪印“" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">维多利亚港星光大道的麦兜”爪印“</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1b88f42f83138033af1fe3db73a92b13"><div class="notion-column notion-block-1b88f42f8313803eb30be7a98aae6245" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f83138061a158dde8bffdbe14"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/hk_3.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8061-a158-dde8bffdbe14" alt="维多利亚港上的”电影机位“" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">维多利亚港上的”电影机位“</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f8313807db003ca99296d8055" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313800f9716c780d6988bdc"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/hk_4.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-800f-9716-c780d6988bdc" alt="港片的计程车" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">港片的计程车</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-1a98f42f83138069a6a2f7e4762e7826">香港之行结束了，我们决定去广州好好吃吃东西。广州在我的印象里就是生活很chill,好吃，好玩，好逛，气候湿润温暖，花多，公园多。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313805da53ee66083e6945c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/gz_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-805d-a53e-e66083e6945c" alt="圣心大教堂" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">圣心大教堂</figcaption></div></figure><div class="notion-text notion-block-1a98f42f83138064b675ed46d2520541">在广州总共只待了一天半，时间基本都是花在吃上了：叉烧，煲仔饭，糖水，海鲜粥火锅，椰子乌鸡汤…等等。不过住的地方可能靠近老城区？总感觉脏脏的。</div><div class="notion-text notion-block-1a98f42f831380e1a4e5d7b763938534">🗻<b>Tokyo</b></div><div class="notion-text notion-block-1b28f42f831380ce9049f18dabc810be">东京相比于去年玩过的大阪，感觉上要更干净一些，但是市民的穿着就没那么”多彩“，多半以黑，灰为主。当时我在那边穿了一件绿色的大衣，电车上特别显眼，一眼就能看出不是当地人哈哈。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313805384d1e14c7597743f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp21.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8053-84d1-e14c7597743f" alt="特意挑了个靠窗的位置，正好能瞥见富士山" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">特意挑了个靠窗的位置，正好能瞥见富士山</figcaption></div></figure><div class="notion-text notion-block-1b88f42f831380bebf86cd49dbec40ad">东京真的是个很好逛，很好买的地方。公园多，商业体多，文化资源（艺术展等）多，而且特别干净。另外这次在东京正好有好朋友带着，吃的质量比上次在大阪好太多了。</div><div class="notion-text notion-block-1b88f42f831380b2a6c7c4c9dd0f88c5">这次在东京，刨去来回的时间，总共有五天的行程：</div><div class="notion-text notion-block-1b88f42f831380af9e37c3ae0f8f9a6e">🧾刚到的晚上吃了泰餐，味道还不错；</div><div class="notion-text notion-block-1b88f42f831380d9b394d9c342c90d31">🧾day1: 浅草寺→上野恩赐公园→东京国立博物馆→秋叶原。中午吃了居酒屋（便宜但是食材一般般），晚上吃了日本猪肉拉面，齁咸；</div><div class="notion-text notion-block-1b88f42f831380bdb5ebc422fa312fef">🧾day2: 吃了回转寿司，光了银座Ginza six，逛了12层优衣库，逛了Montbell ，晚上吃了天妇罗（味道不错，但是有点贵），66家巨型美国汉堡；</div><div class="notion-text notion-block-1b88f42f8313801385a3ce2160d48e41">🧾day3: 逛了W最爱的UR，逛了ABC-MART，逛了日本零食店，中午吃了简单的意大利餐，晚上吃了一家很好吃的炸猪排（名字是盐梅）；</div><div class="notion-text notion-block-1b88f42f831380219a6cea7acf535e04">🧾day4: 镰仓，非常蓝的海和没见过的黑沙，中午吃了好吃的咖喱饭，晚上吃了一家普通的烧鸟；</div><div class="notion-text notion-block-1b88f42f831380909a5bdf58fe89757a">🧾day5: 逛了BIC-CAMERA （BGM非常洗脑），逛了大型药妆店，中午吃了斯里兰卡菜，晚上吃了巴西烤肉自助餐（上海也有，但是比上海便宜…)；</div><div class="notion-row notion-block-1b88f42f8313800fb82cc3ba391288d6"><div class="notion-column notion-block-1b88f42f83138045a5fcfd09d24b17e0" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380ab816bfa82069dd679"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80ab-816b-fa82069dd679" alt="卖相和味道都还错的泰餐" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">卖相和味道都还错的泰餐</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380c580e0d478ff0771a8" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380719ff3da383b62c056"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8071-9ff3-da383b62c056" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1b88f42f831380f1866fecf1405c35c0"> </div></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380f3bda4fdc56c04b57b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_9.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80f3-bda4-fdc56c04b57b" alt="浅草寺" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">浅草寺</figcaption></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380eead34f2c637e72421"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_8.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80ee-ad34-f2c637e72421" alt="秋叶原" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">秋叶原</figcaption></div></figure><div class="notion-row notion-block-1b88f42f8313809bbaeafd189acce44f"><div class="notion-column notion-block-1b88f42f831380f48ae2d0f3c7202877" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380778242ed1f1205fc08"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_3.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8077-8242-ed1f1205fc08" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380f2897ffcae2069bcb3" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380ac96d9cf8eadda899f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_4.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80ac-96d9-cf8eadda899f" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1b88f42f831380ed8996c17495350f50"><div class="notion-column notion-block-1b88f42f8313801483c6da7332ed7601" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f83138015b5bddad7c3e21752"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_6.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8015-b5bd-dad7c3e21752" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f83138062a99bd456490cdac9" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380c28223d3a9b3226d5e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80c2-8223-d3a9b3226d5e" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380888533f297ed5c0ddd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp_7.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8088-8533-f297ed5c0ddd" alt="东京国立博物馆：原本是买了特展”大觉寺“的票，结果特展没什么好看的，就顺道去看了东亚馆的展品。没想到基本全是中国的藏品，感情好东西全是被抢到这里来了，心里五味杂陈…" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">东京国立博物馆：原本是买了特展”大觉寺“的票，结果特展没什么好看的，就顺道去看了东亚馆的展品。没想到基本全是中国的藏品，感情好东西全是被抢到这里来了，心里五味杂陈…</figcaption></div></figure><div class="notion-row notion-block-1b88f42f8313808b928dd74eb3c34cff"><div class="notion-column notion-block-1b88f42f831380d3b3ddf75f13fb22de" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380e8a5a0df52d67498f2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp10.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80e8-a5a0-df52d67498f2" alt="两位老人开的天妇罗店，味道不错，但是价格不便宜" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">两位老人开的天妇罗店，味道不错，但是价格不便宜</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380d5b789c7763c71958a" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380abbb9feed1023c6821"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp12.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80ab-bb9f-eed1023c6821" alt="“盐梅”的炸猪排，特别好吃" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">“盐梅”的炸猪排，特别好吃</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1b88f42f8313809292b2f50e2477fe41"><div class="notion-column notion-block-1b88f42f83138056a474c845949eba26" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380939751d4dea088f22e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp11.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8093-9751-d4dea088f22e" alt="意餐" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">意餐</figcaption></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f8313804cb289c1ffa06013c1" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313800590dee7f01cf57078"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp13.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8005-90de-e7f01cf57078" alt="镰仓吃到的咖喱饭，味道很棒" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">镰仓吃到的咖喱饭，味道很棒</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1b88f42f83138086a8bbdd8397734ef7"><div class="notion-column notion-block-1b88f42f83138046b34eec9c747fe552" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380f6a6afca99d8e85c80"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp16.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80f6-a6af-ca99d8e85c80" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380d49c8dc19d970aee01" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f83138015b655edd0a794c4ea"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp18.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-8015-b655-edd0a794c4ea" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-1b88f42f83138021bd98e59ef0e8dc5d"><div class="notion-column notion-block-1b88f42f8313804285aac3ca8c2a436f" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380be8a6af3c70b237c12"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp17.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80be-8a6a-f3c70b237c12" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b88f42f831380d5a2fecee6e5fcad20" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313803daea9f9095b8097da"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp14.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-803d-aea9-f9095b8097da" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313804d85cfc367a44ae9d8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp15.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-804d-85cf-c367a44ae9d8" alt="镰仓一日游，风景很美，风很大" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">镰仓一日游，风景很美，风很大</figcaption></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f831380e38d46d517f353463a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp22.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-80e3-8d46-d517f353463a" alt="镰仓电车站拿的手绘地图" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">镰仓电车站拿的手绘地图</figcaption></div></figure><div class="notion-callout notion-gray_background_co notion-block-1b88f42f831380f0a994d2ca2ca31770"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="📸">📸</span></div><div class="notion-callout-text"><div class="notion-text notion-block-1b88f42f83138090883cfab9ab4f79f2"><em><span class="notion-inline-underscore">人如果不出去走一走，就无法亲眼见证这个真实的充满偏见的世界，也就无法真正的认识世界和自己</span></em></div></div></div><ul class="notion-list notion-list-disc notion-block-1b88f42f83138044a4d6daf01616941c"><li>你可以永远相信日本的厕所，很干净，但是厕纸全国统一的薄…(我和W吐槽，厕纸上标语大意是保护环境，所以比较薄，但是谈到核污水就开始鞠躬了，守小礼而失大德)；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380eda1e4ccab5e5c7abd"><li>空间利用大师，但是该有的设施都有了，并且细节满满；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380eeb871fb29d7d87194"><li>日本年轻人似乎也不太关心政治，我问了我朋友关于靖国神社的事，他说很多年轻人甚至不知道其中的历史，历史书上也是寥寥几笔带过抗日战争，反而浓墨重彩说了遭受核弹的事，把自己塑造成二战受害者形象了…</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380838d81e9d29e5b6687"><li>游客永远都很多，周围说着英语，韩语，泰语，中文，德文等等各种各样的语言;</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380bc94e1e9e428f0a802"><li>女性地位不如国内，很多看不见的工作都是由日本女性默默维持（比如干净的厕所），成人产业，结了婚之后就辞职全职照顾家庭等等；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f83138066b31fd9bc80edf457"><li>”樱花妹“出门基本都是带妆，很会打扮自己；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f8313803bb6b0d9ffe0e8dab2"><li>房价相比上海，低很多…</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f83138074b13bfb410a9280ca"><li>工作场所很安静，但是居酒屋很吵…</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380a4a0bee42e3e9405ed"><li>日本的教育也不卷，听朋友说东京的高中生下午1.30就放学了…(但是可能是因为快乐教育和压抑的社畜工作导致日本自杀率有点高)；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f831380d3b6f1e6ddbf3eb499"><li>整体比较亲美，各个方面都是；</li></ul><ul class="notion-list notion-list-disc notion-block-1b88f42f83138007a8cbef58ab79c8a7"><li>蔬菜水果很贵，拉面很咸，海鲜/肉/乳制品比较便宜；</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b88f42f8313803b8726c53e375dd53c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jp19.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=1b88f42f-8313-803b-8726-c53e375dd53c" alt="这个地方离东京站30-40分钟的电车，但是整套房子（100平左右）300万RMB不到。真是感叹沪币的威力…" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">这个地方离东京站30-40分钟的电车，但是整套房子（100平左右）300万RMB不到。真是感叹沪币的威力…</figcaption></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1e98f42f831380229743eea317c1f170" data-id="1e98f42f831380229743eea317c1f170"><span><div id="1e98f42f831380229743eea317c1f170" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1e98f42f831380229743eea317c1f170" title="展览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">展览</span></span></h3><div class="notion-text notion-block-2288f42f831380cba05fca0c625539a1">7月暑假初期，和W一起去了趟浦东美术馆，这都是我俩第一次来浦美（之前一直人太多约不上），讲实话感觉和之前去的西岸美术馆相比没什么太多的优越之处，可能是网红给的光环太多了~</div><div class="notion-text notion-block-2288f42f831380bbb71fca147f0a1025">7月份那会浦美正好有一个“巴黎奥赛博物馆”的展品借展，包含了一些网红名作，比如梵高的卧室和自画像，莫奈的草堆，雷诺阿的钢琴前的女孩，米勒的拾穗者，爱德华马奈的左拉，以及其他同时期的印象派的作品等。该展览包了2层，整体的展览脉络是按照时间顺序展开：学院派-》自然主义-》新绘画/印象派-》新印象派-》梵高/高更（超越印象派）。由于这个主题展览的很多作品太过知名，所以人满为患，观看体验很不好，基本上我和W都是走马观花，大致看了一遍。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f8313801c89f0f30007ac853b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_14.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-801c-89f0-f30007ac853b" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380cbb14ff20f44fe0665"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_13.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80cb-b14f-f20f44fe0665" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-row notion-block-2288f42f83138027a8bad809dbde604a"><div class="notion-column notion-block-2288f42f8313805d8edef23d3311d1d3" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380ebbc9ef16388fbe9b3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_11.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80eb-bc9e-f16388fbe9b3" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-2288f42f831380e9b0b7f9375b6b7e7b" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f8313800081a7e226e68b75ec"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_10.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-8000-81a7-e226e68b75ec" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-row notion-block-2288f42f831380cfaedbddb47af2e173"><div class="notion-column notion-block-2288f42f831380808e3bf8abb948f389" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f8313809eb174e59f1efd4296"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_9.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-809e-b174-e59f1efd4296" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-2288f42f831380fd8653c30c37728330" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f8313806e83c9cc0098ed89c4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_12.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-806e-83c9-cc0098ed89c4" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-2288f42f8313800fa4e2f6632ad97111">比较惊喜的是4层的“时代逸飞-陈逸飞回顾展”，由陆家嘴集团主办。陈逸飞老师的作品我此前从未接触过，这次浦美的展览算是完整地展现了逸飞老师的艺术生平，让我打大开眼界，尤其是他那些创新式地融合了摄影和油画的“江南水乡”作品，具有一种朦胧的memory梦境之美。</div><div class="notion-row notion-block-2288f42f831380109fe9d5c9cbd6e922"><div class="notion-column notion-block-2288f42f8313800c88e5fb76cb11526e" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380adb9f1ceb1cf403e1f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_6.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80ad-b9f1-ceb1cf403e1f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-2288f42f831380b8be13d713e290d9e5"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380a188fbe39da2505b10"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:336px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_8.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80a1-88fb-e39da2505b10" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-2288f42f8313809d82a6ed84f7565c65" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380c79ed4cc215a007cec"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/map_5.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80c7-9ed4-cc215a007cec" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1e98f42f831380ec8a80d43a4f8fb992" data-id="1e98f42f831380ec8a80d43a4f8fb992"><span><div id="1e98f42f831380ec8a80d43a4f8fb992" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1e98f42f831380ec8a80d43a4f8fb992" title="书"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">书</span></span></h3><div class="notion-text notion-block-1e98f42f831380f8b0cee94d5a7e2af0"><a class="notion-link" href="https://book.douban.com/subject/37142217/" target="_blank" rel="noopener noreferrer">英伟达之芯</a>。和另一本“英伟达之道”内容差不多，内容比较流水线，有很多废话和重复的句子，只有最后对AI未来担忧的部分写的还有点意思。书中描写的黄仁勋拥有和其他优秀成功领袖/企业家类似的品质：专注，偏执，控制欲，勤奋，远见，坚韧，此外书中最后的访谈部分让我思考一个成功的科技领袖是否应该同时具备科技专业能力和人文思想（比如电气工程/文学双学位，或者同等学力），如果严重偏科某一方，是否会给企业带来完全不同的命运？</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b28f42f83138091b90ede54c1354029" data-id="1b28f42f83138091b90ede54c1354029"><span><div id="1b28f42f83138091b90ede54c1354029" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b28f42f83138091b90ede54c1354029" title="影视剧&amp;综艺&amp;podcast…"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">影视剧&amp;综艺&amp;podcast…</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f83138059a188dfa1eb8e68ad"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jackal_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-8059-a188-dfa1eb8e68ad" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1b28f42f831380dea44ecbaa0951f155"><a class="notion-link" href="https://movie.douban.com/subject/36323224/" target="_blank" rel="noopener noreferrer">豺狼的日子</a>。小雀斑24年底的新剧，小说改编，讲的是一个退役的军人转行当优雅杀手，然后工程款没被结清的故事。故事经不起细致推敲，但是人物塑造很有魅力，强推里面的服化道，这里有一个相关的<a class="notion-link" href="https://movie.douban.com/review/16349095/" target="_blank" rel="noopener noreferrer">解析文章</a>。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f83138093a783fcecd68cc695"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jackal_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-8093-a783-fcecd68cc695" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f8313808b8751f4c697e6f26f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/jackal_3.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-808b-8751-f4c697e6f26f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1db8f42f831380588090d108c8a65fc9"><a class="notion-link" href="https://movie.douban.com/subject/36820950/" target="_blank" rel="noopener noreferrer">混沌少年时</a>。非常棒的一部写实英剧，从一个普通家庭的青少年犯罪从切入点，通过一镜到底的长镜头展示英国的青少年司法程序，校园教育，社交危害，性别对立，心理咨询，家庭教育，男权社会等等一系列社会内容，镜头克制，冷峻，表演无痕迹，剧本扎实。电子信息新时代下诞生的孩子们，生活无时无刻不围绕着电子屏幕和各种各样的信息，从社交媒体到“饭圈”，从AI学习辅导到电子游戏，很容易在不知不觉中陷入虚无、没有意义的认知漩涡里。这些孩子们是无法克制自己，仔细甄别信息的，家长们也疲于奔命，忙于生存，养活家庭已然精疲力尽，无暇顾及孩子的精神世界，所以，朴树说出“我不想生孩子，因为我没办法教育好他”类似的话。我也是一路从“小镇做题家”慢慢走出来的，看到这样的故事我更是绝望，恐惧生孩子，一直挣扎于“想让他看看未来的智能社会”和“万一他/她无法被教育好怎么办”。社会总在向前，借助AI，社会的前景似乎很美好，但是个体对自己的命运又很悲观。“我们一直想努力做得更好，但是为什么最后还是变成这样。”</div><div class="notion-text notion-block-2288f42f831380d5979dc34d708ac5f4"><a class="notion-link" href="https://movie.douban.com/subject/35689244/" target="_blank" rel="noopener noreferrer">F1:狂飙飞车</a>。谁能想到布拉德皮特已经60多了，还能拍这样劲爆的电影！故事围绕老年F1赛车手桑尼为了帮忙拯救好基友的车队展开，顺带完成一波自我拯救和影响激励了身边人，并且一起成长的故事。故事紧凑，沉浸感极强，汉斯季莫的配乐一如既往的无敌，不得不感叹美国电影工业和人才的发达。影后了解了一些幕后，原来该电影也是得到了F1赛事组织的支持，电影里的画面都是蹭真实的F1比赛，而且汉密尔顿也深度参与了制作，并且桑尼的多处故事桥段也带了老汉自己的影子。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f831380a8850dca1af39c08c1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/f1_1.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-80a8-850d-ca1af39c08c1" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2288f42f83138092bbfdf0c34381a09b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://raw.githubusercontent.com/Richardyu114/PicBed_blog/main/Summaryofthisyear-7/f1_2.jpg?spaceId=1b473c6e-f4bc-4dcf-9665-763d67b29864&amp;t=2288f42f-8313-8092-bbfd-f0c34381a09b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2368f42f831380b7b46dc5525381a076"><a class="notion-link" href="https://movie.douban.com/subject/35483395/" target="_blank" rel="noopener noreferrer">戏台</a>。陈佩斯的著名同名戏剧改编。故事发生在军阀混战时期，陈佩斯饰演的戏班头子带着一群戏曲表演班底来北京演“霸王别姬”，遇上不懂戏曲的军阀指染，“霸王”演员互换等一系列冲突的故事。戏剧味很浓，观众一开始就知道演员互换的“明线”会在某个时刻爆发，因此整体比较流畅。看完觉得这个是陈佩斯借着自己的人生经历，同时带上了文艺圈/饭圈等一系列怪象来组织的故事，比如军阀可能代表着政府/资本对文艺界创作的干预，军阀夫人代表着狂热的饭圈文化，又或者是对角色的喜爱投射到了演员身上，“霸王别姬”的传统戏曲代表着自己身上肩负着对老祖宗流传下来的文化精华的坚守的责任等等。总之值得一看，有机会自己也会去现场看看原版戏剧。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f831380029066e2beb8d2170e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af5c1ab2f-e6d6-4643-bc52-67b49823d563%3Aimage.png?table=block&amp;id=2da8f42f-8313-8002-9066-e2beb8d2170e&amp;t=2da8f42f-8313-8002-9066-e2beb8d2170e" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2a78f42f831380158cd1f091d27a371e">罗永浩的十字路口，自己入坑第一集选的是<a class="notion-link" href="https://b23.tv/BMSjsb7" target="_blank" rel="noopener noreferrer">宋方金</a>，宋老师是我之前在脱口秀大会了解到的，第一印象是口才很好，能说会道，讲故事引人入胜。他在这期播客里，讲述了自己对短剧，编剧的困境，创作的困境，文学抄袭以及一些影视界导演的八卦等，很多认识和分析都比较深入，而且是那种真诚地毫无保留地和盘托出地交流，非常推荐听听，就是时长感人，需要耐心。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f831380998680d87899f29ed2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:384px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A84d1ff55-2f1a-4575-b38c-4f7f3f32d145%3Aimage.png?table=block&amp;id=2da8f42f-8313-8099-8680-d87899f29ed2&amp;t=2da8f42f-8313-8099-8680-d87899f29ed2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2288f42f831380319f59d2800c1ed5c9"><a class="notion-link" href="https://movie.douban.com/subject/36877225/" target="_blank" rel="noopener noreferrer">the-thinking-game</a>, DeepMind的纪录片，快速回顾了DeepMind从创立到AlphaGo, AlphaZero,AlphaStar, AlphaFold等的故事，着重描绘了德密斯此人的天赋和对科学，AGI的忠诚。这个纪录片热度很高，不过个人觉得剪辑一般，内容只能说快速回顾一下整个DeepMind的历史，充其量只能看到timeline，更多的DeepMind内部的文化，工作方式以及和Google整合后的故事都没有说。但是依然推荐，因为相关的作品太少，而大众可能也觉得AI系统太过神秘。 </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f831380278dedf088792b982c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A9daaebfa-62e2-4380-84da-74a80d0f29c7%3Aimage.png?table=block&amp;id=2da8f42f-8313-8027-8ded-f088792b982c&amp;t=2da8f42f-8313-8027-8ded-f088792b982c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1b88f42f831380578e4de6bb7523198c"><a class="notion-link" href="https://movie.douban.com/subject/5348089/" target="_blank" rel="noopener noreferrer">阿凡达3</a>，这个不必多说，依然是冲着卡神和阿凡达的瑰丽世界去看的。网上褒贬不一，但是个人觉得还不错。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f83138055bf7cc3b49f909a5a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A1088707f-4a99-4b4e-8581-0c87c5bc8e32%3Aimage.png?table=block&amp;id=2da8f42f-8313-8055-bf7c-c3b49f909a5a&amp;t=2da8f42f-8313-8055-bf7c-c3b49f909a5a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2288f42f831380b192d7dc9c9799aeb4"><a class="notion-link" href="https://movie.douban.com/subject/36438475/" target="_blank" rel="noopener noreferrer">浪浪山小妖怪</a>。西游路上小妖怪，小人物的故事。充满了现实世界里对打工人现状的讽刺。:(</div><div class="notion-row notion-block-2da8f42f831380b3ac2effbe0174d596"><div class="notion-column notion-block-2da8f42f831380aa91cfcc2bc2d272f6" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f83138049953eeddaae97138a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A90cf324f-7248-4d91-8f8d-888be027c306%3Aimage.png?table=block&amp;id=2da8f42f-8313-8049-953e-eddaae97138a&amp;t=2da8f42f-8313-8049-953e-eddaae97138a" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div><div class="notion-column notion-block-2da8f42f8313805ab37fd49ccf14e2e7" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-2da8f42f831380b2af42e555f25a0386"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A0edb19d2-398a-40d3-9dee-c1ae23bc76de%3Aimage.png?table=block&amp;id=2da8f42f-8313-80b2-af42-e555f25a0386&amp;t=2da8f42f-8313-80b2-af42-e555f25a0386" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-2da8f42f831380ea8b5af017d748f5da"><a class="notion-link" href="https://movie.douban.com/subject/37309928/" target="_blank" rel="noopener noreferrer">铁血战士-杀戮之王</a>，<a class="notion-link" href="https://movie.douban.com/subject/36707378/" target="_blank" rel="noopener noreferrer">铁血战士-杀戮之地</a>。同一个导演在今年的铁血战士重启之作，开始从不同的角度来讲述铁血战士的历史和生态，也不故意制造血腥镜头，非常nice!</div><hr class="notion-hr notion-block-2da8f42f83138080861fe454d45acbf6"/><div class="notion-text notion-block-2da8f42f831380a7a485f8600c57936d"><em>此外还有一些张小珺，铜镜等很不错的podacast up主，今年也在陆续听，收获很多</em>。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2da8f42f8313802aba10e2c20323453f" data-id="2da8f42f8313802aba10e2c20323453f"><span><div id="2da8f42f8313802aba10e2c20323453f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2da8f42f8313802aba10e2c20323453f" title="展望2026"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">展望2026</span></span></h3><div class="notion-text notion-block-2da8f42f831380a99615efa6192c655e">不知不觉，自己毕业之后已经走完了快5个年头，每一年都在人生的各个方向上缓慢成长。26年依然希望自己能多去尝试新事物，新方向，能多多思考当下的不足和对未来的规划，坚持阅读和总结。在文章的最后，按照惯例，定一下来年的OKR.</div><ul class="notion-list notion-list-disc notion-block-2da8f42f831380ef8c2bc90243916c6b"><li>学着写写kernel吧，先从简单的cuda kernel开始，然后到flash-attn,到gemm,最后到阅读custlass，学习kernel library</li></ul><ul class="notion-list notion-list-disc notion-block-2da8f42f831380478c6be84e5a2bd4c4"><li>继续总结细化自己的知识库，多多尝试新的输出形式，让自己真正融会贯通</li></ul><ul class="notion-list notion-list-disc notion-block-2da8f42f831380a6bd15eb8e760822a7"><li>学习并坚持一门新的才艺，比如弹钢琴，唱歌或者跳舞</li></ul><ul class="notion-list notion-list-disc notion-block-2da8f42f8313803cbc6cc151f0663b9c"><li>好想去新西兰和欧洲啊，希望能有机会玩一趟</li></ul><div class="notion-callout notion-gray_background_co notion-block-2da8f42f831380a2801ddd886a9cbbb5"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🧗‍♂️">🧗‍♂️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2da8f42f83138071974ffa069490ae31"><em><span class="notion-inline-underscore">Life can only be understood backwards, but it must be lived forwards.</span></em></div><div class="notion-text notion-block-2da8f42f8313804eb4dbf593df49c74d">—索伦・克尔凯郭尔</div></div></div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>