"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "664175b3720d184eb80f0b863a746c140418488e"
Unverified Commit 4f47547c authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[CUDA] consolidate CUDA versions (#5677)



* [ci] speed up if-else, swig, and lint conda setup

* add 'source activate'

* python constraint

* start removing cuda v1

* comment out CI

* remove more references

* revert some unnecessaary changes

* revert a few more mistakes

* revert another change that ignored params

* sigh

* remove CUDATreeLearner

* fix tests, docs

* fix quoting in setup.py

* restore all CI

* Apply suggestions from code review
Co-authored-by: default avatarshiyu1994 <shiyu_k1994@qq.com>

* Apply suggestions from code review

* completely remove cuda_exp, update docs

---------
Co-authored-by: default avatarshiyu1994 <shiyu_k1994@qq.com>
parent 5ffd7571
...@@ -57,7 +57,7 @@ task_to_local_factory = { ...@@ -57,7 +57,7 @@ task_to_local_factory = {
pytestmark = [ pytestmark = [
pytest.mark.skipif(getenv('TASK', '') == 'mpi', reason='Fails to run with MPI interface'), pytest.mark.skipif(getenv('TASK', '') == 'mpi', reason='Fails to run with MPI interface'),
pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Fails to run with CUDA Experimental interface') pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Fails to run with CUDA interface')
] ]
......
...@@ -588,7 +588,7 @@ def test_multi_class_error(): ...@@ -588,7 +588,7 @@ def test_multi_class_error():
assert results['training']['multi_error@2'][-1] == pytest.approx(0) assert results['training']['multi_error@2'][-1] == pytest.approx(0)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_auc_mu(): def test_auc_mu():
# should give same result as binary auc for 2 classes # should give same result as binary auc for 2 classes
X, y = load_digits(n_class=10, return_X_y=True) X, y = load_digits(n_class=10, return_X_y=True)
...@@ -1661,7 +1661,7 @@ def generate_trainset_for_monotone_constraints_tests(x3_to_category=True): ...@@ -1661,7 +1661,7 @@ def generate_trainset_for_monotone_constraints_tests(x3_to_category=True):
return trainset return trainset
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Monotone constraints are not yet supported by CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Monotone constraints are not yet supported by CUDA version')
@pytest.mark.parametrize("test_with_categorical_variable", [True, False]) @pytest.mark.parametrize("test_with_categorical_variable", [True, False])
def test_monotone_constraints(test_with_categorical_variable): def test_monotone_constraints(test_with_categorical_variable):
def is_increasing(y): def is_increasing(y):
...@@ -1751,7 +1751,7 @@ def test_monotone_constraints(test_with_categorical_variable): ...@@ -1751,7 +1751,7 @@ def test_monotone_constraints(test_with_categorical_variable):
assert are_interactions_enforced(constrained_model, feature_sets) assert are_interactions_enforced(constrained_model, feature_sets)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Monotone constraints are not yet supported by CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Monotone constraints are not yet supported by CUDA version')
def test_monotone_penalty(): def test_monotone_penalty():
def are_first_splits_non_monotone(tree, n, monotone_constraints): def are_first_splits_non_monotone(tree, n, monotone_constraints):
if n <= 0: if n <= 0:
...@@ -1791,7 +1791,7 @@ def test_monotone_penalty(): ...@@ -1791,7 +1791,7 @@ def test_monotone_penalty():
# test if a penalty as high as the depth indeed prohibits all monotone splits # test if a penalty as high as the depth indeed prohibits all monotone splits
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Monotone constraints are not yet supported by CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Monotone constraints are not yet supported by CUDA version')
def test_monotone_penalty_max(): def test_monotone_penalty_max():
max_depth = 5 max_depth = 5
monotone_constraints = [1, -1, 0] monotone_constraints = [1, -1, 0]
...@@ -2652,7 +2652,7 @@ def test_model_size(): ...@@ -2652,7 +2652,7 @@ def test_model_size():
pytest.skipTest('not enough RAM') pytest.skipTest('not enough RAM')
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_get_split_value_histogram(): def test_get_split_value_histogram():
X, y = make_synthetic_regression() X, y = make_synthetic_regression()
X = np.repeat(X, 3, axis=0) X = np.repeat(X, 3, axis=0)
...@@ -2735,7 +2735,7 @@ def test_get_split_value_histogram(): ...@@ -2735,7 +2735,7 @@ def test_get_split_value_histogram():
gbm.get_split_value_histogram(2) gbm.get_split_value_histogram(2)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_early_stopping_for_only_first_metric(): def test_early_stopping_for_only_first_metric():
def metrics_combination_train_regression(valid_sets, metric_list, assumed_iteration, def metrics_combination_train_regression(valid_sets, metric_list, assumed_iteration,
...@@ -3573,7 +3573,7 @@ def test_dump_model_hook(): ...@@ -3573,7 +3573,7 @@ def test_dump_model_hook():
assert "LV" in dumped_model_str assert "LV" in dumped_model_str
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Forced splits are not yet supported by CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Forced splits are not yet supported by CUDA version')
def test_force_split_with_feature_fraction(tmp_path): def test_force_split_with_feature_fraction(tmp_path):
X, y = make_synthetic_regression() X, y = make_synthetic_regression()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
......
...@@ -121,7 +121,7 @@ def test_regression(): ...@@ -121,7 +121,7 @@ def test_regression():
assert gbm.evals_result_['valid_0']['l2'][gbm.best_iteration_ - 1] == pytest.approx(ret) assert gbm.evals_result_['valid_0']['l2'][gbm.best_iteration_ - 1] == pytest.approx(ret)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_multiclass(): def test_multiclass():
X, y = load_digits(n_class=10, return_X_y=True) X, y = load_digits(n_class=10, return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
...@@ -134,7 +134,7 @@ def test_multiclass(): ...@@ -134,7 +134,7 @@ def test_multiclass():
assert gbm.evals_result_['valid_0']['multi_logloss'][gbm.best_iteration_ - 1] == pytest.approx(ret) assert gbm.evals_result_['valid_0']['multi_logloss'][gbm.best_iteration_ - 1] == pytest.approx(ret)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_lambdarank(): def test_lambdarank():
rank_example_dir = Path(__file__).absolute().parents[2] / 'examples' / 'lambdarank' rank_example_dir = Path(__file__).absolute().parents[2] / 'examples' / 'lambdarank'
X_train, y_train = load_svmlight_file(str(rank_example_dir / 'rank.train')) X_train, y_train = load_svmlight_file(str(rank_example_dir / 'rank.train'))
...@@ -1091,7 +1091,7 @@ def test_nan_handle(): ...@@ -1091,7 +1091,7 @@ def test_nan_handle():
np.testing.assert_allclose(gbm.evals_result_['training']['l2'], np.nan) np.testing.assert_allclose(gbm.evals_result_['training']['l2'], np.nan)
@pytest.mark.skipif(getenv('TASK', '') == 'cuda_exp', reason='Skip due to differences in implementation details of CUDA Experimental version') @pytest.mark.skipif(getenv('TASK', '') == 'cuda', reason='Skip due to differences in implementation details of CUDA version')
def test_first_metric_only(): def test_first_metric_only():
def fit_and_check(eval_set_names, metric_names, assumed_iteration, first_metric_only): def fit_and_check(eval_set_names, metric_names, assumed_iteration, first_metric_only):
......
...@@ -91,15 +91,15 @@ WARNING | More than one metric available, picking one to plot. ...@@ -91,15 +91,15 @@ WARNING | More than one metric available, picking one to plot.
"INFO | [LightGBM] [Warning] CUDA currently requires double precision calculations.", "INFO | [LightGBM] [Warning] CUDA currently requires double precision calculations.",
"INFO | [LightGBM] [Info] LightGBM using CUDA trainer with DP float!!" "INFO | [LightGBM] [Info] LightGBM using CUDA trainer with DP float!!"
] ]
cuda_exp_lines = [ cuda_lines = [
"INFO | [LightGBM] [Warning] Metric auc is not implemented in cuda_exp version. Fall back to evaluation on CPU.", "INFO | [LightGBM] [Warning] Metric auc is not implemented in cuda version. Fall back to evaluation on CPU.",
"INFO | [LightGBM] [Warning] Metric binary_error is not implemented in cuda_exp version. Fall back to evaluation on CPU.", "INFO | [LightGBM] [Warning] Metric binary_error is not implemented in cuda version. Fall back to evaluation on CPU.",
] ]
with open(log_filename, "rt", encoding="utf-8") as f: with open(log_filename, "rt", encoding="utf-8") as f:
actual_log = f.read().strip() actual_log = f.read().strip()
actual_log_wo_gpu_stuff = [] actual_log_wo_gpu_stuff = []
for line in actual_log.split("\n"): for line in actual_log.split("\n"):
if not any(line.startswith(gpu_or_cuda_exp_line) for gpu_or_cuda_exp_line in gpu_lines + cuda_exp_lines): if not any(line.startswith(gpu_or_cuda_line) for gpu_or_cuda_line in gpu_lines + cuda_lines):
actual_log_wo_gpu_stuff.append(line) actual_log_wo_gpu_stuff.append(line)
assert "\n".join(actual_log_wo_gpu_stuff) == expected_log assert "\n".join(actual_log_wo_gpu_stuff) == expected_log
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment