Skip to main content

LLVM-based compiler for LightGBM models

Project description

lleaves 🍃

CI Documentation Status

A LLVM-based compiler for LightGBM decision trees.

lleaves converts trained LightGBM models to optimized machine code, speeding-up inference by up to 10x.


lgbm_model = lightgbm.Model(model_file="NYC_taxi/model.txt")
%timeit lgbm_model.predict(df)
# 11.6 s ± 442 ms

llvm_model = lleaves.Model(model_file="NYC_taxi/model.txt")
%timeit llvm_model.predict(df)
# 1.84 s ± 68.7 ms

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.

Some LightGBM features are not yet implemented: multiclass prediction, linear models.


Ran on Intel Xeon Haswell, 8vCPUs. Some of the variance is due to performance interference.

Datasets: NYC-taxi (mostly numerical features), Airlines (categorical features with high cardinality)

Small batches (single-threaded)

benchmark small batches

Large batches (multi-threaded)

benchmark large batches


conda env create
conda activate lleaves
pip install -e .
pre-commit install

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lleaves-0.1.1.tar.gz (886.7 kB view hashes)

Uploaded source

Built Distribution

lleaves-0.1.1-py3-none-any.whl (14.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page