执行摘要
- 一句话:清理启动日志噪声,移除冗余日志和 import
- 推荐动作:该 PR 是低风险清理,可快速合并。建议关注是否有可能在调试时需要这些日志,若需可考虑改为 debug 级别而非直接移除。
功能与动机
根据 PR body,目的是清理启动时的日志噪声("Remove noisy startup logs"),使日志更干净,便于用户阅读。具体涉及 custom allreduce v2、speculative decoding 和 finalized token capacity 处理。
实现拆解
- custom_all_reduce_v2.py:移除
log_info_on_rank0 import,在 __init__ 末尾移除初始化成功日志,在 _register_graph_inputs_ipc 末尾移除 IPC 注册地址数量和 cuda graph 地址日志。
- speculative_hook.py:在
_handle_eagle_family 函数中,移除了 else 分支中关于“Overlap spec v2 默认启用”的 warning 日志,仅保留 non-overlap 时的 warning。
- flashinfer_backend.py:移除 CUTLASS 因 TMA 描述符问题而禁用时的 info 日志,并将条件判断从
if check_... 取反为 if not check_...,保留 CUTLASS 回退行为但消除日志。
- model_runner_kv_cache_mixin.py:在
_resolve_max_num_reqs 方法中,移除 finalized token capacity 的 info 日志,仅保留 max_running_requests 被降低时的 warning 日志。
关键文件:
python/sglang/srt/distributed/device_communicators/custom_all_reduce_v2.py(模块 通信层;类别 source;类型 dependency-wiring): 移除了 log_info_on_rank0 import 和两条信息性日志(初始化成功、IPC 注册地址数),减少启动噪声。
python/sglang/srt/arg_groups/speculative_hook.py(模块 参数配置;类别 source;类型 core-logic): 移除了 _handle_eagle_family 中 disable_overlap_schedule 为 False 时的 warning 日志("Overlap spec v2 is enabled by default"),仅保留 non-overlap 时的 warning。
python/sglang/srt/layers/attention/flashinfer_backend.py(模块 注意力层;类别 source;类型 core-logic): 简化了 SM100 上 CUTLASS 后端选择的逻辑,移除 CUTLASS 禁用的 info 日志,同时将条件判断取反,保持相同行为。
python/sglang/srt/model_executor/model_runner_kv_cache_mixin.py(模块 模型执行器;类别 source;类型 data-contract): 移除了 _resolve_max_num_reqs 方法中 finalized token capacity 的 info 日志,减少启动时输出。
关键符号:CustomAllReduceV2.init, CustomAllReduceV2._register_graph_inputs_ipc, _handle_eagle_family, FlashInferBackend.init, _resolve_max_num_reqs
关键源码片段
python/sglang/srt/distributed/device_communicators/custom_all_reduce_v2.py
移除了 log_info_on_rank0 import 和两条信息性日志(初始化成功、IPC 注册地址数),减少启动噪声。
# python/sglang/srt/distributed/device_communicators/custom_all_reduce_v2.py
# 移除 log_info_on_rank0 导入,仅保留 is_sm100_supported
# from sglang.srt.utils import is_sm100_supported, log_info_on_rank0 # 移除 log_info_on_rank0
from sglang.srt.utils import is_sm100_supported
class CustomAllReduceV2:
def __init__(self, ...):
# ... 初始化逻辑 ...
self._post_init_obj()
self.disabled = False
# log_info_on_rank0(logger, "Custom allreduce v2 initialized successfully") # 已移除
def _register_graph_inputs_ipc(self):
# ... 注册逻辑 ...
self.obj.register_inputs(result)
# log_info_on_rank0(logger, f"Registered {len(pairs)} cuda graph addresses via IPC") # 已移除
python/sglang/srt/arg_groups/speculative_hook.py
移除了 _handle_eagle_family 中 disable_overlap_schedule 为 False 时的 warning 日志("Overlap spec v2 is enabled by default"),仅保留 non-overlap 时的 warning。
# python/sglang/srt/arg_groups/speculative_hook.py
# 在 _handle_eagle_family 函数中
if server_args.disable_overlap_schedule:
logger.warning(
"Non-overlap (synchronous) spec v2 is used for eagle/eagle3/standalone "
"speculative decoding."
)
# else: # 已删除
# logger.warning( # 已删除
# "Overlap spec v2 is enabled by default for eagle/eagle3/standalone speculative decoding." # 已删除
# ) # 已删除
python/sglang/srt/layers/attention/flashinfer_backend.py
简化了 SM100 上 CUTLASS 后端选择的逻辑,移除 CUTLASS 禁用的 info 日志,同时将条件判断取反,保持相同行为。
# python/sglang/srt/layers/attention/flashinfer_backend.py
# 在 FlashInferBackend.__init__ 方法中
fmha_backend = "auto"
if is_sm100_supported():
# 当 piecewise cuda graph 启用时禁用 CUTLASS 后端,
# 因为 B200 上存在 TMA 描述符初始化问题。
if not check_cuda_graph_backend(Phase.PREFILL, Backend.TC_PIECEWISE):
fmha_backend = "cutlass"
# 之前版本使用 if check_... 然后 log,现在简化为 if not check_... 直接设置
评论区精华
无 review 评论;仅 Gemini Code Assist 自动 review 提及无反馈。
风险与影响
- 风险:风险极低。所有变更均为移除日志语句或简化条件判断,不改变运行时逻辑。flashinfer_backend 中的条件判断从
if A: log; else: set 改为 if not A: set,行为与之前完全一致。custom_all_reduce_v2 的 log_info_on_rank0 import 移除后确认无其他使用。
- 影响:影响范围小,只影响启动时日志输出,不改变任何运行时行为或性能。用户将看到更简洁的启动日志,但可能失去一些调试信息(如 custom allreduce 初始化成功、IPC 注册数量等)。对生产环境无负面影响。
- 风险标记:低风险清理
关联脉络
参与讨论