Implement GPU accelerated coordinate descent algorithm (#3178)

* Implement GPU accelerated coordinate descent algorithm. 

* Exclude external memory tests for GPU
This commit is contained in:
Rory Mitchell
2018-04-20 14:56:35 +12:00
committed by GitHub
parent ccf80703ef
commit a185ddfe03
12 changed files with 473 additions and 63 deletions

View File

@@ -13,13 +13,13 @@ TEST(Linear, shotgun) {
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("shotgun"));
updater->Init({{"eta", "1."}});
std::vector<xgboost::GradientPair> gpair(mat->Info().num_row_,
xgboost::GradientPair(-5, 1.0));
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
mat->Info().num_row_, xgboost::GradientPair(-5, 1.0));
xgboost::gbm::GBLinearModel model;
model.param.num_feature = mat->Info().num_col_;
model.param.num_output_group = 1;
model.LazyInitModel();
updater->Update(&gpair, mat.get(), &model, gpair.size());
updater->Update(&gpair, mat.get(), &model, gpair.Size());
ASSERT_EQ(model.bias()[0], 5.0f);
}
@@ -32,13 +32,13 @@ TEST(Linear, coordinate) {
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("coord_descent"));
updater->Init({});
std::vector<xgboost::GradientPair> gpair(mat->Info().num_row_,
xgboost::GradientPair(-5, 1.0));
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
mat->Info().num_row_, xgboost::GradientPair(-5, 1.0));
xgboost::gbm::GBLinearModel model;
model.param.num_feature = mat->Info().num_col_;
model.param.num_output_group = 1;
model.LazyInitModel();
updater->Update(&gpair, mat.get(), &model, gpair.size());
updater->Update(&gpair, mat.get(), &model, gpair.Size());
ASSERT_EQ(model.bias()[0], 5.0f);
}

View File

@@ -0,0 +1,14 @@
import sys
sys.path.append('tests/python/')
import test_linear
import testing as tm
import unittest
class TestGPULinear(unittest.TestCase):
def test_gpu_coordinate(self):
tm._skip_if_no_sklearn()
variable_param = {'alpha': [.005, .1], 'lambda': [0.005],
'coordinate_selection': ['cyclic', 'random', 'greedy'], 'n_gpus': [-1, 1]}
test_linear.assert_updater_accuracy('gpu_coord_descent', variable_param)

View File

@@ -144,7 +144,8 @@ def assert_updater_accuracy(linear_updater, variable_param):
train_classification(param_tmp)
train_classification_multi(param_tmp)
train_breast_cancer(param_tmp)
train_external_mem(param_tmp)
if 'gpu' not in linear_updater:
train_external_mem(param_tmp)
class TestLinear(unittest.TestCase):