<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>兼容性 on 硅基深潜</title><link>https://silicondive.com/tags/%E5%85%BC%E5%AE%B9%E6%80%A7/</link><description>Recent content in 兼容性 on 硅基深潜</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sat, 28 Nov 2026 11:43:47 +0800</lastBuildDate><atom:link href="https://silicondive.com/tags/%E5%85%BC%E5%AE%B9%E6%80%A7/index.xml" rel="self" type="application/rss+xml"/><item><title>CUDA 13.3 API 兼容验收标准</title><link>https://silicondive.com/posts/cuda-13-3-api-compatibility-gate/</link><pubDate>Thu, 26 Nov 2026 22:13:00 +0800</pubDate><guid>https://silicondive.com/posts/cuda-13-3-api-compatibility-gate/</guid><description>GPU 厂商对齐 CUDA 时，以 CUDA 13.3 为例的源码级 API 兼容验收标准；不覆盖 ABI/二进制兼容。</description><content:encoded><![CDATA[<h2 id="背景与边界">背景与边界</h2>
<p>不少 GPU 厂商在软件栈上对齐 NVIDIA：头文件、Runtime/Driver API、常用库和框架接口尽量保持 CUDA 形态，降低客户的迁移成本。这个策略有效，但“兼容 CUDA”经常停留在市场描述，缺少可验收的边界。</p>
<p>本文以 CUDA 13.3 为例，给出一套源码级 API 兼容验收标准，把“能不能叫兼容”拆成可执行的条件。</p>
<p>这里只讨论源码/API 兼容：应用使用 13.3 头文件和 API，重新编译后运行。已有 CUDA 二进制不重编译直接运行、soname、符号版本、结构体布局和 driver ABI 与 NVIDIA 一致，不在范围内。</p>
<p>cuBLAS、cuDNN、NCCL、PyTorch 和模型精度也不在这一层验收。API 通过，不等于软件栈兼容。</p>
<p>兼容范围按声明处理：覆盖 13.3 全部公开 Runtime/Driver API，才可以叫“全量兼容”；只覆盖子集，只能标“部分兼容”。</p>
<p>API 兼容的核心是接口形式、语义和行为三层。完整验收还要看工具链、版本、平台和诊断；库、框架、模型和性能属于上层。</p>
<h2 id="目标与迁移路径">目标与迁移路径</h2>
<p>“兼容”最终要落到用户切换成本。至少分四类使用者：</p>
<table>
	<thead>
			<tr>
					<th>使用者</th>
					<th>目标动作</th>
					<th>验收对象</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>CUDA 开发者</td>
					<td>用 13.3 头文件重新编译，尽量不改源码</td>
					<td>编译、接口、语义和行为</td>
			</tr>
			<tr>
					<td>上层库</td>
					<td>使用厂商适配版或源码构建</td>
					<td>库 API、错误传播、性能</td>
			</tr>
			<tr>
					<td>框架</td>
					<td>使用厂商提供的 wheel、容器或源码构建</td>
					<td>框架 smoke test、上游测试</td>
			</tr>
			<tr>
					<td>模型与应用</td>
					<td>切换运行环境，不改业务代码</td>
					<td>目标模型、精度、稳定性</td>
			</tr>
	</tbody>
</table>
<p>本标准的“自然切换”指用户不改业务代码，由厂商承担重编译、打包和适配工作。已有 CUDA 二进制不重编译直接运行属于二进制兼容，不在本标准内。</p>
<p>因此，API 验收之外还要有交付验收：目标框架是否有可安装的包，目标模型是否能在厂商环境中启动，失败时是否有明确错误。</p>
<h2 id="133-基准">13.3 基准</h2>
<p>以 CUDA 13.3 GA 为基准：驱动 610.43.02，cudart 13.3.29。参考环境用于差分测试，不要求厂商驱动号与 NVIDIA 相同。</p>
<p>API 变化以 <a href="https://docs.nvidia.com/cuda/archive/13.3.0/cuda-toolkit-release-notes/index.html">CUDA 13.3 Release Notes</a>、<a href="https://docs.nvidia.com/cuda/archive/13.3.0/cuda-runtime-api/index.html">Runtime API</a> 和 <a href="https://docs.nvidia.com/cuda/archive/13.3.0/cuda-driver-api/index.html">Driver API</a> 为准。</p>
<p>兼容矩阵至少包含：GPU 架构、OS、驱动版本、Runtime 版本、MPS/MIG/Green Context 模式、PTX/cubin 路径。</p>
<h2 id="验收范围">验收范围</h2>
<h3 id="host-api">Host API</h3>
<p>Driver API 至少覆盖：</p>
<ul>
<li>初始化、版本、设备和 primary context</li>
<li>context、module、library</li>
<li>memory、VMM、async allocator、multicast</li>
<li>stream、event、stream memory operations</li>
<li>graph、tensor map、peer access、IPC</li>
<li>green context、logical endpoint、coredump、checkpoint</li>
</ul>
<p>Runtime API 至少覆盖：</p>
<ul>
<li>设备管理、错误处理、版本管理</li>
<li>memory、memory pool、unified memory</li>
<li>stream、event、execution control</li>
<li>graph、external interop、peer access</li>
<li>occupancy、texture/surface、library、profiler</li>
<li>green context、logical endpoint</li>
</ul>
<p>Runtime 封装 Driver，但默认 stream、primary context 和错误语义有自己的规则，两条线分开测试。</p>
<h3 id="设备侧-api">设备侧 API</h3>
<ul>
<li>Device Runtime API：动态并行、device malloc/free、memcpy/memset、stream/event、device synchronize、嵌套 launch。测试需启用 relocatable device code 和 <code>cudadevrt</code>。</li>
<li>PDL：<code>cudaLaunchAttributeProgrammaticStreamSerialization</code>、<code>cudaLaunchAttributeProgrammaticEvent</code>、<code>cudaTriggerProgrammaticLaunchCompletion</code>、<code>cudaGridDependencySynchronize</code>。</li>
<li>Cooperative Groups：block/grid/cluster sync、<code>memcpy_async</code>、reduce。</li>
<li>Cluster/DSMEM：cluster 同步、共享内存映射；只在支持架构上测。</li>
<li>libcu++：<code>cuda::atomic</code>、<code>cuda::barrier</code>、<code>cuda::pipeline</code>、<code>memcpy_async</code>。</li>
<li>Tensor Core wrapper：<code>nvcuda::wmma</code>、MMA/WGMMA/tcgen05 相关接口。</li>
<li>Device Graph Launch：设备侧 graph launch 和更新。</li>
<li>内建与 intrinsics：<code>threadIdx</code>、<code>blockIdx</code>、<code>__syncthreads</code>、<code>__syncwarp</code>、shuffle/ballot、<code>__ldg</code>、atomics、<code>printf</code>/<code>assert</code>。</li>
</ul>
<p>设备侧测试要单独看设备堆 OOM、嵌套 launch 失败、cluster 尺寸、device graph 生命周期和错误传播。</p>
<h3 id="优先级">优先级</h3>
<table>
	<thead>
			<tr>
					<th>级别</th>
					<th>范围</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>P0</td>
					<td>初始化、context、module、memory、stream、event、kernel launch、错误模型、版本管理</td>
			</tr>
			<tr>
					<td>P1</td>
					<td>graph、PDL、device runtime、cooperative groups、cluster/DSMEM、device graph、VMM、async allocator、P2P/IPC、MPS/MIG、green context、PTX JIT</td>
			</tr>
			<tr>
					<td>P2</td>
					<td>interop、texture/surface、profiler、checkpoint 等</td>
			</tr>
	</tbody>
</table>
<p>P0/P1 必须全部通过。声明全量兼容时，P2 也纳入验收；只做部分兼容时，P2 可以列不支持项，但必须记录在兼容矩阵中。</p>
<h2 id="测试方法">测试方法</h2>
<h3 id="接口">接口</h3>
<ul>
<li><code>cudaRuntimeGetVersion()</code> 和 <code>cuDriverGetVersion()</code> 返回 13.3 对应版本号 13030。</li>
<li>使用 13.3 头文件可以编译，API 参数、枚举、回调和常量与 13.3 一致。</li>
<li>声明支持的符号在编译和链接阶段可用；<code>cuGetProcAddress</code> 的版本化入口可用。</li>
<li>deprecated 符号仍能编译、链接、运行。</li>
</ul>
<h3 id="工具链与诊断">工具链与诊断</h3>
<ul>
<li>使用 13.3 头文件和目标编译器编译，覆盖 C++ 标准、宏、<code>-rdc</code>、PTX、cubin 和 fatbin。</li>
<li>检查 deprecated 警告、编译错误和链接错误，不把警告当静默通过。</li>
<li>诊断接口单独验证：CUPTI、NVTX、profiler API、coredump 和错误日志。</li>
<li>编译矩阵要包含目标 OS、GPU 架构和主机编译器组合。</li>
</ul>
<h3 id="状态与并发">状态与并发</h3>
<ul>
<li>context：primary context 的 retain/release、多线程 current context、reset 后资源失效。</li>
<li>module/function：PTX、cubin、fatbin 加载，JIT 选项，符号查找，卸载后调用。</li>
<li>memory：malloc/free、pitched、UVM、VMM、async pool、OOM、非法指针、double free。</li>
<li>stream/event：default stream、non-blocking stream、优先级、回调、跨 stream 依赖、event 计时。</li>
<li>graph：显式构图、capture、instantiate、update、销毁，以及失败后的 graph 状态。</li>
<li>同步与错误：device/stream/event sync 的覆盖范围，异步错误暴露点，sticky error 和 last error 清除规则。</li>
<li>多线程、多 stream、多卡、P2P、IPC、MPS/MIG。</li>
<li>PDL：后继 kernel 提前启动、trigger 条件、事件触发、无 trigger 的退化路径、stream/event 顺序，以及 <code>CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_*</code> 映射。</li>
<li>PTX 和 cubin 分开测试。13.3 文档明确 PTX 在旧驱动上受限，不能混在一起判断。</li>
<li>版本混用按 13.3 的 version mixing rules 测试，不假设任意组合都可用。</li>
</ul>
<h3 id="故障注入">故障注入</h3>
<p>每个高风险用例独立进程运行，避免 sticky error 和 context 损坏污染后续测试。</p>
<ul>
<li>注入 OOM、资源耗尽和分配失败。</li>
<li>在 stream 执行中销毁 event、graph、memory 或 context。</li>
<li>构造非法 handle、错误 device、错误 flag 和越界参数。</li>
<li>观察崩溃、挂起、内存越界和静默成功，而不只是看返回值。</li>
</ul>
<h3 id="判定依据">判定依据</h3>
<p>以 13.3 参考环境做差分测试。比较错误类别、同步点、结果和资源状态；不比较 handle 数值、地址和错误字符串。</p>
<p>文档有明确规定的，以文档为准；文档不明确时，用参考环境确认可观察行为。</p>
<h2 id="133-的增量">13.3 的增量</h2>
<ul>
<li><code>cuStreamBeginRecaptureToGraph</code>：拓扑匹配、非法重捕获、失败后的 graph 状态。</li>
<li>Green Contexts：默认 stream 可选，SM/workqueue 资源划分。</li>
<li>MPS 静态分区错误隔离：分区创建、非法分区 ID、跨分区故障隔离。</li>
<li>DMA-BUF mmap：设备属性、export、<code>mmap</code> 和同步协议；不支持平台明确报错。</li>
<li>PDL 与 cuBLAS：复现 13.3 known issue 中的依赖顺序问题，确认 API 层不会把错误的依赖顺序误判为通过。</li>
<li>13.3 新 API 的错误路径和资源清理。</li>
</ul>
<p>NVIDIA 13.3 release notes 中的 known issues 要映射到测试豁免，不能把已知 bug 当作兼容通过。</p>
<h2 id="通过标准">通过标准</h2>
<ul>
<li>声明范围内 API 覆盖率 100%。</li>
<li>P0/P1 用例通过率 100%。</li>
<li>静默错误、崩溃、挂起、内存越界、context 损坏为 0。</li>
<li>不支持的能力返回文档定义的错误，不能返回成功，也不能静默降级。</li>
<li>13.3 新增 API 全部有实现；只做部分兼容时，才允许记录“不支持结论”。</li>
<li>13.2 已通过的 API 用例在 13.3 上不能退化。</li>
<li>兼容矩阵、测试日志和未支持清单可审计。</li>
</ul>
<p>满足以上标准，才能判定 CUDA 13.3 API 兼容验收通过；缺少任一项，只能标注“CUDA 13.3 部分兼容”。性能、框架、模型和应用需要在上层单独验收。</p>
]]></content:encoded></item></channel></rss>