Skip to content
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

Update all dependencies. #12

Merged
merged 10 commits into from
Nov 30, 2023
Merged

Conversation

ingomueller-net
Copy link
Contributor

This PR depends on and therefore includes #10.

This PR updates the following dependencies in the WORKSPACE file to a
version from around November 2:

  • LLVM
  • XLA
  • JAX (even though there is no actual BUILD dependency)
  • Enzyme

The PR also adds direct dependencies to the following projects:

  • rules_cc (because LLVM requires a newer version than the one that XLA
    imports)

For context: @ftynse pointed me to this repo to copy the Bazel recipe to another project that depends on JAX and I didn't make it work there yet. Since I got stuck on that project, I came back to this one to see if I can make it work here. Turns out I could. I hope that this will serve me as a good base to get the other project to work as well. I don't need this project currently, but since I grinded through making it work, you might as well benefit from it ;)

The current import was non-functional, and that only remained unnoticed
because there is no BUILD dependency to JAX, so JAX isn't actually
built. (The CI tests install JAX through pip, so the JAX dependency
isn't needed there.)

The fix consists in moving the configuration from JAX's WORKSPACE file
(which is emptied when imported via `http_archive`) to the WORKSPACE
file of this project (plus fixing how its dependency `ducc` is loaded).
Now adding `@jax//jax` to some of the build targets actually (and
successfully) builds JAX.
@ingomueller-net ingomueller-net force-pushed the update-dependencies branch 3 times, most recently from acaa8c7 to 3cba4bf Compare November 3, 2023 12:58
This PR updates the following dependencies in the WORKSPACE file to a
version from around November 2:

* LLVM
* XLA
* JAX (even though there is no actual BUILD dependency)
* Enzyme

The PR also adds direct dependencies to the following projects:

* rules_cc (because LLVM requires a newer version than the one that XLA
  imports)
Copy link
Contributor Author

@ingomueller-net ingomueller-net left a comment

Choose a reason for hiding this comment

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

OK, I am done: CI passes :)

@ftynse: Could you or one of your collaborators have a look to check if I do anything stupid (in particular in how to use Bazel)?

@@ -14,10 +28,10 @@ http_archive(
)

load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
llvm_configure(name = "llvm-project", targets = ["X86", "AArch64", "AMDGPU", "ARM", "NVPTX"])
llvm_configure(name = "llvm-project", targets = LLVM_TARGETS)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this ~intentionally breaks the regexes in the CI pipelines that replace the build targets depending on the CI target. This doesn't work anymore since XLA (I believe) always requires X86CodeGen to be present, so the X86 target is always required.

It might be possible to adapt the regexes accordingly but since (one of) the pipelines are (is) signed, I didn't do that change.


py_package(
name = "enzyme_jax_data",
# Only include these Python packages.
packages = ["@//enzyme_jax:enzyme_call.so", "@llvm-project//clang:builtin_headers_gen"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Warning: I don't understand what packages is supposed to do. If I use the line as is, the .so file is not included in the wheel...

Copy link
Member

Choose a reason for hiding this comment

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

So it's supposed to force the so (And those headers) to be made available in the pip package.

Copy link
Member

Choose a reason for hiding this comment

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

It does look like CI thinks that it can no longer find them, so we may need something else here (it worked in the past so I'm not sure what would've changed, and I'm curious if putting it back fixes anything)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When it was there, CI broke. I could observe the same behavior locally: only the py files ended up in the wheel. I don't know what changed, though...

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah so the problem is that the package.bzl forces the dependencies to be included as well, so by getting rid of our version of package.bzl you've removed the ability to import the actual dependencies.

Revert back to our package.bzl and see if it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have also tried that. I started looking into the wheel rule because it broke, even before updating rules_python. Also, the old package.bzl doesn't have filtering logic for all I can tell.

Is there anything in the current behavior that is undesirable?

@@ -29,19 +27,15 @@ cc_library(
],
)

load("@rules_python//python:packaging.bzl", "py_wheel")

load(":package.bzl", "py_package")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By reading the code, I had the feeling that the package.bzl from this repo had no effect other than calling the function of the same name in rules_python (plus allowing but not using the prefix parameter), so I removed it.

@ingomueller-net
Copy link
Contributor Author

I went through the packing rule again. If I revert the last commit, i.e., all changes to that rule, then the resulting *.whl does not contain the .so file:

python -c "from zipfile import ZipFile; from pprint import pprint; pprint(ZipFile('bazel-bin/enzyme_jax-0.0.5-py3-none-manylinux2014_x86_64.whl').namelist())" | grep \\.so
# no output

Commenting out the prefix or packages arguments does not change that behavior. Only if I use the function from the @rules_python package instead of the one from the reverted package.bzl in addition to commenting out prefix and packages parameters does it work. I also tried changing the packages parameter to //enzyme_jax:enzyme_call instead of //enzyme_jax:enzyme_call.so (i.e., without file extension) -- doing that doesn't fix the behavior. Using the rule from @rules_python without packages parameter does work for the old version of rules_python, though. With the new version, no form of the packages argument leads in the resulting wheel containing the .so file.

In short, after the changes in the previous commits, only the fixes in the last commit lead to a valid wheel.

(I just force-pushed an updated last commit where I remove the comment for the also-removed packages argument.)

@ingomueller-net
Copy link
Contributor Author

OK, I investigated more. Values in the packages arguments have all . replaced by / (here -- WTF??) and are used as prefix for matching. So with packages = ["enzyme_jax/enzyme_call"],, the wheel actually contains the *.so file. That filter, instead, filtered out the headers. But I guess that wasn't the intention: they where part of the packages filter originally. As I see it the original packages filter said to include all files that where already selected as deps, so even when they were working, they had no effect (and when they were not, they broke the wheel). TL;DR: I think we should drop the argument as done in the last commit.

@ingomueller-net
Copy link
Contributor Author

OK, I fixed another bunch of problems. I am able to run test/test.py locally now 😄 Hopefully this will pass CI as well...

@wsmoses wsmoses merged commit 5f7f3de into EnzymeAD:main Nov 30, 2023
1 of 2 checks passed
@ingomueller-net
Copy link
Contributor Author

You made it work :) Kudos!

@ingomueller-net ingomueller-net deleted the update-dependencies branch December 1, 2023 08:11
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

Successfully merging this pull request may close these issues.

2 participants