Lightning-AI / Lightning-AI/lightning-thunder

Allow different device and dtype for `prims.copy_` args

Open
#1,084 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently `copy`'s meta function disallows arguments of different device and dtype as in these lines but `torch.Tensor.copy_` allows it.
https://github.com/Lightning-AI/lightning-thunder/blob/339a782e3d75061a065a3d2e47b5206f23aea7c3/thunder/core/prims.py#L3966-L3968

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

Start at thunder/core/prims.py lines 3966-3968, linked in the issue, and compare the meta function's checks with torch.Tensor.copy_. Done means prims.copy_ accepts arguments with differing devices and dtypes in the same cases as torch.Tensor.copy_.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.