Skip to content
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

Segfault when using Enzyme as SymbolicRegression backend #2246

Open
MilesCranmer opened this issue Dec 31, 2024 · 5 comments
Open

Segfault when using Enzyme as SymbolicRegression backend #2246

MilesCranmer opened this issue Dec 31, 2024 · 5 comments

Comments

@MilesCranmer
Copy link
Contributor

MilesCranmer commented Dec 31, 2024

This is on Enzyme 0.13.27, Julia 1.11.2.

To reproduce, run the following code. This is the same code in #2081, but now it hits a segfault whereas before it hit the task switch error.

using SymbolicRegression
using Random: MersenneTwister
using Enzyme
using MLJBase: machine, fit!, predict, report
using Test

X = let rng = MersenneTwister(0), n = 30
    (; x1=randn(rng, n), x2=randn(rng, n), class=rand(rng, 1:2, n))
end

y = let P1 = [0.1, 1.5], P2 = [3.2, 0.5]
    [2 * cos(x2 + P1[class]) + x1^2 - P2[class] for (x1, x2, class) in zip(X.x1, X.x2, X.class)]
end

model = SRRegressor(;
    niterations=100,
    binary_operators=[+, *, /, -],
    unary_operators=[cos, exp],
    populations=30,
    expression_type=ParametricExpression,
    expression_options=(; max_parameters=2),
    autodiff_backend=:Enzyme,
);

mach = machine(model, X, y)
fit!(mach)
@MilesCranmer
Copy link
Contributor Author

Also noting here that when I use --gcthreads=1 for Julia, I get the same task switch error in #2081.

@wsmoses
Copy link
Member

wsmoses commented Jan 1, 2025

To confirm, what happens on 1.10?

@MilesCranmer
Copy link
Contributor Author

MilesCranmer commented Jan 1, 2025

On 1.10.7 it actually runs for a bit, but then hits a segfault:

[69110] signal (11.2): Segmentation fault: 11 second: 7.00e+04. Press 'q' and then <enter> to stop execution early.
in expression starting at REPL[12]:1
gc_mark_outrefs at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XC9YQX9HH2.0/build/default-honeycrisp-XC9YQX9HH2-0/julialang/julia-release-1-dot-10/src/gc.c:2510 [inlined]
gc_mark_and_steal at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XC9YQX9HH2.0/build/default-honeycrisp-XC9YQX9HH2-0/julialang/julia-release-1-dot-10/src/gc.c:2739
gc_mark_loop_parallel at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XC9YQX9HH2.0/build/default-honeycrisp-XC9YQX9HH2-0/julialang/julia-release-1-dot-10/src/gc.c:2886
jl_gc_mark_threadfun at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XC9YQX9HH2.0/build/default-honeycrisp-XC9YQX9HH2-0/julialang/julia-release-1-dot-10/src/partr.c:142
_pthread_start at /usr/lib/system/libsystem_pthread.dylib (unknown line)

@wsmoses
Copy link
Member

wsmoses commented Jan 1, 2025

Interesting, can you try to reduce the complexity of the MWE for us to debug?

@MilesCranmer
Copy link
Contributor Author

I've tried before when I first posted #2081 but I couldn't figure out how to break it down further

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

No branches or pull requests

2 participants