Lightning-AI / Lightning-AI/lightning-thunder

Support `torch.nonzero`

Open
#195 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## 🚀 Feature

I would like Thunder to support [`torch.nonzero`](https://pytorch.org/docs/stable/generated/torch.nonzero.html) as it can be used in Mixtral instead of `torch.where`.

### Pitch

Support `torch.nonzero` as per https://pytorch.org/docs/stable/generated/torch.nonzero.html

### Additional context

This operator might be tricky to get right due to the output shape being input dependent.

cc @apaz-cli

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

No implementation file or test is named. Start with the linked PyTorch torch.nonzero documentation and compare Thunder's existing torch.where support; account for the input-dependent output shape. Done means Thunder supports torch.nonzero with behavior matching the documented PyTorch operator, including its output shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.