Skip to content

Conversation

@trivialfis
Copy link
Member

@trivialfis trivialfis commented Jan 17, 2026

Need benchmarks for training and prediction.

Copy link
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 enables the device vector to shrink its allocated memory when resized to significantly smaller sizes, reducing memory consumption. The implementation uses a "dynamic table" approach where the vector only deallocates and shrinks when the new size falls below half the current capacity.

Changes:

  • Modified resize() to conditionally shrink capacity when new size is less than half of current capacity
  • Updated clear() to immediately deallocate memory and reset capacity to 0
  • Added comprehensive tests for both shrinking scenarios (first and second half of dynamic table)

Reviewed changes

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

File Description
src/common/device_vector.cuh Implements shrinking logic in resize() and immediate deallocation in clear()
tests/cpp/common/test_device_vector.cu Adds test coverage for shrinking behavior in both halves of the dynamic table and verifies clear() deallocates

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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