in train/comms/pt/comms_utils.py [0:0]
def parseRankList(ipStr, ipName, comms_world_info):
rankList = [] # default empty
if ipStr:
if ipStr.isnumeric():
# single rank
rankList = [int(ipStr)]
elif ipStr.find(",") != -1:
# list of unique ranks separated by comma
rankList = list(map(int, [r.strip() for r in ipStr.split(",")]))
rankList = list(OrderedDict.fromkeys(rankList))
elif ipStr.find(":") != -1:
# a range of ranks defined by [start:end]
pos = list(map(int, [r.strip() for r in ipStr.split(":")]))
rankList = [*range(pos[0], pos[1] + 1)]
# Check if input is valid
if len(rankList) == 0 or any(
r < 0 or r >= comms_world_info.world_size for r in rankList
):
if comms_world_info.global_rank == 0:
logger.error(f"Could not parse {ipName}: {ipStr}")
gracefulExit()
return rankList