Skip to content

Use DMatrix Proxy for implementing data callback.#5629

Closed
trivialfis wants to merge 2 commits into
dmlc:masterfrom
trivialfis:use-dmatrix-for-callback
Closed

Use DMatrix Proxy for implementing data callback.#5629
trivialfis wants to merge 2 commits into
dmlc:masterfrom
trivialfis:use-dmatrix-for-callback

Conversation

@trivialfis

@trivialfis trivialfis commented May 5, 2020

Copy link
Copy Markdown
Member

@RAMitchell @hcho3 The second prototype.

Closes #5583, #5571

Please ignore the code in quantile, it's copied and pasted from hist_util.cu.

Depends on #5623 . First prototype is in #5630 .

@trivialfis trivialfis force-pushed the use-dmatrix-for-callback branch from d405ed8 to 6c33130 Compare May 6, 2020 12:07
@hcho3 hcho3 self-requested a review May 9, 2020 08:29

@hcho3 hcho3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like the example in data_iterator.py. The custom data iterator will be quite useful for users who want to integrate a custom data source.

See my questions, especially about data erasure.

next_callback,
ctypes.c_float(missing),
ctypes.c_int(nthread),
ctypes.c_int(256),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we okay with hardcoding 256 for max_bin here?

'''
def __init__(self, data, label=None, weight=None, base_margin=None,
label_lower_bound=None, label_upper_bound=None):
'''Generate some random data for demostration.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this comment make sense here? This is not a demo.

Comment thread src/data/iterative_device_dmatrix.cu Outdated
#define DISPATCH_MEM(__Proxy, __Fn) \
[](DMatrixProxy const* proxy) -> decltype( \
(dmlc::get<CupyAdapterBatch>(proxy->Value())).__Fn()) { \
if (proxy->Value().type() == typeid(CupyAdapterBatch)) { \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it correct to say that the proxy matrix performs type erasure for the batch, and now we're trying to recover the type of the batch dynamically?

From the way I see it, we have an implicit list of allowable types, namely CupyAdapterBatch and CudfAdapterBatch. It may be better to add a type ID field in the DMatrix proxy. Take a look at PackedFunc from TVM project, which uses type erasure to expose a generic function type. The PackedFunc uses type ID to distinguish between underlying types.

Also, is it possible to avoid macro here? Why use macro?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will look into the pack function today.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool, I felt that PackedFunc may give us hint for simplifying the proxy.

Comment thread src/data/ellpack_page.cuh
size_t row_stride);

template <typename AdapterBatch>
explicit EllpackPageImpl(AdapterBatch batch, float missing, int device, bool is_dense, int nthread,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's your rationale for adding a second interface for EllpackPageImpl()? Is it to specify a custom cuts?

Comment thread src/data/ellpack_page.cu Outdated
CopyDataRowMajor(batch, this, device, missing);
} else {
// CopyDataColumnMajor(adapter, batch, this, missing);
LOG(FATAL) << "Not implemented";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What makes the second EllpackPageImpl different from the first EllpackPageImpl, such that column major is not supported?

Comment thread include/xgboost/c/callback.h Outdated

@hcho3 hcho3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving the general idea.

@trivialfis trivialfis force-pushed the use-dmatrix-for-callback branch from 6c33130 to 155be2b Compare May 14, 2020 11:03
* Add new iterative DMatrix.
* Add new proxy DMatrix.
* Add dask interface.
@trivialfis

Copy link
Copy Markdown
Member Author

One last piece would be the dask interface then the big series will be over.

@trivialfis trivialfis closed this Jul 18, 2020
@trivialfis trivialfis deleted the use-dmatrix-for-callback branch July 18, 2020 01:24
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.

[FEA][Python] Multi-GPU training with DeviceQuantileDMatrix

2 participants