CUDA graph capture for the decode step

Open
#12 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
huggingface, python, pytorch

Research direction

Start with decode_tokens_per_s in src/bitsmith/bench/hf.py and compare the two proposed approaches: torch.compile(mode="reduce-overhead") with a static KV cache, or torch.cuda.CUDAGraph around a forward pass. Check src/bitsmith/kernels/int4_triton.py and the GEMV capture example in scripts/bench_kernels.py for capture safety. Done means bitsmith hf reports graph-captured bf16 and fused INT4 speeds, with INT4 faster on Qwen2.5-1.5B.

Written by the indexing model from the issue text.

Description

area: kernels enhancement help wanted performance

Per layer, the fused INT4 kernel is up to 1.33x faster than fp16 cuBLAS, but end-to-end decoding
through Hugging Face generate is still slower than bf16 (25.4 vs 42.4 tokens/s on
Qwen2.5-1.5B), because launching about 200 small kernels per token from Python dominates.

Task: capture one decode step in a CUDA graph and replay it. Options:

  • a static KV cache plus torch.compile(mode="reduce-overhead")
  • a manual torch.cuda.CUDAGraph around a forward with a static cache

Files

  • src/bitsmith/bench/hf.py: decode_tokens_per_s
  • src/bitsmith/kernels/int4_triton.py: kernels must be capture safe (they already are
    for the GEMV path in scripts/bench_kernels.py)

Done when bitsmith hf reports a graph-captured decode speed for bf16 and fused INT4,
and INT4 is faster than bf16 on Qwen2.5-1.5B.

Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from yashwanthdevavarapu/bitsmith

All issues in yashwanthdevavarapu/bitsmith

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.