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

test(backend handler): added tests for inplace update warnings. #26067

Merged
merged 3 commits into from
Sep 27, 2023
Merged

test(backend handler): added tests for inplace update warnings. #26067

merged 3 commits into from
Sep 27, 2023

Conversation

Madjid-CH
Copy link
Contributor

PR Description

when we introduced a warning when a backend does not support inplace update in previous_backend function here that made the warning being throwed multiple times when setting a backend because we are iterating the backend_stack and calling previous_backend here so I added a flag to avoid this behavior.

ivy.set_tensorflow_backend()
 UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(
ivy.set_jax_backend()
UserWarning: The current backend: '' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
UserWarning: The current backend: 'jax' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our contributing guide and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

@Madjid-CH
Copy link
Contributor Author

Madjid-CH commented Sep 25, 2023

@vedpatwardhan I noticed you have provided a solution before I had a chance create a PR.
at least we can add the tests I added, also using the _inplace_update_cache will make the warning of a given backend appear only once even when setting the backend for a second time:

ivy.set_tensorflow_backend()
UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(
ivy.set_tensorflow_backend()

so the second time we call ivy.set_tensorflow_backend() no warning is raised. Do we want this behavior ?

Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

@vedpatwardhan I noticed you have provided a solution before I had a chance create a PR. at least we can add the tests I added, also using the _inplace_update_cache will make the warning of a given backend appear only once even when setting the backend for a second time:

ivy.set_tensorflow_backend()
UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(
ivy.set_tensorflow_backend()

so the second time we call ivy.set_tensorflow_backend() no warning is raised. Do we want this behavior ?

Yep exactly, given that the user has already seen the warning once, throwing the warning a second time could be annoying. Could you please revert the changes except for the tests? Thanks @Madjid-CH 😄

@Madjid-CH
Copy link
Contributor Author

@vedpatwardhan I noticed you have provided a solution before I had a chance create a PR. at least we can add the tests I added, also using the _inplace_update_cache will make the warning of a given backend appear only once even when setting the backend for a second time:

ivy.set_tensorflow_backend()
UserWarning: The current backend: 'tensorflow' does not support inplace updates natively. Ivy would quietly create new arrays when using inplace updates with this backend, leading to memory overhead (same applies for views). If you want to control your memory management, consider doing ivy.set_inplace_mode('strict') which should raise an error whenever an inplace update is attempted with this backend.
  warnings.warn(
ivy.set_tensorflow_backend()

so the second time we call ivy.set_tensorflow_backend() no warning is raised. Do we want this behavior ?

Yep exactly, given that the user has already seen the warning once, throwing the warning a second time could be annoying. Could you please revert the changes except for the tests? Thanks @Madjid-CH 😄

sure

@Madjid-CH Madjid-CH changed the title fix(backend handler): made one warning raised when calling ivy.set_backend test(backend handler): added tests for inplace update warnings. Sep 26, 2023
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

lgtm! Feel free to merge, thanks @Madjid-CH 😄
(Given that the tests aren't running in the CI due to a docker issue, I'd suggest running these tests and ensuring that they're passing before you merge)

@Madjid-CH
Copy link
Contributor Author

lgtm! Feel free to merge, thanks @Madjid-CH 😄 (Given that the tests aren't running in the CI due to a docker issue, I'd suggest running these tests and ensuring that they're passing before you merge)

you don't have to ask 🙌

@Madjid-CH Madjid-CH merged commit 2a037cd into ivy-llc:main Sep 27, 2023
249 of 273 checks passed
@Madjid-CH Madjid-CH deleted the inplace-update-warning-fix branch September 27, 2023 13:43
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

3 participants