Prhub

#24815 Revert "[NPU] fix profiler on npu"

原始 PR 作者 sglang-npu-bot 合并时间 2026-05-09 17:53 文件变更 1 提交数 1 评论 0 代码增减 +0 / -15

执行摘要

回滚 NPU 分析器修复 PR#24685

这是一次自动回滚操作,引用 PR#24685 的具体动机:修复 sglang.bench_serving --profile 在 NPU 上无法收集算子形状信息的问题,原 PR 增加了 experimental_config 参数。回滚原因未在 body 中说明,可能由于该参数导致未知问题。

该 PR 为简单回滚,无需深入审查。建议关注后续是否有重新修复 NPU profiler 的 PR,以更 robust 的方式传入 experimental_config。

讨论亮点

无实质性讨论。只有 gemini-code-assist[bot] 的自动评论,未产生 human review comments。

实现拆解

  1. 定位文件 python/sglang/srt/managers/scheduler_profiler_mixin.pystart_profile() 方法(约第 192-204 行)。
  2. 删除 torch.profiler.profile() 调用中的 experimental_config 关键字参数及其条件表达式 None if not _is_npu else torch_npu.profiler._ExperimentalConfig(...),共 15 行。
  3. 调用 self.torch_profiler.start() 保持不变,后续 profiling 流程未受影响。
文件 模块 状态 重要度
python/sglang/srt/managers/scheduler_profiler_mixin.py 分析器 modified 6.37

关键符号

start_profile

关键源码片段

python/sglang/srt/managers/scheduler_profiler_mixin.py core-logic

唯一变更文件,删除了 NPU 特定的 experimental_config 参数,直接影响 NPU profiling 行为。

def start_profile(self: Scheduler, req: ProfileReq) -> ProfileReqOutput:
    # ... 前面的逻辑 ...
    elif torchprof_activities:
        self.torch_profiler = torch.profiler.profile(
            activities=torchprof_activities,
            with_stack=with_stack if with_stack is not None else True,
            record_shapes=record_shapes if record_shapes is not None else False,
            on_trace_ready=(
                None
                if not _is_npu
                else torch_npu.profiler.tensorboard_trace_handler(
                    str(self.torch_profiler_output_dir)
                )
            ),
            # 删除了 experimental_config 参数,详见 PR#24685 回滚
        )
        self.torch_profiler.start()
        self.profile_in_progress = True
    # ... 后续逻辑 ...

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

回滚后,NPU 平台将失去 experimental_config 中的定制设置(如 profiler_level=Level1、aic_metrics=AiCoreNone 等),可能导致 NPU 上 profiling 信息不完整,无法收集算子形状,恢复修复前的状态。不过由于该 PR 本身是对修复的回滚,如原修复未彻底问题则回滚反而稳定。

仅影响 NPU 平台上的 profiling 功能。用户在使用 sglang.bench_serving --profile 时,若在 NPU 环境,无法获得算子形状等详细信息;其他平台(CUDA、ROCM)无影响。

NPU 平台 profiling 退化 无 review 讨论

关联 Issue

#24685 [NPU] fix profiler on npu

完整报告

参与讨论