Skip to content

Conversation

khushi-411
Copy link
Contributor

@khushi-411 khushi-411 commented Jun 16, 2022

TODO

  • add benchmarks

Benchmarks:

size dtype SciPy CuPy
1000 int8 0.119 ms 0.203 ms
1000 int32 0.111 ms 0.201 ms
1000 uint32 0.115 ms 0.201 ms
1000 float32 0.283 ms 0.207 ms
1000 float64 0.257 ms 0.207 ms
100000 int8 11.396 ms 8.503 ms
100000 int32 11.705 ms 7.147 ms
100000 uint32 11.495 ms 6.202 ms
100000 float32 17.490 ms 6.235 ms
100000 float64 17.482 ms 6.227 ms
1000000 int8 114.541 ms 60.157 ms
1000000 int32 110.311 ms 58.221 ms
1000000 uint32 109.507 ms 58.139 ms
1000000 float32 164.692 ms 59.586 ms
1000000 float64 165.868 ms 62.705 ms
Script: Click Please

import cupy
import cupyx

import scipy

from cupy import testing
from cupyx.profiler import benchmark


n_warmup = 1
n_repeat = 10
dtype_set = ('int8', 'int32', 'uint32', 'float32', 'float64')
n_set = (1000, 100000, 1000000)


def get_time(pref):
    cpu_time = pref.cpu_times.mean()
    gpu_time = pref.gpu_times.mean()
    return max(cpu_time, gpu_time) * 1000  # ms


def time_expn(a, b):
    cp_a = cupy.array(a)
    cp_b = cupy.array(b)
    ref = scipy.special.expn(a, b)
    ret = cupyx.scipy.special.expn(cp_a, cp_b)
    times = []
    perf = benchmark(scipy.special.expn, (a, b),
                     n_warmup=n_warmup, n_repeat=n_repeat)
    times.append(get_time(perf))
    perf = benchmark(cupyx.scipy.special.expn, (cp_a, cp_b),
                     n_warmup=n_warmup, n_repeat=n_repeat)
    times.append(get_time(perf))
    return times


print('size | dtype | SciPy | CuPy')
print('-----|-------|-------|-----')
for n in n_set:
    for dtype in dtype_set:
        a = scipy.random.randint(0, 2, size=n).astype(dtype)
        b = scipy.random.randint(0, 10, size=n).astype(dtype)
        times = time_expn(a, b)
        print('{} | {} | {:.3f} ms | {:.3f} ms'.format(n, dtype, times[0], times[1]))

@takagi takagi self-assigned this Jun 17, 2022
@khushi-411 khushi-411 marked this pull request as ready for review June 25, 2022 19:18
@takagi
Copy link
Contributor

takagi commented Jun 27, 2022

/test mini

@khushi-411
Copy link
Contributor Author

khushi-411 commented Jun 27, 2022

I think this failure is unrelatable to the PR:

Last 10 lines from the test output: |  
-- | --
00:49:43.379276 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_8_{indexes=[[1, 0], 2], shape=(2, 3, 4), value=1}] |  
00:49:43.379775 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_9_{indexes=[[1], slice(1, 2, None)], shape=(2, 3, 4), value=1}] |  
00:49:43.379775 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_10_{indexes=[[[1]], slice(1, 2, None)], shape=(2, 3, 4), value=1}] |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_f_contiguous |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_smaller[F-(3, 5)] |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_larger[F-(6, 5)] |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_larger[F-(2, 3)] |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\creation_tests\test_basic.py::TestBasic::test_empty_zero_sized_array_strides |  
00:49:43.380175 STDOUT 3240] | FAILED cupy_tests\functional_tests\test_vectorize.py::TestVectorizeOps::test_vectorize_div |  
00:49:43.380175 STDOUT 3240] | = 28 failed, 96133 passed, 5852 skipped, 689 deselected, 151 xfailed, 2569 warnings in 2247.59s (0:37:27) =

Last 10 lines from the test output:	
[00:49:43.379276 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4877)	FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_8_{indexes=[[1, 0], 2], shape=(2, 3, 4), value=1}]	
[00:49:43.379775 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4879)	FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_9_{indexes=[[1], slice(1, 2, None)], shape=(2, 3, 4), value=1}]	
[00:49:43.379775 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4881)	FAILED cupy_tests\core_tests\test_ndarray_adv_indexing.py::TestArrayAdvancedIndexingSetitemScalarValueDeprecated::test_adv_setitem[_param_10_{indexes=[[[1]], slice(1, 2, None)], shape=(2, 3, 4), value=1}]	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4883)	FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_f_contiguous	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4884)	FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_smaller[F-(3, 5)]	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4885)	FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_larger[F-(6, 5)]	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4886)	FAILED cupy_tests\core_tests\test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_view_flags_larger[F-(2, 3)]	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4887)	FAILED cupy_tests\creation_tests\test_basic.py::TestBasic::test_empty_zero_sized_array_strides	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4888)	FAILED cupy_tests\functional_tests\test_vectorize.py::TestVectorizeOps::test_vectorize_div	
[00:49:43.380175 STDOUT 3240]](https://ci.preferred.jp/cupy.win.cuda116/104629/#L4889)	= 28 failed, 96133 passed, 5852 skipped, 689 deselected, 151 xfailed, 2569 warnings in 2247.59s (0:37:27) =

What do you think? Thanks!

@takagi
Copy link
Contributor

takagi commented Jun 27, 2022

Yes, its because of NumPy 1.23 that is recently released, and I'm working on fixing it.

Copy link
Contributor

@takagi takagi left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@takagi takagi left a comment

Choose a reason for hiding this comment

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

LGTM!

@takagi takagi added this to the v11.0.0rc1 milestone Jun 27, 2022
@takagi takagi added the cat:feature New features/APIs label Jun 27, 2022
@khushi-411
Copy link
Contributor Author

Thanks a lot for your suggestions and guidance! :)

@takagi
Copy link
Contributor

takagi commented Jun 27, 2022

Would you merge this as the failure of cupy.win.cuda116 is not related? @kmaehashi

@takagi
Copy link
Contributor

takagi commented Jun 27, 2022

Thanks for your work, @khushi-411!

@kmaehashi kmaehashi merged commit bd1cd7e into cupy:master Jun 28, 2022
@khushi-411 khushi-411 deleted the add_expn branch June 28, 2022 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:feature New features/APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants