ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
Find a file
Xavier Dupré a909cc0e1b
Improves parallelization by trees for TreeEnsemble (#13835)
### Description

If the number of trees is >= 100 and batch size >= 2000, the
parallelization by tree becomes slower than the parallelization by rows.
However, by applying the parallelization by trees over smaller chunks of
data, it is still better than the parallelization by rows. The following
script was used to measure the performance
[plot_gexternal_lightgbm_reg_per.zip](https://github.com/microsoft/onnxruntime/files/10149092/plot_gexternal_lightgbm_reg_per.zip)
with different thresholds. The graph were produced by the script
following the graph.

* //N means parallelization by rows
* //T means parallelization by trees
* //T-128 means parallelization by trees every batch of 128 rows.
* //T-1024 means parallelization by trees every batch of 1024 rows.

The following graphs shows that the parallelization by trees is better
than the parallelization by rows on small batches only. It is also
better to split the input tensor by chunks of 128 rows and parallelize
by trees on every chunk of 128 rows. The proposed changes implements
that optimization.

It applies the same idea even when there is only one thread. It also
makes sure one thread is used when the user only wants one.


![image](https://user-images.githubusercontent.com/22452781/205505093-6d04c684-80a3-40b4-b2a5-ca1bcee5f7d2.png)

```python
import pandas
import matplotlib.pyplot as plt

filenames = [
    ("//N",r"plot_gexternal_lightgbm_reg_per_N.csv"),
    ("//T", "plot_gexternal_lightgbm_reg_per_T.csv"),
    ("//T-128", "plot_gexternal_lightgbm_reg_per_128.csv"),
    ("//T-1024", "plot_gexternal_lightgbm_reg_per_1024.csv"),
]
dfs = []
for name, filename in filenames:
    df = pandas.read_csv(filename)
    for c in df.columns:
        if "batch" in c:
            df[f"-{name}-{c}"] = df[c]
    dfs.append(df)

df = dfs[0][["N"]].copy()
for _df in dfs:
    for c in _df.columns:
        if c[0] == "-":
            df[c] = _df[c].copy()

fig, ax = plt.subplots(1, 3, figsize=(14, 6))
Ts = [50, 500, 2000]
ga = df.set_index("N")
for i, nt in enumerate(Ts):
    cs = [c for c in ga.columns if c.endswith(f"-{nt}")]
    ga[cs].plot(ax=ax[i], title=f"Trees={nt}", logy=True, logx=True)
```

Below the performance gain for the monothread implementation by looping
on data in the inner loop.


![image](https://user-images.githubusercontent.com/22452781/207379886-10540b53-d66f-4103-937a-15074154c166.png)


### Motivation and Context
Performance.

Signed-off-by: xadupre <xadupre@microsoft.com>
2023-01-13 10:03:10 +01:00
.config Update tsaoptions.json: update the email alias (#13448) 2022-10-26 15:56:16 -07:00
.devcontainer Remove two lines in the Dockerfile for Github Codespace (#12278) 2022-07-21 20:52:17 -07:00
.gdn
.github Delete add-issues-to-project (#14147) 2023-01-11 14:33:37 -08:00
.pipelines [DML EP] Upgrade DML to 1.10.0 (#13796) 2022-11-30 21:32:14 -08:00
.vscode cpplint & Eager mode: refactor and add comments to empty_* functions, general lint cleanup in ort_aten (#12238) 2022-07-20 11:47:57 -04:00
cgmanifests Add ability to register custom ops by specifying a function name (#14177) 2023-01-12 15:11:34 +10:00
cmake [DML EP] Add FusedMatMul (#14196) 2023-01-12 02:17:04 -08:00
csharp Disable the failing opset 18 model tests that are breaking the packaging pipeline (#14259) 2023-01-13 09:55:52 +10:00
dockerfiles Openvino ep 2022.3 v4.3 (#14210) 2023-01-11 16:31:26 -08:00
docs Some changes to Sampling Op (#14218) 2023-01-12 14:15:26 -08:00
include/onnxruntime/core Add ability to register custom ops by specifying a function name (#14177) 2023-01-12 15:11:34 +10:00
java [java] Sparse tensor support (#10653) 2022-11-22 10:29:24 -08:00
js [web] utility functions for tensor<->image conversion in ORT web (#13603) 2023-01-12 09:05:18 -08:00
objectivec [xnnpack-ep] NEW EP API in objc (#13941) 2022-12-15 20:12:02 +08:00
onnxruntime Improves parallelization by trees for TreeEnsemble (#13835) 2023-01-13 10:03:10 +01:00
orttraining Enable a single build with optimized inference and on device training (#14241) 2023-01-12 21:36:43 -08:00
package/rpm Bumping up version number to 1.14.0 on main branch (#13401) 2022-10-21 19:16:44 -04:00
samples Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
test Multi-stream execution support (#13495) 2022-12-15 07:39:29 -08:00
tools [ROCm] use pytest-xdist for fast pytest (#14261) 2023-01-13 16:57:50 +08:00
winml Enabling thread pool to be numa-aware (#13778) 2022-12-12 10:33:55 -08:00
.clang-format
.clang-tidy Create clang-tidy CI (#12653) 2022-09-30 08:05:38 -07:00
.dockerignore
.flake8 Remove miscellaneous nuphar configs (#13070) 2022-09-26 13:41:28 -07:00
.gitattributes
.gitignore Ignore more build directories and clangd files (#14154) 2023-01-07 06:58:57 +08:00
.gitmodules Remove unused git submodules (#13830) 2022-12-07 21:59:16 -08:00
build.amd64.1411.bat
build.bat
build.sh
CITATION.cff
CODEOWNERS Add cgmanifest file in codeowner list (#13042) 2022-09-22 18:58:01 -07:00
CONTRIBUTING.md
lgtm.yml Fix lgtm C++ error (#13613) 2022-11-10 10:06:22 -08:00
LICENSE
NuGet.config
ort.wprp
ORT_icon_for_light_bg.png
packages.config [DML EP] Upgrade DML to 1.10.0 (#13796) 2022-11-30 21:32:14 -08:00
pyproject.toml Update pylint config to include valid short names (#13631) 2022-11-14 10:00:25 -08:00
README.md Update resource section in readme (#13724) 2022-11-28 09:42:31 -08:00
requirements-dev.txt Introduce parameterized as a dev dependency (#11364) 2022-04-26 17:24:39 -07:00
requirements-doc.txt
requirements-training.txt Remove protobuf pin from training requirements (#13695) 2022-11-22 12:27:18 -08:00
requirements.txt.in Add additional python requirements (#11522) 2022-05-20 16:16:18 -07:00
SECURITY.md Microsoft mandatory file (#11619) 2022-05-25 13:56:10 -07:00
setup.py Openvino ep 2022.3 v4.3 (#14210) 2023-01-11 16:31:26 -08:00
ThirdPartyNotices.txt Add ability to register custom ops by specifying a function name (#14177) 2023-01-12 15:11:34 +10:00
VERSION_NUMBER Bumping up version number to 1.14.0 on main branch (#13401) 2022-10-21 19:16:44 -04:00

ONNX Runtime is a cross-platform inference and training machine-learning accelerator.

ONNX Runtime inference can enable faster customer experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with different hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. Learn more →

ONNX Runtime training can accelerate the model training time on multi-node NVIDIA GPUs for transformer models with a one-line addition for existing PyTorch training scripts. Learn more →

Get Started & Resources

Build Pipeline Status

System CPU GPU EPs
Windows Build Status Build Status Build Status
Linux Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Mac Build Status
Build Status
Android Build Status
iOS Build Status
WebAssembly Build Status

Data/Telemetry

Windows distributions of this project may collect usage data and send it to Microsoft to help improve our products and services. See the privacy statement for more details.

Contributions and Feedback

We welcome contributions! Please see the contribution guidelines.

For feature requests or bug reports, please file a GitHub Issue.

For general discussion or questions, please use GitHub Discussions.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

This project is licensed under the MIT License.