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

Autodiff Upstreaming - single commit #129175

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ZuseZ4
Copy link
Contributor

@ZuseZ4 ZuseZ4 commented Aug 17, 2024

Tracking issue:

This PR/Commit is just here to show the whole picture. I'll also push individual PRs that are easier to review, starting with the backend which due to bootstrapping is the part I am the least confident about.

The documentation currently is hosted at https://enzyme.mit.edu/index.fcgi/rust/. Please see especially the Installation chapter for build instructions (For rustc devs these shouldn't be surprising).

The tests are currently hosted at https://github.com/EnzymeAD/rustbook. To simplify reviewing I would suggest we first focus on upstreaming the code, and then I'll move over the tests once that's done.

A few of the lines like were contributed by other people who helped me with my fork. Since this work touches multiple parts of rustc, it was easier to reimplement than rebase this once in a while. Once individual PRs are approved I'll look up the history and restore author information where needed.

The first individual PR for the backend (builds on it's own) is here: #129176
The frontend PR is here: #129458

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2024

⚠️ Warning ⚠️

  • These commits modify submodules.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 17, 2024
@jackh726
Copy link
Member

This is cool. Over the medium to long-term, though, I think we should work to make the interface in the compiler agnostic to whatever backend/tool is used. I know that's a big ask, and I think it's valuable to land this work in the meantime. But, I don't think we want to commit ourselves to Enzyme or to e.g. supporting autodiff in bootstrap.

@michaelwoerister michaelwoerister removed their assignment Aug 19, 2024
@michaelwoerister michaelwoerister removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2024
@ZuseZ4
Copy link
Contributor Author

ZuseZ4 commented Aug 19, 2024

Agree, both of my Autodfiff and GPU Offloading work could be handled in a crate, by providing better access to compiler internals. Java's reflection proposal even includes Autodiff as example (though they still don't handle all necessary features), and in Julia land, Enzyme.jl is a package that just has a dependency on their compiler package GPUCompiler.jl (terrible name, independent of GPUs these days). The equivalent of my rustc-gpu work is KA.jl (KernelAbstractions) and also works as a normal package for Julia. I talked with Niko about what compiler internals I would need access too.
That being said, I developed this fork for 3 years and it becomes exhausting to keep an out of fork tree up to date, which is why I'm really happy that these got approved as experimental nightly featutes.

@jieyouxu jieyouxu added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Aug 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 6, 2024
…san68

Autodiff Upstreaming - enzyme backend

Tracking issue: rust-lang#124509

Part of rust-lang#129175

This PR should allow building Enzyme from source on Tier 1 targets (when also building LLVM), except MSVC.
It's only a small fraction (~200 lines) of the whole upstream PR, but due to bootstrapping and the number of configurations in which rustc can be build I assume that this will be the hardest to merge, so I'm starting with it.
Happy to hear what changes are required to be able to upstream this code.

**Content:**
It contains a new configure flag `--enable-llvm-enzyme`, and will build the new Enzyme submodule when it is set.

**Discussion:**
Apparently Rust CI isn't able to clone repositories outside the rust-lang org? At least I'm seeing this error in CI:
```
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```
Does that mean we would need to mirror github.com/EnzymeAD/Enzyme in rust-lang, until LLVM upgrades Enzyme from an Incubator project to something that ships as part of the monorepo?

Tracking:

- rust-lang#124509
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 6, 2024
…san68

Autodiff Upstreaming - enzyme backend

Tracking issue: rust-lang#124509

Part of rust-lang#129175

This PR should allow building Enzyme from source on Tier 1 targets (when also building LLVM), except MSVC.
It's only a small fraction (~200 lines) of the whole upstream PR, but due to bootstrapping and the number of configurations in which rustc can be build I assume that this will be the hardest to merge, so I'm starting with it.
Happy to hear what changes are required to be able to upstream this code.

**Content:**
It contains a new configure flag `--enable-llvm-enzyme`, and will build the new Enzyme submodule when it is set.

**Discussion:**
Apparently Rust CI isn't able to clone repositories outside the rust-lang org? At least I'm seeing this error in CI:
```
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```
Does that mean we would need to mirror github.com/EnzymeAD/Enzyme in rust-lang, until LLVM upgrades Enzyme from an Incubator project to something that ships as part of the monorepo?

Tracking:

- rust-lang#124509
@jieyouxu jieyouxu added the F-autodiff `#![feature(autodiff)]` label Sep 7, 2024
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Sep 25, 2024
Autodiff Upstreaming - enzyme backend

Tracking issue: rust-lang/rust#124509

Part of rust-lang/rust#129175

This PR should allow building Enzyme from source on Tier 1 targets (when also building LLVM), except MSVC.
It's only a small fraction (~200 lines) of the whole upstream PR, but due to bootstrapping and the number of configurations in which rustc can be build I assume that this will be the hardest to merge, so I'm starting with it.
Happy to hear what changes are required to be able to upstream this code.

**Content:**
It contains a new configure flag `--enable-llvm-enzyme`, and will build the new Enzyme submodule when it is set.

**Discussion:**
Apparently Rust CI isn't able to clone repositories outside the rust-lang org? At least I'm seeing this error in CI:
```
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```
Does that mean we would need to mirror github.com/EnzymeAD/Enzyme in rust-lang, until LLVM upgrades Enzyme from an Incubator project to something that ships as part of the monorepo?

Tracking:

- rust-lang/rust#124509
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 30, 2024
add has_enzyme/needs-enzyme to the test infra

This unblocks merging the Enzyme / Autodiff frontend.
For the full implementation, see: rust-lang#129175

We don't want to run tests that require Enzyme / Autodiff support when we build rustc without the required features.

It correctly filtered out a test which started with `//@ needs-enzyme`.
```
running 80 tests
i...............................................................................

test result: ok. 79 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 380.41ms
```

Tracking:

- rust-lang#124509

r? jieyouxu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-autodiff `#![feature(autodiff)]` S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants