Add a chapter about scikit-learn-intelex#40
Conversation
david-cortes-intel
left a comment
There was a problem hiding this comment.
Some comments:
- Could make it clear that OMP settings related to affinity will not have an effect.
- Could provide commands to do all of this programmatically instead of manually listing the core IDs after looking at output.
- This advise is not really specific to sklearnex. Maybe could be put as an additional section and then linked from all the relevant articles, like NumPy and scikit-learn.
|
|
||
| To set EPB to Performance mode: | ||
| ``` | ||
| sudo cpupower set -b 0 |
There was a problem hiding this comment.
It doesn't explain the longevity of the effect from this command. Same for the other CPU settings.
Ok, will do.
You mean, python commands doing the same things like affinity modification?
Yes, I thought about it as well, but was not sure. I will restructure the pages accordingly. |
I guess they'd have to be shell commands, otherwise they wouldn't have an effect on an already-launched python process. |
I understand the idea, but it will be a multi-line script for sure. Not a single |
@Vika-F isn't there any built-in numactl command do something like "run only physical cores"? |
No, there is no such option. |
|
@david-cortes-intel An example of a script that runs a process only on physical nodes: For me it looks too heavy for the page like this. What do you think? |
@Vika-F How about something in a pipeline (perhaps with awk?) getting the result from lscpu with arguments, filtering, and selecting a column? |
|
|
||
| ```bash | ||
| export MIN_MHZ=3000 | ||
| cpus=$(lscpu -e=cpu,core,maxmhz | tail -n +2 | awk -v min="$MIN_MHZ" '$3 >= min && !seen[$2]++ {printf sep $1; sep=","}') |
There was a problem hiding this comment.
I think this MIN_MHZ could also be obtained with awk from lscpu -e=cpu,core,maxmhz.
There was a problem hiding this comment.
The problem is that there are various SKUs available, i.e. with P-cores only; with P-cores and E-cores; with E-cores and LP E-cores, etc.
Without MIN_MHZ the solution can exclude not LPE, but another type of cores with the lowest frequency.
That's why I decided just to provide the MHz threshold.
| @@ -0,0 +1,133 @@ | |||
| This chapter contains information about the practices that lead to better performance of scikit-learn-intelex on Intel CPUs. | |||
There was a problem hiding this comment.
Needs title and table of contents.
There was a problem hiding this comment.
Pull request overview
Adds new documentation aimed at improving scikit-learn-intelex workload performance on Intel CPUs by describing recommended system/CPU configuration and process pinning practices, and links the new chapter from the repo’s main README.
Changes:
- Add a new scikit-learn-intelex chapter covering hyper-threading and LPE-core affinity recommendations (Windows/Linux).
- Add a shared “common” chapter with OS-level recommendations (EPB/EPP and CPU frequency scaling).
- Link the new scikit-learn-intelex chapter from the top-level README.
Reviewed changes
Copilot reviewed 3 out of 9 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
software/scikit-learn-intelex/README.md |
New chapter with HT/LPE detection and affinity guidance for Windows and Linux. |
software/common/README.md |
New common system tuning guidance (EPB/EPP and CPU frequency scaling). |
README.md |
Adds the scikit-learn-intelex chapter to the main table of contents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ### On Windows | ||
|
|
||
| Hyper-threading can be deteched by running **Task Manager**. Then navigate to **Performance** > **CPU** tab. |
|
|
||
| <img src="images/cpu-affinity-ht.png" alt="drawing" style="width:600px;"/> | ||
|
|
||
| Which is equivalent to `2BFF` in hexadecimal format. Run following command to disable HT on Windows: |
| The recommended affinity mask that disables both hyper-threading and LPE cores would be `2BFC`: | ||
|
|
| From the output we can see that 4 logical processors (0, 1, 2, 3) are running on two physical cores (0, 1). | ||
| To run the process on physical cores only, use one of the following commands: | ||
|
|
||
| ``` | ||
| numactl -C 0,2,4-13 python <workload.py> | ||
| ``` | ||
| or | ||
| ``` | ||
| taskset -c 0,2,4-13 python <workload.py> | ||
| ``` |
| Run the following command to disable HT and LPE cores on Linux: | ||
|
|
||
| ``` | ||
| numactl -C 0,2,4-11 python <workload.py> | ||
| ``` |
| ## Energy Performance Bias (EPB) | ||
|
|
||
| Energy Performance Bias (EPB) is an Intel Xeon hardware setting that controls the trade-off between power consumption and processing performance. For the best performance, it is recommended to set it to `0` (Performance mode). | ||
|
|
||
| ### On Windows | ||
|
|
||
| Run the following command in `cmd`: | ||
|
|
||
| ``` | ||
| powercfg -setacvalueindex scheme_current sub_processor PERFEPP 0 | ||
| ``` | ||
|
|
||
| [More info about `powercfg`](https://learn.microsoft.com/en-us/windows-hardware/customize/power-settings/options-for-perf-state-engine-perfenergypreference). | ||
|
|
||
| ### On Linux | ||
|
|
||
| To check the current value of EPB, run: | ||
| ``` | ||
| sudo cpupower info | ||
| ``` | ||
|
|
||
| To set EPB to Performance mode: | ||
| ``` | ||
| sudo cpupower set -b 0 | ||
| ``` |
| - [Redis](software/similarity-search/redis/README.md) | ||
| - [Spark](software/spark/README.md) | ||
| - [scikit-learn](software/scikit-learn/README.md) | ||
| - [scikit-learn-intelex](software/scikit-learn-intelex/README.md) |
There was a problem hiding this comment.
I propose that this PR is changed to live completely in the Software->Common directory
| @@ -0,0 +1,140 @@ | |||
| # Introduction | |||
There was a problem hiding this comment.
The contents for the scikit-learn-intelex README don't seem specific to scikit-learn-intelex. I recommend merging this README with the one you created in the "common" directory.
Add information about sklearnex configurations that can provide better performance.
CC @napetrov @david-cortes-intel @avolkov-intel @Alexandr-Solovev