Open
Description
Note: If you have a model or program that is not supported yet but should be, please use the program coverage template.
🐛 Bug
With the torch executor, Thunder cannot correctly compute cross entropy loss (backward) when the reduction used is "sum". It works correctly with "mean"
To Reproduce
Run the code snippet below.
Code sample
device='cuda'
executor=TorchExecutor
def cross_entropy_fn(logits, labels):
return torch.nn.functional.cross_entropy(logits, labels, reduction="sum")
sequence_length, vocab_size = 8192, 32064
logits = torch.rand((sequence_length, vocab_size), device=device, dtype=thunder_dtype, requires_grad=True)
labels = torch.randint(0, sequence_length, (sequence_length,), requires_grad=False, device=device)
fn = executor.make_callable(cross_entropy_fn)
a = fn(logits, labels)
a.backward()
print(logits.grad)
Expected behavior
Should run correctly to completion with output matching that of torch compile.
Environment
- PyTorch Version (e.g., 1.0):
- OS (e.g., Linux):
- How you installed PyTorch (
conda
,pip
, source): - Build command you used (if compiling from source):
- Python version:
- CUDA/cuDNN version:
- GPU models and configuration:
- Any other relevant information:
Additional context
The error seen is:
https://gist.github.com/protonu/ff88fbc9508947f45e39a6190acc6508
Metadata
Metadata
Assignees
Labels
No labels