Update XGBoost max supported version to 3.0.2#2657
Update XGBoost max supported version to 3.0.2#2657sid22669 wants to merge 3 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.
| # --------------------------------------------------------------------------------------- | ||
| _HAS_XGBOOST = True | ||
| _XGBOOST_MAX_VERSION = "1.4.2" | ||
| _XGBOOST_MAX_VERSION = "3.0.2" |
There was a problem hiding this comment.
This is only used for the version warning check.
|
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
| config = json.loads(model.save_config()) | ||
| base_score = float(config['learner']['learner_model_param']['base_score']) | ||
| except (KeyError, ValueError, AttributeError): | ||
| pass |
There was a problem hiding this comment.
Generally, it's a bad idea to silence all exceptions. If you're sure this is the correct thing to do, please leave a comment about why this is the correct behavior.
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