autodiff: higher-order derivative fails: "No forward mode derivative found"
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Reduced from https://github.com/rust-lang/rust/issues/160470#issuecomment-5185373594 (a different bug)
I tried this code:
#![feature(autodiff)]
use std::autodiff::*;
#[autodiff_reverse(d_eval, Const)]
fn eval(_out: &mut [f64]) {}
#[autodiff_forward(hvp_eval, Dual)]
fn grad(out: &mut [f64]) {
d_eval(out);
}
fn main() {
let mut out = [0.0];
let mut out_t = [0.0];
hvp_eval(&mut out, &mut out_t);
}
RUSTFLAGS="-Z autodiff=Enable,NoTT" cargo +enzyme build
I expected to see this happen: compiles
Instead, this happened:
On nightly:
error: src/main.rs:4:1: in function preprocess__RNvCs5ENfmmVW5Vl_3bar6d_eval void (ptr, i64): Enzyme: No forward mode derivative found for __enzyme_autodiff_RNvCs5ENfmmVW5Vl_3bar6d_eval
at context: %3 = call {} (...) @__enzyme_autodiff_RNvCs5ENfmmVW5Vl_3bar6d_eval(ptr @_RNvCs5ENfmmVW5Vl_3bar4eval, ptr @enzyme_const, ptr %0, ptr @enzyme_const, i64 %1) #174, !dbg !75
On head (self-build) we also get:
error: src/main.rs:4:1: in function fwddiffe_RNvCs8wtiwuS546I_3bar6d_eval void (ptr, ptr, i64): Enzyme: Cannot cast __enzyme_autodiff primal argument 3, found ptr %0, type ptr (simplified to ptr %0 ) - to arg 1, i64
error: src/main.rs:4:1: in function fwddiffe_RNvCs8wtiwuS546I_3bar6d_eval void (ptr, ptr, i64): Enzyme: Cannot cast __enzyme_autodiff primal argument 3, found ptr %0, type ptr (simplified to ptr %0 ) - to arg 1, i64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in src/main.rs, the nested #[autodiff_reverse] and #[autodiff_forward] entry points, and the cargo +enzyme build command. Investigate why the higher-order derivative lookup or argument handling produces the shown Enzyme errors; done means this example compiles on nightly and self-build configurations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100