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: dpnp interop for sklearnex #1374

Merged
merged 10 commits into from
Jul 26, 2023

Conversation

samir-nasibli
Copy link
Contributor

@samir-nasibli samir-nasibli commented Jul 24, 2023

Description

  • interop for DPNP ndarrays
  • API support for dpnp ndarrays
  • added dpnp installation into env
  • added examples with dpnp, dpctl usage.
    • updated runner for this

TODO

  • update docs -> on separate PR
  • testing for different dataframe libs on sklearnex own tests -> on separate PR
  • interop for SPMD interfaces

api support for dpnp ndarrays
@samir-nasibli samir-nasibli changed the title ENH: dpnp interop in sklearnex ENH: dpnp interop for sklearnex Jul 24, 2023
@ahuber21
Copy link
Contributor

Here's what I see in the CI summary

======================================================================
ERROR: test_knn_bf_classification_dpnp_batch (test_examples_sklearnex.TestsklearnexExamples.test_knn_bf_classification_dpnp_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/knn_bf_classification_dpnp_batch.py']' returned non-zero exit status 1.

======================================================================
ERROR: test_random_forest_classifier_dpctl_batch (test_examples_sklearnex.TestsklearnexExamples.test_random_forest_classifier_dpctl_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/random_forest_classifier_dpctl_batch.py']' returned non-zero exit status 1.

======================================================================
ERROR: test_random_forest_regressor_dpnp_batch (test_examples_sklearnex.TestsklearnexExamples.test_random_forest_regressor_dpnp_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/random_forest_regressor_dpnp_batch.py']' returned non-zero exit status 1.

Do these checks work locally for you?

@samir-nasibli
Copy link
Contributor Author

Here's what I see in the CI summary

======================================================================
ERROR: test_knn_bf_classification_dpnp_batch (test_examples_sklearnex.TestsklearnexExamples.test_knn_bf_classification_dpnp_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/knn_bf_classification_dpnp_batch.py']' returned non-zero exit status 1.

======================================================================
ERROR: test_random_forest_classifier_dpctl_batch (test_examples_sklearnex.TestsklearnexExamples.test_random_forest_classifier_dpctl_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/random_forest_classifier_dpctl_batch.py']' returned non-zero exit status 1.

======================================================================
ERROR: test_random_forest_regressor_dpnp_batch (test_examples_sklearnex.TestsklearnexExamples.test_random_forest_regressor_dpnp_batch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vsts/work/1/s/tests/test_examples_sklearnex.py", line 43, in testit
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/share/miniconda/envs/CB/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '/home/vsts/work/1/s/examples/sklearnex/random_forest_regressor_dpnp_batch.py']' returned non-zero exit status 1.

Do these checks work locally for you?

Yeah I am working on it, trying understand public CI env, will reproduce it. Locally it works

Comment on lines +207 to +209
result = _copy_to_usm(usm_iface["syclobj"], result)
if dpnp_available and isinstance(data[0], dpnp.ndarray):
result = dpnp.array(result, copy=False)
Copy link
Contributor Author

@samir-nasibli samir-nasibli Jul 25, 2023

Choose a reason for hiding this comment

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

This and related dpnp import are only functional changes in this file, the rest is formatting.

@samir-nasibli
Copy link
Contributor Author

/intelci: run

@samir-nasibli
Copy link
Contributor Author

/intelci: run

@samir-nasibli samir-nasibli marked this pull request as ready for review July 26, 2023 08:58
@samir-nasibli
Copy link
Contributor Author

Job: http://intel-ci.intel.com/ee2baa7b-5115-f127-aa37-a4bf010d0e2e. Specifically for sklearnex examples GPU.

@samir-nasibli
Copy link
Contributor Author

samir-nasibli commented Jul 26, 2023

Job: http://intel-ci.intel.com/ee2baa7b-5115-f127-aa37-a4bf010d0e2e. Specifically for sklearnex examples GPU.

examples/sklearnex/random_forest_classifier_dpctl_batch.py
	PASSED	random_forest_classifier_dpctl_batch.py

examples/sklearnex/random_forest_regressor_dpnp_batch.py
	PASSED	random_forest_regressor_dpnp_batch.py

examples/sklearnex/knn_bf_classification_dpnp_batch.py
	PASSED	knn_bf_classification_dpnp_batch.py

@samir-nasibli
Copy link
Contributor Author

/intelci: run

dpnp_X_test = dpnp.asarray(X_test, usm_type="device", sycl_queue=q)

knn_mdl = KNeighborsClassifier(
algorithm="brute", n_neighbors=20, weights="uniform", p=2, metric="minkowski"
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose weights="uniform", p=2, metri="minkowski" - correspond to the Euclidean metric and normal mode of classification which are default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be patched for both spmd and batch examples. Let's do it on separate PR

# ===============================================================================

# sklearnex kNN example for GPU offloading with DPNP ndarray:
# python ./knn_bf_classification_dpnp_batch.py.py
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
# python ./knn_bf_classification_dpnp_batch.py.py
# python ./knn_bf_classification_dpnp_batch.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@samir-nasibli samir-nasibli merged commit 0ccbbfa into intel:master Jul 26, 2023
20 checks passed
@samir-nasibli samir-nasibli deleted the enh/dpnp_api_support branch July 26, 2023 16:44
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.

4 participants