MCPcopy
hub / github.com/deepspeedai/DeepSpeed / print_json_dist

Function print_json_dist

deepspeed/utils/logging.py:156–180  ·  view source on GitHub ↗
(message, ranks=None, path=None)

Source from the content-addressed store, hash-verified

154
155
156def print_json_dist(message, ranks=None, path=None):
157 from deepspeed import comm as dist
158 """Print message when one of following condition meets
159
160 + not dist.is_initialized()
161 + dist.get_rank() in ranks if ranks is not None or ranks = [-1]
162
163 Args:
164 message (str)
165 ranks (list)
166 path (str)
167
168 """
169 should_log = not dist.is_initialized()
170 ranks = ranks or []
171 my_rank = dist.get_rank() if dist.is_initialized() else -1
172 if ranks and not should_log:
173 should_log = ranks[0] == -1
174 should_log = should_log or (my_rank in set(ranks))
175 if should_log:
176 message['rank'] = my_rank
177 import json
178 with open(path, 'w') as outfile:
179 json.dump(message, outfile)
180 os.fsync(outfile)
181
182
183def get_log_level_from_string(log_level_str):

Callers 2

forwardMethod · 0.90
_autotuning_exitMethod · 0.90

Calls 3

dumpMethod · 0.80
is_initializedMethod · 0.45
get_rankMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…