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

chore: initial refactoring of incremental spmd algos #2248

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

Conversation

ethanglaser
Copy link
Contributor

@ethanglaser ethanglaser commented Jan 9, 2025

Description

Specifies class name to invoke _get_backend, and _get_policy in the event that this is not supported for the spmd class. Allows removal of duplicate code for incremental spmd algos, and utilization of onedal4py pca transform. Also adds transform function to onedal4py PCA because scikit-learn PCA does not have a predict function, so transform was added and redirects to predict.


PR should start as a draft, then move to ready for review state after CI is passed and all applicable checkboxes are closed.
This approach ensures that reviewers don't spend extra time asking for regular requirements.

You can remove a checkbox as not applicable only if it doesn't relate to this PR in any way.
For example, PR with docs update doesn't require checkboxes for performance while PR with any change in actual code should have checkboxes and justify how this code change is expected to affect performance (or justification should be self-evident).

Checklist to comply with before moving PR from draft:

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.

@ethanglaser
Copy link
Contributor Author

/intelci: run

1 similar comment
@ethanglaser
Copy link
Contributor Author

/intelci: run

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Flag Coverage Δ
azure ?
github 71.01% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...l/basic_statistics/incremental_basic_statistics.py 100.00% <100.00%> (ø)
onedal/covariance/incremental_covariance.py 92.68% <100.00%> (ø)
onedal/decomposition/incremental_pca.py 96.77% <100.00%> (ø)
onedal/decomposition/pca.py 93.39% <100.00%> (+0.06%) ⬆️
onedal/linear_model/incremental_linear_model.py 97.75% <100.00%> (ø)

... and 70 files with indirect coverage changes

Copy link
Contributor

@icfaust icfaust left a comment

Choose a reason for hiding this comment

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

I know this is still a WIP, but maybe we should have a chat about strategy?

@ethanglaser
Copy link
Contributor Author

/intelci: run

@ethanglaser
Copy link
Contributor Author

/intelci: run

@ethanglaser
Copy link
Contributor Author

/intelci: run

@ethanglaser ethanglaser requested a review from icfaust January 21, 2025 19:21
@ethanglaser
Copy link
Contributor Author

/intelci: run

@icfaust
Copy link
Contributor

icfaust commented Jan 28, 2025

/intelci: run

@ethanglaser ethanglaser changed the title Refactor incremental spmd algos chore: initial refactoring of incremental spmd algos Jan 28, 2025
Copy link
Contributor

@icfaust icfaust left a comment

Choose a reason for hiding this comment

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

I'll be honest, the get_backend stuff just seems to be a headache through and through. Small stuff but overall really good work.

@@ -71,8 +71,9 @@ def __init__(self, result_options="all"):

def _reset(self):
self._need_to_finalize = False
self._partial_result = self._get_backend(
"basic_statistics", None, "partial_compute_result"
# Not supported with spmd policy so IncrementalBasicStatistics must be specified
Copy link
Contributor

Choose a reason for hiding this comment

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

Love the comment

"basic_statistics", None, "partial_compute_result"
# Not supported with spmd policy so IncrementalBasicStatistics must be specified
self._partial_result = IncrementalBasicStatistics._get_backend(
IncrementalBasicStatistics, "basic_statistics", None, "partial_compute_result"
Copy link
Contributor

Choose a reason for hiding this comment

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

@ahuber21 these changes are likely going to interact with #2168 (just as a heads up).

onedal/decomposition/pca.py Outdated Show resolved Hide resolved
@@ -40,7 +40,7 @@ def test_on_gold_data(queue, is_deterministic, whiten, num_blocks, dtype):

result = incpca.finalize_fit()

transformed_data = incpca.predict(X, queue=queue)
transformed_data = incpca.transform(X, queue=queue)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for conformance purposes to sklearn (though not strictly necessary in the onedal folder)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly - pca predict does not exist in sklearn so would prefer to not use this convention if possible

@ethanglaser ethanglaser marked this pull request as ready for review January 29, 2025 19:32
@ethanglaser
Copy link
Contributor Author

/intelci: run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants