MCPcopy
hub / github.com/FlagAI-Open/FlagAI / log_dist

Function log_dist

flagai/logger.py:61–85  ·  view source on GitHub ↗

Log message when one of following condition meets + not dist.is_initialized() + dist.get_rank() in ranks if ranks is not None or ranks = [-1] Args: message (str) ranks (list) level (int)

(message, ranks=None, level=logging.INFO)

Source from the content-addressed store, hash-verified

59
60
61def log_dist(message, ranks=None, level=logging.INFO):
62 """Log message when one of following condition meets
63 + not dist.is_initialized()
64 + dist.get_rank() in ranks if ranks is not None or ranks = [-1]
65 Args:
66 message (str)
67 ranks (list)
68 level (int)
69 """
70
71 my_rank = -1
72 if is_bmt and bmt.init.is_initialized():
73 should_log = not bmt.init.is_initialized()
74 my_rank = bmt.rank() if bmt.init.is_initialized() else -1
75 else:
76 should_log = not dist.is_initialized()
77 my_rank = dist.get_rank() if dist.is_initialized() else -1
78
79 ranks = ranks or []
80 if ranks and not should_log:
81 should_log = ranks[0] == -1
82 should_log = should_log or (my_rank in set(ranks))
83 if should_log:
84 final_message = "[Rank {}] {}".format(my_rank, message)
85 logger.log(level, final_message)
86
87def print_json_dist(message, ranks=None, path=None):
88 """Print message when one of following condition meets

Callers 15

logMethod · 0.90
report_memoryFunction · 0.90
save_checkpointFunction · 0.90
get_checkpoint_iterationFunction · 0.90
load_checkpointFunction · 0.90
load_optimFunction · 0.90
load_rngFunction · 0.90
__init__Method · 0.90
get_dataloaderMethod · 0.90
pre_trainMethod · 0.90
do_trainMethod · 0.90

Calls 1

logMethod · 0.80

Tested by

no test coverage detected