fix: xgboost nthreads and remove obsolete code
@@ -54,9 +54,6 @@ def _get_model_info(
) -> t.Tuple["ModelInfo", str, t.Dict[str, t.Any]]:
model_info = model_store.get(tag)
if model_info.module != __name__:
- if model_info.module == "bentoml.mlflow":
- pass
- else:
raise BentoMLException( # pragma: no cover
f"Model {tag} was saved with"
f" module {model_info.module},"
@@ -186,6 +183,7 @@ class _XgBoostRunner(Runner):
self._model_info = model_info
self._model_file = model_file
self._predict_fn_name = predict_fn_name
+ booster_params = dict() if booster_params is None else booster_params
self._booster_params = self._setup_booster_params(booster_params)
@property
@@ -196,7 +194,10 @@ class _XgBoostRunner(Runner):
def num_concurrency_per_replica(self) -> int:
if self.resource_quota.on_gpu:
return 1
+ nthreads = self._booster_params.get("nthread", -1) # type: int
+ if nthreads == -1:
return int(round(self.resource_quota.cpu))
+ return nthreads
@property
def num_replica(self) -> int:
@@ -215,12 +216,16 @@ class _XgBoostRunner(Runner):
booster_params["nthread"] = 1
else:
booster_params["predictor"] = "cpu_predictor"
- booster_params["nthread"] = self.num_concurrency_per_replica
+ booster_params["nthread"] = -1
return booster_params
# pylint: disable=arguments-differ,attribute-defined-outside-init
def _setup(self) -> None: # type: ignore[override]
+ """_setup.
+
+ :rtype: None
+ """
self._model = xgb.core.Booster(
params=self._booster_params,
model_file=self._model_file,
