Kernoscope 0.2.0 · 协议 a9cf970df3a2 · 层 3 (instrumented)
------------------------------------------------------------------------------------------------
[ok  ] 最耗时的是 ks_window_probe_kernel（23.407 ms / 20 次，占 kernel 时间 100.0%），进程内 kernel 时间合计 23.407 ms  (23.407 ms, exact)
        前提 该 kernel 占全部 kernel 时间的比例：100.0%
        前提 kernel 时间占进程 wall 的比例：0.1%
        下一步：用 -k 只选这个 kernel 再跑一次，拿到它的 DRAM/occupancy/roofline 判词
[soft] 整窗口 DRAM 约 28.2 TB（代理口径：NVML 显存忙碌 × 本机实测峰值）  (28248539300000.0 B, estimated)
        前提 窗口是否被被测负载主导：98.8%（门槛 50.0%）→ 满足
        前提 参与积分的窗口内显存忙碌均值：95.7%
        下一步：与你的账本对拍（--ks-ledger-total-mb）确认这个量级是否符合预期
[soft] 每次 launch 约 1.06 GB（代理口径）  (1057640000.0 B, estimated)
        前提 窗口是否被被测负载主导：98.8%（门槛 80.0%）→ 满足
        前提 被匹配 kernel 是否占窗口 kernel 时间 ≥95%：100.0%（门槛 95.0%）→ 满足
        下一步：改一次 kernel 再跑 diff：差值小于 MDD 就是噪声，不要当成改进
[no  ] 不给数字：访存轨迹给不出字节数
        怎么办：轨迹口径给不出字节时，改用 NVML 代理口径（--ks-calibration + --…（代价 ≈20s）
[soft] 理论上界 100.0%；限制因素 threads+warps  (100.0 %, exact)
        下一步：装上 NVBit 探针可拿到实测 occupancy（不只是上界）

没测到什么（共 4 个指标，按原因归组）：
  - 2 个 counters_denied（硬件计数器被权限/驱动策略拒绝）；怎么办：计数器是 host-wide 的，容器内无法突破（不要用 sudo/setuid 试）；换…
  - 1 个 no_workload（没有给工作量（FLOPs/bytes））；怎么办：给出每次 launch 的工作量：--ks-gemm M,N,K 或 --ks-flops…（代价 ≈0）
  - 1 个 trace_unavailable（访存轨迹给不出字节数）；怎么办：轨迹口径给不出字节时，改用 NVML 代理口径（--ks-calibration + --…（代价 ≈20s）
  - 本机缺件 no_instr_hist（没有提供指令直方图）；怎么办：加 --ks-instr-hist <opcode_hist.txt>：给出动态指令数与发…
  - 本机缺件 no_memtrace（没有提供访存轨迹文件）；怎么办：加 --ks-memtrace <trace>：轨迹口径只测被追踪的 kernel，不受窗…
  - 本机缺件 no_occupancy_probe（没跑 occupancy 探针）；怎么办：跑 occupancy 探针并把 JSON 用 --ks-achieved-occupan…
  - 本机缺件 no_static_input（没有提供 cubin/.so）；怎么办：用 --ks-cubin <cubin/.so> 指向被测二进制；没有它就没有寄存器/共享…

本次代价：wall 37.667s · 包 3843B · 完整报告 33 KB · 20 次 launch · 无本机误差带（跑 kernoscope selftest 后 diff 才有 MDD） · 包已按尺寸预算裁剪（unmeasured_examples, verdict_metrics, next_pointers）

====================================================================================================
完整报告（上面的判词都出自这里的数据；每个数字都带出处）
====================================================================================================
==PROF== Kernoscope 0.2.0 - provenance-honest profile (no performance counters required)
==PROF== Target: <python> bench/window_probe.py --run --elems 134217728 --target-s 30
==PROF== DRAM 估算 28248539.3 MB（窗口显存忙碌 95.7%／整进程 82.5% × 峰值 910 GB/s，窗口覆盖率 98.8%；参与估算的是 ks__dram_window_mem_busy_mean_pct）；窗口主导性 100.0%（内核时间份额，门槛 95%） → 1057.64 MB/launch（归因上偏估计 +0%）
==PROF== Kernel time: 23.407 ms of 37667.302 ms wall (0.1%)
==PROF== Window: mode=auto（已裁剪） 采样 162 点 / 参与积分 32.4 s / 裁掉 5.2 s / 进程 wall 37.7 s
==PROF== source[kernel activity]: nsys sqlite CUPTI_ACTIVITY_KIND_KERNEL (no counters needed)
==PROF== source[device counters]: pynvml (energy/PCIe/mem-busy are management counters, available without admin)
==PROF== source[static]: not used
==PROF== source[peaks]: measured calibration (bench/artifacts/20261011-094535/machine-profile.json)

Kernel: ks_window_probe_kernel
  20 launch(es), 23.4066 ms total, 1.1703 ms mean

  Section: Duration                           [exact]
    gpu__time_duration.sum                                23.4066 ms       [exact]
    ks__launch_time_mean                                   1.1703 ms       [exact]
    ks__launch_time_min                                    1.1642 ms       [exact]
    ks__launch_time_max                                    1.1732 ms       [exact]
    ks__launch_count                                           20          [exact]

  Section: LaunchStats                        [exact]
    launch__grid_size                                      131072          [exact]
    launch__block_size                                        128          [exact]
    launch__thread_count                                 16777216          [exact]
    launch__registers_per_thread                               18          [exact]
    ks__registers_used_for_occupancy                           18          [exact]
    launch__shared_mem_per_block_static                         0 B        [exact]
    launch__shared_mem_per_block_dynamic                        0 B        [exact]
    launch__local_mem_per_thread                                0 B        [exact]
    ks__cuda_graph_capture                                    yes          [exact]

  Section: Occupancy                          [exact] (+1 n/a)
    ks__theoretical_occupancy_pct                             100 %        [exact]
    ks__blocks_per_sm                                          12          [exact]
    ks__warps_per_sm                                           48          [exact]
    ks__occupancy_limiter                           threads+warps          [exact]  (并列的限制因素用 + 连接)
    sm__maximum_warps_per_active_cycle_pct                    n/a          [unavailable]  [counters_denied] requires GPU hardware performance counters, which are restricted here (RmProfilingAdminOnly=1 and no CAP_SYS_ADMIN/CAP_PERFMON in the container); CUPTI reports 
        fix: 计数器是 host-wide 的，容器内无法突破（不要用 sudo/setuid 试）；换用本工具的非计数器口径，或在有权限的机器上跑 ncu  (代价≈本机不可行)

  Section: SpeedOfLight                       [unavailable] (+2 n/a)
    est__achieved_tflops                                      n/a          [unavailable]  [no_workload] workload not provided: pass --ks-gemm M,N,K or --ks-flops/--ks-bytes (plus --ks-calibration machine-profile.json for measured peaks)
        observed peaks_provided=True  (downgraded: degraded)
        fix: 给出每次 launch 的工作量：--ks-gemm M,N,K 或 --ks-flops/--ks-bytes  (代价≈≈0)
    sm__throughput.avg.pct_of_peak_sustained_elapsed            n/a          [unavailable]  [counters_denied] requires GPU hardware performance counters, which are restricted here (RmProfilingAdminOnly=1 and no CAP_SYS_ADMIN/CAP_PERFMON in the container); CUPTI reports 
        fix: 计数器是 host-wide 的，容器内无法突破（不要用 sudo/setuid 试）；换用本工具的非计数器口径，或在有权限的机器上跑 ncu  (代价≈本机不可行)

----------------------------------------------------------------------------------------------------
Kernel: (device)
  0 launch(es), 0.0000 ms total, 0.0000 ms mean

  Section: DeviceStatistics                   [estimated]
    meas__nvml_mem_busy_mean_pct                             82.5 %        [measured]  [resolution 1 %（整数百分比）]  (区间平均；是「显存子系统忙碌占比」，不是 DRAM 吞吐本身。读数 0.0% 只说明低于分辨率下限，不等于「DRAM 完全没动」；必须让 GPU 保持饱和，否则会被宿主间隙稀释（实测 96.8% vs 6.3%）)
    est__dram_busy_equivalent_gbs                           750.8 GB/s     [estimated]  [resolution 1 %]  (等效带宽口径；与按字节/时间的口径略有差异)
    meas__sm_clock_mean_mhz                                2514.3 MHz      [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__sm_clock_max_mhz                                   2730 MHz      [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__power_max_w                                         268 W        [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__device_energy_j                                 8601.53 J        [measured]  [resolution 1 mJ]  (ncu 不提供能耗指标)

  Section: DramTraffic                        [estimated] (+1 n/a)
    est__dram_bytes_total                                  28.249 TB       [estimated]  [resolution 1 %]  (窗口已按首个/末个忙碌采样点裁到稳态段（--ks-window auto）：参与积分 32.4 s，裁掉约 5.2 s 启动/JIT/空闲；用 --ks-window full 可关闭；采样周期 200 ms、区间平均（utilization.memory 分辨率 1 个百分点）；字节 = Σ(mem_util×Δt)×实测峰值带宽)
    est__dram_bytes_per_launch                               1.06 GB       [estimated]  [resolution 归因上偏估计 +0 %]  (仅在『被匹配 kernel 占窗口 ≥95% + 窗口覆盖率 ≥80% + 分母与分子覆盖同一窗口』时成立（前提②见 ks__matched_kernel_kernel_share_pct）；分母 = 窗口内等效 launch 数 26709（整段运行匹配到 26709 个；窗口 32.4 s，比整段短 14%）；offset ±1 采样周期下的计数区间 26709…26709；launch 时间戳与采样时钟的推导偏移 +26765142.7 s、速率比 1.026)
    est__dram_throughput_pct_of_peak                         95.7 %        [estimated]  [resolution 1 %]  (忙碌时间占比口径，与按字节/时间的口径略有差异)
    ks__sampler_window_coverage_pct                          98.8 %        [derived]  [resolution 1 个采样点]  (前提①「窗口被被测负载主导」：<80% 不给 per-launch 归因，<50% 连总量也不给)
    ks__matched_kernel_kernel_share_pct                       100 %        [derived]  [resolution 0.1 %]  (前提②「窗口被被匹配的 kernel 主导」：<95% 不给 per-launch 归因。空闲时段贡献 0 字节，所以判据用内核时间份额而不是墙钟份额：单 kernel 的窗口无论有多少空闲都是 100%；窗口里还有 1 个 kernel)
    ks__matched_kernel_window_share_pct                      96.2 %        [derived]  [resolution 0.1 %]  (与覆盖率同量纲的对照量（95% 门槛用的是内核时间份额）；通常 ≤ 覆盖率，差值就是窗口里的空闲；本次分子含窗口外的同名 launch（窗口被裁过），所以它是**上界**，可能高于覆盖率，不能当作保守估计)
    ks__attribution_bias_estimate_pct                           0 %        [derived]  [resolution 0.1 %]  (实测校验：k_fused 内核时间份额 44.9% → 估计 +123%，而那次观测误差是 +146.9% —— 观测值比估计更高，因为该 kernel 的字节密度低于窗口里其他 kernel。所以这是**估计而非严格上界**：字节强度不一致的混合窗口必须换轨迹口径)
    ks__window_busy_segments                                    1 段        [derived]  [resolution 1 段]  (多段 ⇒ 窗口可能是多个阶段/变体拼接（例如先跑正确性再跑性能、依次跑 v1/v2/v3），此时 per-launch 归因需谨慎：这是启发式信号，不是判据)
    ks__dram_window_mem_busy_mean_pct                        95.7 %        [derived]  [resolution 1 %]  (这就是摘要里那个「窗口显存忙碌」，也是字节估算真正用到的那个数；整进程均值另见 meas__nvml_mem_busy_mean_pct，两者不可互换)
    est__dram_bytes_per_launch_trace                          n/a          [unavailable]  [trace_unavailable] 未提供访存轨迹：加 --ks-memtrace <trace> 可换用轨迹口径，在 NVML 代理口径不成立时仍能完成账本对拍
        observed trace_bytes_per_launch=None
        fix: 轨迹口径给不出字节时，改用 NVML 代理口径（--ks-calibration + --ks-window auto）或检查轨迹是否覆盖了被匹配的 kernel  (代价≈20 秒)

----------------------------------------------------------------------------------------------------

Provenance summary: exact=18, derived=6, measured=5, estimated=4, unavailable=4
Legend: exact=与 ncu 同源 | derived=本机实测标定/模型 | measured=我们的探针实测 | estimated=采样或代理(附误差) | unavailable=需要硬件计数器，只报 n/a
Output(json): bench/artifacts/20261011-094535/window-auto.ksreport.json
Output(perfetto): bench/artifacts/20261011-094535/window-auto.perfetto.json
Open the timeline at https://ui.perfetto.dev -> Load trace -> the file above
