Skip to content

GSoC 2021

Vassil Vassilev edited this page Feb 19, 2021 · 5 revisions

Project Description

Utilize second order derivatives from Clad in ROOT

In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation.

ROOT is a framework for data processing, born at CERN, at the heart of the research on high-energy physics. Every day, thousands of physicists use ROOT applications to analyze their data or to perform simulations. ROOT has a clang-based C++ interpreter Cling and integrates with Clad to enable flexible automatic differentiation facility.

Task ideas and expected results:

TFormula is a ROOT class which bridges compiled and interpreted code. Teach TFormula to use second order derivatives (using clad::hessian). The implementation should be very similar to what was done in this pull request. The produced code should be well tested and documented. The student should be prepared to write a progress report and present the results. If time permits, we should pursue converting the C++ gradient function to CUDA device kernels. The integration of that feature should be comparable in terms of complexity to integrating clad::hessians.

Necessary skills: Intermediate C++; Understanding basic differential calculus; intermediate knowledge of clang and ROOT.

Mentors: Vassil Vassilev (vgvassilev); Ioana Ifrim (ioanaif)

Add support for functor objects in clad

In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation. The AD library is able to differentiate non-trivial functions, to find a partial derivative for trivial cases and has good unit test coverage.

Many computations are modelled using functor objects. Usually, a functor object is a lightweight C++ object which has state stored as members and has overridden call operator (operator()). For example:

 struct Functor {
   double x;
   double operator()() { return x * x ;}
 };

 int main () {
   Functor Fn;
   Fn.x = 2;
   double pow2 = Fn();
   auto dpow2_dx = clad::differentiate(Fn, /*wrt*/ 0); // unsupported
   return pow2;
 }

The goal of this project is to modify Clad to handle such cases.

Task ideas and expected results:

Implement functor object differentiation in both forward and reverse mode. The candidate should be ready to investigate performance bottlenecks, add test and benchmarking coverage and improve documentation for various parts of clad not only limited to the functor object differentiation support. The student should be prepared to write a progress report and present the results.

Necessary skills: Intermediate C++; Understanding basic differential calculus; intermediate knowledge of clang.

Mentors: Vassil Vassilev (vgvassilev); David Lange (davidlange6)

Add initial integration of Clad with Enzyme

In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation. The AD library is able to differentiate non-trivial functions, to find a partial derivative for trivial cases and has good unit test coverage. Enzyme is a prominent autodiff framework which works on LLVM IR.

Clad and Enzyme can be considered as a C++ frontend and a backend automatic differentiation framework. In many cases, when clad needs to fall back to numeric differentiation it can try configuring and using Enzyme to perform the automatic differentiation on lower level.

Task ideas and expected results:

Understand how both systems work. Define the Enzyme configuration requirements and enable Clad to communicate efficiently with Enzyme. That may require several steps: start building and using the optimization pass of Enzyme as part of the Clad toolchain; use Enzyme for cross-validation derivative results; etc. The student should be prepared to write a progress report and present the results.

Necessary skills: Intermediate C++; Understanding basic differential calculus; intermediate knowledge of clang and llvm.

Mentors: Vassil Vassilev (vgvassilev); William Moses (wsmoses)

Add numerical differentiation support in clad

In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation. The AD library is able to differentiate non-trivial functions, to find a partial derivative for trivial cases and has good unit test coverage. In a number of cases, due different limitations, it is either inefficient or impossible to differentiate a function. For example, clad cannot differentiate declared-but-not-defined functions. In that case it issues an error. Instead, clad should fall back to its future numerical differentiation facilities.

Task ideas and expected results:

Implement numerical differentiation support in clad. It should be available through a dedicated interface (for example clad::num_differentiate). The new functionality should be connected to the forward mode automatic differentiation. If time permits, a prototype of configurable error estimation for the numerical differentiation should be implemented. The student should be prepared to write a progress report and present the results.

Necessary skills: Intermediate C++; Understanding basic differential calculus; intermediate knowledge of clang.

Mentors: Vassil Vassilev (vgvassilev); Alexander Penev (alexander-penev)

If you have used clad and you have particular project proposal please contact vgvassilev.

Candidate Guidelines

If you have interest in working on the project there is a list of things to do in order to maximize your chances to get selected:

  1. Contact the mentors and express interest in the project. Make sure you attach your CV;
  2. Download the source code of the project, build it and run the demos;
  3. Start familiarizing yourself with the codebase;
  4. If you have questions you can always contact a mentor.

Candidate Evaluation

The mentors are interested in working with all candidates but unfortunately the rules allow only one to be selected. There are a few tasks which give bonus points to candidate's application:

  • Submit a valid bug -- demonstrates that the candidate has completed step 2 and 3 from the previous section.
  • Fix a bug -- demonstrates the technical skills of the candidate and shows he/she can work independently on the project. The mentors can suggest looking into these good first issues. Fixing one issue may be enough to become a successful candidate.

Good luck!