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

TF: tf.debugging assertions without tf.running_eagerly() protection #19030

Merged
merged 3 commits into from
Sep 14, 2022

Conversation

gante
Copy link
Member

@gante gante commented Sep 14, 2022

What does this PR do?

In most cases, tf.debugging assertions (which exist as normal asserts in PyTorch models) are protected by a check for eager execution. In some places, we have stated in comments that these ops do not work with XLA, hence the check for eager execution.

The actual state of tf.debugging is the following:

  • They never cause crashes, not even in XLA;
  • In XLA, they are not executed.

Since they are innocuous, this PR removes the checks for eager execution. Non-XLA graph-mode model calls will now benefit from these checks (e.g. when a user calls model.fit())

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 14, 2022

The documentation is not available anymore as the PR was closed or merged.

@gante gante force-pushed the debugging_without_eager branch from 394ea22 to 5ae40fe Compare September 14, 2022 15:02
@gante gante marked this pull request as ready for review September 14, 2022 15:18
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Good end-of-summer cleaning, thanks!

src/transformers/models/flaubert/modeling_tf_flaubert.py Outdated Show resolved Hide resolved
src/transformers/models/xlm/modeling_tf_xlm.py Outdated Show resolved Hide resolved
Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

LGTM! Do we need the tf.control_dependencies line and identity op either, or can they be dropped in TF 2?

@gante gante merged commit 31be02f into huggingface:main Sep 14, 2022
@gante gante deleted the debugging_without_eager branch September 14, 2022 17:19
oneraghavan pushed a commit to oneraghavan/transformers that referenced this pull request Sep 26, 2022
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 this pull request may close these issues.

4 participants