EnzymeAD / EnzymeAD/Enzyme

Regression: No augmented forward pass found for _RNvCsbpInmopFggX_7___rustc19___rust_alloc_zeroed(__rustc::__rust_alloc_zeroed)

Open
#2,444 11 comments 0 reactions 1 assignee Claimed by @ZuseZ4 View on GitHub
Dominant language
LLVM
Stars
1.7k
Forks
188
Avg merge
1d 22h
Merged PRs (30d)
26

Description

Here's another regression, autodiff on Karpathy's gpt2 doesn't work anymore. The mwe is manually minimized/translated from Rust
[mwe.ll.txt](https://github.com/user-attachments/files/22267473/mwe.ll.txt)
This is the semi-automatically minimized version:

```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define fastcc {} @_ZN5llmrs6main_017ha3c193b20e45989fE() {
%1 = call {} (...) @__enzyme_autodiff_ZN5llmrs16gpt2_ad_backward17hdd0c6bf2325259a6E(ptr @gpt2_forward, metadata !"enzyme_dup", ptr null, ptr null, metadata !"enzyme_const", ptr null, metadata !"enzyme_const", ptr null, metadata !"enzyme_const", ptr null, metadata !"enzyme_const", i64 0, metadata !"enzyme_const", i64 0, metadata !"enzyme_dup", ptr null, ptr null)
ret {} %1
}

define void @gpt2_forward(ptr %0, ptr %1, ptr %2, ptr %3, i64 %4, i64 %5, ptr %6) {
call void @matmul_forward(ptr %0)
ret void
}

define void @matmul_forward(ptr %0) {
call void @_RNvCsbpInmopFggX_7___rustc35___rust_no_alloc_shim_is_unstable_v2()
%2 = tail call ptr @_RNvCsbpInmopFggX_7___rustc19___rust_alloc_zeroed(i64 noundef range(i64 1, 0) 32, i64 noundef range(i64 1, -9223372036854775807) 4)
%3 = load float, ptr %2, align 4
store float %3, ptr %0, align 4
ret void
}

; Function Attrs: nounwind nonlazybind
declare void @_RNvCsbpInmopFggX_7___rustc35___rust_no_alloc_shim_is_unstable_v2() unnamed_addr #1

; Function Attrs: nounwind nonlazybind allockind("alloc,zeroed,aligned") allocsize(0)
declare ptr @_RNvCsbpInmopFggX_7___rustc19___rust_alloc_zeroed(i64, i64)

declare {} @__enzyme_autodiff_ZN5llmrs16gpt2_ad_backward17hdd0c6bf2325259a6E(...)

```

Also:
```
/home/manuel/prog/llvm21/build/bin/llvm-cxxfilt _RNvCsbpInmopFggX_7___rustc19___rust_alloc_zeroed
__rustc::__rust_alloc_zeroed
```
And
```
enzyme/Enzyme/LibraryFuncs.h
58: if (name == "__rust_alloc" || name == "__rust_alloc_zeroed")
210: if (funcName == "calloc" || funcName == "__rust_alloc_zeroed")

enzyme/Enzyme/GradientUtils.cpp
9476: if (allocationfn == "__rust_alloc" || allocationfn == "__rust_alloc_zeroed") {

enzyme/test/Enzyme/ReverseMode/initializeretrust.ll
11: %call = tail call i8* @__rust_alloc_zeroed(i64 %mul, i64 4)
20:declare dso_local noalias i8* @__rust_alloc_zeroed(i64, i64)
85:; CHECK-NEXT: %"call'mi" = tail call noalias nonnull i8* @__rust_alloc_zeroed(i64 %mul, i64 4)
86:; CHECK-NEXT: %call = tail call i8* @__rust_alloc_zeroed(i64 %mul, i64 4)
```

Not sure why the Enzyme logic regressed?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.