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

Performance issue with NaN functions #2086

Open
jeshi96 opened this issue Oct 4, 2024 · 3 comments
Open

Performance issue with NaN functions #2086

jeshi96 opened this issue Oct 4, 2024 · 3 comments
Assignees

Comments

@jeshi96
Copy link

jeshi96 commented Oct 4, 2024

Hi,

I've been testing dpnp on CPU with some standard NaN functions (nan_to_num, nansum), and my performance results seem to show that dpnp is quite slow single-threaded compared to NumPy. I was wondering if you had any insight to why this might be the case (e.g., if there is something specific dpnp does in handling NaNs), and/or if there was a fix for this.

Here are some of the scalability plots (number of threads vs. running time) comparing dpnp and NumPy (and Numba), for nan_to_num and nansum respectively:

image

image

While the dpnp scaling looks good, the single-threaded performance in particular is almost an order of magnitude worse. The test environment is an Intel Xeon Platinum 8380 processor, with 80 threads. Both tests were run on arrays with 6.4e9 float32s, taking the average (median) over 10 runs and discarding the first run (so the cache is warm).

Here was the code to generate the input array for all of these tests:

import numpy as np
from numpy.random import default_rng

N = 80000
rng = default_rng(42)
array_1 = rng.uniform(0, 1000, size=(N * N,)).astype(np.float32)

N_nan = N // 10
nan_choice = np.random.choice(N * N, N_nan, replace=False)
array_1[nan_choice] = np.nan
array_1 = array_1.reshape((N, N))

For dpnp, I ran array_1 = dpnp.asarray(array_1, device="cpu") before starting the tests (not included in the timing results). The times were measuring only array_out = np.nan_to_num(array_1) or array_out = dpnp.nan_to_num(array_1) (similarly for nansum).

Any help is much appreciated -- thanks!

Best,
Jessica

@antonwolfy
Copy link
Contributor

@jeshi96 , could you please specify what dpnp version you used?
The output of python -c "import dpnp; print(dpnp.__version__)" should be enough.

@jeshi96
Copy link
Author

jeshi96 commented Oct 8, 2024

I'm using 0.17.0dev0+14.g8cab1af7f1a, from commit 8cab1af7f1a (built from source). I'm also using dpctl built from source (0.19.0dev0+44.g8c47c65635, from commit 8c47c65635).

@jeshi96
Copy link
Author

jeshi96 commented Nov 4, 2024

Hi, I just wanted to follow up on this and see if you had any idea of the possible cause -- I saw that there was a new release, and reran the tests on the latest commits (of both dpnp and dpctl), but with the same effect. Thanks!

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

No branches or pull requests

2 participants