WCNegentropy commited on
Commit
b19af44
·
verified ·
1 Parent(s): 2bb2eda

Remove nested directory: BitTransformerLM/bit_transformer/distributed.py

Browse files
BitTransformerLM/bit_transformer/distributed.py DELETED
@@ -1,30 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
- from typing import List, Optional
4
-
5
- from torch.distributed.fsdp import FullyShardedDataParallel
6
- try:
7
- from torch.distributed.pipeline.sync import Pipe
8
- except Exception: # pragma: no cover - Pipe may not be available in CPU builds
9
- Pipe = None
10
-
11
- from .model import BitTransformerLM
12
-
13
-
14
- def wrap_fsdp(model: BitTransformerLM, **kwargs) -> FullyShardedDataParallel:
15
- """Return a ``FullyShardedDataParallel`` wrapped model on the given device."""
16
- device = kwargs.pop("device_id", torch.device("cpu"))
17
- model = model.to(device)
18
- return FullyShardedDataParallel(model, device_id=device, **kwargs)
19
-
20
-
21
- def make_pipeline(model: BitTransformerLM, chunks: int = 1) -> Pipe:
22
- """Wrap the model with ``Pipe`` for simple pipeline parallelism.
23
-
24
- The entire model is placed in an ``nn.Sequential`` so all existing telemetry
25
- remains available. ``chunks`` controls microbatch splitting.
26
- """
27
- if Pipe is None:
28
- raise RuntimeError("Pipeline parallelism not available in this build")
29
- seq = nn.Sequential(model)
30
- return Pipe(seq, chunks=chunks)