Skip to content

Implement UBJ and JSON models for latest XGBoost#96

Open
bradleypeabody wants to merge 1 commit intodmitryikh:masterfrom
bradleypeabody:xg-json-ubj
Open

Implement UBJ and JSON models for latest XGBoost#96
bradleypeabody wants to merge 1 commit intodmitryikh:masterfrom
bradleypeabody:xg-json-ubj

Conversation

@bradleypeabody
Copy link
Copy Markdown

@bradleypeabody bradleypeabody commented Feb 24, 2026

Since version 2.1, XGBoost now uses UBJ and JSON as its standard format. This PR adds support for that.

Key things to note:

  • The surface area impacted by this change is very small - xgensemble_io.go now checks for .json and .ubj and does a quick check to make sure the first bytes look correct and takes this alternate path to parse from that format. And in the main directory only xgensemble_json_io.go and xgensemble_json_test.go were added, with the intent of following the same general pattern as the rest of the files.
  • UBJ binary decoding is implemented directly in internal/ubjdecode - this was done in order to avoid external dependencies. I make no claims about it's completeness, but it works for our purposes here. No tests are included because we sufficiently test it by loading actual models.
  • The data structures that correspond to the JSON and UBJ guts live in internal/xgjson
  • I put various test cases in internal/xgjson/testdata - everything is committed and nothing special is required for go test to work properly. If you run go generate this requires uv and runs the Python code for various relevant test cases to generate some models and expected values, which are then compared in Go. xgensemble_json_test.go uses these.
  • Warning: I am not a data scientist, I am just some clown with a keyboard and a Claude Code API key. It's entirely possible I'm missing something important about this implementation. That said I believe it to be workable and a useful upgrade. I did put a fair amount of care into thinking through how to make these changes in a way that they fit in well with what you have and are unlikely to break anything.

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.

1 participant