Jetson Thor Roofline 模型 Jetson Thor Roofline 模型本文档说明Jetson ThorT5000 为主的 Roofline 性能模型硬件顶、拐点、kernel 判读方法以及与 π0.5 LLM / TensorRT FP8 推理的关系。1. Roofline 是什么Roofline 用一张图同时看算力上限和带宽上限Performance (FLOP/s) ▲ │ ╱──────────── Compute Roof算力顶 │ ╱ │ ╱ ← 斜线Memory Roof带宽顶 │ ╱ └──────────────────────► Operational Intensity (FLOP/Byte) 每从内存读 1 Byte做多少 FLOP1.1 核心公式Operational Intensity运算强度相对拐点位置含义(AI AI_{\text{ridge}})更偏memory-bound带宽主导(AI AI_{\text{ridge}})更偏compute-bound算力主导2. Jetson Thor T5000 硬件参数来源NVIDIA Jetson T5000 Modules Data SheetDS-11945。2.1 Memory Roof内存顶项目值类型128 GB LPDDR5X256-bit峰值带宽273 GB/s特性统一内存CPU / GPU 共享无独立 GDDRRoofline 输入实际 sustained 带宽通常低于 273 GB/sCPU 访问、拷贝、多 client 争用。ncu 中用dram__throughput.avg.pct_of_peak_sustained_elapsed衡量离顶多远。2.2 Compute Roof算力顶按精度 / 执行路径选择不同的水平「顶」路径MAXN~130W120W说明FP32 CUDA Core8.064 TFLOP/s7.096 TFLOP/s通用 CUDA kernelFP8 Tensor CoreDense517 TFLOP/s455 TFLOP/sllm_fp8.engine应走这条FP8 Tensor CoreSparse1035 TFLOP/s910 TFLOP/s需稀疏模式不作默认顶FP4 Tensor CoreDense1035 TFLOP/s910 TFLOP/sNVFP4 等GPU 规模DevKit 常见20 SM2560 CUDA coresBlackwell sm_100 系GPU 名NVIDIA Thor。Datasheet未单独列出 FP16/BF16 峰值。BF16 TRT 路径可先用 ncu 的sm__inst_executed_pipe_tensor反推实际算力利用率。2.3 功耗与频率模式GPU 频率up toFP32 顶FP8 Dense 顶MAXN1.575 GHz8.064 TFLOP/s517 TFLOP/s120W1.386 GHz7.096 TFLOP/s455 TFLOP/sProfiling 前建议锁频避免 roof 与 kernel 点漂移sudojetson_clocks# 或 nvpmodel 固定 MAXNnvidia-smi --query-gpuname,compute_cap,clocks.max.graphics--formatcsv3. Ridge Point拐点Compute Roof(P_{\text{peak}})(AI_{\text{ridge}})典型用途FP32 CUDAMAXN8.064 TFLOP/s~29.5 FLOP/B通用 CUDAFP32 CUDA120W7.096 TFLOP/s~26.0 FLOP/B降功耗FP8 TC DenseMAXN517 TFLOP/s~1894 FLOP/Bllm_fp8.engineFP8 TC Dense120W455 TFLOP/s~1667 FLOP/B降功耗 FP8FP8 TC SparseMAXN1035 TFLOP/s~3791 FLOP/B仅 sparse workload3.1 对 π0.5 LLM prefill 的含义典型配置batch1seq_len968TRT FP8 engine。GEMM 理论 AI 随 M/N/K 变化小 batch、大 K 时常在几十 FLOP/B量级相对 FP8 ridge~1894 FLOP/B绝大多数 kernel远在拐点左侧 → DRAM memory-boundCUTLASS 大 tile227 KiB shared/block是在带宽受限下提高achieved FLOP/s低 occupancy 不一定是 bug示意FP8 Dense MAXN横轴 log scalePerformance │ 517T │──────────────────────────── FP8 Tensor Core 顶 │ ╱ │ ╱ ← 斜率 273 GB/s │ ╱ │ ╱ ★ 典型 LLM GEMMbatch1 │ ╱ └──────────────────► AI (FLOP/Byte) 1 10 100 1K 10K ↑ ridge ≈ 18944. 多层 RooflineRoofline 不只有 DRAM 一条斜线还可叠加L2 / L1数据已在 cache 内时Performance │ │──────── FP8 Compute Roof │ ╱ │ ╱ L2 roof更高斜率容量有限 │ ╱ │ ╱ DRAM roof273 GB/s └────────────────► AI层级ncu 指标说明DRAMdram__bytes_*dram__throughput.*主 roofThor 统一内存 273 GB/sL2lts__t_sectors.sumlts__throughput.*Blackwell L2 更大reuse 好时可抬离 DRAM 斜线L1 / Sharedl1tex__*大 shared GEMM 在 SM 内 tile权重/激活仍从 DRAM 进入ncuSpeed of Light页的Memory Throughput % vs Compute Throughput %是简化版 roofline 判读。5. 用 ncu 把 kernel 标到 Roofline 上5.1 采集命令单热点 kernelexportENGINE/tmp/pi05/build/llm/llm.engineexportSHAPESinputs_embeds:1x968x2048,attention_mask:1x1x968x968,position_ids:1x968sudoncu\--launch-count1\--kernel-name-base demangled\--kernel-namemyl_Fc|cutlass\--metrics\dram__bytes_read.sum,dram__bytes_write.sum,\dram__throughput.avg.pct_of_peak_sustained_elapsed,\sm__inst_executed_pipe_tensor.avg.pct_of_peak_sustained_elapsed,\gpu__compute_memory_throughput.avg.pct_of_peak_sustained_elapsed\-f-o/tmp/roofline_kernel\/opt/tensorrt/bin/trtexec\--loadEngine${ENGINE}\--shapes${SHAPES}\--warmUp0\--iterations1\--noDataTransfers5.2 计算 AI 与 Achieved FLOP/sBytes ≈ dram__bytes_read.sum dram__bytes_write.sum 该 kernel 一次 launch FLOPs ≈ MatMul: 2 × M × N × K 或 ncu --section ComputeWorkloadAnalysis AI FLOPs / Bytes Achieved FLOP/s FLOPs / kernel_duration在 Thor FP8 roof 上标点(AI, Achieved FLOP/s)观察解读点贴近 DRAM 斜线下方memory-bound优化带宽、融合、量化、layoutpipe_tensor低、dram高Tensor Core 未吃满layout / tile / occupancy点贴近 compute 顶且 AI 很大compute-bound大 batch GEMM 才常见5.3 整趟 LLM forward 的分层分析层级Roofline 用法整 engine ~63 ms总 FLOPs / 总 DRAM bytes → 宏观 AI单个myl_FcGEMM找最胖的点看是否贴 DRAM 斜线LayerNorm 小 kernelAI 低、FLOPs 小 → 常latency-bound非 roofline 主矛盾6. Thor 特有注意点6.1 统一内存273 GB/s 由 CPU GPU 拷贝共享不是 GPU 独占带宽trtexec --noDataTransfers去掉边界 H2D/DtoH更接近纯 kernel DRAM roofwebui 真实路径若 CPU 频繁喂数effective (B_{\text{mem}}) 低于 273 GB/s6.2 选对 Compute Roofllm_fp8.engine Tensor Core GEMM → Compute Roof 517 TFLOP/sDense FP8, MAXN → Memory Roof 273 GB/s → Ridge ≈ 1894 FLOP/Byte 不要用 - FP4 Sparse 2070除非真开 sparse - FP32 8 TFLOP/s除非 kernel 走 CUDA Core 而非 Tensor Core6.3 与 shared / occupancy 的关系低 occupancy不一定劣于高 occupancyroofline 上看achieved FLOP/s 是否贴近 (B \times AI)273 GB/s 是硬顶π0.5 prefill 优化空间常在算子融合、FP8、少读写、FMHA plugin而非单纯堆 occupancy7. 快速心算表T5000DRAM 273 GB/s7.1 带宽利用率Achieved 带宽占 273 GB/s136 GB/s~50%205 GB/s~75%245 GB/s~90%7.2 FP8 Tensor Core 利用率Dense MAXN517 TFLOP/sAchieved 算力占比130 TFLOP/s~25%260 TFLOP/s~50%415 TFLOP/s~80%LLM prefill 粗经验以 ncu 实测为准DRAM 50–85% 峰值Tensor Core 30–70% 峰值。7.3 Ridge Point 速查AI_ridge(FP8 Dense, MAXN) 517e12 / 273e9 ≈ 1894 FLOP/Byte AI_ridge(FP32 CUDA, MAXN) 8.064e12 / 273e9 ≈ 29.5 FLOP/Byte8. GEMM 运算强度估算参考单精度 MatMul (C A \times B)(A \in \mathbb{R}^{M \times K})(B \in \mathbb{R}^{K \times N})[\text{FLOPs} 2MNK]若各矩阵各读一次最简模型[\text{Bytes} \approx (MK KN MN) \times \text{sizeof(dtype)}][AI \approx \frac{2MNK}{(MK KN MN) \times \text{bytes}}]例(M968, N16384, K2048)FP81 byteFLOPs ≈ 2 × 968 × 16384 × 2048 ≈ 6.5×10^11 Bytes ≈ (968×2048 2048×16384 968×16384) ≈ 3.6×10^7 AI ≈ 18000 FLOP/Byte理论 upper实际因 cache/reuse 更高 effective AI实际 kernel 的 AI 以 ncudram__bytes_*为准cache hit 会使 achieved 性能高于仅用 DRAM bytes 估的斜线。9. 常见误解误解正确理解离 FP8 compute 顶远 性能差batch1 LLM 多在 memory-bound 区应看是否贴近 DRAM 斜线用 FP4 Sparse 2070 TFLOP/s 作顶仅 sparse 模式Dense FP8 应用517 TFLOP/s273 GB/s 是 GPU 独占统一内存CPU / 拷贝共享总线occupancy 低 roofline 差大 tile GEMM 故意低 occupancy看 achieved FLOP/s--noDataTransfers不测内存只关 Host↔Device 边界拷贝kernel DRAM 访问仍在10. 一句话总结Jetson Thor 的 Roofline 273 GB/s 的 DRAM 斜线 按精度选的 Compute 水平线。对llm_fp8.engineCompute Roof517 TFLOP/sFP8 Dense Tensor Core MAXNMemory Roof273 GB/sRidge Point≈1894 FLOP/Byteπ0.5 batch1 prefill 的 GEMM/FMHA 多在拐点左侧memory-bound优化应优先DRAM 流量与 Tensor Core 利用率而非单纯提高 occupancy。