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: array_indices_axis helper updated to use args to control vals from dtypes_and_values helper #28168

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

Kacper-W-Kozdon
Copy link
Contributor

@Kacper-W-Kozdon Kacper-W-Kozdon commented Feb 3, 2024

PR Description

array_indices_axis helper updated to use args to control vals from dtypes_and_values helper.

Related Issue

array_indices_axis helper function did not ensure that generated values made sense for the dtype, for example generating values of the order 1e+38 for dtype float16. It might be the cause of some pytest fails.

Closes #

Checklist

  • Did you add a function?
  • Did you add the tests?
  • Did you run your tests and are your tests passing?
  • Did pre-commit not fail on any check?
  • Did you follow the steps we provided?

Socials

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.

@Kacper-W-Kozdon
Copy link
Contributor Author

Hey, @joaozenobio , maybe you would like to take a look? It's a small change :) And it might solve the errors popping up in the test_gather()

@joaozenobio
Copy link
Contributor

joaozenobio commented Feb 5, 2024

Hi @Kacper-W-Kozdon! Thank you for your PR 🚀 The modifications are valid. Could you confirm that those are enough to make the errors vanish by testing on your current torch.gather() with them? So you don't have to make another PR to solve the same issue again 😄

@Kacper-W-Kozdon
Copy link
Contributor Author

Hi @Kacper-W-Kozdon! Thank you for your PR 🚀 The modifications are valid. Could you confirm that those are enough to make the errors vanish by testing on your current torch.gather() with them? So you don't have to make another PR to solve the same issue again 😄

Test with 500 examples just on the torch backend, so it should be fine this time :) The errors in the end were caused by the mismatch between the effective range of dtypes and the order of the generated values- together with the gradient flag being set to True (that's where the too big values caused issues before the addition of safeties). Both PRs are ready for the review (maybe a separate pytest run); #27757 is already updated with the arguments large_abs_safety_factor=1.5, small_abs_safety_factor=1.5, safety_factor_scale="log", with the values being suggested by Ved.

$ pytest -s -v --num-examples=500 --full-trace --debug=pytestdebug.log ivy_tests/test_ivy/test_functional/test_core/test_general.py::test_gather[cpu-torch-False-False]
writing pytest debug information to pytestdebug.log
Use Database in ReadOnly Mode with local caching !
================================================= test session starts ==================================================platform linux -- Python 3.10.0, pytest-7.4.4, pluggy-1.4.0 -- /home/bubble/miniconda3/envs/ivy_dev/bin/python
using: pytest-7.4.4
setuptools registered plugins:
  pytest-json-report-1.5.0 at /home/bubble/miniconda3/envs/ivy_dev/lib/python3.10/site-packages/pytest_jsonreport/plugin.py
  hypothesis-6.97.0 at /home/bubble/miniconda3/envs/ivy_dev/lib/python3.10/site-packages/_hypothesis_pytestplugin.py
  pytest-metadata-3.0.0 at /home/bubble/miniconda3/envs/ivy_dev/lib/python3.10/site-packages/pytest_metadata/plugin.py
  anyio-4.2.0 at /home/bubble/miniconda3/envs/ivy_dev/lib/python3.10/site-packages/anyio/pytest_plugin.py
cachedir: .pytest_cache
hypothesis profile 'ivy_profile' -> print_blob=True, max_examples=500, deadline=timedelta(milliseconds=500000), suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much, HealthCheck.data_too_large], database=MultiplexedDatabase(DirectoryBasedExampleDatabase(PosixPath('/home/bubble/ivy/.hypothesis/examples')), ReadOnlyDatabase(RedisExampleDatabase(Redis<ConnectionPool<Connection<host=redis-17011.c259.us-central1-2.gce.cloud.redislabs.com,port=17011,db=0>>>, expire_after=datetime.timedelta(days=8))))
metadata: {'Python': '3.10.0', 'Platform': 'Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.35', 'Packages': {'pytest': '7.4.4', 'pluggy': '1.4.0'}, 'Plugins': {'json-report': '1.5.0', 'hypothesis': '6.97.0', 'metadata': '3.0.0', 'anyio': '4.2.0'}}
backend(s): all
device: cpu
number of Hypothesis examples: 500
rootdir: /home/bubble/ivy
plugins: json-report-1.5.0, hypothesis-6.97.0, metadata-3.0.0, anyio-4.2.0
collected 1 item

ivy_tests/test_ivy/test_functional/test_core/test_general.py::test_gather[cpu-torch-False-False] PASSED

Copy link
Contributor

@Ishticode Ishticode 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 @Kacper-W-Kozdon. These additional controls should have been already in array_indices_axis helper as they are pretty important sometimes but great that you added them now. Will merge this and will take a look at the other PR for gather. Thank you very much for the effort : )

@Ishticode Ishticode merged commit c3980e6 into ivy-llc:main Feb 14, 2024
275 of 285 checks passed
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