lleaves

Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.

https://github.com/siboehm/lleaves

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

decision-trees gradient-boosting lightgbm llvm machine-learning python

Keywords from Contributors

interactive mesh interpretability profiles sequences generic projection standardization optim embedded
Last synced: 6 months ago · JSON representation ·

Repository

Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.

Basic Info
Statistics
  • Stars: 439
  • Watchers: 8
  • Forks: 36
  • Open Issues: 22
  • Releases: 16
Topics
decision-trees gradient-boosting lightgbm llvm machine-learning python
Created almost 5 years ago · Last pushed 10 months ago
Metadata Files
Readme License Citation

README.md

lleaves 🍃

CI Documentation Status Downloads

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.Model is a subset of LightGBM.Booster.
  • Dependencies: llvmlite and numpy. 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

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

All Time
  • Total Commits: 244
  • Total Committers: 8
  • Avg Commits per committer: 30.5
  • Development Distribution Score (DDS): 0.119
Past Year
  • Commits: 5
  • Committers: 3
  • Avg Commits per committer: 1.667
  • Development Distribution Score (DDS): 0.6
Top Committers
Name Email 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
enhancement (3) performance (2)
Pull Request Labels
dependencies (30)

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

  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 6,439 Last month
  • Docker Downloads: 80,722
Rankings
Docker downloads count: 1.2%
Downloads: 3.6%
Stargazers count: 3.8%
Average: 8.1%
Forks count: 8.2%
Dependent packages count: 10.1%
Dependent repos count: 21.5%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: lleaves
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 24.9%
Dependent repos count: 34.0%
Average: 38.4%
Forks count: 43.4%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

.github/workflows/ci.yml actions
  • 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
setup.py pypi
  • llvmlite >=0.36
pyproject.toml pypi
environment.yml conda
  • 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