Update XGBoost max supported version to 3.0.2#2657
Update XGBoost max supported version to 3.0.2#2657sid22669 wants to merge 4 commits intoapple:mainfrom
Conversation
The XGBoost converter is already compatible with 3.x — the JSON tree dump format and API (get_booster, get_dump, feature_names, copy) are unchanged. Tested with XGBRegressor, XGBClassifier (binary and multi-class), and raw Booster conversion.
|
The tests are still using the old version of XGBoost. See the link I shared in the issue. |
Update the pinned XGBoost version in test requirements to match the new max supported version.
|
Thanks for the review! I've updated While testing, I also found two compatibility issues with XGBoost 3.x:
Added a test to verify base_score propagation. Will push these changes shortly. |
- Read base_score from booster config instead of hardcoding 0.5/0.0 - Convert feature_names to list for XGBoost 3.x compatibility - Add test verifying base_score is correctly propagated
save_config() exists in all supported XGBoost versions (1.4.2+), so silencing exceptions would hide real breakage.
|
Thanks for removing the try/except. CI: https://gitlab.com/coremltools1/coremltools/-/pipelines/2376256024 |
JiwaniZakir
left a comment
There was a problem hiding this comment.
The new XGBoostBaseScoreTest only exercises the regressor path, but the diff also modifies base_prediction for both binary and multiclass classifiers in _tree_ensemble.py (lines ~252–265). The classifier branches—where base_score from the model config is spread across n_classes slots—have no corresponding test coverage, which is worth adding given that the semantics of base_score differ between regression and classification objectives (e.g., log-odds vs. raw margin for binary logistic).
Additionally, load_boston() was deprecated in scikit-learn 1.2 and removed in 1.4; the test class's setUpClass will fail on any modern scikit-learn installation. The existing tests in the file use it too, but introducing new test cases that rely on it compounds the problem rather than addressing it—switching to a synthetic dataset via sklearn.datasets.make_regression would be straightforward and future-proof.
Finally, the config['learner']['learner_model_param']['base_score'] key path is duplicated verbatim in both the converter (_tree_ensemble.py:203) and the test (test_boosted_trees_regression_numeric.py:332). Extracting a small helper (e.g., _get_base_score(booster)) in the converter module and importing it in the test would eliminate the duplication and make any future schema changes easier to handle in one place.
Motivation
Fixes #2596
Users are blocked from converting XGBoost 3.x models because
_XGBOOST_MAX_VERSIONis set to1.4.2. XGBoost 1.4.2 is incompatible with newer Python versions (3.12+), forcing users into a dependency nightmare.Modifications
coremltools/_deps/__init__.py:_XGBOOST_MAX_VERSIONfrom"1.4.2"to"3.0.2"Verification
Tested all conversion paths with XGBoost 3.0.2 — the converter is fully compatible:
The JSON tree dump format (
split,split_condition,children,leaf,cover,yes,no,missing) is unchanged between 1.4.2 and 3.0.2. All APIs used by the converter (get_booster(),get_dump(),feature_names,copy(),n_classes_) work identically.Checklist