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

Use DMatrix Proxy for implementing data callback. #5629

Closed
wants to merge 2 commits into from

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented May 5, 2020

@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 .

Copy link
Collaborator

@hcho3 hcho3 left a comment

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
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
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.

#define DISPATCH_MEM(__Proxy, __Fn) \
[](DMatrixProxy const* proxy) -> decltype( \
(dmlc::get<CupyAdapterBatch>(proxy->Value())).__Fn()) { \
if (proxy->Value().type() == typeid(CupyAdapterBatch)) { \
Copy link
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
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
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.

size_t row_stride);

template <typename AdapterBatch>
explicit EllpackPageImpl(AdapterBatch batch, float missing, int device, bool is_dense, int nthread,
Copy link
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?

CopyDataRowMajor(batch, this, device, missing);
} else {
// CopyDataColumnMajor(adapter, batch, this, missing);
LOG(FATAL) << "Not implemented";
Copy link
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?

include/xgboost/c/callback.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@hcho3 hcho3 left a comment

Choose a reason for hiding this comment

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

Approving the general idea.

* Add new iterative DMatrix.
* Add new proxy DMatrix.
* Add dask interface.
@trivialfis
Copy link
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