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
BUG: const
signature changes in cython_blas
and cython_lapack
broke backwards compatibility
#18377
Comments
cc @andyfaff maybe you have some idea as you've been working through some linalg stuff lately |
Yes there are a few changes happening simultaneously (new cython stuff and CI changes). I am also identifying them one by one on #18358 but most issues are now gone apart from a unicode problem for cython if you rebase to You have to clear the cache I think to get rid of the old Cython signatures. |
Is it possible this is actually a |
|
Okay I'll open a scikit-learn issue to see if they want to deal with that at their end |
The wheel building infrastructure hasn't been touched for a while, so any problems with a wheel is probably coming from a different place. The work in the CI has been transferring jobs from azure to gha, but none of them re responsible for issuing wheels for public consumption. |
Agreed #18247 is probably the culprit because the failure reported there is similar and the signature change is problematic. We'll see what the scikit-learn folks say, more likely they need to change something at their end to accommodate this signature change. I guess older SciPy wheels could have the old signature and newer wheels the new one so they'll have to be able/willing to use either of them. |
Is there a 160 character summary of the benefits of #18247? I had a quick look at the top comment in the PR but couldn't find benchmarks or other hint. I think for existing scikit-learn releases it is going to be difficult to adjust to this change in the function signature. For future scikit-learn releases we'd need a way to support both old and new versions of scipy (across this signature change). Does someone have an example of how to do this/existing code to look at? |
Hi all, I think it would have been nice to synchronize with downstream libraries' maintainers before changing those FFI which have been stable for many years. To me, those seemingly simple changes on those interfaces introduce a significant burden for scikit-learn's maintenance. It might also tbe the case for other libraries'. Moreover (and independently of a maintenance perspective), I think some users' workflows will break if those changes are released. Could you please revert this merge commit and could we synchronize and agree on a pathway to resolve #14262? Thank you. 🙏 |
I want to first understand what the problem would be. These don't change any argument types or number of arguments or their order. They only change the signatures. So are you saying that you redefine the signatures on the scikit-learn side? These are not backported changes hence each SciPy is consistent within itself. So many things resolve when you invalidate cache and rebuild. What am I missing here regarding downstream? |
For dasum for example this is the new one
replacing the old one
is this causing a problem ? Excuse my ignorance I am genuinely curious |
scikit-learn/scikit-learn#26290 (comment) has the error and steps to reproduce the problem. I think what happens is that the scikit-learn nightly wheel is built with scipy 1.10.1 and I think it is then used with the latest scipy. Another case where I am not sure what will happen is something like scikit-learn 1.2.2 where the wheel will have been built with a version of scipy that contains the old signature. Will the existing scikit-learn 1.2.2 wheel work with the next release of scipy that contains the new signatures? |
Also, if newer versions of SciPy featuring these changes were to be released, errors might be present with older versions of scikit-learn (i.e. |
I think it goes the other way. Because in my limited understanding, I am not sure if this will leak into wheels but seems like a nightly build problem. But admittedly I can't quite make up my mind yet. Because once you compile the cython files they are not (or shouldn't be) necessarily dynamically linking to scipy but to the BLAS lib. But then I don't have an answer why this is happening. So clearly I don't know enough. @lysnikolaou @rgommers any thoughts? |
@betatim
|
I was very happy to see the const added to the signatures. My limited understanding is that this is a build problem, not a runtime problem. So it should not be that hard to fix (on the scikit-learn side). Scipy now is (a tiny bit) more correct 😄 |
I'm running into this on a bog-standard dev setup on linux with mamba. Basically, |
@ev-br could you please try to build from fresh? The prebuilt files before the PR are typically conflicting. |
Yes, |
I think this is almost certainly going to be the case. I can check if people really want to know. But that would be too disruptive to the ecosystem I think. FYI it shows up on Windows now, too (haven't tested macOS): My vote is to revert the |
+1 |
Indeed if this is causing issues I agree with that. But I don't see how future will solve this problem other than pinning scipy >= 1.11 |
Unfortunately, pinning #14262 (comment) gives details about two failing configurations (there might be more). |
True but at some point we have to bite the bullet by not supporting old SciPy hence the conda or pip install need to upgrade SciPy too otherwise we can't use |
Aside from feasibility, I think it would make the number of failure modes blow up even more.
conda(-forge) can handle this much more easily (e.g. patching in a constraint Assuming such a harsh break is not in the cards, such a path would be quite painful regardless when & how it's rolled out, so I'm wondering if we can turn it around by doing some C-API versioning like numpy does: e.g. if we encounter something compiled against a newer API version that what (an old) scipy has at runtime, then we error out. The main issue is that we'd need to leave these markers in the compiled sources somewhere and then check against them, and of course do that for a while in published versions before we can rely on it. |
First we need confirmation that a sklearn (or any other package) built with new SciPy with const fails to work with an old SciPy at runtime before anything. In sklearn case they apparently also modified the signatures which is a different story altogether. |
When possible, Scikit-learn prefers to use
Using
Note, this is the reverse error from mne-python's failing test run:
|
Thanks @thomasjpfan for verifying. CI machines always do some tricky stuff that we can never be sure.
Why would that be a throw-away? We do that all the time with our upstream with Cython or any other package, we don't enforce NumPy because there are multiple cases that lead to problems in the past for jumping the gun. I don't think we have to be such conservative everytime for every case. By the way, I am not saying we should not revert this, we will do it anyways but at some point SciPy will have to do this. So the challenge here is to find a solution that is easy enough for downstream to accept. Not doing it is not a viable option and just way too problematic for us since it is becoming an issue.
Leaving markers and checking them is not an issue, we can do it. But in case of incompatibility, what would it say? Install a newer scipy version? That won't work because sklearn would still be compiled with the old nonconst signatures because we didn't release it due to compatibility issues. It will just keep on delaying things. At some point we have to address this. Unless we want to keep two copies of the signatures (which is also fine for me) but not very hopeful that it would push people to switch to the new one. |
And having cython breaking changes, pythran breaking changes and this happening at the same weekend is really not helping either 😃 |
Maybe it's worth asking if Cython could have some way to optionally disable that runtime signature check in specific cases (e.g. for adding const)? From what I understand if the runtime check is relaxed, things might just work? |
I'm warming up to the idea that we should keep two copies of this file. And use some sort of And again, please keep us in the loop when you are working on the signatures downstream. We should be able to move together as this affects almost every C-API using package, as I just painfully learned here. |
The signature changes are reverted and I just started a run of the nightly wheel builds, so the problem for scikit-learn & co should disappear in an hour or so once the new nightlies are uploaded. |
const
signature changes in cython_blas
and cython_lapack
broke backwards compatibility
@ilayn this issue got quite long pretty quickly. How about we close it, and open a new issue with a good summary and a focus on re-introducing the |
Thanks for all the brain power to work this out! A new issue sounds like a good idea, could you post a message here that links to it once it exists? I think if you just refer to this issue from the new one there won't be a notification to participants of this issue, and I'd be interested in following along. |
Yes I'll do that this evening, thanks everyone. And apologies for wreaking havoc downstream (sigh... again...) |
It's okay, this kind of mistake happens and can be fixed easily. 🙂 I would be happy participating to discussing to best introduce |
@ilayn Did you maybe get some time to open a new issue with the summary of the findings so far regarding this? Will you be able to do so or would you like me to maybe work on it? |
I forgot. I took a note and will come back to this just trying to stabilize a few open PRs. Please go ahead if you have the idea already otherwise I'll catch up. |
@lysnikolaou, are you still planning to open a new issue here? Or should we just reopen #14262 and continue there? |
@h-vetinari I was planning to wait until we have a clearer picture of what the Cython folks decide on cython/cython#5488 before opening a new issue. Totally fine to open a new issue now though, if you feel it's needed. |
Describe your issue.
In MNE-Python we run a pip-pre job with thhe latest
scipy-wheels-nightly
builds. The latest 1.11.0.dev0+1956.7c74503 pip-pre wheel appears to be buggy:It worked with 1.11.0.dev0+1926.070b2a8 :
Reproducing Code Example
Error message
TypeError: C function scipy.linalg.cython_blas.dasum has wrong signature
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: