Migration guide#

Basic workflow#

Call load_model(), load_from_sklearn(), or load_from_treelite_model(). Note that it is no longer necessary to specify the is_classifier parameter.

# BEFORE
import cuml
fil_model = cuml.fil.ForestInference.load_from_sklearn(skl_model, is_classifier=True)
fil_model.optimize(batch_size=1024)
predictions = fil_model.predict(X)
probabilities = fil_model.predict_proba(X)
per_tree_pred = fil_model.predict_per_tree(X)
lead_ids = fil_model.apply(X)
# AFTER
import nvforest
nvforest_model = nvforest.load_from_sklearn(skl_model)
nvforest_model = nvforest_model.optimize(batch_size=1024)
predictions = nvforest_model.predict(X)
probabilities = nvforest_model.predict_proba(X)
per_tree_pred = nvforest_model.predict_per_tree(X)
lead_ids = nvforest_model.apply(X)

Device selection#

Specify the device parameter when calling load_model().

# BEFORE
with cuml.fil.set_fil_device_type("cpu"):
    fil_model = cuml.fil.ForestInference.load_from_sklearn(skl_model)
# AFTER
nvforest_model = nvforest.load_from_sklearn(skl_model, device="cpu")

nvForest also differs from FIL when it comes to the behavior when no device is explicitly specified. The device parameter defaults to "auto". nvForest will attempt to load the tree model onto a GPU device, if one is available. If no GPU is available, nvForest will fall back to the CPU.