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

feature: enabling oneDPL and sort primitive refactoring #3046

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

Alexandr-Solovev
Copy link
Contributor

@Alexandr-Solovev Alexandr-Solovev commented Jan 16, 2025

Description:

Feature: enabling oneDPL and sort primitive refactoring

Summary:

This PR introduces oneDPL enabling and radix sort replacement.

PR completeness and readability

  • I have reviewed my changes thoroughly before submitting this pull request.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with update and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have added a respective label(s) to PR if I have a permission for that.
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least summary table with measured data, if performance change is expected.
  • I have provided justification why performance has changed or why changes are not expected.
  • I have provided justification why quality metrics have changed or why changes are not expected.
  • I have extended benchmarking suite and provided corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR.

@david-cortes-intel
Copy link
Contributor

Before merging, please remember to add this new dependency to the installation instructions in INSTALL.md, along with instructions for setting necessary env. variables when using conda:
https://github.com/uxlfoundation/oneDAL/blob/main/INSTALL.md

@Alexandr-Solovev Alexandr-Solovev added dpc++ Issue/PR related to DPC++ functionality dependencies Pull requests that update a dependency file labels Jan 22, 2025
@Alexandr-Solovev Alexandr-Solovev changed the title init adding dpl feature: enabling oneDPL and sorting primitive refactoring Jan 22, 2025
@Alexandr-Solovev Alexandr-Solovev marked this pull request as ready for review January 22, 2025 20:28
@Alexandr-Solovev
Copy link
Contributor Author

/intelci: run

@Alexandr-Solovev Alexandr-Solovev changed the title feature: enabling oneDPL and sorting primitive refactoring feature: enabling oneDPL and sort primitive refactoring Jan 22, 2025
Comment on lines +51 to +56
auto event = oneapi::dpl::experimental::kt::gpu::esimd::radix_sort_by_key<true, 8>(
queue,
val_in.get_mutable_data(),
val_in.get_mutable_data() + val_in.get_count(),
ind_in.get_mutable_data(),
dpl::experimental::kt::kernel_param<256, 32>{});
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic value 8, 256, 32 should be at least explained here.

Also, it might be beneficial not to hardcode them, but let the algorithmic kernel define them. I think different values can be chosen for different algorithms, or for different hardware platforms for better performance.

Copy link
Contributor

Choose a reason for hiding this comment

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

At least write the comments that the parameters are chosen for PVC.

Copy link
Contributor

@Vika-F Vika-F left a comment

Choose a reason for hiding this comment

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

The code looks good to me, I only have couple of minor comments.

@@ -19,7 +19,7 @@
#include "oneapi/dal/table/row_accessor.hpp"
#include "oneapi/dal/detail/profiler.hpp"
#include "oneapi/dal/algo/decision_forest/backend/gpu/train_helpers.hpp"

#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this include.

return ::oneapi::dal::backend::primitives::engine_type::philox4x32x10;
case df_engine_types::mt19937:
return ::oneapi::dal::backend::primitives::engine_type::mt19937;
default: throw std::invalid_argument("Unsupported engine type 2");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the message in the exception. "type 2" sounds strange.

@@ -133,6 +133,20 @@ enum class splitter_mode {
random
};

/// Available engine methods for building trees
enum class df_engine_types {
/// mt2203 engine
Copy link
Contributor

Choose a reason for hiding this comment

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

Those comments look excessive. Consider removing.

@@ -594,6 +611,17 @@ class descriptor : public detail::descriptor_base<Task> {
return *this;
}

/// Engine method for the random numbers generator used by the algorithm
/// @remark default = df_engine_method::philox
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @remark default = df_engine_method::philox
/// @remark default = df_engine_method::philox4x32x10

const auto model = train_result.get_model();
this->infer_base_checks(desc, data_test, this->get_homogen_table_id(), model, checker_list);
}
// DF_SPMD_CLS_TEST("df cls base check with default params and train weights") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain the reason of commenting out the test?

Comment on lines 54 to 61
else {
auto& device_engine =
*(static_cast<gen_mt2203*>(engine_.get_device_engine_base_ptr().get()))->get();
return oneapi::mkl::rng::generate(distr, device_engine, count, dst, deps);
}

// default: throw std::runtime_error("Unsupported engine type in generate_rng");
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add error handling

Suggested change
else {
auto& device_engine =
*(static_cast<gen_mt2203*>(engine_.get_device_engine_base_ptr().get()))->get();
return oneapi::mkl::rng::generate(distr, device_engine, count, dst, deps);
}
// default: throw std::runtime_error("Unsupported engine type in generate_rng");
//}
else if (engine_type == engine_type::mt2203) {
auto& device_engine =
*(static_cast<gen_mt2203*>(engine_.get_device_engine_base_ptr().get()))->get();
return oneapi::mkl::rng::generate(distr, device_engine, count, dst, deps);
} else {
throw std::runtime_error("Unsupported engine type in generate_rng");
}

@@ -19,6 +19,15 @@
#include "oneapi/dal/detail/profiler.hpp"

#include <sycl/ext/oneapi/experimental/builtins.hpp>
#include <sycl/ext/oneapi/experimental/builtins.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

Suggested change
#include <sycl/ext/oneapi/experimental/builtins.hpp>

Comment on lines +51 to +56
auto event = oneapi::dpl::experimental::kt::gpu::esimd::radix_sort_by_key<true, 8>(
queue,
val_in.get_mutable_data(),
val_in.get_mutable_data() + val_in.get_count(),
ind_in.get_mutable_data(),
dpl::experimental::kt::kernel_param<256, 32>{});
Copy link
Contributor

Choose a reason for hiding this comment

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

At least write the comments that the parameters are chosen for PVC.

Comment on lines +640 to +643
INSTANTIATE_RADIX_SORT(std::int32_t)
INSTANTIATE_RADIX_SORT(std::uint32_t)
INSTANTIATE_RADIX_SORT(std::int64_t)
INSTANTIATE_RADIX_SORT(std::uint64_t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need all those instantiations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have these types for non dpl(for no pvc devices) radix sort, so its aligned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file dpc++ Issue/PR related to DPC++ functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants