已合并
【flight recorder】增加world size的范围校验 #19890
yinqian创建于 2025年4月1日
【flight recorder】增加world size的范围校验 #19890
已合并
yinqian创建于 2025年4月1日
refs/pull/19890/head合入到master
1 个文件变更+12-5
@@ -1,4 +1,5 @@
1import os1import os
2+import sys
2import pickle3import pickle
3import logging4import logging
4from collections import defaultdict5from collections import defaultdict
@@ -100,7 +101,7 @@ def analyze_pg_groups(hccl_dict):
100 latest_op = max(completed_ops, key=lambda x: x["time_discovered_completed_ns"] or 0)101 latest_op = max(completed_ops, key=lambda x: x["time_discovered_completed_ns"] or 0)
101 logging.info(102 logging.info(
102 f"The computational task of the pg_id {pg_id} "103 f"The computational task of the pg_id {pg_id} "
103- f"after the communication operator {latest_op['name']} " 104+ f"after the communication operator {latest_op['name']} "
104 "took too long."105 "took too long."
105 )106 )
106 107 
@@ -111,14 +112,20 @@ def analyze_pg_groups(hccl_dict):
111def main():112def main():
112 # 设置默认值113 # 设置默认值
113 default_path = os.getenv("TORCH_HCCL_DEBUG_INFO_TEMP_FILE")114 default_path = os.getenv("TORCH_HCCL_DEBUG_INFO_TEMP_FILE")
114- default_world_size = 8
115 115 
116 # 使用 argparse 解析命令行参数116 # 使用 argparse 解析命令行参数
117 parser = argparse.ArgumentParser(description="Process HCCL debug info.")117 parser = argparse.ArgumentParser(description="Process HCCL debug info.")
118- parser.add_argument('--path', type=str, default=default_path, help='Path to the recorder data file')118+ parser.add_argument("--path", type=str, default=default_path, help="Path to the recorder data file")
119- parser.add_argument('--world-size', type=int, default=default_world_size, help='World size for the operation')119+ parser.add_argument(
120- 120+ "--world-size",
121+ type=int,
122+ default=8,
Cmjsz
Cchenhao_12092025年4月9日

[review][编码]此处实现和设计不符合,实际范围为2~10000,--help的信息呈现存在误导性,建议修改成跟校验逻辑一致的提示信息

likedislike
mjszmjsz2025年4月1日

【review】建议不要取2^64 作为限制,这个值没有任何的业务含义。如果实在不好找最大值,可以只提示大于0 就好。下面正式的判断限制不能大于 2^64,再给错误提示

likedislike
123+ help="World size for the operation (range: greater than or equal to 2)",
124+ )
125+ 
121 args = parser.parse_args()126 args = parser.parse_args()
127+ if args.world_size <= 1 or args.world_size > sys.maxsize:
128+ parser.error("--world-size must be in [2, 2^63-1]")
122 129 
123 logging.info("Path: %r", args.path)130 logging.info("Path: %r", args.path)
124 logging.info("World Size: %r", args.world_size)131 logging.info("World Size: %r", args.world_size)