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 matrix for gradient. #9508

Merged
merged 4 commits into from
Aug 23, 2023
Merged

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Aug 21, 2023

  • Use the linalg::Matrix for storing gradients.
  • New API XGBoosterTrainOneIter for the custom objective. Deprecating the XGBoosterBoostOneIter
  • Custom objective for multi-class/multi-target is now required to return the correct shape.
  • Custom objective for Python can accept arrays with any strides. (row-major, column-major) In addition, CUDA input is now supported.

The new function can be extended to irregular shape of input gradient by changing the JSON array interface into a dictionary from an array.

Close #9089 .

@trivialfis trivialfis changed the title Use matrix for gradient. [WIP] Use matrix for gradient. Aug 21, 2023
@trivialfis trivialfis mentioned this pull request Aug 12, 2023
39 tasks
@trivialfis trivialfis changed the title [WIP] Use matrix for gradient. [WIP][breaking] Use matrix for gradient. Aug 22, 2023
@trivialfis trivialfis changed the title [WIP][breaking] Use matrix for gradient. [WIP] Use matrix for gradient. Aug 22, 2023
@trivialfis trivialfis changed the title [WIP] Use matrix for gradient. Use matrix for gradient. Aug 22, 2023
- Use the `linalg::Matrix` for storing gradients.
- New API for the custom objective.
- Custom objective for multi-class/multi-target is now required to return the correct shape.
- Custom objective for Python can accept arrays with any strides. (row-major, column-major)
@trivialfis trivialfis force-pushed the multi-matrix-gradient branch from 4e6f51d to 425d8d8 Compare August 22, 2023 17:03
@trivialfis
Copy link
Member Author

@rongou Would you like to help review this guy when time allows?

@trivialfis trivialfis requested a review from hcho3 August 23, 2023 08:31
@trivialfis
Copy link
Member Author

@wbo4958 Could you please help take a look into the changes in the JVM packages?

R-package/R/utils.R Show resolved Hide resolved
R-package/src/xgboost_R.cc Show resolved Hide resolved
include/xgboost/base.h Show resolved Hide resolved
include/xgboost/c_api.h Outdated Show resolved Hide resolved
include/xgboost/gbm.h Show resolved Hide resolved
python-package/xgboost/core.py Show resolved Hide resolved
python-package/xgboost/core.py Show resolved Hide resolved
src/c_api/c_api_utils.h Show resolved Hide resolved
src/gbm/gbtree.cc Show resolved Hide resolved
demo/guide-python/multioutput_regression.py Show resolved Hide resolved
auto const labels_h = info.labels.HostView();
for (size_t i = 0; i < preds_h.size(); ++i) {
bst_float w = info.GetWeight(i);
float w = info.GetWeight(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't these just be auto?

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 don't have a preference, just trying to clean up some of these old types.

@trivialfis trivialfis merged commit 972730c into dmlc:master Aug 23, 2023
@trivialfis trivialfis deleted the multi-matrix-gradient branch August 23, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Inefficient Casting Grad and Hess to c_float for Custom Obj in Python API
2 participants