Skip to main content

Distributed Inference for Large Language Models.

Project description

distllm

PyPI version

Distributed Inference for Large Language Models.

  • Create embeddings for large datasets at scale.
  • Generate text using language models at scale.
  • Semantic similarity search using Faiss.

Installation

distllm is available on PyPI and can be installed using pip:

pip install distllm

To install the package on Polaris@ALCF as of 12/12/2024, run the following command:

git clone git@github.com:ramanathanlab/distllm.git
cd distllm
module use /soft/modulefiles; module load conda
conda create -n distllm python=3.12 -y
conda activate distllm-12-12
pip install faiss-gpu-cu12
pip install vllm
pip install -e .
python -m nltk.downloader punkt

Protein Embedding Installation

For ESMC, you can install the following package:

pip install esm

For ESM2, you can install the following package:

pip install flash-attn --no-build-isolation
pip install faesm[flash_attn]

Or, if you want to forego flash attention and just use SDPA

pip install faesm

Usage

To create embeddings at scale, run the following command:

nohup python -m distllm.distributed_embedding --config examples/your-config.yaml &> nohup.out &

For LLM generation at scale, run the following command:

nohup python -m distllm.distributed_generation --config examples/your-config.yaml &> nohup.out &

To run smaller datasets on a single GPU, you can use the following command:

distllm embed --encoder_name auto --pretrained_model_name_or_path pritamdeka/S-PubMedBert-MS-MARCO --data_path /lus/eagle/projects/FoundEpidem/braceal/projects/metric-rag/data/parsed_pdfs/LUCID.small.test/parsed_pdfs --data_extension jsonl --output_path cli_test_lucid --dataset_name jsonl_chunk --batch_size 512 --chunk_batch_size 512 --buffer_size 4 --pooler_name mean --embedder_name semantic_chunk --writer_name huggingface --quantization --eval_mode

Or using a larger model on a single GPU, such as Salesforce/SFR-Embedding-Mistral:

distllm embed --encoder_name auto --pretrained_model_name_or_path Salesforce/SFR-Embedding-Mistral --data_path /lus/eagle/projects/FoundEpidem/braceal/projects/metric-rag/data/parsed_pdfs/LUCID.small.test/parsed_pdfs --data_extension jsonl --output_path cli_test_lucid_sfr_mistral --dataset_name jsonl_chunk --batch_size 16 --chunk_batch_size 2 --buffer_size 4 --pooler_name last_token --embedder_name semantic_chunk --writer_name huggingface --quantization --eval_mode

To merge the HF dataset files, you can use the following command:

distllm merge --writer_name huggingface --dataset_dir /lus/eagle/projects/FoundEpidem/braceal/projects/metric-rag/data/semantic_chunks/lit_covid_part2.PubMedBERT/embeddings --output_dir lit_covid_part2.PubMedBERT.merge

To generate text using a language model, you can use the following command:

distllm generate --input_dir cli_test_lucid/ --output_dir cli_test_generate --top_p 0.95

Contributing

For development, it is recommended to use a virtual environment. The following commands will create a virtual environment, install the package in editable mode, and install the pre-commit hooks.

python3.10 -m venv venv
source venv/bin/activate
pip install -U pip setuptools wheel
pip install -e '.[dev,docs]'
pre-commit install

To test the code, run the following command:

pre-commit run --all-files
tox -e py310

To release a new version of distllm to PyPI:

  1. Merge the develop branch into the main branch with an updated version number in pyproject.toml.
  2. Make a new release on GitHub with the tag and name equal to the version number.
  3. Clone a fresh distllm repository and run the installation commands above.
  4. Run the following commands from the main branch:
rm -r dist
python3 -m build
twine upload dist/*

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

distllm-1.0.2.tar.gz (65.8 kB view details)

Uploaded Source

Built Distribution

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

distllm-1.0.2-py3-none-any.whl (87.3 kB view details)

Uploaded Python 3

File details

Details for the file distllm-1.0.2.tar.gz.

File metadata

  • Download URL: distllm-1.0.2.tar.gz
  • Upload date:
  • Size: 65.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for distllm-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5c11ceb58223ff056137f74bdcb33c943d136623c4fd9fca88e793b2ea18aa66
MD5 28af22af964f30d9b168958c87cd35c9
BLAKE2b-256 7387833f0b368796b0947aa16b483ed7b34815ed3fc4a60b5337819360d9be33

See more details on using hashes here.

File details

Details for the file distllm-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: distllm-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 87.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for distllm-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d52b4a797f9cb83c1a7421aa9b77cb986dda32d42804d6a441452b68ff93424a
MD5 a8a7fc1838428e7f73d01255a6e69882
BLAKE2b-256 5d3a96bb7c6602f965cb16ef14097373275bb576f76a87c7846fda405afd34cd

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