Skip to content

python3Packages.numpy: fix failing tests and clang 16#244250

Merged
vcunat merged 3 commits intoNixOS:staging-nextfrom
reckenrode:numpy-fixes
Jul 20, 2023
Merged

python3Packages.numpy: fix failing tests and clang 16#244250
vcunat merged 3 commits intoNixOS:staging-nextfrom
reckenrode:numpy-fixes

Conversation

@reckenrode
Copy link
Copy Markdown
Contributor

Description of changes

This PR fixes the failing tests on Darwin. The clang 16 fix was submitted upstream.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Jul 19, 2023
Copy link
Copy Markdown
Contributor

@tjni tjni left a comment

Choose a reason for hiding this comment

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

Apart from one comment, LGTM.

I think this should target staging-next (I think numpy will start to be broken there).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should use the commit link in case the PR has to be amended:

https://github.com/numpy/numpy/commit/609fee4324f3521d81a3454f5fcc33abb0d3761e.patch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I switched it to use the commit link.

@reckenrode reckenrode changed the base branch from staging to staging-next July 19, 2023 01:32
@reckenrode
Copy link
Copy Markdown
Contributor Author

I think this should target staging-next (I think numpy will start to be broken there).

I also retargeted it to staging-next.

@ofborg ofborg bot requested a review from FRidh July 19, 2023 01:52
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jul 19, 2023
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please make this unconditional, none of the core python maintainers uses a Mac regularly to test numpy updates

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can move the conditional to the Python-side, but it seems like the test should be run on platforms where it is expected to work. The patch itself just uses pytest.mark.skipif to skip the complex256 test on x86_64-darwin.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, I see the complication that we already have lots of binaries on other platforms and this would make them rebuild again, slowing everything down.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then we can send a patch to staging afterwards making this unconditional

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes. It's slightly more complicated to do, but otherwise sounds like a very good solution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Won’t the other patches cause rebuilds regardless? Am I making all of the changes conditional?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should be able to sleep name this unconditional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can make this patch apply unconditionally. It can be dropped with the derivation is updated to numpy 1.25.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We probably don't want to include the other patches based on distutils

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That was already in the derivation. I assumed it was necessary until numpy is updated and switched to meson.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was more hinting that we need to close the list here before adding the other patches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, you’re right. I completely missed the conditional. I understand now and will push a fix for that piece.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I meant talking about the whole bunch, as they don't seem useful/needed for our gcc linux builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made each of the patches conditional.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This got uglier than I expected. Cleanup PR: #244461

@reckenrode reckenrode force-pushed the numpy-fixes branch 3 times, most recently from 6422c40 to 5c7d9aa Compare July 19, 2023 16:14
@reckenrode
Copy link
Copy Markdown
Contributor Author

Latest push reflects the requested changes.

@vcunat vcunat mentioned this pull request Jul 19, 2023
1 task
* Fix an invalid function pointer conversion; and
* Disable strict overflow hardening due to an unused argument warning
  that is promoted to -Werror.
The `atanhl` function is broken under Rosetta 2 with 80-bit long
doubles, which numpy uses to implement long double complex numbers. This
results in a test failure. Attempts were made to change the
implementation of things, but that just changed the breakage.

The following Swift program demonstrates the problem.

    import Foundation
    import Numerics

    let x = Float80(1.00000000e-20)
    let z = Complex(x)

    print("X: \(x), Z: \(z)")

    let x_atanh = Float80.atanh(x)
    let z_atanh = Complex.atanh(z)

    print("atanh:")
    print("X: \(x_atanh), Z: \(z_atanh)")

    let d = abs(x_atanh / z_atanh.real - 1)

    print("d: \(d)")

On x86_64-darwin hardware, it prints the following:

    X: 1e-20, Z: (1e-20, 0.0)
    atanh:
    X: 1e-20, Z: (1e-20, 0.0)
    d: 0.0

On aarch64-darwin under Rosetta 2, it prints the following:

   X: 1e-20, Z: (1e-20, 0.0)
   atanh:
   X: 1e-20, Z: (-1.0237493319595677839e-40, 0.0)
   d: 9.7680161420558978584e+19

The latter is obviously incorrect. FB12656897 was submitted to Apple,
but even if this is fixed eventually, this derivation needs to build for
users (and Hydra) who aren’t on the latest version.
vcunat added a commit that referenced this pull request Jul 20, 2023
@vcunat vcunat merged commit 4f923aa into NixOS:staging-next Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants