8000 Wrong result from np.linalg.cholesky on 32-bit win32 in numpy 1.13.3 · Issue #9795 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Wrong result from np.linalg.cholesky on 32-bit win32 in numpy 1.13.3 #9795

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

Closed
pv opened this issue Sep 30, 2017 · 36 comments
Closed

Wrong result from np.linalg.cholesky on 32-bit win32 in numpy 1.13.3 #9795

pv opened this issue Sep 30, 2017 · 36 comments

Comments

@pv
Copy link
Member
pv commented Sep 30, 2017

The following program produces wrong results for Numpy 1.13.3 for the 32-bit win32 wheel numpy-1.13.3-cp36-none-win32.whl:

import numpy as np
m = np.array([[1, 0.3], [0.3, 1]])
c = np.linalg.cholesky(m)
print(np.__version__, "\n", c)
assert np.allclose(c @ c.T, m)

it prints

1.13.3 
 [[ -2.00000000e+00   0.00000000e+00]
 [ -1.50000000e-01  -9.55902467e-54]]
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    assert np.allclose(c @ c.T, m)
AssertionError

The 64-bit windows wheels appear to be OK.

The result for Numpy 1.13.1 (numpy-1.13.1-cp36-none-win32.whl) is also OK:

1.13.1 
 [[ 1.         0.       ]
 [ 0.3        0.9539392]]

@pv
Copy link
Member Author
pv commented Sep 30, 2017

I can't think of other causes than a broken LAPACK/BLAS linalg library. Was the build changed between 1.13.1 and 1.13.3 (it appears yes, atlas was swapped for openblas)? Also, doesn't numpy have tests for cholesky that would have caught this?

@pv
Copy link
Member Author
pv commented Sep 30, 2017

This issue probably can be handled just with the wheel build tags...

@matthew-brett
Copy link
Contributor

No better using mingwpy build of later OpenBLAS commit : https://ci.appveyor.com/project/matthew-brett/numpy-wheels/build/job/uf1r7hsa6rmxe962

This is OpenBLAS commit 5f998ef

How easy would it be to make a minimal test case for the OpenBLAS guys?

@pv
Copy link
Member Author
pv commented Sep 30, 2017

Fairly easy, OpenMathLib/OpenBLAS#1318

@charris
Copy link
Member
charris commented Sep 30, 2017

Doesn't look to be an easy way to choose between ATLAS and OpenBLAS for building Windows wheels. The quick fix would be to use ATLAS for the four 32 bit windows wheels, then use OpenBLAS again when it is fixed.

@charris
Copy link
Member
charris commented Sep 30, 2017

So, just to clarify the procedure for bad wheels, as opposed to bad source,

  • Remove the bad wheels from PyPI, should fall back to last good release.
  • Upload good wheels, when available, using a build tag.

@rgommers Thoughts? The wheel names are already so arcane that I think adding a build tag is not much of a problem.

matthew-brett added a commit to MacPython/numpy-wheels that referenced this issue Sep 30, 2017
@matthew-brett
Copy link
Contributor

@charris - I've built the 32-bit ATLAS wheels : https://ci.appveyor.com/project/matthew-brett/numpy-wheels/build/1.0.75 - just a hack for now, using an older numpy-wheels commit. I've downloaded them, got the build tags done, can upload on your say-so.

@charris
Copy link
Member
charris commented Sep 30, 2017

@matthew-brett Let's give it a shot. I'll download them once they are up in order to redo the hashes for Github.

@charris
Copy link
Member
charris commented Sep 30, 2017

Oh, and which cythonized version did you use? Just want to make sure it was 0.26.1.

@matthew-brett
Copy link
Contributor

Oops - no - it was Cython 0.27. Silly me. Build tag 2 I guess.

@matthew-brett
Copy link
Contributor

Done rebuild with Cython 0.26.1 : https://ci.appveyor.com/project/matthew-brett/numpy-wheels/build/1.0.76

Checked they are using ATLAS, and are not the same as previous wheels built with Cython 0.27.

Added build tag. Ready to upload. This will be build tag 2...

@charris
Copy link
Member
charris commented Sep 30, 2017

Sounds good.

@matthew-brett
Copy link
Contributor

Done.

@charris
Copy link
Member
charris commented Sep 30, 2017

Great, thanks. I'll leave the other files in for a bit to see if PyPI works correctly with them there.

@pv
Copy link
Member Author
pv commented Sep 30, 2017

pip install numpy still gives the broken wheel (with no build tags).
Maybe pip just doesn't actually have support for build tags?

@pv
Copy link
Member Author
pv commented Sep 30, 2017

Ok, seems to work now (after charris deleted the old wheels --- or due to something else).

@rgommers
Copy link
Member

Maybe pip just doesn't actually have support for build tags?

My internet connection is too slow to search for it now, but I'd like to point out again that we tried using .post0 build tags before, they didn't work as expected, and we decided to not do that again.

So, just to clarify the procedure for bad wheels, as opposed to bad source,

Remove the bad wheels from PyPI, should fall back to last good release.
Upload good wheels, when available, using a build tag.

@rgommers Thoughts? The wheel names are already so arcane that I think adding a build tag is not much of a problem.

Unless we experiment with this thoroughly (not in the main numpy account) and prove that everything works as expected, I'd say that either broken wheels or broken source means we pull the whole release if the breakage is bad enough to warrant that.

@pv
Copy link
Member Author
pv commented Sep 30, 2017

If we want openblas for the windows numpy wheels, gh-9645 may be a better way to go, because that relies on vanilla mingw-w64 rather than on mingwpy.

@charris
Copy link
Member
charris commented Sep 30, 2017

@rgommers, If this works I'm inclined to leave it be. That said, IIRC, the reason for not allowing reuse of file names was that synchronizing different servers could take time. I don't know that build tags solve that problem. I think we need more feedback from the PyPA people.

@pv
Copy link
Member Author
pv commented Sep 30, 2017

Before closing this, consider fixing the numpy-wheels repo configuration.

@ghost
Copy link
ghost commented Sep 30, 2017

I thought we already had found that mingwpy caused problems. I would recommend using the same procedure in the source repository as the release repository.

@matthew-brett
Copy link
Contributor

@xoviat - yes - that's a good idea. Do you have any interest in porting your stuff over to the numpy-wheels repo?

@ghost
Copy link
ghost commented Sep 30, 2017

Yes but I think the pull request on this repository needs to be merged first (#9645).

@matthew-brett
Copy link
Contributor

For the build tags - I'm pretty confident that they work - I've used them before a few times, and we're testing it again now, with this fix. I have always deleted the previous versions after uploading the new build tag, but I suspect that's not necessary.

@charris
Copy link
Member
charris commented Oct 1, 2017

@xoviat #9645 is in.

@ghost
Copy link
ghost commented Oct 1, 2017

I'll look at the wheels repository sometime soon.

@ghost
Copy link
ghost commented Oct 1, 2017

@rgommers
Copy link
Member
rgommers commented Oct 1, 2017

@rgommers, If this works I'm inclined to leave it be. That said, IIRC, the reason for not allowing reuse of file names was that synchronizing different servers could take time. I don't know that build tags solve that problem. I think we need more feedback from the PyPA people.

Now that I've looked at it in a little more detail: what you currently did should be robust. It's not a build tag like .post0, which is a version modifier (that is the thing that should be avoided). By deleting the old wheel and putting in a new one with an extra tag -1 in this case, it should still find this wheel for the relevant OS/Python combo. It could be any tag, doesn't have to be -1, -2 etc. The only requirement is that it's a valid tag format.

@matthew-brett
Copy link
Contributor

I believe the build tag has to start with a digit - see: https://github.com/pypa/pip/blob/master/src/pip/_internal/wheel.py#L488

@rgommers
Copy link
Member
rgommers commented Oct 1, 2017

@matthew-brett you're right. And it's not just an implementation detail, there's an actual spec: https://www.python.org/dev/peps/pep-0491/#file-name-convention

I thought there were also arbitrary tags, but doesn't look like that's right. The .post0 business has been removed.

@njsmith
Copy link
Member
njsmith commented Oct 1, 2017

.post0 is still a thing; in the file name layout in PEP 491 that you linked, .post0 would be part of the version. The .post nonsense is described in PEP 440 (though even it suggests that you avoid using it).

The key distinction here is that .post0 is part of the actual version number, so as far as the tools are concerned 1.13.1.post0 is a whole new release that comes after 1.13.1. It's basically a more confusing way of spelling 1.13.1.1. OTOH a wheel build tag indicates a new build of the same release.

@charris
Copy link
Member
charris commented Oct 1, 2017

@njsmith Would be good if build tags could also be used with sources, although the naming scheme might be too flexible for that. I suspect the possiblity of different source builds was overlooked.

@njsmith
Copy link
Member
njsmith commented Oct 1, 2017

@charris I believe (for better or for worse) the concept is exactly that a given release has 1 source and possibly lots of builds, and if you want to roll a new sdist then you should bump the actual version. I guess this makes some sense; if you have multiple source builds then how do you know which ones were used for which binary builds?

@ghost
Copy link
ghost commented Oct 1, 2017 via email

@njsmith
Copy link
Member
njsmith commented Oct 1, 2017

Cythonized files in the source distribution work fine, but yeah, if you want to regenerate the cython files it means you have to bump the version number.

@charris
Copy link
Member
charris commented Dec 17, 2017

I'm going to close this. The NumPy problem seems to have been solved by moving to vanilla mingw-w64.

@charris charris closed this as completed Dec 17, 2017
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

5 participants
0