Commit ff6e773
fix: improve error message when DPC++ backend (libonedal_dpc.so) fails to load (#2998)
* fix: improve error message when DPC++ backend fails to load
When libonedal_dpc.so is missing (e.g. CPU-only oneDAL package split),
the ImportError was silently swallowed and users received a cryptic
internal message when attempting SYCL/queue-based inference:
RuntimeError: Operations using queues require the DPC/SPMD backend
This change:
1. Captures the ImportError reason in _dpc_load_error at module load time
2. Surfaces a user-actionable error message with the actual load failure
and install instructions when a SYCL queue is used without DPC++ support
Example new message:
RuntimeError: oneDAL GPU/DPC++ support is not available in the
current installation.
Reason: libonedal_dpc.so.3: cannot open shared object file: ...
To enable SYCL/GPU acceleration, install the GPU extras:
pip install scikit-learn-intelex[gpu]
or via conda:
conda install -c https://software.repos.intel.com/python/conda scikit-learn-intelex
* fix: wrap long string to satisfy flake8 E501 (max-line-length=90)
* fix: use scikit-learn-intelex-gpu in conda install hint
* docs: note Polars DataFrame support in supported input types
* fix: refactor DPC++ load error into throw_if_no_dpc_available()
Addresses david-cortes-intel review comments on #2998:
- Add _spmd_load_error captured from SPMD backend ImportError
- Replace _dpc_load_error inline check with throw_if_no_dpc_available(require_spmd)
which handles both DPC++ and SPMD backends uniformly
- Function raises actionable error with reason + install instructions
only when the backend actually failed to load (avoids misleading message
when file exists but import fails for other reasons like SYCL runtime)
- Use require_spmd=self.backend.is_spmd so SPMD-only backends surface
the correct error message
* lint: fix docstring style for throw_if_no_dpc_available
* fix: rename to _ensure_dpc_available, always raise when backend is None, remove dead raise
- Rename throw_if_no_dpc_available -> _ensure_dpc_available (Pythonic convention)
- Change gate from 'if error_msg' to 'if backend is None' so the function
always raises with install instructions, even when the package was never
installed (no ImportError captured). The Reason line is only included when
an ImportError message is available.
- Remove the dead 'raise RuntimeError("Operations using...")' fallthrough in
_backend.py — _ensure_dpc_available unconditionally raises when backend is None
- Remove private _dpc_load_error/_spmd_load_error from __all__; only expose
the public helper function
- Add Notes section to docstring documenting import-time capture semantics
Addresses david-cortes-intel review comments.
* revert: remove Polars line from input-types.rst (out of scope for this PR)
* Update onedal/__init__.py
Co-authored-by: david-cortes-intel <david.cortes@intel.com>
* fix: only capture ImportError reason when .so file is present
When the DPC++/SPMD backend package is simply not installed,
ImportError gives 'No module named onedal._onedal_py_dpc' which
is not actionable. Only populate _dpc_load_error/_spmd_load_error
when the .so file actually exists in the package directory — meaning
the library is present but failed to load (e.g. missing SYCL runtime,
incompatible libsycl.so). Uses pathlib.glob() at module init time.
Addresses david-cortes-intel review comment.
* refactor: reuse backend binary presence check for Windows and load diagnostics
---------
Co-authored-by: david-cortes-intel <david.cortes@intel.com>1 parent 2dd961a commit ff6e773
2 files changed
Lines changed: 77 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
100 | 111 | | |
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
106 | 117 | | |
107 | | - | |
108 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
109 | 121 | | |
| 122 | + | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
117 | 131 | | |
118 | 132 | | |
119 | 133 | | |
120 | | - | |
| 134 | + | |
121 | 135 | | |
| 136 | + | |
| 137 | + | |
122 | 138 | | |
123 | 139 | | |
124 | 140 | | |
| |||
128 | 144 | | |
129 | 145 | | |
130 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
131 | 191 | | |
132 | 192 | | |
| 193 | + | |
133 | 194 | | |
134 | 195 | | |
135 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
0 commit comments