ceholden / yatsm

Yet Another Time Series Model
https://yatsm.readthedocs.org/en/latest/
MIT License
63 stars 30 forks source link

Optimization via Numba #70

Closed ceholden closed 8 years ago

ceholden commented 8 years ago

Now that the CCDCesque implementation has a regression test (4ac359fddc38c6ae52e3334f0f93d5393b047ddd) so we can be sure we optimization didn't break anything, let's try to make CCDCesque algorithm run faster by JIT-ing as much of the computation as possible when numba is installed.

Plan:

  1. [x] Create a shim decorator for numba.jit that will return a JIT function when numba is available but returns an unaltered function when it is not.
    • This way we can tag functions with @jit without worry of segregating the codebase because of an optional dependency
  2. [x] Refactor out as much generic computation logic from CCDCesque into appropriate YATSM module
    • e.g., RMSE calculation goes to yatsm.regression
  3. [x] Refactor methods that perform heavy computation in CCDCesque into functions so they can be JIT-ed
  4. [x] Leave with CCDCesque as more of a container for results that pairs with methods for creating, working with, and visualizing said results
    • At this stage, implement API changes referenced in #67
ceholden commented 8 years ago

Added Jupyter notebook to keep a log of benchmark timings for code changes/commits. Development will continue on branch feat/issue70

ceholden commented 8 years ago

Testing on the p022r049 example dataset showed a speedup of ~2x between v0.5.5 (906d4ec48e3158ea69a1bfec8cdaef49d6a8e424) and upcoming v0.6.0 (ec0d06ec6a3cb2eb9086c1b0c188b366b4c96eea) for running CCDCesque.

Last goal is somewhat accomplished. There is far too much state information and other variables to completely rip out all the computation and put into one big, JIT'd function.

Speed ups are result of see (31e21f905adf9dce0b521a588b2cbf488dbbec24):

Closing for now, with possible round 2 of optimizations in store for CCDCesque. For now we also have a working "JIT when possible" decorator to use with other algorithms.