Lightning-AI / Lightning-AI/lightning-thunder

Support user-side CUDA graph capturing

Open
#1,945 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cudagraphs
Dominant language
Python
Stars
1.5k
Forks
121
PR merge metrics
No merged PRs in 30d

Description

## 🚀 Feature

Let users do their own cuda graph capturing for `thunder.jit(model)`.

### Motivation

While thunder has its own [`thunder.transforms.cudagraph.CUDAGraphTransform`](https://github.com/Lightning-AI/lightning-thunder/blob/7c2735c527bfa7e7b12dc0bdfeed44428bd3128b/thunder/transforms/cudagraph.py#L231-L237), some libraries such as SGLang has its own way of cuda graph capturing.
If I just use [`thunderfx`](https://github.com/Lightning-AI/lightning-thunder/blob/7c2735c527bfa7e7b12dc0bdfeed44428bd3128b/thunder/dynamo/compiler.py#L204) as a drop-in replacement of `torch.compile` in SGLang, then it fails unless I pass `--disable_cuda_graph` (which is one of SGLang debug options https://docs.sglang.ai/backend/server_arguments.html#debug-options).

### Pitch

### Alternatives

### Additional context

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by reading thunder/transforms/cudagraph.py around CUDAGraphTransform and thunder/dynamo/compiler.py around the thunderfx entry point. Reproduce the SGLang failure with thunderfx and its CUDA graph capture path, then determine the user-facing capture boundary and verify that user-managed capture works without requiring --disable_cuda_graph.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.