Skip to content

Fix autodiff debug builds #140030

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged

Fix autodiff debug builds #140030

merged 1 commit into from
Apr 21, 2025

Conversation

ZuseZ4
Copy link
Member

@ZuseZ4 ZuseZ4 commented Apr 19, 2025

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 20, 2025
[DO NOT MERGE] start building enzyme on x86_64-gnu-llvm-{19|20} builders

My goal is to put this in CI on April 26, to have a week to land some of the outstanding PRs:
rust-lang#139700
rust-lang#139308
rust-lang#139557
rust-lang#140030
rust-lang#140049
The autodiff flags PR should land first, but otherwise they don't overlap and are mostly ready, so it shouldn't be too hard to land them. In the meantime, I'll experiment here with some builders.

r? `@oli-obk`

Tracking:

- rust-lang#124509

try-job: x86_64-gnu-llvm-19
try-job: x86_64-gnu-llvm-20
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 20, 2025
[DO NOT MERGE] start building enzyme on x86_64-gnu-llvm-{19|20} builders

My goal is to put this in CI on April 26, to have a week to land some of the outstanding PRs:
rust-lang#139700
rust-lang#139308
rust-lang#139557
rust-lang#140030
rust-lang#140049
The autodiff flags PR should land first, but otherwise they don't overlap and are mostly ready, so it shouldn't be too hard to land them. In the meantime, I'll experiment here with some builders.

r? `@oli-obk`

Tracking:

- rust-lang#124509

try-job: dist-x86_64-linux
Comment on lines +257 to +259
// We can't differentiate a function that got inlined.
let autodiff_active = cfg!(llvm_enzyme)
&& matches!(mono_item, MonoItem::Fn(_))
Copy link
Member

@jieyouxu jieyouxu Apr 21, 2025

Choose a reason for hiding this comment

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

Discussion: this kinda feels backwards to me, I feel like if autodiff is applied to some fn it should inhibit inlining. Is there a small test case (synthetic or not) that can demonstrate this change? Or rather, under what situation can this condition be previously wrong (the change itself looks reasonable)?

Copy link
Member Author

@ZuseZ4 ZuseZ4 Apr 21, 2025

Choose a reason for hiding this comment

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

I add inline(never) in my frontend macro to source and target function. However, those aren't guaranteedon a language level to prevent inlinung, so I additionally check it here in rustc_monomorphize. So yes, autodiff prevents inlining. (Edited a bit, but I think I still miss your point).
https://doc.rust-lang.org/nightly/reference/attributes/codegen.html?highlight=inline
Pretty much every codegen test will fail if you remove these two barriers.

The change btw. is needed since we currently also inspect non fn items like Asm, which triggers a debug assertion, causing bootstrap to fail. But you already mentioned that this looks reasonable to you

Copy link
Member

@jieyouxu jieyouxu Apr 21, 2025

Choose a reason for hiding this comment

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

But I feel like I probably misunderstand your question?

I moreso meant if there's a smaller example that would fail without this PR, not changing the front-end/middle-end bits, as a regression test.

... But also not building -> building seems like an improvement, yes 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

aah, yes now I get your question. I only mentioned it in the title, not the PR body, but you can find the panic stacktrace in the linked issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

#140064 (comment)

@jieyouxu since you already looked at it, it's a one line change, fixes bootstrap and eliminates the ad overhead, do you mind to rubberstamp it? Then I can drop it from my final enable-aitodiff PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, at least this makes it possible to build, and I can't come up with a smaller test...

@jieyouxu
Copy link
Member

r? jieyouxu @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 21, 2025

📌 Commit b3739f3 has been approved by jieyouxu

It is now in the queue for this repository.

@rustbot rustbot assigned jieyouxu and unassigned oli-obk Apr 21, 2025
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 21, 2025
…enton

Rollup of 8 pull requests

Successful merges:

 - rust-lang#139946 (fix missing word in comment)
 - rust-lang#139982 (SystemTime doc tweaks)
 - rust-lang#140009 (docs(LocalKey<T>): clarify that T's Drop shouldn't panic)
 - rust-lang#140021 (Don't ICE on pending obligations from deep normalization in a loop)
 - rust-lang#140029 (Relocate tests in `tests/ui`)
 - rust-lang#140030 (Fix autodiff debug builds)
 - rust-lang#140120 (Use `output_base_dir` for `mir_dump_dir`)
 - rust-lang#140121 (Document why CodeStats::type_sizes is public)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c43b82f into rust-lang:master Apr 21, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 21, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 21, 2025
Rollup merge of rust-lang#140030 - EnzymeAD:autodiff-debug, r=jieyouxu

Fix autodiff debug builds

r? `@oli-obk`

closes: rust-lang#139704

Tracking:

- rust-lang#124509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

building rustc with autodiff and debug enabled fails.
5 participants