Lightning-AI / Lightning-AI/lightning-thunder

`requires_grad` attribute for cache key

Open
#1,905 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

constraints & caching tracing architecture
Dominant language
Python
Stars
1.5k
Forks
121
PR merge metrics
No merged PRs in 30d

Description

## 🐛 Bug

The key making logic for Thunder's cache relies on requires_grad attribute of `TensorProxy` but it shouldn't:

https://github.com/Lightning-AI/lightning-thunder/blob/a8c063676cbecad7c196dcfe4fbeacf85775c9c5/thunder/common.py#L394-L400

Thunder does not propagate requires_grad information throughout the trace and therefore this results in many unnecessary cache misses.

cc @mruberry @lantiga @IvanYashchuk

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 in thunder/common.py at lines 394-400, where the cache key uses TensorProxy.requires_grad. Trace the key-making logic and verify how differing requires_grad values affect cache reuse; the work is done when that attribute no longer causes unnecessary cache misses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.