Skip to content

chore: bump both enzyme and jax versions #858

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

chore: bump both enzyme and jax versions #858

wants to merge 17 commits into from

Conversation

avik-pal
Copy link
Collaborator

No description provided.

@avik-pal
Copy link
Collaborator Author

build seems broken locally let me try and fix

@avik-pal
Copy link
Collaborator Author

src/enzyme_ad/jax/Passes/AffineCFG.cpp:3503:38: error: 'class mlir::AffineExpr' has no member named 'cast'
 3503 |             dimDescriptors[minorExpr.cast<AffineDimExpr>().getPosition()] =
      |                                      ^~~~
src/enzyme_ad/jax/Passes/AffineCFG.cpp:3503:56: error: expected primary-expression before '>' token
 3503 |             dimDescriptors[minorExpr.cast<AffineDimExpr>().getPosition()] =
      |                                                        ^
src/enzyme_ad/jax/Passes/AffineCFG.cpp:3503:58: error: expected primary-expression before ')' token
 3503 |             dimDescriptors[minorExpr.cast<AffineDimExpr>().getPosition()] =

@wsmoses
Copy link
Member

wsmoses commented Apr 23, 2025

Ah so that finally landed, we need to rewrite a.cast() into cast(a)

@avik-pal
Copy link
Collaborator Author

and isa / dyn_cast 😓

@avik-pal
Copy link
Collaborator Author

 4506 |   ty.isa<ComplexType>() ||
      |      ^~~
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4506:21: error: expected primary-expression before '>' token
 4506 |   ty.isa<ComplexType>() ||
      |                     ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4506:23: error: expected primary-expression before ')' token
 4506 |   ty.isa<ComplexType>() ||
      |                       ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4507:8: error: 'class mlir::Type' has no member named 'isa'
 4507 |     ty.isa<TensorType>() &&
      |        ^~~
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4507:22: error: expected primary-expression before '>' token
 4507 |     ty.isa<TensorType>() &&
      |                      ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4507:24: error: expected primary-expression before ')' token
 4507 |     ty.isa<TensorType>() &&
      |                        ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4508:8: error: 'class mlir::Type' has no member named 'cast'
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |        ^~~~
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4508:23: error: expected primary-expression before '>' token
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |                       ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4508:25: error: expected primary-expression before ')' token
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |                         ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4508:59: error: expected primary-expression before '>' token
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |                                                           ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4508:61: error: expected primary-expression before ')' token
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |                                                             ^
bazel-out/k8-dbg/bin/src/enzyme_ad/jax/Implementations/MHLODerivatives.inc:4503:32: error: void value not ignored as it ought to be
 4503 |               bool condition = ({
      |                                ^~
 4504 | 
      |                                 
 4505 |   auto ty = imVal.getType();
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~    
 4506 |   ty.isa<ComplexType>() ||
      |   ~~~~~~~~~~~~~~~~~~~~~~~~      
 4507 |     ty.isa<TensorType>() &&
      |     ~~~~~~~~~~~~~~~~~~~~~~~     
 4508 |     ty.cast<TensorType>().getElementType().isa<ComplexType>();
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4509 | 
      |                                 
 4510 |               });

Are these from Enzyme's td?

@wsmoses
Copy link
Member

wsmoses commented Apr 23, 2025

yeah, though I thought I fixed those in upstream enzyme, but maybe not. Specifically tablegen will automatically generate those. I presume that comes from https://github.com/EnzymeAD/Enzyme/blob/da27d526b8a755f80a116a5d5f3319c2ab5ecfd5/enzyme/Enzyme/MLIR/Implementations/Common.td#L122

@avik-pal
Copy link
Collaborator Author

ERROR: /home/avik-pal/reactant/Enzyme-JAX/src/enzyme_ad/jax/BUILD:438:11: Compiling src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp failed: (Exit 1): gcc failed: error executing CppCompile command (from target //src/enzyme_ad/jax:XLADerivatives) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g '-std=c++14' -MD -MF ... (remaining 229 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/llvm-project/mlir/include/mlir/Support/LLVM.h:23,
                 from external/llvm-project/mlir/include/mlir/IR/Visitors.h:16,
                 from external/llvm-project/mlir/include/mlir/IR/AffineExpr.h:17,
                 from external/llvm-project/mlir/include/mlir/IR/AffineMap.h:17,
                 from external/llvm-project/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h:16,
                 from external/llvm-project/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h:17,
                 from ./src/enzyme_ad/jax/Passes/AffineUtils.h:4,
                 from src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp:13:
external/llvm-project/llvm/include/llvm/Support/Casting.h: In instantiation of 'static bool llvm::isa_impl<To, From, Enabler>::doit(const From&) [with To = mlir::AffineConstantExpr; From = mlir::arith::ConstantOp; Enabler = void]':
external/llvm-project/llvm/include/llvm/Support/Casting.h:81:36:   required from 'static bool llvm::isa_impl_cl<To, const From>::doit(const From&) [with To = mlir::AffineConstantExpr; From = mlir::arith::ConstantOp]'
external/llvm-project/llvm/include/llvm/Support/Casting.h:137:41:   required from 'static bool llvm::isa_impl_wrap<To, FromTy, FromTy>::doit(const FromTy&) [with To = mlir::AffineConstantExpr; FromTy = const mlir::arith::ConstantOp]'
external/llvm-project/llvm/include/llvm/Support/Casting.h:257:62:   required from 'static bool llvm::CastIsPossible<To, From, Enable>::isPossible(const From&) [with To = mlir::AffineConstantExpr; From = const mlir::arith::ConstantOp; Enable = void]'
external/llvm-project/llvm/include/llvm/Support/Casting.h:549:46:   required from 'bool llvm::isa(const From&) [with To = mlir::AffineConstantExpr; From = mlir::arith::ConstantOp]'
external/llvm-project/llvm/include/llvm/Support/Casting.h:572:3:   required from 'decltype(auto) llvm::cast(From&) [with To = mlir::AffineConstantExpr; From = mlir::arith::ConstantOp]'
src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp:2041:59:   required from here
external/llvm-project/llvm/include/llvm/Support/Casting.h:64:64: error: 'classof' is not a member of 'mlir::AffineConstantExpr'
   64 |   static inline bool doit(const From &Val) { return To::classof(&Val); }
      |                                                     ~~~~~~~~~~~^~~~~~
Target //:enzymexlamlir-opt failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 16.015s, Critical Path: 14.40s
INFO: 73 processes: 70 internal, 3 processwrapper-sandbox.
ERROR: Build did NOT complete successfully

this seems to be from inside llvm?

@wsmoses
Copy link
Member

wsmoses commented Apr 23, 2025

not quite, it looks like there's an incompatible cast, specificallt To=mlir::AffineConstantExpr; From = mlir::arith::ConstantOp

@wsmoses
Copy link
Member

wsmoses commented Apr 23, 2025

presumably on src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp:2041:

@avik-pal
Copy link
Collaborator Author

locally tests pass 🎉

@avik-pal
Copy link
Collaborator Author

@wsmoses
Copy link
Member

wsmoses commented Apr 24, 2025

cc @ezhulenev I presume this comes from openxla/xla@f71e49d ?

ERROR: /home/runner/.bazel/external/xla/xla/backends/cpu/runtime/BUILD:163:11: Compiling xla/backends/cpu/runtime/parallel_loop_runner.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target @@xla//xla/backends/cpu/runtime:parallel_loop_runner) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 49 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:16:
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:102:13: error: explicit specialization in non-namespace scope 'class xla::cpu::ParallelLoopRunner'
  102 |   template <> struct TaskIndex<RangeDim> { using Index = RangeIndex; };
      |             ^
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:102:22: error: too few template-parameter-lists
  102 |   template <> struct TaskIndex<RangeDim> { using Index = RangeIndex; };
      |                      ^~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:103:13: error: explicit specialization in non-namespace scope 'class xla::cpu::ParallelLoopRunner'
  103 |   template <> struct TaskIndex<TileDim>  { using Index = TileIndex; };
      |             ^
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:103:22: error: too few template-parameter-lists
  103 |   template <> struct TaskIndex<TileDim>  { using Index = TileIndex; };
      |                      ^~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc: In member function 'void xla::cpu::ParallelLoopRunner::ParallelTask1D::operator()(size_t) const':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:114:35: error: no matching function for call to 'xla::cpu::ParallelLoopRunner::Delinearize(size_t&, const xla::cpu::ParallelLoopRunner::RangeDim&) const'
  114 |       std::apply(task, Delinearize(task_index, this->i));                   \
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:168:1: note: in expansion of macro 'DEFINE_PARALLEL_TASK_1D'
  168 | DEFINE_PARALLEL_TASK_1D(Task1D, RangeDim);
      | ^~~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note: candidate: 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...)'
  121 |   static std::tuple<task_index_t<Dims>...> Delinearize(size_t task_index,
      |                                            ^~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note:   template argument deduction/substitution failed:
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h: In substitution of 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...) [with Dims = {xla::cpu::ParallelLoopRunner::RangeDim}]':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:168:1:   required from here
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:326:6: error: invalid use of incomplete type 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::RangeDim>'
  326 | auto ParallelLoopRunner::Delinearize(size_t task_index, Dims... dims)
      |      ^~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:101:34: note: declaration of 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::RangeDim>'
  101 |   template <typename Dim> struct TaskIndex;
      |                                  ^~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc: In member function 'void xla::cpu::ParallelLoopRunner::ParallelTask1DTile1D::operator()(size_t) const':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:114:35: error: no matching function for call to 'xla::cpu::ParallelLoopRunner::Delinearize(size_t&, const xla::cpu::ParallelLoopRunner::TileDim&) const'
  114 |       std::apply(task, Delinearize(task_index, this->i));                   \
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:169:1: note: in expansion of macro 'DEFINE_PARALLEL_TASK_1D'
  169 | DEFINE_PARALLEL_TASK_1D(Task1DTile1D, TileDim);
      | ^~~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note: candidate: 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...)'
  121 |   static std::tuple<task_index_t<Dims>...> Delinearize(size_t task_index,
      |                                            ^~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note:   template argument deduction/substitution failed:
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h: In substitution of 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...) [with Dims = {xla::cpu::ParallelLoopRunner::TileDim}]':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:169:1:   required from here
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:326:6: error: invalid use of incomplete type 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::TileDim>'
  326 | auto ParallelLoopRunner::Delinearize(size_t task_index, Dims... dims)
      |      ^~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:101:34: note: declaration of 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::TileDim>'
  101 |   template <typename Dim> struct TaskIndex;
      |                                  ^~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc: In member function 'void xla::cpu::ParallelLoopRunner::ParallelTask2D::operator()(size_t) const':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:123:35: error: no matching function for call to 'xla::cpu::ParallelLoopRunner::Delinearize(size_t&, const xla::cpu::ParallelLoopRunner::RangeDim&, const xla::cpu::ParallelLoopRunner::RangeDim&) const'
  123 |       std::apply(task, Delinearize(task_index, this->i, this->j));          \
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:171:1: note: in expansion of macro 'DEFINE_PARALLEL_TASK_2D'
  171 | DEFINE_PARALLEL_TASK_2D(Task2D, RangeDim, RangeDim);
  157 |       std::apply(task, Delinearize(task_index, this->i, this->j, this->k,   \
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158 |                                    this->l, this->m));                      \
      |                                    ~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:183:1: note: in expansion of macro 'DEFINE_PARALLEL_TASK_5D'
  183 | DEFINE_PARALLEL_TASK_5D(Task5DTile2D, RangeDim, RangeDim, RangeDim, TileDim,
      | ^~~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note: candidate: 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...)'
  121 |   static std::tuple<task_index_t<Dims>...> Delinearize(size_t task_index,
      |                                            ^~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:121:44: note:   template argument deduction/substitution failed:
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h: In substitution of 'template<class ... Dims> static std::tuple<typename xla::cpu::ParallelLoopRunner::TaskIndex<Dims>::Index ...> xla::cpu::ParallelLoopRunner::Delinearize(size_t, Dims ...) [with Dims = {xla::cpu::ParallelLoopRunner::RangeDim, xla::cpu::ParallelLoopRunner::RangeDim, xla::cpu::ParallelLoopRunner::RangeDim, xla::cpu::ParallelLoopRunner::TileDim, xla::cpu::ParallelLoopRunner::TileDim}]':
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.cc:183:1:   required from here
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:326:6: error: invalid use of incomplete type 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::RangeDim>'
  326 | auto ParallelLoopRunner::Delinearize(size_t task_index, Dims... dims)
      |      ^~~~~~~~~~~~~~~~~~
external/xla/xla/backends/cpu/runtime/parallel_loop_runner.h:101:34: note: declaration of 'struct xla::cpu::ParallelLoopRunner::TaskIndex<xla::cpu::ParallelLoopRunner::RangeDim>'
  101 |   template <typename Dim> struct TaskIndex;
      |                                  ^~~~~~~~~
[2,993 / 8,705] Compiling src/enzyme_ad/jax/Passes/LowerJIT.cpp; 13s disk-cache, processwrapper-sandbox ... (3 actions running)
Target //:wheel failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1383.127s, Critical Path: 82.21s
INFO: 1678 processes: 362 disk cache hit, 324 internal, 992 processwrapper-sandbox.
ERROR: Build did NOT complete successfully

@avik-pal
Copy link
Collaborator Author

trying to use clang to see if it works, I am getting errors in Enzyme

bazel build --color=yes -c dbg --repo_env=CC=/home/avik-pal/software/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04/bin/clang --repo_env=BAZEL_COMPILER=/home/avik-pal/software/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04/bin/clang --copt -Wno-sign-compare --copt -Wno-error=unused-command-line-argument --copt -Wno-gnu-offsetof-extensions  :wheel

the options are based off https://github.com/openxla/xla/blob/ee9ee727b533dbd14698c9eda979a8c83ed86e11/build_tools/configure/configure.py#L417

external/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:3944:19: error: no member named 'nvvm_fabs' in namespace 'llvm::Intrinsic'
 3944 |   case Intrinsic::nvvm_fabs:
      |        ~~~~~~~~~~~^
external/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:3945:19: error: no member named 'nvvm_fabs_ftz' in namespace 'llvm::Intrinsic'
 3945 |   case Intrinsic::nvvm_fabs_ftz:
      |        ~~~~~~~~~~~^

@wsmoses
Copy link
Member

wsmoses commented Apr 25, 2025

yeah that commit updates for a newer llvm version [only acceepted by newer xla]

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