Lightning-AI / Lightning-AI/lightning-thunder
Support `torch.where(condition)` with thunder.jit
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🚀 Feature
### Motivation
Mixtral uses it: https://github.com/mistralai/mistral-src/blob/8598cf582091a596671be31990448e0620017851/moe_one_file_ref.py#L215
Minimal Repro
```python
import thunder
def fn(cond):
return torch.where(cond)
thunder.jit(fn)(torch.randn(3) > 0)
```
### Pitch
Support

from https://pytorch.org/docs/stable/generated/torch.where.html
### Additional context
We already support `torch.where(condition, input, other)`: https://github.com/search?q=repo%3ALightning-AI%2Flightning-thunder+%22def+where%22&type=code
cc @apaz-cli
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing `def where` implementation referenced in the issue's repository search, then compare its supported three-argument path with the one-argument `torch.where(condition)` API shown in the minimal repro. Add coverage for the repro and verify that the returned indices match PyTorch's documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100