Skip to content

[mt] Split up the tree model weights, support extmem.#11814

Merged
trivialfis merged 13 commits intodmlc:masterfrom
trivialfis:mt-reduced-tree-weight
Nov 18, 2025
Merged

[mt] Split up the tree model weights, support extmem.#11814
trivialfis merged 13 commits intodmlc:masterfrom
trivialfis:mt-reduced-tree-weight

Conversation

@trivialfis
Copy link
Copy Markdown
Member

@trivialfis trivialfis commented Nov 17, 2025

  • Store base weight and leaf weight differently, as the size of base weight can be smaller.
  • Basic tests for external memory.

Ref #9043 .

  • MemCostBytes
  • Copy
  • Document about the storage format.

Device copy.

cleanup, mapping.

IO.

view.

split targets.

Method.

small cleanups.

set leaves.

Fix cpp tests.

Test set leaves.

more specific.

derive the size.

check.

check.

check.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the multi-target tree model to separate internal base weights from leaf output weights. The key motivation is that base weights can be smaller when using reduced gradients, while leaf weights always need to be full-size for predictions.

Key changes:

  • Split weights_ into weights_ (internal base weights) and leaf_weights_ (output weights)
  • Reuse the right_ child field to store leaf weight indices for leaf nodes
  • Add SetLeaves() method to copy base weights to leaf weights for non-reduced trees

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
include/xgboost/multi_target_tree_model.h Add leaf_weights_ member, split NodeWeight methods, add SetLeaves() and NumSplitTargets()
src/tree/multi_target_tree_model.cc Implement weight splitting logic, update serialization to save both weight types
src/tree/tree_view.h Rename weights to leaf_weights, update LeafValue() to use leaf index mapping
src/tree/tree_view.cc Simplify view constructors, update to use LeafWeights()
src/tree/io_utils.h Add kLeafWeight field for serialization
src/tree/updater_quantile_hist.cc Add ExpandTreeLeaf() calls to copy base weights to leaves
src/tree/updater_gpu_hist.cuh Rename UpdateTreeLeaf to ExpandTreeLeaf, add SetLeaves() call
tests/cpp/tree/test_multi_target_tree_model.cc Add comprehensive tests for new SetLeaves() functionality
tests/cpp/predictor/test_predictor.cc Update test to call SetLeaves()
src/common/cuda_stream.h Add CUDA guards for non-CUDA builds
src/common/cuda_rt_utils.h/.cc Add MemcpyAsync utility function
src/gbm/gbtree.h Fix error message notation from (0, to [0,
src/tree/tree_model.cc Add early return for root node in GetDepth()
Comments suppressed due to low confidence (1)

src/tree/multi_target_tree_model.cc:354

  • The MemCostBytes() function is missing leaf_weights_.SizeBytes() in its calculation. With the introduction of the separate leaf_weights_ member, it should be included in the memory cost calculation.
[[nodiscard]] std::size_t MultiTargetTree::MemCostBytes() const {
  std::size_t n_bytes = 0;
  n_bytes += left_.SizeBytes();
  n_bytes += right_.SizeBytes();
  n_bytes += parent_.SizeBytes();
  n_bytes += split_index_.SizeBytes();
  n_bytes += default_left_.SizeBytes();
  n_bytes += split_conds_.SizeBytes();
  n_bytes += weights_.SizeBytes();
  return n_bytes;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tree/multi_target_tree_model.cc Outdated
Comment thread include/xgboost/multi_target_tree_model.h Outdated
Comment thread src/tree/tree_view.h
Comment thread src/tree/multi_target_tree_model.cc
Comment thread src/tree/updater_quantile_hist.cc Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tree/multi_target_tree_model.cc
@trivialfis
Copy link
Copy Markdown
Member Author

cc @rongou

@trivialfis trivialfis changed the title [mt] Split up the tree model weights. [mt] Split up the tree model weights, support extmem. Nov 18, 2025
@trivialfis trivialfis merged commit 62a3a4b into dmlc:master Nov 18, 2025
63 checks passed
@trivialfis trivialfis deleted the mt-reduced-tree-weight branch November 18, 2025 19:57
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.

3 participants