Skip to content

fix rustc installation#15

Merged
ZuseZ4 merged 1 commit into
EnzymeAD:mainfrom
shua:patch-1
Nov 2, 2024
Merged

fix rustc installation#15
ZuseZ4 merged 1 commit into
EnzymeAD:mainfrom
shua:patch-1

Conversation

@shua

@shua shua commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

The 0.0.1 release of enzyme rust doesn't include the std component. The intent of this change is to get rust enzyme working again in enzyme explorer, by using the enzyme-0.0.2 release, and using the provided install.sh script to install only the necessary components: rustc, and rust std lib.

@shua

shua commented Nov 2, 2024

Copy link
Copy Markdown
Contributor Author

Not sure if @ZuseZ4 already has a fix in the works with his rustc "enzyme-0.0.2" release, but I saw the last message in rust-lang/rust-project-goals#109 so I thought I'd take a crack at fixing it.

Also not sure how to test this. Any pointers would be appreciated (marking as draft until I can properly test)

@shua
shua marked this pull request as draft November 2, 2024 16:14
@ZuseZ4

ZuseZ4 commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

Hi @shua, glad you saw the project goal update and are interested!
I had past discussions on what needs to be done here with Onur, before I had to move on: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/dist.20build.20-.20why.20is.20my.20std.20not.20working.3F/near/473297504
Feel free to ping him when you experimented a bit in case you end up stuck.

On how to test things, luckily you won't need a server or our website for this, local testing should work just fine.
You will need to do a dist build, so clone the github.com/EnzymeAD/rust repository, configure it, do a dist build, copy one of the tar.gz files to a new folder, unpack it, and see if you can compile something with the rustc compiler inside of it.
In the past I never managed to do that (even though that's as far as I know how dist builds should work), so I might be wrong on my instructions about how to use these dist builds above. Any correction would be appreciated.
Once you manage to configure and build them locally s.t. they work for you, it should be easy to deploy them on our explorer instance.

Also, in case you haven't seen our docs yet, these are instructions on how to do a normal local (non-dist) build:
https://enzyme.mit.edu/index.fcgi/rust/installation.html

@shua

shua commented Nov 2, 2024

Copy link
Copy Markdown
Contributor Author

aha, yes, with the change in this PR I'm able to compile example rust files like

#[no_mangle]
pub fn f(x: &[f32; 2], y: &mut f32) {
    *y = x[0] * x[0] + x[1] * x[0];
}

without autodiff using rustc and std lib from the enzyme-0.0.2 release and it fixes the "std not found" errors, but

use std::autodiff::autodiff;
#[autodiff(df, Forward, Dual, Dual)]
#[no_mangle]
pub fn f(x: &[f32; 2], y: &mut f32) {
    *y = x[0] * x[0] + x[1] * x[0];
}

fails with something like error[E0432]: unresolved import `std::autodiff` so it might have the wrong std lib?

I can take a look at what incantations are required to build a tarball that includes rustc and libstd with autodiff.

@ZuseZ4

ZuseZ4 commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

ping @tgymnich shall we try again to ssh to the server and test with the changes shown here?

@shua The error comes from the fact that during upstreaming some of the code from my fork into rustc some changes were necessary, so the docs are updated to reflect that. The archives in this repo are based on an older fork that doesn't need the use statement, I'll look up how to push some new artifact.

@tgymnich
tgymnich requested a review from ZuseZ4 November 2, 2024 20:57
@tgymnich
tgymnich marked this pull request as ready for review November 2, 2024 20:58
@shua

shua commented Nov 2, 2024

Copy link
Copy Markdown
Contributor Author

@ZuseZ4 (seemed like the best place to put this comment, but I can also message on zulip if you'd prefer)

as I'm waiting on ./x.py dist to build everything, I noticed you can save some time and space by skipping some of the final steps via an edit to your config.toml:

[build]
# default is a list of tools like cargo, rustfmt, that get built as the final steps of `./x.py dist`
# empty list skips those and all you get is rustc+stdlib in build/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
tools = []

this assumes you don't want any of those tools, which I guess for compiler-explorer purposes you're not using cargo or rust-analyzer anyway

@ZuseZ4

ZuseZ4 commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

Great, my dist build in the docker container (Ubuntu 22.04) just finished, I published an experimental enzyme-0.0.3 release. I'll just test it with your commands in a new docker container, if that works we can merge this and add some docs to our website.

@ZuseZ4

ZuseZ4 commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

@shua thanks for testing/fixing this, it worked on my fresh docker container. If you update the tag for the latest release (https://github.com/EnzymeAD/rust/releases/tag/enzyme-0.0.3) we should be able to merge this.

The 0.0.1 release of enzyme rust doesn't include the std component. The intent of this change is to get rust enzyme working again in enzyme explorer, by using the enzyme-0.0.3 release
@shua

shua commented Nov 2, 2024

Copy link
Copy Markdown
Contributor Author

done. I pre-emptively squashed the changes all into one commit

@ZuseZ4
ZuseZ4 merged commit 4f6308b into EnzymeAD:main Nov 2, 2024
@ZuseZ4

ZuseZ4 commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

re-pinging @tgymnich because you mentioned that sometimes you need to run a script to trigger updates.
(Also we should delete the previous broken rustc from the explorer)

@shua
shua deleted the patch-1 branch November 2, 2024 22:54
@ZuseZ4

ZuseZ4 commented Nov 3, 2024

Copy link
Copy Markdown
Contributor

@shua After some small follow-up fixes you can now select Rust: https://enzyme.mit.edu/explorer/
The output is correct, but the LLVM-IR and ASM unfortunately still aren't (they are showing the dummy placeholder that I delete in the lowering process, before replacing it with the true derivative code from Enzyme).
Once I figured out how to fix that I'll add the link to the website. Thanks again.

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.

3 participants