Skip to content

Commit 10918a1

Browse files
committed
fix(logging): Disable logging in generate unless set in the env
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 <[email protected]>
1 parent c1574db commit 10918a1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

torchchat/generate.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,18 @@
4545
from torchchat.utils.device_info import get_device_info
4646

4747

48-
logger = logging.getLogger(__name__)
48+
# NOTE: Logging disabled by default here due to conflicts with torch._dynamo
49+
class NoOpLogger:
50+
def __no_op(self, *_, **__):
51+
pass
52+
def __getattr__(self, name):
53+
return self.__no_op
54+
55+
56+
logger = (
57+
NoOpLogger() if os.getenv("LOG_LEVEL") is None
58+
else logging.getLogger(__name__)
59+
)
4960

5061
## Chat Formatters #############################################################
5162

0 commit comments

Comments
 (0)