[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-06-13 Thread Matti Picus
In PR 23925 the tests for allowed ULP error for sin and cos were tightened for float32 and float64 to 1.49 and 1.00 respectively. The use of SVML/SIMD routines for sin/cos on float64 was disabled across the board, and the checks all pass. People using the latest

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Allan, Daniel via NumPy-Discussion
/ Dan Daniel B. Allan, Ph.D (he/him) Data Science and Systems Integration NSLS-II Brookhaven National Laboratory From: Thomas Caswell Sent: Wednesday, May 31, 2023 6:38 PM To: Discussion of Numerical Python Subject: [Numpy-discussion] Re: Precision changes to sin/cos

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Thomas Caswell
Just for reference, this is the current results on the numpy main branch at special points: In [1]: import numpy as np In [2]: np.sin(0.0) Out[2]: 0.0 In [3]: np.cos(0.0) Out[3]: 0. In [4]: np.cos(2*np.pi) Out[4]: 0.9998 In [5]: np.sin(2*np.pi) Out[5]:

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Robert Kern
On Wed, May 31, 2023 at 5:51 PM Benjamin Root wrote: > I think it is the special values aspect that is most concerning. Math is > just littered with all sorts of identities, especially with trig functions. > While I know that floating point calculations are imprecise, there are > certain

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Aaron Meurer
On Wed, May 31, 2023 at 3:51 PM Benjamin Root wrote: > > I think it is the special values aspect that is most concerning. Math is just > littered with all sorts of identities, especially with trig functions. While > I know that floating point calculations are imprecise, there are certain >

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Benjamin Root
I think it is the special values aspect that is most concerning. Math is just littered with all sorts of identities, especially with trig functions. While I know that floating point calculations are imprecise, there are certain properties of these functions that still held, such as going from -1

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Robert Kern
On Wed, May 31, 2023 at 5:01 PM David Menéndez Hurtado < davidmen...@gmail.com> wrote: > On Wed, 31 May 2023, 22:41 Robert Kern, wrote: > >> Not sure anyone really uses tanh for serious work. >> > > At the risk of derailing the discussion, the case I can think of (but kind > of niche) is using

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread David Menéndez Hurtado
On Wed, 31 May 2023, 22:41 Robert Kern, wrote: > Not sure anyone really uses tanh for serious work. > At the risk of derailing the discussion, the case I can think of (but kind of niche) is using neural networks to approximate differential equations. Then you need non linearities in the

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Robert Kern
On Wed, May 31, 2023 at 12:37 PM Devulapalli, Raghuveer < raghuveer.devulapa...@intel.com> wrote: > I wouldn’t the discount the performance impact on real world benchmarks > for these functions. Just to name a couple of examples: > > > >- 7x speed up of np.exp and np.log results in a 2x speed

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Andrew Nelson
What is the effect of these changes for transcendental functions in the complex plane? ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Devulapalli, Raghuveer
I wouldn't the discount the performance impact on real world benchmarks for these functions. Just to name a couple of examples: * 7x speed up of np.exp and np.log results in a 2x speed up of training neural networks like logistic regression [1]. I would expect np.tanh will show similar

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Charles R Harris
On Wed, May 31, 2023 at 9:12 AM Robert Kern wrote: > On Wed, May 31, 2023 at 10:40 AM Ralf Gommers > wrote: > >> >> >> On Wed, May 31, 2023 at 4:19 PM Charles R Harris < >> charlesr.har...@gmail.com> wrote: >> >>> >>> >>> On Wed, May 31, 2023 at 8:05 AM Robert Kern >>> wrote: >>> I would

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Stefano Miccoli via NumPy-Discussion
On 31 May 2023, at 16:32, numpy-discussion-requ...@python.org wrote: It seems fairly clear that with this recent change, the feeling is that the tradeoff is bad and that too much accuracy was lost, for not enough real-world gain. However, we now

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Robert Kern
On Wed, May 31, 2023 at 10:40 AM Ralf Gommers wrote: > > > On Wed, May 31, 2023 at 4:19 PM Charles R Harris < > charlesr.har...@gmail.com> wrote: > >> >> >> On Wed, May 31, 2023 at 8:05 AM Robert Kern >> wrote: >> >>> I would much, much rather have the special functions in the `np.*` >>>

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Jerome Kieffer
On Wed, 31 May 2023 15:59:45 +0300 Matti Picus wrote: > There is a discussion about a runtime context variable/manager that > would extend errorstate to have a precision flag as well in > https://github.com/numpy/numpy/issues/23362. I like this idea ... -- Jérôme Kieffer tel +33 476 882 445

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Ralf Gommers
On Wed, May 31, 2023 at 4:19 PM Charles R Harris wrote: > > > On Wed, May 31, 2023 at 8:05 AM Robert Kern wrote: > >> I would much, much rather have the special functions in the `np.*` >> namespace be more accurate than fast on all platforms. These would not >> have been on my list for general

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Thomas Caswell
I am not in favor of reverting this change. We already accounted for this in Matplotlib ( https://github.com/matplotlib/matplotlib/issues/25789 and https://github.com/matplotlib/matplotlib/pull/25813). It was not actually that disruptive and mostly identified tests that were too brittle to begin

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Charles R Harris
On Wed, May 31, 2023 at 8:05 AM Robert Kern wrote: > I would much, much rather have the special functions in the `np.*` > namespace be more accurate than fast on all platforms. These would not > have been on my list for general purpose speed optimization. How much time > is actually spent inside

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Matthew Brett
On Wed, May 31, 2023 at 3:04 PM Robert Kern wrote: > > I would much, much rather have the special functions in the `np.*` namespace > be more accurate than fast on all platforms. These would not have been on my > list for general purpose speed optimization. How much time is actually spent >

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Robert Kern
I would much, much rather have the special functions in the `np.*` namespace be more accurate than fast on all platforms. These would not have been on my list for general purpose speed optimization. How much time is actually spent inside sin/cos even in a trig-heavy numpy program? And most numpy

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Matti Picus
On 31/5/23 14:12, Matthew Brett wrote: The ideal would be a run-time toggle for people to experiment with, with binary wheels. Is that practical? Cheers, Matthew There is a discussion about a runtime context variable/manager that would extend errorstate to have a precision flag as well

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Matthew Brett
Hi, On Wed, May 31, 2023 at 11:52 AM Ralf Gommers wrote: > > > > On Wed, May 31, 2023 at 12:28 PM Chris Sidebottom > wrote: >> >> Matthew Brett wrote: >> > Hi, >> > On Wed, May 31, 2023 at 8:40 AM Matti Picus matti.pi...@gmail.com wrote: >> > > On 31/5/23 09:33, Jerome Kieffer wrote: >> > > Hi

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Chris Sidebottom
Ralf Gommers wrote: > On Wed, May 31, 2023 at 12:28 PM Chris Sidebottom chris.sidebot...@arm.com > wrote: > > Matthew Brett wrote: > > Hi, > > On Wed, May 31, 2023 at 8:40 AM Matti Picus matti.pi...@gmail.com wrote: > > On 31/5/23 09:33, Jerome Kieffer wrote: > > Hi Sebastian, > > I had a quick

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Ralf Gommers
On Wed, May 31, 2023 at 12:28 PM Chris Sidebottom wrote: > Matthew Brett wrote: > > Hi, > > On Wed, May 31, 2023 at 8:40 AM Matti Picus matti.pi...@gmail.com wrote: > > > On 31/5/23 09:33, Jerome Kieffer wrote: > > > Hi Sebastian, > > > I had a quick look at the PR and it looks like you

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread David Menéndez Hurtado
What about having a np.fastmath module for faster, lower precision implementations? The error guarantees there would be lower, and possibly hardware dependent. By default we get the high precision version, but if the user knows what they are doing, they can get the speed. /David On Wed, 31 May

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Chris Sidebottom
Matthew Brett wrote: > Hi, > On Wed, May 31, 2023 at 8:40 AM Matti Picus matti.pi...@gmail.com wrote: > > On 31/5/23 09:33, Jerome Kieffer wrote: > > Hi Sebastian, > > I had a quick look at the PR and it looks like you re-implemented the > > sin-cos > > function using SIMD. > > I wonder how it

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Matthew Brett
Hi, On Wed, May 31, 2023 at 8:40 AM Matti Picus wrote: > > > On 31/5/23 09:33, Jerome Kieffer wrote: > > Hi Sebastian, > > > > I had a quick look at the PR and it looks like you re-implemented the > > sin-cos > > function using SIMD. > > I wonder how it compares with SLEEF (header only library,

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Matti Picus
On 31/5/23 09:33, Jerome Kieffer wrote: Hi Sebastian, I had a quick look at the PR and it looks like you re-implemented the sin-cos function using SIMD. I wonder how it compares with SLEEF (header only library, CPU-architecture agnostic SIMD implementation of transcendental functions with

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Sebastian Berg
On Tue, 2023-05-30 at 23:31 -0700, Stefan van der Walt wrote: > Hi Sebastian, > > Could you clarify whether there are now varying code paths, depending > on the CPU features available? There is less variation then before because the new code path will be taken on practically all CPUs and I

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Jerome Kieffer
Hi Sebastian, I had a quick look at the PR and it looks like you re-implemented the sin-cos function using SIMD. I wonder how it compares with SLEEF (header only library, CPU-architecture agnostic SIMD implementation of transcendental functions with precision validation). SLEEF is close to the

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Stefan van der Walt
Hi Sebastian, Could you clarify whether there are now varying code paths, depending on the CPU features available? As mentioned on the skimage issue, if results differ but errors are reduced across the board, I'd be happy to fix the test suite. But if this simply jiggers results, I'm less

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Juan Nunez-Iglesias
On Wed, 31 May 2023, at 4:11 PM, Juan Nunez-Iglesias wrote: > For me it is indeed too surprising, and I would be in favour of reverting. ( Incidentally I wrote that before seeing https://github.com/scikit-image/scikit-image/pull/6970 ) > On Wed, 31 May 2023, at 3:55 PM, Sebastian Berg wrote:

[Numpy-discussion] Re: Precision changes to sin/cos in the next release?

2023-05-31 Thread Juan Nunez-Iglesias
For me it is indeed too surprising, and I would be in favour of reverting. On Wed, 31 May 2023, at 3:55 PM, Sebastian Berg wrote: > Hi all, > > there was recently a PR to NumPy to improve the performance of sin/cos > on most platforms (on my laptop it seems to be about 5x on simple > inputs). >