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

Fix tf2.4 #9120

Merged
merged 6 commits into from
Dec 15, 2020
Merged

Fix tf2.4 #9120

merged 6 commits into from
Dec 15, 2020

Conversation

jplu
Copy link
Contributor

@jplu jplu commented Dec 15, 2020

What does this PR do?

Fix the tests to make them compliant with the new TF 2.4

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Thanks a lot @jplu

@@ -76,12 +76,12 @@ def accumulate(grad1, grad2):
local_variables = strategy.experimental_local_results(gradient_placeholder)
local_variables[0].assign(grad1)
local_variables[1].assign(grad2)
strategy.experimental_run_v2(accumulate_on_replica, args=(gradient_placeholder,))
strategy.run(accumulate_on_replica, args=(gradient_placeholder,))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused, if the strategy was just removed from experimental, how is this going to be compatible with versions <2.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The run method is not experimental anymore since the TF 2.2 release, and removed of the experimental namespace since the 2.4.

Copy link
Collaborator

@sgugger sgugger Dec 15, 2020

Choose a reason for hiding this comment

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

Ok but we are pinned to is >=2.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, at some point if we want to keep improve the TF codebase we have to change this sometime, this will be soon the case with the upcoming perf improvements. We will have to move to at least 2.3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As example here #9124

Copy link
Collaborator

@sgugger sgugger Dec 15, 2020

Choose a reason for hiding this comment

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

I understand, but unless that move happens today, we need some code that deals with both versions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like this? (just pushed an update)

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

LGTM! The part with the version check looks like it would break TensorFlow code given that it's in a tf.function, but I trust you tried it out. Thanks for fixing!

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.

Just added some nits to do the version checks like in other parts of the lib for consistency. Feel free to ignore if it breaks anything.

tests/test_optimization_tf.py Outdated Show resolved Hide resolved
tests/test_optimization_tf.py Outdated Show resolved Hide resolved
tests/test_optimization_tf.py Outdated Show resolved Hide resolved
jplu and others added 3 commits December 15, 2020 15:51
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
@jplu
Copy link
Contributor Author

jplu commented Dec 15, 2020

LGTM!

@sgugger sgugger merged commit ef2d4cd into huggingface:master Dec 15, 2020
@jplu jplu deleted the fix-tf2.4 branch December 15, 2020 15:11
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.

None yet

4 participants