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

Tensorflow 2.11 support #1016

Merged
merged 11 commits into from
Mar 29, 2023
Merged

Tensorflow 2.11 support #1016

merged 11 commits into from
Mar 29, 2023

Conversation

edknv
Copy link
Contributor

@edknv edknv commented Mar 10, 2023

Goals ⚽

Support Tensorflow 2.11

Implementation Details 🚧

  • Tensorflow 2.11 has introduced a new set of Keras optimizers and moved the old Keras optimizers into the namespace tf.keras.optimizers.legacy. Most of the changes in this PR involve checking the Tensorflow version and using the correct namespace for the version.
  • MultiOptimizer only works with legacy optimizers, and it does not work with newly introduced Keras optimizers. This PR opted to throw an error if the user tries to use it with the new optimizers. Supporting new optimizers in MultiOptimizer is left as future work.
  • There was another change in TF 2.11 with saving formet. See Enable pickle of model with TensorFlow 2.11  #1040.

Testing Details 🔍

Needs horovod 0.27. Related: NVIDIA-Merlin/Merlin#883
For GPU test, manually built docker image with NVIDIA-Merlin/Merlin#883 and ran tests.

@edknv edknv changed the title Tensorflow 2.11 support [WIP] Tensorflow 2.11 support Mar 10, 2023
@edknv edknv self-assigned this Mar 10, 2023
@edknv edknv added enhancement New feature or request area/tensorflow labels Mar 10, 2023
@github-actions
Copy link

Documentation preview

https://nvidia-merlin.github.io/models/review/pr-1016

@rnyak rnyak added this to the Merlin 23.03 milestone Mar 13, 2023
@edknv edknv modified the milestones: Merlin 23.03, Merlin 23.04 Mar 21, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Comment on lines +18 to +21
@pytest.mark.skipif(
version.parse(tf.__version__) < version.parse("2.9.0"),
reason="tf.keras.optimizers.legacy is not available in TF <= 2.8",
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we need to use legacy optimizers in MultiOptimizer, I updated the incremental training notebook to use tf.keras.optimizers.legacy optimizers. And since this namespace was not available in TF 2.8, I opted to skip testing for TF 2.8, effectively dropping support for TF 2.8 for this notebook. Open questions: Is there a better way to handle this? It's likely not feasible to support all previous versions forever. Do we need an SLA or something for when to drop support for old dependency versions?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the last 4 releases of TensorFlow or something would be reasonable. Might depend a bit on the level of complexity in supporting each one

@edknv edknv marked this pull request as ready for review March 28, 2023 19:45
@edknv edknv changed the title [WIP] Tensorflow 2.11 support Tensorflow 2.11 support Mar 28, 2023
elif hasattr(optimizer, "variables") and callable(
optimizer.variables
): # Tensorflow >= 2.11
weights += optimizer_blocks.optimizer.variables()
Copy link
Member

Choose a reason for hiding this comment

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

if variables() was present in earlier versions of tensorflow (2.8, 2.9, 2.10) and equivalent to .weights ? then we might be able to simplify to be only this line?

@edknv edknv merged commit e6b4bbd into NVIDIA-Merlin:main Mar 29, 2023
@edknv edknv deleted the tf-2.11 branch March 29, 2023 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tensorflow enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants