Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework consteval to be more memory efficient. (#14504)
* Also adds an option to use the llvm-cpu backend instead of VMVX. This isn't quite ready for primetime because I need to isolate some flags better, but it can be used in a pinch. * Changes the way that JIT programs are constructed so that stateless functions are compiled at once for all constants and the data is passed in/out vs being cloned from module globals. * Each global has a public function to compute it, allowing us to run them one by one or in batches to keep memory use under control. * In this patch, I am just running them one by one and also haven't optimized memory by use of resources yet. Still a big improvement. * Drops compilation time of h2ogpt from ~45m to 2m47s. More optimization is possible. * JIT'ing globals now takes 52s for this model (vs ~42m with the Linalg const evaler). * Memory pressure is kept under control and does not regress from the current state (more optimization is possible - just a starting point). I also changed the behavior of the constexpr hoisting and jit passes to produce/process initializers with the `iree.compiler.consteval` attribute. This was advisable because in the new way of doing evaluation, we are doing a non-general transformation on the initializers and I didn't want it stumbling over arbitrary initializers in the wild. Having the behavior be opt-in seemed prudent. Flag changes: * `iree-consteval-jit-use-vmvx` (default true): Uses the VMVX backend. When false, uses the LLVMCPU backend. I'll be doing work to change this to false by default when LLVMCPU is available. * `iree-consteval-jit-debug`: Prints debugging information about constant evaluation. * `iree-opt-const-eval`: Flipped to true since it now only processes initializers targeted at it and is therefore safe to always have enabled.
- Loading branch information