-
Notifications
You must be signed in to change notification settings - Fork 68
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
Error with phi or function boundaries #2122
Comments
Can you paste the whole log |
ah you did! |
I would be grateful if this one could get looked at at some point, it is (I think) the only error holding Molly back from switching to Enzyme for CPU. |
Yeah sorry I’ve personally been staring at compile time issues recently, if you have a chance to see if you can reduce this a bit further that would be massively appreciated (this is not an error that I can tell a quick fix from the log sadly). |
Here is a shorter version showing a similar error on main (c24b383), StaticArrays 1.9.8 and Julia 1.10.6. Some ways to remove the error:
using Enzyme, StaticArrays, LinearAlgebra
Enzyme.Compiler.VERBOSE_ERRORS[] = true
struct A{T}
f1::T
end
struct PeriodicTorsion{N, E}
ks::NTuple{N, E}
end
struct InteractionList4Atoms{I, T}
is::I
js::I
inters::T
end
function periodic_torsion_vectors(coords_i, coords_j)
bc_norm = norm(coords_j)
return coords_i, bc_norm
end
function specific_forces!(fs_nounits, coords, sils_4_atoms)
for inter_list in sils_4_atoms
for ind in 1:length(inter_list.is)
i, d = inter_list.is[ind], inter_list.inters[ind]
ab, bc_norm = periodic_torsion_vectors(coords[i], coords[i+1])
fi = d.ks[1] * bc_norm * SVector(1.0, 1.0, 1.0)
sf = A(fi)
fs_nounits[i] += sf.f1
end
end
return fs_nounits
end
inject_interaction(inter) = inter
function inject_inter_list(inter)
inters_grad = inject_interaction.(inter.inters)
InteractionList4Atoms(inter.is, inter.js, inters_grad)
end
function test_forces_grad(sis_in, coords)
sis = inject_inter_list.(sis_in)
fs_nounits = zero(coords)
sis2 = A(sis)
fill!(fs_nounits, zero(eltype(fs_nounits)))
sils_4_atoms = filter(il -> il isa InteractionList4Atoms, values(sis2.f1))
specific_forces!(fs_nounits, coords, sils_4_atoms)
return sum(sum.(abs, fs_nounits))
end
pt1 = [PeriodicTorsion((1.0, 1.0)), PeriodicTorsion((1.0, 1.0))]
sis = (
InteractionList4Atoms([1, 2], [2, 3], pt1),
InteractionList4Atoms([1, 2], [2, 3], pt1),
)
coords = rand(SVector{3, Float64}, 5)
test_forces_grad(sis, coords) # Works
autodiff(
set_runtime_activity(Reverse),
test_forces_grad,
Active,
Const(sis),
Duplicated(copy(coords), zero(coords)),
)
|
I am on Enzyme main (d096464), StaticArrays 1.9.8 and Julia 1.10.6. This is a rather long example but it is self-contained, I found it hard to trim it down. I could get rid of the error in a few ways, for example by removing
norm
or inlining some functions, but nothing I tried fixed it in the larger codebase. The full error is attached as error.txt.The text was updated successfully, but these errors were encountered: