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

Add default arg values to JAX decorator #5115

Merged
merged 21 commits into from
Oct 27, 2023

Conversation

awolant
Copy link
Contributor

@awolant awolant commented Oct 24, 2023

Category:

New feature

Description:

Adds default values for device_id and num_threads for decorated JAX iterator functions. Thanks to this change it is easier to apply sharding to scale up the computation in the most common pattern.

Additional information:

Affected modules and functionalities:

JAX iterator decorator.

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-3671

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant
Copy link
Contributor Author

awolant commented Oct 24, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10415392]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10415392]: BUILD PASSED

Comment on lines 249 to 250
if 'num_threads' not in wrapper_kwargs:
wrapper_kwargs['num_threads'] = 4
Copy link
Contributor

Choose a reason for hiding this comment

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

This choice seems quite arbitrary. I'd recommend getting the number of processors (or perhaps the number of processors per GPU?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that because that's what we do it a lot in our codebase and especially in the tutorials. Do we have some benchmarks of what it does to the performance?

Copy link
Contributor

Choose a reason for hiding this comment

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

But you need to account for the number of CPUs that may need to be used for the JAX itself, the speed of the network, and things that may run in parallel.
I'm afraid that without an elaborate autotune we can't provide an accurate value here.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot of middle ground between elaborate autotune and a fixed number.
Still, I'd at least like to have a big, fat comment saying that it's subject to change.

Copy link
Contributor Author

@awolant awolant Oct 27, 2023

Choose a reason for hiding this comment

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

Done, added docs, comments and tutorial section on num_threads

Copy link
Contributor

@mzient mzient left a comment

Choose a reason for hiding this comment

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

Add a comment about the "4" not being special.

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant
Copy link
Contributor Author

awolant commented Oct 27, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10473251]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10473251]: BUILD PASSED

@awolant awolant merged commit 40a1d9f into NVIDIA:main Oct 27, 2023
4 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.

6 participants