Skip to content

Turn RunAttributor into a compile-time preference#3047

Open
vchuravy wants to merge 5 commits intomainfrom
vc/prefs
Open

Turn RunAttributor into a compile-time preference#3047
vchuravy wants to merge 5 commits intomainfrom
vc/prefs

Conversation

@vchuravy
Copy link
Copy Markdown
Member

Attributor yet again seems to be the cause of some illegal code transformation,
and I would like my last few days of investigating #3041 (comment) back.

This PR turns running it into an preference flag (so that folks who want it don't need to remember passing an environment flag),
but turns it off by default.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Benchmark Results

main dc3959b... main / dc3959b...
basics/make_zero/namedtuple 0.0535 ± 0.002 μs 0.0527 ± 0.0037 μs 1.01 ± 0.081
basics/make_zero/struct 0.277 ± 0.0051 μs 0.277 ± 0.0075 μs 0.999 ± 0.033
basics/overhead 4.95 ± 0.01 ns 4.95 ± 0.001 ns 1 ± 0.002
basics/remake_zero!/namedtuple 0.221 ± 0.0093 μs 0.224 ± 0.0086 μs 0.988 ± 0.056
basics/remake_zero!/struct 0.229 ± 0.011 μs 0.227 ± 0.011 μs 1.01 ± 0.07
fold_broadcast/multidim_sum_bcast/1D 10.3 ± 0.3 μs 10.3 ± 0.3 μs 1.01 ± 0.042
fold_broadcast/multidim_sum_bcast/2D 12.1 ± 0.28 μs 10.2 ± 0.17 μs 1.19 ± 0.034
time_to_load 1.08 ± 0.015 s 1.17 ± 0.029 s 0.923 ± 0.026

Benchmark Plots

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

@vchuravy
Copy link
Copy Markdown
Member Author

Sigh it seems necessary for 1.10 test to pass.

Comment thread src/preferences.jl Outdated
Comment thread src/preferences.jl Outdated
@vchuravy vchuravy requested a review from wsmoses April 28, 2026 14:42
Comment thread lib/EnzymeTestUtils/test/test_forward.jl Outdated
@wsmoses
Copy link
Copy Markdown
Member

wsmoses commented Apr 29, 2026

is there a reason for doing this since we already have the ref option?

I agree this is nicer, but technically breaking

@vchuravy
Copy link
Copy Markdown
Member Author

is there a reason for doing this since we already have the ref option?

Attributor is turned off already by default for 1.12 and as #3041 shows causes compilation issues that are really frustrating to debug in 1.11 (I spent ~4days trying to root cause that bug this week).

So yes as CI shows it sometimes does positive things, but it also continuously seems to create deeply frustrating bugs and I for one had enough of it.

@wsmoses
Copy link
Copy Markdown
Member

wsmoses commented Apr 30, 2026

oh I meant more in reference to it being a preference vs the current ref [not wrt the default or not].

we should look at the remaining failure with 1.11 when disabled. part of why its okay to turn off is ive been slowly making an "attributor lite" pass for our specific needs, though not as aggressive

@vchuravy
Copy link
Copy Markdown
Member Author

vchuravy commented May 6, 2026

oh I meant more in reference to it being a preference vs the current ref [not wrt the default or not].

I think that's fine. We are promoting it from an internal interface, to something more official and documented.

vchuravy and others added 5 commits May 6, 2026 10:31
Add src/preferences.jl with documented run_attributor() getter and
set_run_attributor!() setter, defaulting to false. Export both from
the top-level Enzyme module.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document the attributor pass in faq.md with a description of what it
does, why it defaults to false, and how to use run_attributor() and
set_run_attributor!(). Add a basic test for the preference round-trip.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
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.

2 participants