Skip to content

Conversation

@vchuravy
Copy link
Member

@vchuravy vchuravy commented Nov 8, 2025

julia> Enzyme.autodiff(Forward, mul_caller_static, Duplicated(A, dA), Duplicated(1.2, 1.0))
C = max(64 ÷ prod(size(A)), 1) = 1
ERROR: 
No forward mode derivative found for jl_get_builtin_fptr
 at context:   %15 = call {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @jl_get_builtin_fptr({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 139935955039648 to {}*) to {} addrspace(10)*)) #20, !dbg !53

Stacktrace:
 [1] construct
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779
 [2] _mul!
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61
 [3] mul!
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:68
 [4] mul_caller_static
   @ ./REPL[11]:4


Stacktrace:
  [1] construct
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779 [inlined]
  [2] _mul!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61 [inlined]
  [3] mul!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:68 [inlined]
  [4] mul_caller_static
    @ ./REPL[11]:4 [inlined]
  [5] fwddiffejulia_mul_caller_static_23728wrap
    @ ./REPL[11]:0
  [6] macro expansion
    @ ~/src/Enzyme/src/compiler.jl:5887 [inlined]
  [7] enzyme_call
    @ ~/src/Enzyme/src/compiler.jl:5421 [inlined]
  [8] ForwardModeThunk
    @ ~/src/Enzyme/src/compiler.jl:5323 [inlined]
  [9] autodiff
    @ ~/src/Enzyme/src/Enzyme.jl:673 [inlined]
 [10] autodiff
    @ ~/src/Enzyme/src/Enzyme.jl:562 [inlined]
 [11] autodiff(::ForwardMode{…}, ::typeof(mul_caller_static), ::Duplicated{…}, ::Duplicated{…})
    @ Enzyme ~/src/Enzyme/src/Enzyme.jl:534
 [12] top-level scope
    @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.

@wsmoses
Copy link
Member

wsmoses commented Nov 8, 2025

what exactly is jl_get_builtin_fptr

and can we define a relevant custom derivative handler for it?

it's come up a few times

@wsmoses
Copy link
Member

wsmoses commented Nov 8, 2025

per JuliaLang/julia#55803

it looks like its a different way of throwing a method error?

which would explain why the unreachable thing happened?

@vchuravy
Copy link
Member Author

vchuravy commented Nov 8, 2025

The primal code doesn't throw, so it might be something that is emitted as a fallback.

Now I have a small enough example that I can stare at Monday

@vchuravy vchuravy force-pushed the vc/ka_broken_on_1.11 branch from 1944a5a to 50e1738 Compare November 10, 2025 18:17
@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Benchmark Results

main 6beb4b9... main / 6beb4b9...
basics/make_zero/namedtuple 0.0549 ± 0.0027 μs 0.0562 ± 0.0028 μs 0.977 ± 0.068
basics/make_zero/struct 0.261 ± 0.0077 μs 0.261 ± 0.0072 μs 1 ± 0.04
basics/overhead 4.34 ± 0.01 ns 4.65 ± 1.8 ns 0.933 ± 0.37
basics/remake_zero!/namedtuple 0.246 ± 0.008 μs 0.245 ± 0.0082 μs 1 ± 0.047
basics/remake_zero!/struct 0.236 ± 0.0099 μs 0.234 ± 0.0098 μs 1.01 ± 0.06
fold_broadcast/multidim_sum_bcast/1D 10.4 ± 0.55 μs 10.3 ± 0.34 μs 1.01 ± 0.063
fold_broadcast/multidim_sum_bcast/2D 12.2 ± 0.33 μs 12.2 ± 0.33 μs 1 ± 0.038
time_to_load 1.31 ± 0.0046 s 1.35 ± 0.011 s 0.975 ± 0.0087

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/19274745464/artifacts/4534972919.

@vchuravy vchuravy force-pushed the vc/ka_broken_on_1.11 branch from 220c730 to c076dd6 Compare November 10, 2025 20:36
@vchuravy
Copy link
Member Author

@wsmoses with Cthulhu:

; │┌ @ /home/vchuravy/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61 within `_mul!`
; ││┌ @ /home/vchuravy/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779 within `construct`
     %12 = call ptr @jl_get_builtin_fptr(ptr nonnull @"+Core.#_compute_sparams#20514.jit")
builtins.c
2181:JL_CALLABLE(jl_f__compute_sparams)
2183:    JL_NARGSV(_compute_sparams, 1);
2185:    JL_TYPECHK(_compute_sparams, method, (jl_value_t*)m);

But the error that Enzyme gives only the pointer:

  Enzyme: jl_call calling convention not implemented in forward for   %15 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* %14, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 137585066522080 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 137578224249072 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 137578224248752 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 137577969042512 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %13, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 137578224222272 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 137580755331088 to {}*) to {} addrspace(10)*)) #17, !dbg !48

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/compiler/validation.jl b/src/compiler/validation.jl
index 9623f24d..6931b2e6 100644
--- a/src/compiler/validation.jl
+++ b/src/compiler/validation.jl
@@ -100,8 +100,8 @@ function __init__()
         "jl_array_typetagdata",
         "ijl_array_typetagdata",
         "jl_idtable_rehash",
-        "jl_f__compute_sparams",
-        "ijl_f__compute_sparams",
+            "jl_f__compute_sparams",
+            "ijl_f__compute_sparams",
     )
     for name in known_names
         sym = LLVM.find_symbol(name)
diff --git a/src/llvm/attributes.jl b/src/llvm/attributes.jl
index fc880da7..d1dafd30 100644
--- a/src/llvm/attributes.jl
+++ b/src/llvm/attributes.jl
@@ -125,8 +125,8 @@ const nofreefns = Set{String}((
     "ijl_f__typevar",
     "jl_f_isa",
     "ijl_f_isa",
-    "jl_f__compute_sparams",
-    "ijl_f__compute_sparams",
+        "jl_f__compute_sparams",
+        "ijl_f__compute_sparams",
     "jl_set_task_threadpoolid",
     "ijl_set_task_threadpoolid",
     "jl_types_equal",
@@ -260,8 +260,8 @@ const inactivefns = Set{String}((
     "ijl_f__typevar",
     "jl_f_isa",
     "ijl_f_isa",
-    "jl_f__compute_sparams",
-    "ijl_f__compute_sparams",
+        "jl_f__compute_sparams",
+        "ijl_f__compute_sparams",
     "jl_set_task_threadpoolid",
     "ijl_set_task_threadpoolid",
     "jl_types_equal",

@vchuravy
Copy link
Member Author

@wsmoses adding jl_f__compute_sparams to the list is not effective... I assume this is because the pointer to name thing failed? Which is why the error message is not helpful?

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.92%. Comparing base (986bbf4) to head (6beb4b9).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2751   +/-   ##
=======================================
  Coverage   68.91%   68.92%           
=======================================
  Files          58       58           
  Lines       19861    19861           
=======================================
+ Hits        13688    13689    +1     
+ Misses       6173     6172    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wsmoses
Copy link
Member

wsmoses commented Nov 11, 2025

also add it to the list of names to lookup?

"jl_idtable_rehash",

@vchuravy
Copy link
Member Author

None of the other jl_f_ functions are listed there? And it doesn't help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants