Skip to content

Split autodiff into autodiff_forward and autodiff_reverse #140697

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

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

Conversation

Sa4dUs
Copy link
Contributor

@Sa4dUs Sa4dUs commented May 6, 2025

This PR splits #[autodiff] macro so #[autodiff(df, Reverse, args)] would become #[autodiff_reverse(df, args)] and #[autodiff(df, Forward, args)] would become #[autodiff_forwad(df, args)].

Pending tasks:

  • Fix cannot find a built-in macro with name error.
  • Update the tests to reflect the new macro structure.
  • Review the implementation for better code.

Pending fix.
```
error: cannot find a built-in macro with name `autodiff_forward`
    --> library\core\src\macros\mod.rs:1542:5
     |
1542 | /     pub macro autodiff_forward($item:item) {
1543 | |         /* compiler built-in */
1544 | |     }
     | |_____^

error: cannot find a built-in macro with name `autodiff_reverse`
    --> library\core\src\macros\mod.rs:1549:5
     |
1549 | /     pub macro autodiff_reverse($item:item) {
1550 | |         /* compiler built-in */
1551 | |     }
     | |_____^

error: could not compile `core` (lib) due to 2 previous errors
```
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 6, 2025
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@ZuseZ4 ZuseZ4 self-assigned this May 6, 2025
@ZuseZ4 ZuseZ4 added the F-autodiff `#![feature(autodiff)]` label May 6, 2025
@ZuseZ4
Copy link
Member

ZuseZ4 commented May 6, 2025

I'd almost bet it has to do with bootstrapping, see e.g. https://github.com/rust-lang/rust/pull/129458/files#diff-ea30f57e78f3b861b784ae315b3ac31358b7cea2aa14a668084ad412de12e586
It will be removed by other people later after landing, that's probably why you didn't see it anymore when just looking at the current code for it. Ping me if that doesn't solve the issue, then I can try to play around with it locally.

@jieyouxu
Copy link
Member

jieyouxu commented May 7, 2025

I don't remember exactly, can built-in attributes be namespaced now? E.g. #[autodiff::forward()] and #[autodiff::reverse()]. That way, only one "top-level" name would cause macro ambiguities from the built-in attribute (autodiff), instead of two.

@ZuseZ4
Copy link
Member

ZuseZ4 commented May 7, 2025

I think :: looks much prettier than _. Our attribute is called rustc_autodiff and not autodiff, so I don't think there will be ambiguities either way.
@jdonszelmann is probably the right person to ask about parsing. (see the question above)

@jieyouxu
Copy link
Member

jieyouxu commented May 7, 2025

Right sorry, I keep forgetting there's two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) F-autodiff `#![feature(autodiff)]` 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. 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