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

ENH: fallback to stock scikit-learn after onedal fail #1907

Merged

Conversation

samir-nasibli
Copy link
Contributor

@samir-nasibli samir-nasibli commented Jun 29, 2024

Description

In several estimators there are second level fallback flow, that is not obvious and controlled by the user.
Proposed to add control on fallback computation to stock scikit-learn after onedal backend in case of runtime error on onedal backend computations. config_context extended for allow_sklearn_after_onedal param, that control this behavior.
By default it is allowed to fallback to stock scikit-learn after onedal backend in case of runtime error. In sklearnex testing and sklearn conformance testing this is blocked, just to check onedal backend.

Done

  • new sklearnex config paramter to control fallback to stock scikit-learn if onedal fails
  • added new test case to check config_contex proper work: test_config_context_works
  • refactor and fixed test_set_config_works test suit.
  • added comments and docstrings.
  • 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, if necessary (updated in # - add PR number)
  • The unit tests pass successfully.
  • I have run it locally and tested the changes extensively.
  • I have resolved any merge conflicts that might occur with the base branch.
  • 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.

@icfaust
Copy link
Contributor

icfaust commented Jul 8, 2024

@samir-nasibli do you need clarification on the background of this oddity in the codebase before we close this PR? It comes from these steps in the DAAL codebase: https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/service_kernel_math.h#L721

@samir-nasibli
Copy link
Contributor Author

@samir-nasibli do you need clarification on the background of this oddity in the codebase before we close this PR? It comes from these steps in the DAAL codebase: https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/service_kernel_math.h#L721

@icfaust thank you! I am definitely not going to close this PR, some case needed to be addressed.

@icfaust
Copy link
Contributor

icfaust commented Jul 8, 2024

@samir-nasibli do you need clarification on the background of this oddity in the codebase before we close this PR? It comes from these steps in the DAAL codebase: https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/service_kernel_math.h#L721

@icfaust thank you! I am definitely not going to close this PR, some case needed to be addressed.

I'll wait to review until you mark it ready, I'm curious to see if you plan to refactor the fallback mechanism or fix a bug in the PLU factorization on oneDAL-side first.

@samir-nasibli
Copy link
Contributor Author

@samir-nasibli do you need clarification on the background of this oddity in the codebase before we close this PR? It comes from these steps in the DAAL codebase: https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/service_kernel_math.h#L721

@icfaust thank you! I am definitely not going to close this PR, some case needed to be addressed.

I'll wait to review until you mark it ready, I'm curious to see if you plan to refactor the fallback mechanism or fix a bug in the PLU factorization on oneDAL-side first.

I'll wait to review until you mark it ready, I'm curious to see if you plan to refactor the fallback mechanism or fix a bug in the PLU factorization on oneDAL-side first.

Please read the short description to the PR more carefully.
At the moment there is no ready-made solution for a particular case, there is a draft PR, in the future it is planned to manage this through config_context.

When the proposal is expanded and ready for discussion/review, the PR will be marked ready for review
Thank you!

@samir-nasibli
Copy link
Contributor Author

/intelci: run

@samir-nasibli samir-nasibli marked this pull request as ready for review August 9, 2024 20:54
@samir-nasibli samir-nasibli marked this pull request as draft August 9, 2024 20:56
@samir-nasibli
Copy link
Contributor Author

samir-nasibli commented Aug 9, 2024

Linear regression fails all tests on both GPU and CPU, that requires additional investigation.

I will separate deprecation and changes for the LogReg into the separate PR, since this eventually passed all tests. See #1996

@samir-nasibli samir-nasibli changed the title DEP: deprecate fallback to sklearn after onedal DEP: deprecate fallback to sklearn after onedal for LinRegression Sep 4, 2024
@samir-nasibli
Copy link
Contributor Author

The statistics of the onedal4py backend usage and sklearn after onedal4py backend should be investigate.
It seems LinReg has some defects, that should be addressed.

The mechanism itself for falling back sklearn_after_onedal will be updated via config_context.

Follow up tickets will be created.

@samir-nasibli
Copy link
Contributor Author

/intelci: run

@samir-nasibli samir-nasibli changed the title DEP: deprecate fallback to sklearn after onedal for LinRegression DEP: fallback to sklearn after onedal for LinRegression Sep 27, 2024
@samir-nasibli samir-nasibli changed the title DEP: fallback to sklearn after onedal for LinRegression DEP: fallback to sklearn after onedal Sep 27, 2024
@samir-nasibli samir-nasibli changed the title DEP: fallback to sklearn after onedal DEP: fallback to sklearn after onedal fail Sep 27, 2024
@samir-nasibli samir-nasibli changed the title DEP: fallback to sklearn after onedal fail ENH: fallback to sklearn after onedal fail Sep 27, 2024
@samir-nasibli samir-nasibli added the enhancement New feature or request label Oct 19, 2024
@samir-nasibli
Copy link
Contributor Author

/intelci: run

@samir-nasibli samir-nasibli changed the title ENH: fallback to sklearn after onedal fail ENH: fallback to stock scikit-learn after onedal fail Oct 19, 2024
sklearnex/_config.py Outdated Show resolved Hide resolved
@samir-nasibli samir-nasibli marked this pull request as ready for review October 19, 2024 23:02
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.

This is impacted by #2083 , that would mean only LinearRegression GPU, and LogisticRegression GPU estimators are influenced. Is it worth having a new config keyword for these specific cases? @Alexsandruss should weigh in. I'm still in favor of closing this PR. I would say the removal can occur naturally when these issues are addressed in the individual estimators.

@icfaust
Copy link
Contributor

icfaust commented Oct 21, 2024

Forgot to mention @avolkov-intel for comment on this as well.

@samir-nasibli
Copy link
Contributor Author

samir-nasibli commented Oct 21, 2024

This is impacted by #2083 , that would mean only LinearRegression GPU, and LogisticRegression GPU estimators are influenced. Is it worth having a new config keyword for these specific cases? @Alexsandruss should weigh in. I'm still in favor of closing this PR. I would say the removal can occur naturally when these issues are addressed in the individual estimators.

This PR doesn't change py default anything. Only on testing we are removing these.
We are already have flag for example allowing do computations on onedal cpu if gpu not supported, and it is disabled for testing. The same idea here. If this cases will be addressed then we can remove totally this flag from config_context.

@samir-nasibli samir-nasibli requested a review from icfaust October 21, 2024 13:05
fixed set_config for the config default values
@samir-nasibli
Copy link
Contributor Author

/intelci: run

Comment on lines 30 to +33
def test_set_config_works():
"""Test validates that the config settings were applied correctly by
set_config.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests will require generalization and parameterization in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @Alexsandruss . Please suggest inputs I will cover with a ticket

@samir-nasibli samir-nasibli merged commit b61cc90 into uxlfoundation:main Oct 30, 2024
26 checks passed
@samir-nasibli samir-nasibli deleted the dep/skl_fallback_after_onedal branch October 30, 2024 08:01
david-cortes-intel pushed a commit to david-cortes-intel/scikit-learn-intelex that referenced this pull request Oct 31, 2024
…ion#1907)

* ENH: fallback to stock `scikit-learn` after `onedal` fail

* fix `allow_sklearn_after_onedal` setting

* covered config_context with more tests

* fixed set_config for the config default values
@samir-nasibli samir-nasibli mentioned this pull request Nov 4, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants