This is an English summary of a long Chinese draft document: the leaves project evolution plan (draft v1.0, 2026-06-13). leaves is a pure-Go GBRT prediction library (v0.8.0) that loads models trained by LightGBM, XGBoost, and scikit-learn. The plan proposes using GoMLX (a JAX-style symbolic graph + XLA JIT framework for Go) as the computation base to evolve leaves into a full GBRT framework, benchmarked against XGBoost as reference (not a clone).
Key points
Overall vision
- leaves today is a "translator": it reads trained model files, walks each tree, and emits predictions. It has good bones (unified API + multi-backend IO) but lacks "muscle" (GPU acceleration, SHAP) and a "brain" (training).
- Core question: how to add GoMLX-backed training, GPU acceleration, and interpretability without breaking ecosystem compatibility (LightGBM/XGBoost/sklearn model loading).
- Design principles: incremental phases each shipping usable versions; stable
Ensemblepublic API; GoMLX-first with fallback to the native pure-Go path; test-driven evolution with benchmarks per phase. - Supported: LightGBM (text/JSON), XGBoost (binary), sklearn (pickle); gbtree/dart/gblinear/random forest; dense + CSR inputs; Raw/Logistic/Softmax/Exponential/LeafIndex transforms; NaN default-left handling; LightGBM categorical one-hot rules; goroutine-pool batch prediction.
- Gaps vs XGBoost: SHAP values, feature importance, ~24 built-in metrics, JSON model format, native categorical features, multi-output trees, GPU inference, training, survival objectives, distributed execution.
- Performance bottleneck: scalar per-node tree traversal loops—no SIMD/GPU utilization; currently near C-API performance (<20% gap single-threaded).
- Upgrade Go toolchain; add
github.com/gomlx/gomlxdependency. - Split the monolithic root package into
model/,tree/,io/,ensemble/,transform/,mat/, etc., keeping backward compatibility via type aliases in the root package until v1.0.0. - Define a pluggable
tree.Engineinterface (PredictDense,PredictCSR,PredictSingle,NOutputGroups,Close) plus aFactory. - Introduce a framework-agnostic intermediate representation:
ForestIR/TreeIR(split feature, threshold, default-left, child indices, leaf values, categorical thresholds), unified from all model sources. - Represent tree traversal as symbolic graphs using
Gather,LessThan,Where, optionalWhileloops,ReduceSum, andIsNaNfor missing values. - Approach A (recommended): fully unroll loops for fixed-depth trees (depth 6 typical). Approach B:
Whileloops for variable-depth trees. Categorical decisions via vectorized membership checks. - Forest-level parallelism: stack per-tree outputs as
[batch, numTrees]and reduce-sum. - Transforms map to GoMLX built-ins (
Logistic, fusedSoftmax,Exp). - New
WithBackend()option:BackendAuto(GoMLX/XLA with native fallback),BackendGoMLX,BackendNative,BackendSimpleGo(WASM-compatible). - Performance expectations: native best for tiny batches; XLA GPU best for large batches (10K+); SimpleGo is the only WASM option.
- XGBoost JSON model loader (parse
gbtree_model_param,trees[],train_param), converting intoForestIR. - A
metrics/package with core metrics: RMSE, MAE, MAPE, RMSLE, LogLoss, AUC, Error, multi-class LogLoss/Error, NDCG@k, MAP. - XGBoost-native categorical features (partition-based,
ftype == 1) distinct from LightGBM one-hot. - Multi-output trees with vector leaves via
Reshape/Gather. - Tree SHAP contribution values and interaction values (pure-Go path computation on
ForestIR, GoMLX for batch post-processing); O(TLD²) complexity considered acceptable. - Five feature importance types (weight/gain/total gain/cover/total cover), requiring IO parsers to extract
loss_chgandsum_hessintoTreeIR. - Model visualization: text / JSON / Graphviz DOT dumps; Saabas approximate contributions as a lightweight SHAP alternative.
- Consistency tests against XGBoost Python SHAP.
- XGBoost-style layered architecture: Trainer (loop, CV, early stopping, callbacks) → GradientBooster (gbtree/dart/gblinear) → Objective/Metric → histogram TreeBuilder → GoMLX backend.
- Initial objectives: squared error, logistic, binary logistic, gamma, multi:softmax, rank:pairwise (LambdaRank); histogram-based tree building with optional GoMLX acceleration for histogram aggregation and split-gain computation.
- GPU/distributed training, quantized inference, ONNX interoperability, WASM deployment.
- The document includes risk/mitigation sections and a milestone timeline mapping each phase to versions v0.9.0 → v3.0.0; mitigations for GoMLX limits include shape caching in Exec, per-tree subgraphs, loop unrolling for shallow trees, and Dense-first sparse handling.