执行摘要
在 rollout 日志中新增 spec 和 prefix cache 指标
补齐 rollout 过程中缺少的关键性能指标,便于监控和调试投机采样与前缀缓存的运行状态。
建议合入,但建议作者或 reviewer 确认 _compute_spec_metrics 和 _compute_prefix_cache_metrics 的返回值对日志系统的兼容性(如是否可能返回非 dict 类型)。
无 review 讨论。
补齐 rollout 过程中缺少的关键性能指标,便于监控和调试投机采样与前缀缓存的运行状态。
建议合入,但建议作者或 reviewer 确认 _compute_spec_metrics 和 _compute_prefix_cache_metrics 的返回值对日志系统的兼容性(如是否可能返回非 dict 类型)。
无 review 讨论。
在 slime/ray/rollout.py 的 compute_metrics_from_samples 函数中,在调用 _compute_reward_cat_metrics 之前,新增两条调用:log_dict |= _compute_spec_metrics(args, samples) 和 log_dict |= _compute_prefix_cache_metrics(args, samples)。这两个函数已经在同一文件中定义,但之前未被集成到指标收集主流程中,导致相关指标遗漏。
| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
slime/ray/rollout.py |
rollout | modified | 4.54 |
slime/ray/rollout.py
core-logic
核心变更文件,在 compute_metrics_from_samples 中新增了两个指标收集调用
def compute_metrics_from_samples(args, samples):
response_lengths = [sample.effective_response_length for sample in samples]
log_dict = {}
log_dict |= dict_add_prefix(compute_statistics(response_lengths), "response_len/")
log_dict |= _compute_zero_std_metrics(args, samples)
# 新增:添加投机采样(speculative decoding)指标
log_dict |= _compute_spec_metrics(args, samples)
# 新增:添加前缀缓存(prefix cache)指标
log_dict |= _compute_prefix_cache_metrics(args, samples)
log_dict |= _compute_reward_cat_metrics(args, samples)
log_dict["repetition_frac"] = np.mean([int(has_repetition(s.response)) for s in samples]).item()
log_dict["truncated_ratio"] = np.mean([int(s.status == Sample.Status.TRUNCATED) for s in samples]).item()
return log_dict
当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。
低风险。变更仅添加两行函数调用,被调用的函数已存在且仅计算并返回字典,不会影响原有逻辑。但若 _compute_spec_metrics 或 _compute_prefix_cache_metrics 内部存在未预期的异常或性能开销,可能影响日志记录流程。建议确认这两个函数在无 spec/prefix cache 时的行为(应返回空字典或默认值)。
对用户:启用 spec/prefix cache 的任务将获得更丰富的指标,方便分析性能;未启用用户不受影响。对系统:无性能影响,因为函数仅从现有样本数据中计算统计量。对团队:监控面板可补充新指标,但需注意指标命名和前缀以避免冲突。
当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。
参与讨论