Nsight Systems 和 Nsight Compute 有什么区别?
怎么判断 kernel 是 memory bound 还是 compute bound?

英文问法What's the difference between Nsight Systems and Nsight Compute? · How do you tell whether a kernel is memory bound or compute bound? · An operator has an arithmetic intensity of 0.5 FLOP per byte. What limits it?

考过都是别家面经原题:新紫光 算子工程师一面 2026-09-21「ncu 和 nsys 的区别和分别的作用」(牛客)· 科大讯飞 推理工程部 AI Infra 一面 2026-10-26「推理时的瓶颈主要在哪?内存瓶颈和计算瓶颈分别怎么定位?」(牛客)· 华为 AI Infra / 大模型部署优化岗 社招一面 2026-09-08「如果一个算子的算术强度是 0.5 FLOP/Byte,它属于什么瓶颈?」(牛客)· 快手 AI Infra 一面 2026-09-28「算子优化常见两类瓶颈是什么」(营销号模板帖,可信度中等,牛客)· Unity 自己的材料:FlashVector 的 GPU kernel 层用 Nsight 做 profile,原话是要 "precise kernel traces (nsys/ncu) instead of torch.profiler's coarser summaries" · 没有 Unity 自己的面经原题

先弄清楚:每个概念是什么

Nsight Systems(nsys)
整个程序的 timeline,上面有 CPU thread、CUDA API 调用、每个 kernel 和 memcpy。
Nsight Compute(ncu)
只看一个 kernel,报它的硬件指标。常看 GPU Speed Of Light Throughput、Occupancy、Warp State Statistics 三节。
Memory bound 和 compute bound
memory bound 是 kernel 被 memory bandwidth 卡住,算力闲着。compute bound 反过来。
Arithmetic intensity
每读写 1 byte 做几次 FLOP,低于 roofline 的 ridge point 就是 memory bound。
Warp stall
一个 warp 这个 cycle 发不出指令。

看图:先找到 kernel,再看它卡在哪

① Nsight Systems:整个程序的 timeline CPU GPU 每个小框是一次 launch A kernel B C GPU 空等 占 GPU 时间 60% ② Nsight Compute:只看 kernel B 占理论峰值的百分比 memory throughput 92% compute throughput 9% memory 接近峰值,compute 很低 → memory bound
图 1:数字是示意。先在 timeline 上找占时间最多的 kernel,再看它的 memory 和 compute 哪个接近峰值。

30 秒回答

Nsight Systems shows the whole program as a timeline. I use it first to find where the time goes: one slow kernel, or gaps where the GPU sits idle. Then Nsight Compute profiles that kernel with hardware counters. If memory throughput is near peak and compute is low, it's memory bound, so I fuse kernels and cut reads and writes. If compute throughput is near peak, it's compute bound, so I use tensor cores or lower precision. If both are low, warps are stalled, so I check occupancy and stall reasons.

两个工具各看什么

Nsight Systems(nsys)Nsight Compute(ncu)
回答的问题时间花在哪这个 kernel 为什么慢
看什么GPU 空等、launch 间隙、memcpy、最耗时的 kernelmemory 和 compute throughput 占峰值多少、occupancy、warp stall 原因、roofline chart

timeline 上 GPU 空白很多时问题不在 kernel 里,见训练慢怎么查。

怎么判断 bound,下一步做什么

类型判断依据下一步
Memory boundarithmetic intensity 低于 ridge point;memory throughput 接近峰值,compute 很低kernel fusion;少读写 HBM;向量化访存
Compute bound高于 ridge point;compute throughput 接近峰值用 tensor core;降精度
两个都低warp 在 stall,或 occupancy 太低看 Warp State Statistics 和 Occupancy 两节

手算华为那道题,公式见 roofline。A100 的 ridge point 约 153 FLOP/B,0.5 远低于它,是 memory bound。上限是 0.5 × 2,039 GB/s ≈ 1.0 TFLOPS,只有峰值 312 TFLOPS 的 0.3%,加算力没有用。

必答点

追问

Nsight Systems 能看到指令级流水吗?

卓驭校招一面 2026-03-03 原题。不能,它的粒度是一次 API 调用或一个 kernel。指令级的统计在 ncu 的 Instruction Statistics 和 Source Counters 两节。

warp stall 有哪几类原因?

long scoreboard 在等 global 或 local memory 的数据,short scoreboard 多在等 shared memory,barrier 在同步点等别的 warp。

agent 为什么要用 Nsight,不用 torch.profiler?

FlashVector 说 torch.profiler 的 summary 太粗,agent 要精确的 kernel trace 和 tensor shape,做 roofline 分析时才少 hallucinate。profiler feedback 的收益见 kernel agent 设计。

最慢的 kernel 快了 2 倍,整体为什么只快一点?

占 timeline 60% 的 kernel 快 2 倍,整体只有 \(1/(0.4+0.3)\approx 1.43\) 倍(见 Amdahl's law 和 局部和端到端)。

来源Nsight Compute Profiling Guide(Sections and Rules 的各节名称,§2.4.7 的 stall 原因,§2.9 Roofline Charts)· Nsight Systems User Guide · FlashVector §4.2 · ml-八股 08 第 3 题 · 面经出处见 面试题与 JD 3.1、3.3 节