Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking] Accept multi-dim meta info. #7405

Merged
merged 7 commits into from
Nov 18, 2021

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Nov 8, 2021

This is the last part of the original PR for extending meta info to multi-dimension arrays. This PR changes base_margin into a 3-dim array, with one of them being reserved for multi-target classification. Also, a breaking change is made for binary serialization due to extra dimension along with a fix for saving the feature weights. Lastly, it unifies the prediction initialization between CPU and GPU. After this PR, the meta info setter in Python will be based on array interface.

Original description

  • Extend the array interface class to multi-dim.
  • Define tensor storage class as an extension to host device vector.
  • Move some calculation of tensor view to compile time for better checks.
  • Use them for base margin.
  • Use array interface for Python meta info.
  • Unify InitPredOutput function from both predictors.

Motivation

These are basic infrastructures for multi-target model training. The type erased array interface class is used to consume user inputs and typed tensor/tensor_view is used for internal algorithms. For the typed tensor, it makes sense to consider existing implementations instead of rolling out our own. Here are a few things that we need to consider and I haven't found a candidate yet. Firstly the tensor needs to be trivially passed into CUDA kernel. Secondly, we need to have control over its memory allocation for both host and device. Lastly, it should work with any type of data instead of numeric-only since we have custom gradient and might use it to manage the grid of trees (model slicing).

The implementation here satisfies all the above items and features efficient indexing and slicing, along with compile-time dimension safety checks.

To-dos:

  • Unify device side meta info initialization.
  • More tests.
  • JVM packages native code.
  • Require latest __cuda_array_interface__.
  • Update binary format.
  • Python test for f-contiguous input.

@trivialfis trivialfis marked this pull request as draft November 8, 2021 18:15
@trivialfis
Copy link
Member Author

Now let's see how many compilers are failing. ;-)

@trivialfis
Copy link
Member Author

Hmm??

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include\thrust/detail/cpp11_required.h(23): fatal error C1189: #error: C++11 is required for this Thrust feature; please upgrade your compiler or pass the appropriate -std=c++XX flag to it. [C:\Users\Administrator\workspace\xgboost-win64_PR-7405\build\src\objxgboost.vcxproj]

@trivialfis
Copy link
Member Author

trivialfis commented Nov 9, 2021

Note to myself:

  • Some tests are failing because the getters of DMatrix don't understand ndarray.
  • Some tests are failing because they pass incorrect shapes of meta info, like np.empty(0, 0) for feature weights.
  • Some code was written assuming cuda is the only place array interface is available (jvm gpu).

@trivialfis
Copy link
Member Author

trivialfis commented Nov 10, 2021

Will start extracting components for reviews.

include/xgboost/linalg.h Outdated Show resolved Hide resolved
include/xgboost/string_view.h Outdated Show resolved Hide resolved
python-package/setup.cfg Outdated Show resolved Hide resolved
src/c_api/c_api.cc Outdated Show resolved Hide resolved
src/common/linalg_op.cuh Outdated Show resolved Hide resolved
src/data/array_interface.h Outdated Show resolved Hide resolved
src/data/validation.h Outdated Show resolved Hide resolved
src/gbm/gblinear.cc Outdated Show resolved Hide resolved
doc/contrib/coding_guide.rst Outdated Show resolved Hide resolved
doc/contrib/coding_guide.rst Outdated Show resolved Hide resolved
doc/contrib/coding_guide.rst Show resolved Hide resolved
doc/contrib/coding_guide.rst Outdated Show resolved Hide resolved
doc/contrib/coding_guide.rst Outdated Show resolved Hide resolved
@trivialfis trivialfis force-pushed the tensor-storage branch 4 times, most recently from b1b1cde to 482ab07 Compare November 14, 2021 18:24
@trivialfis trivialfis changed the title [WIP] Accept multi-dim meta info. [Breaking] Accept multi-dim meta info. Nov 16, 2021
@trivialfis trivialfis marked this pull request as ready for review November 16, 2021 04:20
* Use typed tensor for storing meta info like base margin.
* Extend the array interface handler to multi-dim.

Implement a general array view.

* Replace existing matrix and vector view.

lint.

Remove const too.

Doc/Test.

Include.

Use it in AUC.

Win build.

Use int32_t.

Use integral.

force the same type.

Use constexpr for old nvcc.

Test for empty tensor.

Rename to view.

Format.

Better document and perf.

Address reviewer's comment.

tidy.

Implement a general array view.

* Replace existing matrix and vector view.

lint.

Remove const too.

Doc/Test.

Include.

Use it in AUC.

Win build.

Use int32_t.

Use integral.

force the same type.

Use constexpr for old nvcc.

Test for empty tensor.

Rename to view.

Format.

Prototype.

Move string view.

Compile on CPU.

Some fixes for GPU compilation.

Array interface.

Use it in file iter.

Cleanup.

itemsize.

Documents.

Cache the pointer.

port.

cuda compilation.

Start working on ari.

Add clang-format config. (dmlc#7383)

Generated using `clang-format -style=google -dump-config > .clang-format`, with column
width changed from 80 to 100 to be consistent with existing cpplint check.

Define shape and stride.

Convert some uses.

Prototype for copy tensor info.

proto unravel

Indexer.

Unravel.

Cleanup.

Fixes.

fixe.s

WAR.

as column vector.

Convert some code.

some more.

some more.

Compile.

Ensure column vector from the beginning.

IO.

Add code comments.

Test for trivial dimension.

Start CPU implementation.

Refactor.

Dispatch.

Compile.

Cleanup slice and index for array interface.

Add document about handling user input.

Validate the shape of base margin.

Cleanup out prediction.

Use it in Python.

Optimization.

Cleanup.

Define unravel index as an interface.

Dispatch DType.

Err.

By pass the iterator.

Cleanup old code.

comment.

Cleanup.

Remove duplicated function.

Add contiguous.

Typo.

Fix copying for group.

comment.

Fix CSR.

Fix empty dimensions.

Use linalg for utilities.

Fix test.

Fix streams.

Basic elementwise kernel.

Fixes.

fix dtype.

Fix index.

Comment.

Cleanup.

popcnt implementation.

Move to compile time.

Fix.

Fix.

Move to compile time.

Forward.

Forward.

Include.

Lint.

Reintroduce the checks.

Fix long double.

Remove check.

Comment.

Remove macro.

Some changes in jvm package.

Include.

Ignore 0 shape.

Fix.

Restore bound check for now.

Fix slice.

Fix test feature weights.

Stricter requirements.

Reshape.

Require v3 interface.

Use CUDA ptr attr.

Fix test.

Invalid stream.

tidy.

Fix versions.

test stack.

CPU only.

Simplifies.

Reverse version.

Force c++14 for msvc.

Lint.

Remove imports.

Revert cmake changes.

Reset.

Check.

Unify device initialization.

Tests.

Just bypass the error.

Fix.

Fix.

test qid.

Fix test.

Cleanup.

lint.

Fix.

Restore the heuristic.

Update metainfo binary.

Fix typo.

Restore the optimization.

Cleanup sklearn tests.

Cleanup dask test.

Tidy.

Tidy is happy.

Polish.

Unittest.

Typo.

Polish.

Port the changes to parent PR.

Add Python test.

Fix GPU tests.
@trivialfis trivialfis merged commit d33854a into dmlc:master Nov 18, 2021
@trivialfis trivialfis deleted the tensor-storage branch November 18, 2021 15:03
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.

2 participants