Skip to main content

StreamLLM

Run bigger LLMs on smaller GPUs through intelligent, asynchronous layer streaming.

StreamLLM is a lightweight, memory-aware LLM inference runtime that breaks the physical VRAM barrier. By dynamically streaming transformer layers between host RAM and GPU VRAM using pre-allocated double-buffer scratchpads, StreamLLM allows running large quantized models on consumer GPUs (such as 4GB/6GB/8GB cards) with minimal transfer overhead.


Key Architectural Highlights

  • Static GPU Scratchpad Pool (GPUScratchpadPool): Pre-allocates two static VRAM buffers (Slot A and Slot B). Eliminates cudaMalloc and cudaFree allocation churn during the token generation loop.
  • Dual CUDA Streams: Dedicated compute_stream and transfer_stream with zero-CPU-blocking synchronization via torch.cuda.Event hardware queues.
  • Pinned Host Memory (PinnedHostWeightRegistry): Uses page-locked RAM (torch.Tensor.pin_memory()) for true non-blocking PCIe DMA transfers.
  • KV-Cache Sizing Manager: Deterministic VRAM memory budgeting ensuring safe context lengths without Out-Of-Memory (OOM) crashes.

Installation

# Install locally in development mode:
pip install -e .

# Or install from GitHub / PyPI:
# pip install streamllm

Quickstart & Python Usage

from streamllm import AutoModel

MAX_LENGTH = 128

# 1. Initialize AutoModel (supports HuggingFace repo IDs or local paths)
model = AutoModel.from_pretrained("Qwen/Qwen2.5-7B-Instruct", prefetching=True)

# 2. Tokenize input prompt
input_text = ['What is the capital of the United States?']
input_tokens = model.tokenizer(
    input_text,
    return_tensors="pt", 
    return_attention_mask=False, 
    truncation=True, 
    max_length=MAX_LENGTH, 
    padding=False
)

# 3. Streamed layer generation
generation_output = model.generate(
    input_tokens['input_ids'].cuda(), 
    max_new_tokens=20,
    use_cache=True,
    return_dict_in_generate=True
)

# 4. Decode output tokens
output = model.tokenizer.decode(generation_output.sequences[0])
print(output)

CLI & Diagnostic Commands

Once installed, the streamllm command is available directly in your terminal:

1. Check Hardware & PCIe Bandwidth

Measure GPU VRAM, system RAM, and live Host-to-Device (H2D) PCIe throughput:

streamllm hardware

2. Run Streaming vs. Prefetch Micro-Benchmark

Benchmark sequential layer execution against double-buffered prefetching:

streamllm bench --layers 16 --hidden-dim 2048 --seq-len 128

3. Run Test Suite

python -m unittest discover -s tests

Download files

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

Source Distribution

streamllm-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

streamllm-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamllm-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for streamllm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9eb9a42da7027c46a078ab1461209ab5fad5003452ca387eb7a1835ff923f501
MD5 0265cff04b3cd21246cc3466abcdb2d2
BLAKE2b-256 ab01d75bfd2167025a5b306588d09b312310ed5d9698bc622e76966c227742a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: streamllm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for streamllm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7a396fc8a3353e7dce3ead5da6fc7311d12487f71c74595dacf027328219460
MD5 86b965c80d07ecea4c6e39ae9902d1ad
BLAKE2b-256 36709b416e4c723f5c71d7b851b01f109a34dd44ad01a04610a525764e85533b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page