Lightning-AI/lightning-thunder

Support `torch.where(condition)` with thunder.jit

Offen

#124 geöffnet am 03.04.2024

 (12 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (114 Forks)github user discovery
enhancementhelp wantedoperators

Repository-Metriken

Stars
 (1.460 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

🚀 Feature

Motivation

Mixtral uses it: https://github.com/mistralai/mistral-src/blob/8598cf582091a596671be31990448e0620017851/moe_one_file_ref.py#L215

Minimal Repro

import thunder

def fn(cond):
    return torch.where(cond)

thunder.jit(fn)(torch.randn(3) > 0)

Pitch

Support image 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