diff --git a/R-package/tests/testthat/test_callbacks.R b/R-package/tests/testthat/test_callbacks.R index f49755eae..913eed896 100644 --- a/R-package/tests/testthat/test_callbacks.R +++ b/R-package/tests/testthat/test_callbacks.R @@ -175,16 +175,16 @@ test_that("cb.reset.parameters works as expected", { }) test_that("cb.save.model works as expected", { - files <- c('xgboost_01.bin', 'xgboost_02.bin', 'xgboost.bin') + files <- c('xgboost_01.json', 'xgboost_02.json', 'xgboost.json') for (f in files) if (file.exists(f)) file.remove(f) bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0, - save_period = 1, save_name = "xgboost_%02d.bin") - expect_true(file.exists('xgboost_01.bin')) - expect_true(file.exists('xgboost_02.bin')) - b1 <- xgb.load('xgboost_01.bin') + save_period = 1, save_name = "xgboost_%02d.json") + expect_true(file.exists('xgboost_01.json')) + expect_true(file.exists('xgboost_02.json')) + b1 <- xgb.load('xgboost_01.json') expect_equal(xgb.ntree(b1), 1) - b2 <- xgb.load('xgboost_02.bin') + b2 <- xgb.load('xgboost_02.json') expect_equal(xgb.ntree(b2), 2) xgb.config(b2) <- xgb.config(bst) @@ -193,9 +193,9 @@ test_that("cb.save.model works as expected", { # save_period = 0 saves the last iteration's model bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0, - save_period = 0, save_name = 'xgboost.bin') - expect_true(file.exists('xgboost.bin')) - b2 <- xgb.load('xgboost.bin') + save_period = 0, save_name = 'xgboost.json') + expect_true(file.exists('xgboost.json')) + b2 <- xgb.load('xgboost.json') xgb.config(b2) <- xgb.config(bst) expect_equal(bst$raw, b2$raw) diff --git a/include/xgboost/generic_parameters.h b/include/xgboost/generic_parameters.h index 752342b9a..a78453604 100644 --- a/include/xgboost/generic_parameters.h +++ b/include/xgboost/generic_parameters.h @@ -27,7 +27,7 @@ struct GenericParameter : public XGBoostParameter { int gpu_id; // gpu page size in external memory mode, 0 means using the default. size_t gpu_page_size; - bool enable_experimental_json_serialization {false}; + bool enable_experimental_json_serialization {true}; bool validate_parameters {false}; void CheckDeprecated() { @@ -68,7 +68,7 @@ struct GenericParameter : public XGBoostParameter { .set_lower_bound(0) .describe("GPU page size when running in external memory mode."); DMLC_DECLARE_FIELD(enable_experimental_json_serialization) - .set_default(false) + .set_default(true) .describe("Enable using JSON for memory serialization (Python Pickle, " "rabit checkpoints etc.)."); DMLC_DECLARE_FIELD(validate_parameters) diff --git a/tests/cpp/test_serialization.cc b/tests/cpp/test_serialization.cc index e0322fe17..ed1a5d998 100644 --- a/tests/cpp/test_serialization.cc +++ b/tests/cpp/test_serialization.cc @@ -224,7 +224,6 @@ TEST_F(SerializationTest, Exact) { {"nthread", "1"}, {"base_score", "3.14195265"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); @@ -234,7 +233,6 @@ TEST_F(SerializationTest, Exact) { {"base_score", "3.14195265"}, {"max_depth", "2"}, {"num_parallel_tree", "4"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); @@ -243,7 +241,6 @@ TEST_F(SerializationTest, Exact) { {"nthread", "1"}, {"base_score", "3.14195265"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); } @@ -253,7 +250,6 @@ TEST_F(SerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); @@ -262,7 +258,6 @@ TEST_F(SerializationTest, Approx) { {"nthread", "1"}, {"max_depth", "2"}, {"num_parallel_tree", "4"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); @@ -270,7 +265,6 @@ TEST_F(SerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); } @@ -280,7 +274,6 @@ TEST_F(SerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); @@ -289,7 +282,6 @@ TEST_F(SerializationTest, Hist) { {"nthread", "1"}, {"max_depth", "2"}, {"num_parallel_tree", "4"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); @@ -297,7 +289,6 @@ TEST_F(SerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); } @@ -306,7 +297,6 @@ TEST_F(SerializationTest, CPUCoordDescent) { TestLearnerSerialization({{"booster", "gblinear"}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "coord_descent"}}, fmap_, p_dmat_); } @@ -315,7 +305,6 @@ TEST_F(SerializationTest, CPUCoordDescent) { TEST_F(SerializationTest, GpuHist) { TestLearnerSerialization({{"booster", "gbtree"}, {"seed", "0"}, - {"enable_experimental_json_serialization", "1"}, {"nthread", "1"}, {"max_depth", "2"}, {"tree_method", "gpu_hist"}}, @@ -323,7 +312,6 @@ TEST_F(SerializationTest, GpuHist) { TestLearnerSerialization({{"booster", "gbtree"}, {"seed", "0"}, - {"enable_experimental_json_serialization", "1"}, {"nthread", "1"}, {"max_depth", "2"}, {"num_parallel_tree", "4"}, @@ -332,7 +320,6 @@ TEST_F(SerializationTest, GpuHist) { TestLearnerSerialization({{"booster", "dart"}, {"seed", "0"}, - {"enable_experimental_json_serialization", "1"}, {"nthread", "1"}, {"max_depth", "2"}, {"tree_method", "gpu_hist"}}, @@ -390,7 +377,6 @@ TEST_F(SerializationTest, GPUCoordDescent) { TestLearnerSerialization({{"booster", "gblinear"}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "gpu_coord_descent"}}, fmap_, p_dmat_); } @@ -425,7 +411,6 @@ TEST_F(LogitSerializationTest, Exact) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); @@ -434,7 +419,6 @@ TEST_F(LogitSerializationTest, Exact) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); } @@ -445,7 +429,6 @@ TEST_F(LogitSerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); @@ -454,7 +437,6 @@ TEST_F(LogitSerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); } @@ -465,7 +447,6 @@ TEST_F(LogitSerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); @@ -474,7 +455,6 @@ TEST_F(LogitSerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); } @@ -483,7 +463,6 @@ TEST_F(LogitSerializationTest, CPUCoordDescent) { TestLearnerSerialization({{"booster", "gblinear"}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "coord_descent"}}, fmap_, p_dmat_); } @@ -495,14 +474,12 @@ TEST_F(LogitSerializationTest, GpuHist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "gpu_hist"}}, fmap_, p_dmat_); TestLearnerSerialization({{"booster", "gbtree"}, {"objective", "binary:logistic"}, {"seed", "0"}, - {"enable_experimental_json_serialization", "1"}, {"nthread", "1"}, {"max_depth", "2"}, {"num_parallel_tree", "4"}, @@ -514,7 +491,6 @@ TEST_F(LogitSerializationTest, GpuHist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", "2"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "gpu_hist"}}, fmap_, p_dmat_); } @@ -524,7 +500,6 @@ TEST_F(LogitSerializationTest, GPUCoordDescent) { {"objective", "binary:logistic"}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "gpu_coord_descent"}}, fmap_, p_dmat_); } @@ -560,7 +535,6 @@ TEST_F(MultiClassesSerializationTest, Exact) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); @@ -570,7 +544,6 @@ TEST_F(MultiClassesSerializationTest, Exact) { {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, {"num_parallel_tree", "4"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); @@ -579,7 +552,6 @@ TEST_F(MultiClassesSerializationTest, Exact) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "exact"}}, fmap_, p_dmat_); } @@ -590,7 +562,6 @@ TEST_F(MultiClassesSerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); @@ -599,7 +570,6 @@ TEST_F(MultiClassesSerializationTest, Approx) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "approx"}}, fmap_, p_dmat_); } @@ -610,7 +580,6 @@ TEST_F(MultiClassesSerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); @@ -619,7 +588,6 @@ TEST_F(MultiClassesSerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"num_parallel_tree", "4"}, {"tree_method", "hist"}}, fmap_, p_dmat_); @@ -629,7 +597,6 @@ TEST_F(MultiClassesSerializationTest, Hist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "hist"}}, fmap_, p_dmat_); } @@ -638,7 +605,6 @@ TEST_F(MultiClassesSerializationTest, CPUCoordDescent) { TestLearnerSerialization({{"booster", "gblinear"}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "coord_descent"}}, fmap_, p_dmat_); } @@ -654,7 +620,6 @@ TEST_F(MultiClassesSerializationTest, GpuHist) { // different result (1e-7) with CPU predictor for some // entries. {"predictor", "gpu_predictor"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "gpu_hist"}}, fmap_, p_dmat_); @@ -666,7 +631,6 @@ TEST_F(MultiClassesSerializationTest, GpuHist) { // GPU_Hist has higher floating point error. 1e-6 doesn't work // after num_parallel_tree goes to 4 {"num_parallel_tree", "3"}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "gpu_hist"}}, fmap_, p_dmat_); @@ -675,7 +639,6 @@ TEST_F(MultiClassesSerializationTest, GpuHist) { {"seed", "0"}, {"nthread", "1"}, {"max_depth", std::to_string(kClasses)}, - {"enable_experimental_json_serialization", "1"}, {"tree_method", "gpu_hist"}}, fmap_, p_dmat_); } @@ -685,7 +648,6 @@ TEST_F(MultiClassesSerializationTest, GPUCoordDescent) { {"num_class", std::to_string(kClasses)}, {"seed", "0"}, {"nthread", "1"}, - {"enable_experimental_json_serialization", "1"}, {"updater", "gpu_coord_descent"}}, fmap_, p_dmat_); } diff --git a/tests/python/test_cli.py b/tests/python/test_cli.py index eca1b24e3..e437f426c 100644 --- a/tests/python/test_cli.py +++ b/tests/python/test_cli.py @@ -47,9 +47,12 @@ eval[test] = {data_path} seed = 1994 with tempfile.TemporaryDirectory() as tmpdir: - model_out_cli = os.path.join(tmpdir, 'test_load_cli_model-cli.bin') - model_out_py = os.path.join(tmpdir, 'test_cli_model-py.bin') - config_path = os.path.join(tmpdir, 'test_load_cli_model.conf') + model_out_cli = os.path.join( + tmpdir, 'test_load_cli_model-cli.json') + model_out_py = os.path.join( + tmpdir, 'test_cli_model-py.json') + config_path = os.path.join( + tmpdir, 'test_load_cli_model.conf') train_conf = self.template.format(data_path=data_path, seed=seed,