Skip to main content

Correctness-gated CUDA Graph pooling for Hugging Face greedy decoding

Project description

GPUOpt Runtime

I built this because a lot of smaller LLM workloads waste time launching the same CUDA operations over and over. GPUOpt captures that decode work once, checks the output, and reuses it when the next request has a compatible shape.

It is not a driver replacement and it does not pretend every model gets faster. If graph capture or validation fails, it drops back to eager SDPA instead of silently returning questionable output.

What it does

  • pools CUDA Graphs by model, GPU, dtype, batch, and capacity
  • validates every token for a new shape before trusting it
  • resets and refills the KV cache after capture
  • reuses compatible graphs with an LRU cache
  • tracks capture time, cache hits, speed, and VRAM
  • enforces configurable VRAM limits

Install

For development:

python -m pip install -e ".[examples,test]"

Or install the built wheel:

python -m pip install gpuopt_runtime-0.1.0-py3-none-any.whl

Use it

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from gpuopt import CUDAGraphPool

name = "Qwen/Qwen2.5-0.5B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(
    name,
    dtype=torch.float16,
    device_map={"": "cuda"},
    attn_implementation="sdpa",
).eval()
inputs = tokenizer("Explain GPU launch overhead.", return_tensors="pt").to("cuda")

pool = CUDAGraphPool(max_entries=4)
result = pool.generate_greedy(model, inputs, new_tokens=64)
print(tokenizer.decode(result.token_ids[0]))
print(result.metrics())

The first compatible request captures and validates the graph. Later requests reuse it without paying that cost again.

Results so far

GPU Eager SDPA CUDA Graph Steady state speedup Exact
RTX 5070 60.06 tok/s 281.18 tok/s 4.68x 64/64
A100 1g.10gb MIG 70.55 tok/s 130.14 tok/s 1.84x 64/64

These are Qwen2.5-0.5B greedy decode measurements, not a promise for every GPU or model. Cold requests also pay capture and validation costs.

Current limits

Version 0.1 is for NVIDIA CUDA, Hugging Face causal models, greedy decoding, and unpadded prompts. Sampling, padded batches, continuous batching, and serving across multiple GPUs still need proper tests before I call them supported.

Licensed under Apache-2.0.

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

gpuopt_runtime-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

gpuopt_runtime-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gpuopt_runtime-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for gpuopt_runtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4328c0d8959c044674980a4b03cd50442854d0096813f471add6b3d536c2173b
MD5 676ca28a84770cc66ef79d178d1fdbcf
BLAKE2b-256 868ac2ce97befccdde94578f7e5084dc37e0211129ad262986682ed5da65fec0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpuopt_runtime-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for gpuopt_runtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1abb0e35bdb6c0a384e3780ecebf2acbe72cd617ef9d33873fe1755935d37e38
MD5 f766a8f952960abc825ffebf19fa641d
BLAKE2b-256 bc10e60afba4bd8873dd11cd1e5cadf53849a108eab0febadcc05d336789b731

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