acalejos / exgboost

Elixir bindings to the XGBoost C API (https://xgboost.readthedocs.io/en/stable/c.html) using Native Implemented Functions (NIFs)
Apache License 2.0
159 stars 6 forks source link

EXGBoost.compile/1 does not exist #43

Open alexkaf opened 1 month ago

alexkaf commented 1 month ago

I was following the Livebook provided in the docs. I noticed that there exists an EXGBoost.compile/2 invocation, however this function does not exist in the current version and the notebook fails.

Also, I searched older commits and noticed that EXGBoost.compile/2 was essentially a simple invocaon to Mockingjay.convert/2 function. Yet, even after replacing the EXGBoost.compile/1 with Mockingjay.convert/2 on the notebook example, I get the following error:

(mockingjay 0.1.0) lib/mockingjay/tree.ex:1: Mockingjay.DecisionTree.impl_for!/1
(mockingjay 0.1.0) lib/mockingjay/strategies/gemm.ex:13: Mockingjay.Strategies.GEMM.init/2
(mockingjay 0.1.0) lib/mockingjay.ex:64: Mockingjay.convert/2
(stdlib 5.0.2) erl_eval.erl:746: :erl_eval.do_apply/7
(stdlib 5.0.2) erl_eval.erl:494: :erl_eval.expr/6
(elixir 1.15.4) src/elixir.erl:361: :elixir.eval_forms/4
(elixir 1.15.4) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
lib/livebook/runtime/evaluator.ex:622: anonymous fn/3 in Livebook.Runtime.Evaluator.eval/4

What is the correct approach of transforming an XGBoost loaded model to a series of tensor operations?

acalejos commented 1 month ago

Hey thanks for raising the issue. Check out this notebook to see if it helps. Otherwise I'll look at it over the weekend because I haven't looked at Mockingjay in a while.

https://gist.github.com/acalejos/4598e5e2b2b91e420a4cf609bc2ffc03#compiling-the-exgboost-model

alexkaf commented 1 month ago

Same thing. All in all, the missing EXGBoost.compile/2 is not a problem since MockingJay.convert/2 can be used, the problem I see (and correct me if I'm wrong) is that the implementation of the MockingJay.DecisionTree is missing for EXGBoost.Booster.

acalejos commented 1 month ago

Did you make sure to pull from the feature branch?

{:mockingjay,
     git: "https://github.com/acalejos/mockingjay.git", branch: "make_tree_travs_jit_compilable"}

I'll take some time to try and clean it up and merge into main but it's been very low priority hence why its still in that state