hinter.py 309 B

12345678910111213
  1. import sys
  2. import torch.distributed
  3. import logging
  4. HINTED = set()
  5. def hint_once(content, uid, rank=None):
  6. if (rank is None) or (not torch.distributed.is_initialized()) or torch.distributed.get_rank() == rank:
  7. if uid not in HINTED:
  8. logging.info(content)
  9. HINTED.add(uid)