Skip to content

Commit

Permalink
fix(logging): Disable logging in generate unless set in the env
Browse files Browse the repository at this point in the history
There is an incompatibility with logging and torch._dynamo, so this
disables it unless the developer asks for it explicitly.

NOTE: The TC team has stated that they have holistic logging on the roadmap
so this is a short-term solution pending a more robust approach.

REF: https://github.com/pytorch/torchchat/actions/runs/11963066986/job/33493237302#step:14:3599

Branch: GraniteCodeSupport

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
  • Loading branch information
gabe-l-hart committed Dec 11, 2024
1 parent 8178596 commit 2fdacd0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion torchchat/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@
from torchchat.utils.device_info import get_device_info


logger = logging.getLogger(__name__)
# NOTE: Logging disabled by default here due to conflicts with torch._dynamo
class NoOpLogger:
def __no_op(self, *_, **__):
pass
def __getattr__(self, name):
return self.__no_op


logger = (
NoOpLogger() if os.getenv("LOG_LEVEL") is None
else logging.getLogger(__name__)
)

## Chat Formatters #############################################################

Expand Down

0 comments on commit 2fdacd0

Please sign in to comment.