Skip to content

Update XGBoost max supported version to 3.0.2#2657

Open
sid22669 wants to merge 3 commits intoapple:mainfrom
sid22669:feature/xgboost-3x-support
Open

Update XGBoost max supported version to 3.0.2#2657
sid22669 wants to merge 3 commits intoapple:mainfrom
sid22669:feature/xgboost-3x-support

Conversation

@sid22669
Copy link
Contributor

@sid22669 sid22669 commented Mar 5, 2026

Motivation

Fixes #2596

Users are blocked from converting XGBoost 3.x models because _XGBOOST_MAX_VERSION is set to 1.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:

  • Updated _XGBOOST_MAX_VERSION from "1.4.2" to "3.0.2"

Verification

Tested all conversion paths with XGBoost 3.0.2 — the converter is fully compatible:

  • XGBRegressor → CoreML spec: OK
  • XGBClassifier (binary) → CoreML spec: OK
  • XGBClassifier (multi-class) → CoreML spec: OK
  • Raw Booster → CoreML spec: OK

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

  • Format code with pre-commit
  • Follow coremltools code style

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used for the version warning check.

@TobyRoseman
Copy link
Collaborator

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.
@sid22669
Copy link
Contributor Author

sid22669 commented Mar 7, 2026

Thanks for the review! I've updated reqs/test.pip to use XGBoost 3.0.2.

While testing, I also found two compatibility issues with XGBoost 3.x:

  1. base_score auto-estimation — XGBoost 3.x auto-estimates base_score from training data. The converter was hardcoding 0.5/0.0, causing prediction mismatches. Fixed by reading the actual value from booster.save_config().

  2. feature_names type — XGBoost 3.x requires feature_names to be a list. Added a type check before assignment.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support latest XGBoost version

2 participants