pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

Basic GraalPy Support

Open timfel opened this issue 2 years ago • 21 comments
trafficstars

With these changes, a GraalPy master build, and using maturin master, I can run the pytests and the examples. I have 3 failures in the pytests still. Please let me know if this is going in the right direction for you.

timfel avatar Jun 16 '23 08:06 timfel

I think the most important question to clarify here is the status of this integration in the CI. If we are planning on proper support we should include it both for checking PR and for full target checks for the merge queues.

Is this possible and could you sketch an approach here?

adamreichold avatar Jun 16 '23 12:06 adamreichold

I think the most important question to clarify here is the status of this integration in the CI. If we are planning on proper support we should include it both for checking PR and for full target checks for the merge queues. Is this possible and could you sketch an approach here?

There are some changes for this that are only in graalpy master. Our releases go into pyenv, and our next release that will include the relevant changes will be out in September. So one option is to then setup the CI action to add graalpy to the matrix, install it using pyenv and simply run nox -s test-py with it. We can also at any time do nightly builds and we start by adding an action that just uses a well-known nightly build in CI, and we switch to a release build via pyenv once that is out.

timfel avatar Jun 16 '23 12:06 timfel

install it using pyenv and simply run nox -s test-py with it

Ideally, this would use exactly the same CI jobs we use for CPython and PyPy or is there a technical limitation which makes this unreasonable?

We can also at any time do nightly builds and we start by adding an action that just uses a well-known nightly build in CI, and we switch to a release build via pyenv once that is out.

I think this mainly depends on how urgent this is for you, if you'd like to have this in our main branch before your release, then integrating a nightly build would be a prerequisite. Otherwise, waiting for the next release appears preferable.

adamreichold avatar Jun 16 '23 15:06 adamreichold

install it using pyenv and simply run nox -s test-py with it

Ideally, this would use exactly the same CI jobs we use for CPython and PyPy or is there a technical limitation which makes this unreasonable?

We would first have to get graalpy into github actions.

We can also at any time do nightly builds and we start by adding an action that just uses a well-known nightly build in CI, and we switch to a release build via pyenv once that is out.

I think this mainly depends on how urgent this is for you, if you'd like to have this in our main branch before your release, then integrating a nightly build would be a prerequisite. Otherwise, waiting for the next release appears preferable.

We would of course prefer to have this in before our next release, so that we can start running the tests of actual packages that use PyO3 in our CI and fix any additional issues that occur before the September release.

timfel avatar Jun 19 '23 08:06 timfel

We are adding support for graalpy to the setup-python action, then running it in the PyO3 CI should need minimal changes

timfel avatar Jun 27 '23 07:06 timfel

The setup-python action maintainers had a question about GraalPy's licence, I hope they are happy with it soon and will merge, at which point I will rebase this PR and add GraalPy pytest to your CI (https://github.com/actions/setup-python/pull/694)

timfel avatar Jul 18 '23 12:07 timfel

This now passes all pytests on GraalPy 23.1 with the latest maturin release. Once https://github.com/PyO3/maturin/pull/1773 and https://github.com/actions/setup-python/pull/694 are merged, I can add GraalPy to the CI config.

timfel avatar Sep 15 '23 16:09 timfel

Great! Do you have a sense of how close the setup-python PR is to merging? I think we're going to push an 0.20 release imminently, so if this is extremely close we could wait for it. (Otherwise this could land in 0.20.1 later.)

davidhewitt avatar Sep 16 '23 01:09 davidhewitt

Great! Do you have a sense of how close the setup-python PR is to merging? I think we're going to push an 0.20 release imminently, so if this is extremely close we could wait for it. (Otherwise this could land in 0.20.1 later.)

I couldn't say. We've tried to be very quick to do any requested changes, but I assume the github folks are busy and they end up not getting back to us for a week or two each time they ask for something. So don't wait for us.

timfel avatar Sep 16 '23 04:09 timfel

Ah okay, frustrating!

davidhewitt avatar Sep 16 '23 05:09 davidhewitt

@timfel I added CI-build-full label, so if you fix the fit issues and push again you should find we do a full CI run including the new graalpy job.

davidhewitt avatar Oct 11 '23 21:10 davidhewitt

Ok, it's basically working now. The failure on python3.9 is a 500 server error downloading the manylinux image, so I suspect it's transient.

For GraalPy, we need a new release of maturin with this PR: https://github.com/PyO3/maturin/pull/1802. I ran the CI config locally and with an updated maturin it passes that one step that's not running.

timfel avatar Oct 13 '23 18:10 timfel

Great, I will try to give this a full review in the coming days! I just got back from EuroRust with a ton of threads to follow up before they go cold as well as some time due for my family, so please forgive me if it takes a little longer than usual 🙏

davidhewitt avatar Oct 13 '23 23:10 davidhewitt

@messense, when might you plan to do the next maturin release?

I'll release a new version after fixing https://github.com/PyO3/maturin/issues/1804 this week.

messense avatar Oct 24 '23 03:10 messense

maturin 1.3.1 is out with the GraalPy wheel filename fix.

messense avatar Oct 24 '23 13:10 messense

maturin 1.3.1 is out with the GraalPy wheel filename fix.

looks like the pytests are passing on graalpy with that 🙂

timfel avatar Oct 25 '23 20:10 timfel

@timfel I think if you rebase you should have a passing CI (nightly is still broken but won't block merge).

davidhewitt avatar Oct 25 '23 21:10 davidhewitt

Overall it looks to me like this is probably ready to merge, and there's going to be follow-up / cleanup work for a while too. @timfel how much help can we expect from you folks upstream if users are reporting problems here?

Please @-mention me and @msimacek for GraalPy issues. We will continue with the follow up issues and also respond as quickly as we can to any issues here. We are internally running the tests of around 600 Python packages daily on GraalPy, so if people report issues with packages using PyO3, we will also add more tests to our CI.

I think we should also seriously consider working on HPy support in PyO3 in the mid term so that both PyPy and GraalPy implementations can use that, to reduce complexity for everyone.

I agree, we discussed this in the past and I will bring it up again in the next HPy monthly call.

timfel avatar Oct 26 '23 05:10 timfel

CodSpeed Performance Report

Merging #3247 will not alter performance

Comparing timfel:timfel/graalpy-support-mk2 (c5ae4c7) with main (7d319a9)

Summary

✅ 70 untouched benchmarks

codspeed-hq[bot] avatar Oct 26 '23 07:10 codspeed-hq[bot]

Just looping back to here, I think with 0.21 release the gil-refs removal will not be far enough along to safely support GraalPy; I think that in 0.22 when we fully gate the gil-refs API we can enable GraalPy support as long as that feature is not enabled.

davidhewitt avatar Jan 04 '24 16:01 davidhewitt

Just looping back to here, I think with 0.21 release the gil-refs removal will not be far enough along to safely support GraalPy; I think that in 0.22 when we fully gate the gil-refs API we can enable GraalPy support as long as that feature is not enabled.

Thanks. We have (on GraalPy master) now changed our PyObject* representation, and are now allocating and populating PyObject* structures in native memory and handing out the real pointers to that memory to C extensions. So from our side once we do our next release in April we could also simply work with the current codebase of non-opaque structures

timfel avatar Jan 04 '24 16:01 timfel

With release of GraalPy 24.0 last week we now actually allocate proper memory for PyObject structures. So I made everything else opaque/configured away.

timfel avatar Mar 23 '24 06:03 timfel

With release of GraalPy 24.0 last week we now actually allocate proper memory for PyObject structures. So I made everything else opaque/configured away.

So assuming conflict resolution, this can be reviewed and possibly merged now and CI should continue to pass against the publicly available versions of GraalPy?

adamreichold avatar Mar 23 '24 07:03 adamreichold

So assuming conflict resolution, this can be reviewed and possibly merged now and CI should continue to pass against the publicly available versions of GraalPy?

Yes 🙂

timfel avatar Mar 23 '24 08:03 timfel

Do GraalPy wheels get uploaded to PyPI? Does the GraalPy version (presumably 24.0) go in the tag?

davidhewitt avatar Mar 23 '24 13:03 davidhewitt

Do GraalPy wheels get uploaded to PyPI? Does the GraalPy version (presumably 24.0) go in the tag?

Yes, the graalpy and implemented cpython version go in the tag. pip debug gives wheel tags like graalpy310-graalpy240_310_native-manylinux_2_35_x86_64

timfel avatar Mar 25 '24 08:03 timfel

I'm not entirely sure how the performance differences (both regressions and improvements) are caused by my changes. Maybe those benchmarks are so micro that there is jitter?

timfel avatar Mar 25 '24 10:03 timfel

Yep there's a few benchmarks which need to have volatility ignored after I re-enabled them in #3986

I cleared those now 👍

davidhewitt avatar Mar 25 '24 10:03 davidhewitt

Is the failure in "CI / python3.12-x64 ubuntu-latest rust-nightly" something I could have done? It fails in pyo3-macros-backend, I haven't touched that, but I fear I don't understand enough to rule out some interaction with my changes.

timfel avatar Mar 25 '24 12:03 timfel

Nightly probably has improved dead code detection. I don't think you need to worry about it here.

davidhewitt avatar Mar 25 '24 13:03 davidhewitt