lleaves
Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 8 committers (12.5%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.
Basic Info
- Host: GitHub
- Owner: siboehm
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://lleaves.readthedocs.io/en/latest/
- Size: 4.75 MB
Statistics
- Stars: 439
- Watchers: 8
- Forks: 36
- Open Issues: 22
- Releases: 16
Topics
Metadata Files
README.md
lleaves 🍃
A LLVM-based compiler for LightGBM decision trees.
lleaves converts trained LightGBM models to optimized machine code, speeding-up prediction by ≥10x.
Example
```python lgbmmodel = lightgbm.Booster(modelfile="NYCtaxi/model.txt") %timeit lgbmmodel.predict(df)
12.77s
llvmmodel = lleaves.Model(modelfile="NYCtaxi/model.txt") llvmmodel.compile() %timeit llvm_model.predict(df)
0.90s
```
Why lleaves?
- Speed: Both low-latency single-row prediction and high-throughput batch-prediction.
- Drop-in replacement: The interface of
lleaves.Modelis a subset ofLightGBM.Booster. - Dependencies:
llvmliteandnumpy. LLVM comes statically linked.
Installation
conda install -c conda-forge lleaves or pip install lleaves (Linux and MacOS only).
Benchmarks
Ran on a dedicated Intel i7-4770 Haswell, 4 cores. Stated runtime is the minimum over 20.000 runs.
Dataset: NYC-taxi
mostly numerical features.
|batchsize | 1 | 10| 100 |
|---|---:|---:|---:|
|LightGBM | 52.31μs | 84.46μs | 441.15μs |
|ONNX Runtime| 11.00μs | 36.74μs | 190.87μs |
|Treelite | 28.03μs | 40.81μs | 94.14μs |
|lleaves | 9.61μs | 14.06μs | 31.88μs |
Dataset: MTPL2
mix of categorical and numerical features.
|batchsize | 10,000 | 100,000 | 678,000 |
|---|---:|---:|---:|
|LightGBM | 95.14ms | 992.47ms | 7034.65ms |
|ONNX Runtime | 38.83ms | 381.40ms | 2849.42ms |
|Treelite | 38.15ms | 414.15ms | 2854.10ms |
|lleaves | 5.90ms | 56.96ms | 388.88ms |
Advanced Usage
To avoid expensive recompilation, you can call lleaves.Model.compile() and pass a cache=<filepath> argument.
This will store an ELF (Linux) / Mach-O (macOS) file at the given path when the method is first called.
Subsequent calls of compile(cache=<same filepath>) will skip compilation and load the stored binary file instead.
For more info, see docs.
To eliminate any Python overhead during inference you can link against this generated binary.
For an example of how to do this see benchmarks/c_bench/.
The function signature might change between major versions.
Development
High-level explanation of the inner workings of the lleaves compiler: link
bash
mamba env create
conda activate lleaves
pip install -e .
pre-commit install
./benchmarks/data/setup_data.sh
pytest -k "not benchmark"
Cite
If you're using lleaves for your research, I'd appreciate if you could cite it. Use:
@software{Boehm_lleaves,
author = {Boehm, Simon},
title = {lleaves},
url = {https://github.com/siboehm/lleaves},
license = {MIT},
}
Owner
- Name: Simon Boehm
- Login: siboehm
- Kind: user
- Location: SF
- Company: Anthropic
- Website: siboehm.com
- Repositories: 65
- Profile: https://github.com/siboehm
performance @ Anthropic
Citation (CITATION.cff)
cff-version: 1.2.0
title: lleaves
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Simon
family-names: Boehm
repository-code: 'https://github.com/siboehm/lleaves'
url: 'https://github.com/siboehm/lleaves'
license: MIT
GitHub Events
Total
- Create event: 3
- Issues event: 2
- Release event: 1
- Watch event: 62
- Delete event: 1
- Issue comment event: 8
- Push event: 1
- Pull request review event: 2
- Pull request event: 5
- Fork event: 6
Last Year
- Create event: 3
- Issues event: 2
- Release event: 1
- Watch event: 62
- Delete event: 1
- Issue comment event: 8
- Push event: 1
- Pull request review event: 2
- Pull request event: 5
- Fork event: 6
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Simon Boehm | s****n@s****m | 215 |
| dependabot[bot] | 4****] | 17 |
| Simeon Stoykov | 8****C | 3 |
| fuyw | r****y@1****m | 2 |
| SunHaoOne | 2****9@s****n | 2 |
| Steve Lorimer | s****e@n****z | 2 |
| wangzj | w****j@w****m | 2 |
| chenglin | c****g@a****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 48
- Total pull requests: 45
- Average time to close issues: 13 days
- Average time to close pull requests: 8 days
- Total issue authors: 33
- Total pull request authors: 11
- Average comments per issue: 2.35
- Average comments per pull request: 0.71
- Merged pull requests: 36
- Bot issues: 0
- Bot pull requests: 21
Past Year
- Issues: 8
- Pull requests: 9
- Average time to close issues: 14 days
- Average time to close pull requests: 18 days
- Issue authors: 6
- Pull request authors: 5
- Average comments per issue: 0.25
- Average comments per pull request: 1.44
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 4
Top Authors
Issue Authors
- fuyw (5)
- siboehm (4)
- jamespinkerton (3)
- TomScheffers (2)
- Zahlii (2)
- chenglin (2)
- dragonbra (2)
- jtilly (2)
- trendelkampschroer (2)
- inkrement (1)
- jiazou-bigdata (1)
- nepslor (1)
- bai-jian (1)
- aurotripathy (1)
- lbittarello (1)
Pull Request Authors
- dependabot[bot] (30)
- siboehm (17)
- steve-numeus (2)
- Soontosh (2)
- SimeonStoykovQC (2)
- starkwj (2)
- zjzjwang (2)
- mark-thm (2)
- fuyw (1)
- chenglin (1)
- SunHaoOne (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 6,439 last-month
- Total docker downloads: 80,722
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 24
- Total maintainers: 1
pypi.org: lleaves
LLVM-based compiler for LightGBM models
- Homepage: https://github.com/siboehm/lleaves
- Documentation: https://lleaves.readthedocs.io/en/latest/
- License: MIT
-
Latest release: 1.3.0
published about 1 year ago
Rankings
Maintainers (1)
conda-forge.org: lleaves
- Homepage: https://github.com/siboehm/lleaves
- License: MIT
-
Latest release: 0.2.6
published over 3 years ago
Rankings
Dependencies
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- conda-incubator/setup-miniconda v2 composite
- pre-commit/action v3.0.0 composite
- pypa/gh-action-pypi-publish v1.6.4 composite
- llvmlite >=0.36
- benchmark
- cmake
- compilers
- hypothesis
- libcnpy
- lightgbm
- llvmlite >=0.36
- numpy
- numpydoc
- onnxmltools
- onnxruntime
- pandas
- pre-commit
- pyarrow
- pytest
- python >=3.7
- setuptools-scm
- sphinx
- sphinx_rtd_theme
- sphinxcontrib-apidoc
- treelite