Lightning-AI / Lightning-AI/lightning-thunder

dtype inconsistencies when dividing/rounding tensors

Open
#467 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## 🐛 Bug

This bug was found when submitting a PR for `torch.div`(https://github.com/Lightning-AI/lightning-thunder/pull/441). Specifically, there was a dtype mismatch when rounding and dividing tensors.

### To Reproduce

The torch.div opinfo currently xfails the `test_core_vs_torch_consistency_div` test with nvfuser. However, by removing the xfail with nvfuser in div_opinfo,, it will throw the following error message:

```
FAILED thunder/tests/test_ops.py::test_core_vs_torch_consistency_div_nvfuser_cuda_int32 - AssertionError: The values for attribute 'dtype' do not match: torch.float32 != torch.int32.
FAILED thunder/tests/test_ops.py::test_core_vs_torch_consistency_div_nvfuser_cuda_int64 - AssertionError: The values for attribute 'dtype' do not match: torch.float32 != torch.int64.
FAILED thunder/tests/test_ops.py::test_core_vs_torch_consistency_div_nvfuser_cuda_float32 - AssertionError: The values for attribute 'dtype' do not match: torch.float64 != torch.float32.
```

### Expected behavior

It is expected to for the tensors/numbers to have the same dtype when using nvFuser.

### Additional context

This can potentially be addressed by adding an OpInfo for `prims.div`.

cc. @mruberry

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 with the torch.div OpInfo and the xfailed test_core_vs_torch_consistency_div tests in thunder/tests/test_ops.py, focusing on the nvFuser CUDA cases listed in the report. Check whether adding an OpInfo for prims.div addresses the rounding and division dtype mismatches. Done means the affected tests no longer report differing dtypes for the compared tensors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.