dmlc / treelite

Universal model exchange and serialization format for decision tree forests

Home Page:https://treelite.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Treelite crashes with XGBoost 2.0 dev

hcho3 opened this issue · comments

XGBoost version used: https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/master/xgboost-2.0.0.dev0%2B250b22dd22f9bda7fb02201ec7daa58dd70b20e9-py3-none-manylinux2014_x86_64.whl

Reproducer:

import xgboost as xgb
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)

params = {"max_depth": 3, "eta": 0.1, "objective": "multi:softprob",
          "eval_metric": "mlogloss", "num_class": 3}
dtrain = xgb.DMatrix(X, label=y)
bst = xgb.train(params, dtrain, num_boost_round=20,
                evals=[(dtrain, 'train')])
bst.save_model("my_model.model")

Using JSON:

model = treelite.Model.from_xgboost(bst)

errors out:

TreeliteError: [09:49:34] /home/conda/feedstock_root/build_artifacts/treelite_1683008603774/work/src/frontend/xgboost_json.cc:670: Provided JSON could not be parsed as XGBoost model. Parsing error at offset 198: Terminate parsing due to Handler error.
lel_tree":"1","num_trees":"60"},"iteration_indptr":[0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using binary format;

model = treelite.Model.load("my_model.model", model_format="xgboost")

throws error

TreeliteError: std::bad_alloc