Kernoscope 0.2.0 · 协议 eef61ed797ee · 层 3 (instrumented)
------------------------------------------------------------------------------------------------
[ok  ] 最耗时的是 copy_k(const float *, float *, long)（3009.522 ms / 4701 次，占 kernel 时间 100.0%），进程内 kernel 时间合计 3009.522 ms  (3009.522 ms, exact)
        前提 该 kernel 占全部 kernel 时间的比例：100.0%
        前提 kernel 时间占进程 wall 的比例：49.6%
        下一步：用 -k 只选这个 kernel 再跑一次，拿到它的 DRAM/occupancy/roofline 判词
[soft] 整窗口 DRAM 约 2.7 MB（代理口径：NVML 显存忙碌 × 本机实测峰值）  (2726718.6 B, estimated)
        前提 窗口是否被被测负载主导：88.2%（门槛 50.0%）→ 满足
        前提 参与积分的窗口内显存忙碌均值：88.2%
        下一步：与你的账本对拍（--ks-ledger-total-mb）确认这个量级是否符合预期
[soft] 每次 launch 约 0.0 MB（代理口径）  (580.0 B, estimated)
        前提 窗口是否被被测负载主导：88.2%（门槛 80.0%）→ 满足
        前提 被匹配 kernel 是否占窗口 kernel 时间 ≥95%：100.0%（门槛 95.0%）→ 满足
        下一步：改一次 kernel 再跑 diff：差值小于 MDD 就是噪声，不要当成改进
[no  ] 不给数字：访存轨迹给不出字节数
        怎么办：轨迹口径给不出字节时，改用 NVML 代理口径（--ks-calibration + --…（代价 ≈20s）
[soft] 与账本相差 +8.0%（同口径对拍）  (8.0 %, derived)
        下一步：误差超出本机误差带才值得继续优化；否则先改测量口径
[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 6.064s · 包 3930B · 完整报告 2407 KB · 4701 次 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: bench/artifacts/.build/ledger_probe --kernel copy --mb 256 --target-s 3
==PROF== DRAM 估算 2726718.6 MB（窗口显存忙碌 88.2%／整进程 50.0% × 峰值 908 GB/s，窗口覆盖率 88.2%；参与估算的是 ks__dram_window_mem_busy_mean_pct）；窗口主导性 100.0%（内核时间份额，门槛 95%） → 580.03 MB/launch；vs 账本 536.9 MB（per-launch，口径 NVML 代理 per-launch），误差 +8.0%
==PROF== Kernel time: 3009.522 ms of 6064.113 ms wall (49.6%)
==PROF== Window: mode=auto（已裁剪） 采样 17 点 / 参与积分 3.4 s / 裁掉 2.7 s / 进程 wall 6.1 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/20261009-012257/machine-profile.json)

Kernel: copy_k(const float *, float *, long)
  nsys short name: copy_k
  4701 launch(es), 3009.5221 ms total, 0.6402 ms mean

  Section: Duration                           [exact]
    gpu__time_duration.sum                                3009.52 ms       [exact]
    ks__launch_time_mean                                   0.6402 ms       [exact]
    ks__launch_time_min                                    0.6332 ms       [exact]
    ks__launch_time_max                                    0.6583 ms       [exact]
    ks__launch_count                                         4701          [exact]

  Section: LaunchStats                        [exact]
    launch__grid_size                                        1024          [exact]
    launch__block_size                                        256          [exact]
    launch__thread_count                                   262144          [exact]
    launch__registers_per_thread                               32          [exact]
    ks__registers_used_for_occupancy                           32          [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                                           6          [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                               50 %        [measured]  [resolution 1 %（整数百分比）]  (区间平均；是「显存子系统忙碌占比」，不是 DRAM 吞吐本身。读数 0.0% 只说明低于分辨率下限，不等于「DRAM 完全没动」；必须让 GPU 保持饱和，否则会被宿主间隙稀释（实测 96.8% vs 6.3%）)
    est__dram_busy_equivalent_gbs                           454.2 GB/s     [estimated]  [resolution 1 %]  (等效带宽口径；与按字节/时间的口径略有差异)
    meas__sm_clock_mean_mhz                                  2245 MHz      [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__sm_clock_max_mhz                                   2775 MHz      [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__power_max_w                                       231.7 W        [measured]  [resolution 1 MHz / 1 W（驱动报数粒度）]
    meas__device_energy_j                                 861.633 J        [measured]  [resolution 1 mJ]  (ncu 不提供能耗指标)

  Section: DramTraffic                        [estimated] (+1 n/a)
    est__dram_bytes_total                                   2.727 TB       [estimated]  [resolution 1 %]  (窗口已按首个/末个忙碌采样点裁到稳态段（--ks-window auto）：参与积分 3.4 s，裁掉约 2.7 s 启动/JIT/空闲；用 --ks-window full 可关闭；采样周期 200 ms、区间平均（utilization.memory 分辨率 1 个百分点）；字节 = Σ(mem_util×Δt)×实测峰值带宽)
    est__dram_bytes_per_launch                             580.03 MB       [estimated]  [resolution 归因上偏估计 +0 %]  (仅在『被匹配 kernel 占窗口 ≥95% + 窗口覆盖率 ≥80%』时成立（前提②见 ks__matched_kernel_window_share_pct）)
    est__dram_throughput_pct_of_peak                         88.2 %        [estimated]  [resolution 1 %]  (忙碌时间占比口径，与按字节/时间的口径略有差异)
    ks__sampler_window_coverage_pct                          88.2 %        [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%)
    ks__matched_kernel_window_share_pct                      88.5 %        [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                        88.2 %        [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 秒)
    est__dram_vs_ledger_err_pct                                 8 %        [estimated]  [resolution 归因上偏估计 +0 %]  (账本 536.9 MB；对拍常用 |误差| < 10% 作为验收线)

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

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