Skip to content

Add module level filter for deprecation warning in common - #813

Merged
ksivaman merged 3 commits into
NVIDIA:mainfrom
ksivaman:limit_warning_scope
Apr 29, 2024
Merged

Add module level filter for deprecation warning in common#813
ksivaman merged 3 commits into
NVIDIA:mainfrom
ksivaman:limit_warning_scope

Conversation

@ksivaman

Copy link
Copy Markdown
Member

Fixes#812

Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Comment threadtransformer_engine/common/utils.py Outdated
from enum import Enum

warnings.simplefilter('default')
warnings.filterwarnings("module", category=DeprecationWarning, module="utils")

@timmoon10timmoon10Apr 26, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not matching the right module:

Suggested change
warnings.filterwarnings("module", category=DeprecationWarning, module="utils")
warnings.filterwarnings(
"default",
category=DeprecationWarning,
module="transformer_engine.common.utils",
)

With this fix, I see the expected behavior with the following test case:

importwarningswarnings.simplefilter("error")
importtransformer_engine.jaxasteprint(te.MajorShardingType.SINGLE) # Print warningprint(te.MajorShardingType.DP) # No warningx=te.ShardingResource() # Print warningwarnings.warn("hi", DeprecationWarning) # Error

One thing I don't understand about warnings.filterwarnings is the difference between action="default" and action="module" since I see the same behavior with both. The docs say that action="module" only prints the first warning in a module, but that doesn't seem to be happening.

Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
@ksivaman
ksivaman requested a review from timmoon10April 29, 2024 05:17
@ksivaman

Copy link
Copy Markdown
MemberAuthor

/te-ci pytorch

@timmoon10timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ksivaman
ksivaman merged commit 38c01c8 into NVIDIA:mainApr 29, 2024
phu0ngng pushed a commit to phu0ngng/TransformerEngine that referenced this pull request May 3, 2024
* Add module level filter for deprecation warning in common
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
* Fix module
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
---------
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
pggPL pushed a commit to pggPL/TransformerEngine that referenced this pull request May 23, 2024
* Add module level filter for deprecation warning in common
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
* Fix module
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
---------
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warnings.simplefilter('default') in global scope causes excessive DeprecationWarnings

2 participants

@ksivaman@timmoon10