Lightning-AI / Lightning-AI/pytorch-lightning

Add support for `torchshard`

Open
#13,869 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion strategy
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

## 🚀 Feature

[torchshard](https://github.com/KaiyuYue/torchshard) is a newly and simple library for model parallel. In some case, we need to split one very large layer (larger than one gpu) to multiple gpus, and `torchshard` seems a simple solution.

Here's one of my use-case:

1. I have a very large tensor (9M*1024), aka. `VeryLargeTensor`, which is the representation vectors of 9M examples pre-computed from their features.
2. Given a new example `e`, I use model `Model` to generate `e`'s representation `v`(1*1024).
3. I need to compute dot-product similarity between `v` and `VeryLargeTensor`, and get a 9M*1 score tensor. However, `VeryLargeTensor` is so large that it must be split into multiple gpus.
4. During training, only `Model` is updated. `VeryLargeTensor` is always freezed and never updated.
5. (Since `VeryLargeTensor` is a plug-in tensor and not updated, I don't want to register it as `Model`'s parameter.)6.
6. If I split `VeryLargeTensor` in to multiple gpus, I do not need DP or DDP.

I think `torchshard` is a simple solution for my use-case. Or, is there better solution in pytorch-lightning?
### Motivation

### Pitch

### Alternatives

### Additional context

______________________________________________________________________

cc @borda @akihironitta @justusschock

Contributor guide

Open the contributing guide

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 by reviewing the torchshard project linked in the issue and the repository's existing distributed training support. Clarify whether support means integration, documentation, or an alternative approach for sharding a frozen tensor across GPUs; the issue is complete only after that scope and an acceptance criterion are defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.