-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
np.mod ~3x slower in numpy 1.20 #18607
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
Comments
Possibly related to #16161. |
@anirudh2290 Thoughts? |
Milestoneing it for now, this seems like it is probably higher on the priority list. Part of that PR was because of clang problems I think? And that part might just have been that missing |
Apologies for the delay in reply. There is a slowdown in 1.20.1 because of this PR #16161 (because of the additional is_nan and is_inf checks) which is around 30%, and I think this is expected because of the additional nan and inf checks. Doing some git bisect, I also see some additional slowdown because of #17596 which seems to be around 40% (tested with the first timeit mentioned above). Regarding the flags, the main motivation for the PR was One thing that hasn't been clearly called out in the PR is the behavior with nan's . While adding the tests for nans with divmod and friends, I realized that the nan behavior is not same across compiler versions. So the behavior was made same across the compiler versions, to keep the behavior same as the later compilers, for example: One option we may have right now, if users compiling with earlier gcc versions are running into issues because of behavior difference, is to remove the nan checks and resort to the compiler behavior. WDYT ? |
Pushing this off to 1.22.0 for tracking. There seems to be some discussion about the modifications that led to this slowdown. |
This should have been improved by gh-19316, although I am not certain how much. I think it is probably not yet quite back to the 1.19.x speed. In any case, I am going to close the issue. If it is still much slower, please re-open or comment. For now, I will consider any big remaining slow-down a failure to optimize correctly in MSVC. Looking at it in godbolt, it seems to me that |
A reference in case anyone wants to follow-up with MSVC (I am not willing to create an account just to report this): https://developercommunity.visualstudio.com/t/std::isnan-missed-optimization/417076?entry=problem&space=62&q=isnan It seems to me that they fixed it, but only for C++, and not for C?! Even on C++, I think they really fixed |
@seberg alright, thanks a lot for the updates. I'll see to make a visual studio bugreport with the info you gathered. |
Using
np.mod
with numpy 1.20 is slower than with 1.19 or 1.18.I am using a mambaforge environment with numpy packages from
conda-forge
on Windows. In all cases I have the same mkl backend (version 2020.4-hb70f87d_311)Reproducing code example:
timings with numpy 1.19.5
Version info:
1.19.5 3.8.6 | packaged by conda-forge | (default, Dec 26 2020, 04:30:06) [MSC v.1916 64 bit (AMD64)]
timings with numpy 1.20.1
Version info :
1.20.1 3.8.6 | packaged by conda-forge | (default, Dec 26 2020, 04:30:06) [MSC v.1916 64 bit (AMD64)]
I get similar timings with numpy 1.20.0.
The text was updated successfully, but these errors were encountered: