Skip to content

ENH: Ridge Regression CPU SPMD support#3506

Open
DDJHB wants to merge 8 commits into
uxlfoundation:mainfrom
DDJHB:dev_ridge_cpu_spmd
Open

ENH: Ridge Regression CPU SPMD support#3506
DDJHB wants to merge 8 commits into
uxlfoundation:mainfrom
DDJHB:dev_ridge_cpu_spmd

Conversation

@DDJHB
Copy link
Copy Markdown
Contributor

@DDJHB DDJHB commented Feb 9, 2026

Description

This PR adds distributed (SPMD) training support for Ridge Regression on CPU, following Linear Regression changes.


Checklist:

Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • 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.
    No new failures.
  • I have extended testing suite if new functionality was introduced in this PR.

Performance

Not applicable

@DDJHB
Copy link
Copy Markdown
Contributor Author

DDJHB commented Feb 9, 2026

/intelci: run

}

TEMPLATE_LIST_TEST_M(lr_spmd_test, "RR common flow", "[rr][spmd]", lr_types) {
SKIP_IF(this->not_float64_friendly());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why would it need to skip this one if it's on CPU?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is common for CPU and GPU and this check is necessary just for GPU without native float64 support

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@DDJHB @Alexandr-Solovev it would be better to add if_gpu condition then.

@DDJHB
Copy link
Copy Markdown
Contributor Author

DDJHB commented Mar 29, 2026

/intelci: run

Comment thread cpp/oneapi/dal/algo/linear_regression/test/spmd.cpp
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds CPU distributed (SPMD) Ridge Regression training support to the oneAPI flow, mirroring existing distributed Linear Regression patterns and extending the SPMD test suite accordingly.

Changes:

  • Added new distributed Ridge Regression C++ samples for MPI and CCL backends.
  • Extended linear_regression SPMD tests with a Ridge Regression (alpha-regularized) common-flow test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
samples/oneapi/cpp/mpi/sources/ridge_regression_distr_mpi.cpp New MPI-based distributed Ridge Regression sample using SPMD preview::train / preview::infer with alpha regularization.
samples/oneapi/cpp/ccl/sources/ridge_regression_distr_ccl.cpp New CCL-based distributed Ridge Regression sample using SPMD communicator and alpha regularization.
cpp/oneapi/dal/algo/linear_regression/test/spmd.cpp Adds an RR-tagged SPMD test invoking run_and_check_ridge() to validate distributed ridge flow.

Comment thread cpp/oneapi/dal/algo/linear_regression/test/spmd.cpp
Comment on lines +17 to +23
#include <iomanip>
#include <iostream>

#include "oneapi/dal/algo/linear_regression.hpp"
#include "oneapi/dal/io/csv.hpp"
#include "oneapi/dal/spmd/mpi/communicator.hpp"

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

std::runtime_error is used in main() but <stdexcept> is not included. Relying on transitive includes is non-portable and may break builds with stricter standard library headers. Include <stdexcept> directly in this sample.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Valid, but this should be changed in all the samples - a task for another PR.

Comment on lines +68 to +79
int main(int argc, char const *argv[]) {
int status = MPI_Init(nullptr, nullptr);
if (status != MPI_SUCCESS) {
throw std::runtime_error{ "Problem occurred during MPI init" };
}

run();

status = MPI_Finalize();
if (status != MPI_SUCCESS) {
throw std::runtime_error{ "Problem occurred during MPI finalize" };
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

If run() throws (e.g., CSV read / train / infer exceptions), MPI_Finalize() will be skipped, which can leave MPI in an undefined state and cause hangs/aborts on some runtimes. Consider wrapping run() in a try/catch that always calls MPI_Finalize() (or introduce an RAII guard that finalizes in its destructor).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This code is aligned with other samples. Need to make those changes in all samples - a task for another PR.

Comment on lines +17 to +23
#include <iomanip>
#include <iostream>

#include "oneapi/dal/algo/linear_regression.hpp"
#include "oneapi/dal/io/csv.hpp"
#include "oneapi/dal/spmd/ccl/communicator.hpp"

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

std::runtime_error is used in main() but <stdexcept> is not included. Relying on transitive includes is non-portable and may break builds with stricter standard library headers. Include <stdexcept> directly in this sample.

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +80
int main(int argc, char const *argv[]) {
ccl::init();
int status = MPI_Init(nullptr, nullptr);
if (status != MPI_SUCCESS) {
throw std::runtime_error{ "Problem occurred during MPI init" };
}

run();

status = MPI_Finalize();
if (status != MPI_SUCCESS) {
throw std::runtime_error{ "Problem occurred during MPI finalize" };
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

If run() throws (e.g., CSV read / train / infer exceptions), MPI_Finalize() will be skipped, which can leave MPI in an undefined state and cause hangs/aborts on some runtimes. Consider wrapping run() in a try/catch that always calls MPI_Finalize() (or introduce an RAII guard that finalizes in its destructor).

Copilot uses AI. Check for mistakes.
Comment thread cpp/oneapi/dal/algo/linear_regression/test/spmd.cpp
@Vika-F
Copy link
Copy Markdown
Contributor

Vika-F commented Apr 15, 2026

/intelci: run

@Vika-F Vika-F marked this pull request as ready for review April 16, 2026 08:31
@ethanglaser
Copy link
Copy Markdown
Contributor

These samples (oneapi/cpp) do not appear to be running anywhere in our private CI - is this expected? Or if they are, please point to where

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants