rust-lang / rust-lang/rust

Add error handling for incorrect activities in Forward mode autodiff

Open
#139,590 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-autodiff I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#[autodiff(df, Forward, Dual, Dual)]
fn f(x: f32, _y: f32) -> f32 {
    x
}

Discussion: https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Assistance.20with.20autodiff.20compiler.20panic/with/510644112
Bug repro in enzyme explorer: https://fwd.gymni.ch/rMla2i

Meta

rustc --version --verbose:

 rustc --version --verbose
rustc 1.85.0-nightly (0aeaa5eb2 2024-12-14)
binary: rustc
commit-hash: 0aeaa5eb22180fdf12a8489e63c4daa18da6f236
commit-date: 2024-12-14
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.5
Error output
error: expected 3 activities, but found 2
Backtrace

thread 'rustc' panicked at compiler/rustc_builtin_macros/src/autodiff.rs:506:17:
Expected two return types for dual
stack backtrace:
   0:        0x10b93a3bc - std::backtrace::Backtrace::create::hd5f74c9541fa041c
...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Rust example and the error output, then inspect compiler/rustc_builtin_macros/src/autodiff.rs around line 506. Reproduce the Forward-mode autodiff case with the incorrect activities and trace how it reaches the panic. Done means the case reports an error instead of panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.