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.

Example

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")
llvm_model.compile()
%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.

Benchmarks

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

Development

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

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.0.tar.gz (886.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lleaves-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file lleaves-0.1.0.tar.gz.

File metadata

  • Download URL: lleaves-0.1.0.tar.gz
  • Upload date:
  • Size: 886.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for lleaves-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2c1d1779a27c316b6d5838c0972d584bf0a39fa658442d280cd78aaa4cc28f5
MD5 c5bf0ee5d3b5114c713049df0e349caa
BLAKE2b-256 6cf8563b9401929041601bbbc91d8b029fb6b6492b3e76ef6287bf1d50285961

See more details on using hashes here.

File details

Details for the file lleaves-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lleaves-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for lleaves-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c09a0eec5d6de221e9d3c39a5a7a32c2be1bd6e3929510411f544160dfb14091
MD5 fe8f4e426e6dba719133ab77ff778100
BLAKE2b-256 c245f1bc060188ef16e1b1eea9350cd6a9c9a5e25e360aae92945851c714a683

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page