Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PyTorch] transformer engine modifies root logger #1294

Open
Marks101 opened this issue Oct 28, 2024 · 2 comments · May be fixed by #1380
Open

[PyTorch] transformer engine modifies root logger #1294

Marks101 opened this issue Oct 28, 2024 · 2 comments · May be fixed by #1380
Assignees

Comments

@Marks101
Copy link
Contributor

Hello everyone,

we noticed that since #1226, transformer engine modifies the root logger of Python in the global scope:

fa_logger = logging.getLogger()
fa_logger.setLevel(_log_level)

That means that importing transformer-engine already modifies the logger setup of the application.

Is it maybe possible to use a named logger? fa_logger = logging.getLogger("FlashAttention") for example?

(related to this issue #1065)

Thank you 😄

@cyanguwa cyanguwa self-assigned this Oct 28, 2024
@cyanguwa
Copy link
Collaborator

Hi Markus!

I can certainly add a name to the logger! I guess I meant for these package availability messages (e.g. this and this) to be global messages that are not tied to a particular module.

What do you mean by importing transformer-engine already modifies the logger setup of the application? Did this fa_logger change the formatting of other loggers in your application? I think the formatter is only applied here right?

@Marks101
Copy link
Contributor Author

Hi Charlene,

Did this fa_logger change the formatting of other loggers in your application?

Not the format, but the log level. I was surprised as well 😄 By omitting the name argument when calling getLogger(), the fa_logger is assigned to the root logger of the logging framework. Modifying the logging level of the root logger influences other loggers. This is from the documentation of logging:

Logged messages to the module-level logger get forwarded to handlers of loggers in higher-level modules, all the way up to the highest-level logger known as the root logger

So modyfing the root logger with these two lines:

fa_logger = logging.getLogger()
fa_logger.setLevel(_log_level)
modifies all other loggers.

I double checked that with the following snippet:

import logging

logger = logging.getLogger("MyApp")
logging.basicConfig(level=logging.DEBUG)

# when this gets uncommented, there is no logging output to the console anymore
#import transformer_engine

logger.debug("This is a debug message.")

Can you reproduce this?

@sagostinho-nvidia sagostinho-nvidia linked a pull request Dec 19, 2024 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants