Skip to content

Enzyme should be loaded on-demand at runtime #143295

Open
@workingjubilee

Description

@workingjubilee

This is an enhancement request for the sake of making the Enzyme autodiff functionality more maintainable: load Enzyme at runtime, on demand, via a mechanism like dlopen. My understanding is that both T-infra (or at least @Kobzol) and the relevant autodiff lead (@ZuseZ4) are interested in seeing this happen, because it would help decouple the Enzyme bindings and thus the infrastructure maintenance required to ship Enzyme support.

I do not fully understand what Enzyme actually "is" (is it actually a shared object that is loaded by LLVM? or do you open it and then it runs LLVM? or do you just have both in the same address space and then... magic happens?) so I cannot describe further what is required other than that. I am opening this issue so we can better identify and track

  • what we hope to gain by doing this work?
  • how will this affect the API's library support?
  • how will this affect the internal compiler support?
  • how do we actually do it?
    • we first have to identify how Enzyme and LLVM actually... interact on the procedural level and what role rustc plays
    • @bjorn3 says a complication is from compiling Enzyme as a .so, because LLVM is sometimes "statically"1 linked by rustc
    • once that is done, I suspect the easiest route is to not use dlopen directly but rather libloading

@rustbot label: +C-enhancement +F-autodiff +A-LLVM +T-compiler +T-infra +T-libs

Footnotes

  1. "statically" in this case means "required dynamic linkage", so it is loaded by the dynamic loader upon loading librustc_driver.so

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.F-autodiff`#![feature(autodiff)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions