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

Optimize dtype conversion for FIL #4070

Merged
merged 5 commits into from
Jul 28, 2021

Conversation

dantegd
Copy link
Member

@dantegd dantegd commented Jul 19, 2021

cc @canonizer @levsnv @wphicks

After doing a little bit of profiling for the slowness we observed for FIL when data had to be converted from int16 to float32 I found out that ~98% of the time was being spent in the check of whether there would be information lost to under/overflows in

return ((X < target_dtype_range.min) |

Created this proposal PR to add a parameter to skip that check in methods that are fast enough to benefit from fast dtype conversion like FIL as well as skip the check when upcasting.

In my first quick benchmarks the dtype conversion was between 4x~14x faster when disabling the checks in some cases. PR is still in progress, but figured I'd ping you in case you wanted to take a look

@dantegd dantegd added the 2 - In Progress Currenty a work in progress label Jul 19, 2021
@dantegd dantegd added this to PR-WIP in v21.08 Release via automation Jul 19, 2021
@github-actions github-actions bot added the Cython / Python Cython or Python issue label Jul 19, 2021
@dantegd dantegd added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 19, 2021
@levsnv
Copy link
Contributor

levsnv commented Jul 20, 2021

nice! much better than current state

@canonizer
Copy link
Contributor

Thanks for looking into this!

Thinking further: I think the conversion (implemented on the GPU) can be fast even with the accuracy check enabled.

@dantegd dantegd changed the title Optimize dtype conversion Optimize dtype conversion for FIL Jul 28, 2021
@dantegd dantegd marked this pull request as ready for review July 28, 2021 01:47
@dantegd dantegd requested a review from a team as a code owner July 28, 2021 01:47
Copy link
Contributor

@wphicks wphicks left a comment

Choose a reason for hiding this comment

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

Looks great! Very nice improvement. Just a grammatical issue in 2 places in the docstrings, but otherwise everything looks perfect to me.

python/cuml/fil/fil.pyx Outdated Show resolved Hide resolved
python/cuml/fil/fil.pyx Outdated Show resolved Hide resolved
@dantegd dantegd changed the title Optimize dtype conversion for FIL Optimize dtype conversion for FIL [skip-ci] Jul 28, 2021
dantegd and others added 2 commits July 28, 2021 10:04
Co-authored-by: William Hicks <wphicks@users.noreply.github.com>
@dantegd dantegd changed the title Optimize dtype conversion for FIL [skip-ci] Optimize dtype conversion for FIL Jul 28, 2021
@dantegd
Copy link
Member Author

dantegd commented Jul 28, 2021

rerun tests

Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

LGTM

v21.08 Release automation moved this from PR-WIP to PR-Reviewer approved Jul 28, 2021
@dantegd
Copy link
Member Author

dantegd commented Jul 28, 2021

@gpucibot merge

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.08@3c11ebd). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.08    #4070   +/-   ##
===============================================
  Coverage                ?   85.83%           
===============================================
  Files                   ?      231           
  Lines                   ?    18272           
  Branches                ?        0           
===============================================
  Hits                    ?    15684           
  Misses                  ?     2588           
  Partials                ?        0           
Flag Coverage Δ
dask 48.20% <0.00%> (?)
non-dask 78.31% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c11ebd...5ac3cb8. Read the comment docs.

@rapids-bot rapids-bot bot merged commit f2e4652 into rapidsai:branch-21.08 Jul 28, 2021
v21.08 Release automation moved this from PR-Reviewer approved to Done Jul 28, 2021
vimarsh6739 pushed a commit to vimarsh6739/cuml that referenced this pull request Oct 9, 2023
cc @canonizer @levsnv @wphicks 

After doing a little bit of profiling for the slowness we observed for FIL when data had to be converted from int16 to float32 I found out that ~98% of the time was being spent in the check of whether there would be information lost to under/overflows in https://github.com/rapidsai/cuml/blob/c3c4376ab8a3af3e0c92aa2c9ae5d8b8fe116b8c/python/cuml/common/input_utils.py#L590

Created this proposal PR to add a parameter to skip that check in methods that are fast enough to benefit from fast dtype conversion like FIL as well as skip the check when upcasting.

 In my first quick benchmarks the dtype conversion was between **4x~14x** faster when disabling the checks in some cases. PR is still in progress, but figured I'd ping you in case you wanted to take a look

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - William Hicks (https://github.com/wphicks)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: rapidsai#4070
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - In Progress Currenty a work in progress Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants