MCPcopy Create free account
hub / github.com/ModalityDance/Omni-R1 / is_main_process

Function is_main_process

src/transformers/src/transformers/trainer_utils.py:356–365  ·  view source on GitHub ↗

Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on `local_rank`.

(local_rank)

Source from the content-addressed store, hash-verified

354
355
356def is_main_process(local_rank):
357 """
358 Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on
359 `local_rank`.
360 """
361 if is_torch_xla_available():
362 import torch_xla.core.xla_model as xm
363
364 return xm.get_ordinal() == 0
365 return local_rank in [-1, 0]
366
367
368def total_processes_number(local_rank):

Callers 15

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 1

is_torch_xla_availableFunction · 0.85

Tested by

no test coverage detected