pytorch/torch/distributed/_spmd/config.py
Chien-Chin Huang 250c054bdd [SPMD] Pull the minimal working distribute API and SPMD module to PyTorch (#94802)
Pull the minimal working distribute API and SPMD module to PyTorch. The original code is on https://github.com/pytorch/tau/tree/main/spmd/compiler.

Other main contributors to the original code base: @anj-s, @lessw2020, @wanchaol @aazzolini

Differential Revision: [D43197230](https://our.internmc.facebook.com/intern/diff/D43197230/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94802
Approved by: https://github.com/anj-s, https://github.com/wanchaol
2023-02-16 00:36:16 +00:00

28 lines
879 B
Python

import logging
import sys
from types import ModuleType
from typing import Set
# log level (levels print what it says + all levels listed below it)
# DEBUG print full traces <-- lowest level + print tracing of every instruction
# INFO print compiler functions + distributed graphs
# WARN print warnings
# ERROR print exceptions
log_level: int = logging.DEBUG
# Verbose will print full stack traces on warnings and errors
verbose = False
# the name of a file to write the logs to
log_file_name: None = None
class _AccessLimitingConfig(ModuleType):
def __setattr__(self, name, value) -> None:
if name not in _allowed_config_names:
raise AttributeError(f"{__name__}.{name} does not exist")
return object.__setattr__(self, name, value)
_allowed_config_names: Set[str] = {*globals().keys()}
sys.modules[__name__].__class__ = _AccessLimitingConfig