Iterable-based offline generation helpers for vLLM.
Project description
vllm-iter
vllm-iter provides iterable-friendly offline generation utilities on top of
vllm.LLM.
IterableLLM.generate_iter() keeps a bounded number of unfinished requests in
flight while yielding final completions incrementally in input order. The
max_inflight setting controls wrapper-managed unfinished requests, not the
model-side microbatch size. By default it follows vLLM's scheduler capacity
(max_num_seqs), and you can set a smaller or larger value to tune host-side
backpressure. When the input iterable length is known ahead of time, pass
total= to keep the tqdm progress bar stable instead of growing it dynamically
as prompts are submitted.
Motivation
This is useful when your prompts come from a large streaming source and you do not want to materialize either the full input set or the full output set in memory.
For example, imagine a huge JSON Lines file. You can iterate over the input
lines, convert each one into a PromptType, and feed that iterable directly
into generate_iter(). As results come back, you can immediately append them
to an output JSON Lines file and forget about them. That keeps memory bounded and
also means a crash or interruption does not lose everything that was already
written.
Installation
pip install git+https://github.com/michielree/vllm-iter.git
Example
from vllm import SamplingParams
from vllm_iter import IterableLLM
def prompt_source():
for topic in ["redis", "postgres", "kafka"]:
yield f"Give me a one-line summary of {topic}."
llm = IterableLLM(
model="distilbert/distilgpt2",
tensor_parallel_size=1,
gpu_memory_utilization=0.10,
enforce_eager=True,
)
for output in llm.generate_iter(
prompt_source(),
sampling_params=SamplingParams(max_tokens=32),
use_tqdm=False,
):
print(output.prompt)
print(output.outputs[0].text)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vllm_iter-0.1.0.tar.gz.
File metadata
- Download URL: vllm_iter-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7de3396b6f6e33d98560f6781f5b6cc866ec7219d867d9e432dddfc99b3cbbeb
|
|
| MD5 |
b8b84e8f32969f0555b9ea76a213f057
|
|
| BLAKE2b-256 |
631e9e190c9eed81c8421048697c59065852692aba75491ab6cb53a0ea573ba7
|
File details
Details for the file vllm_iter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vllm_iter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
469b63cd8d374f7202390cea34b5bbeaf1975e75ffd011d3361313cf05707f35
|
|
| MD5 |
7a3dd7d5b3f1140164898bff27b3f9e7
|
|
| BLAKE2b-256 |
01e59f8d88c595f4b8b258aa78902092d7fabd5d8a810c10f88b28f353fdd606
|