younesbelkada commited on
Commit
bfd63d9
1 Parent(s): 5bdad4f

updte readme

Browse files
Files changed (1) hide show
  1. README.md +10 -104
README.md CHANGED
@@ -1,104 +1,10 @@
1
- # bloom-demo
2
- Early dev prototype for decentralized bloom. Not for public eyes **yet**.
3
-
4
- Roadmap: [issue #12](https://github.com/learning-at-home/bloom-demo/issues/12)
5
-
6
- Latest news @ main branch (max 5):
7
- - [Jul 4] @dbaranchuk implemented chained rpc_forward and rpc_backward (for prompt tuning)
8
- - [Jul 3] @dbaranchuk optimized DistributedBloom to reduce embeddings/logits RAM usage
9
- - [Jul 1] @yozh added RemoteSequential and test for full model exact match
10
- - [June 28] @dbaranchunk added quick deployment scripts for testnet
11
-
12
- ### install
13
-
14
-
15
- ```bash
16
- conda create -y --name bloom-demo python=3.8.12 pip
17
- conda activate bloom-demo
18
-
19
- conda install -y -c conda-forge cudatoolkit-dev==11.3.1 cudatoolkit==11.3.1 cudnn==8.2.1.32
20
- pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
21
- pip install accelerate==0.10.0 huggingface-hub==0.7.0 hivemind==1.1.0
22
- pip install bitsandbytes-cuda113==0.26.0
23
- pip install https://github.com/huggingface/transformers/archive/6589e510fa4e6c442059de2fab84752535de9b23.zip
24
- ```
25
-
26
-
27
- ### run local inference:
28
- No networking whatsoever, used to verify architecture optimizations
29
-
30
- ```bash
31
- # run one bloom block for a few steps -- on a local machine
32
- python -m cli.inference_one_block --config cli/config.json # see other args
33
- ```
34
-
35
- ### run distributed inference / training
36
-
37
- First, run one or more servers like this:
38
- ```bash
39
- # minimalistic server with non-trained bloom blocks
40
- python -m cli.run_server --converted_model_name_or_path bigscience/test-bloomd-6b3 \
41
- --block_indices 3:5 --torch_dtype float32 --identity_path ./server1.id --host_maddrs /ip4/127.0.0.1/tcp/31337
42
- # when running multiple servers:
43
- # - give each server a unique --identity_path (or remote --identity_path arg when debugging)
44
- # - if running multiple servers on the same machine, give each a unique port (last integer in --host_maddrs, 0 means random port)
45
- # - when running over the internet, change --host_maddrs according to https://learning-at-home.readthedocs.io/en/latest/user/dht.html#running-across-the-internet
46
- # - each server except first should have --initial_peers pointing to one of pre-existing servers
47
- ```
48
-
49
- Then open a python notebook or console and run:
50
- ```python
51
- import torch
52
- import hivemind
53
- from src import get_remote_module
54
-
55
-
56
- dht = hivemind.DHT(
57
- initial_peers=[TODO_COPY_FULL_ADDRESS_FROM_ANY_OF_THE_SERVERS], # e.g. /ip4/127.0.0.1/...
58
- client_mode=True, start=True,
59
- )
60
-
61
- layer3, layer4 = get_remote_module(dht, ['bigscience/test-bloomd-6b3.3', 'bigscience/test-bloomd-6b3.4'])
62
- assert layer3 is not None and layer4 is not None, "one or both layers were not found in DHT"
63
- # test forward/backward, two blocks
64
- outputs, = layer4(*layer3(torch.randn(1, 64, 4096)))
65
- loss = (outputs * torch.randn_like(outputs)).norm()
66
- loss.backward()
67
-
68
- # test inference, one block
69
- with layer3.begin_inference_session() as sess:
70
- for i in range(10):
71
- res = sess.step(torch.ones(1, 1, 4096))
72
- ```
73
-
74
-
75
- ### convert regular bloom to distributed
76
- ```bash
77
-
78
- # convert model from HF hub to a distributed format (can take hours depending on your connection!)
79
- MY_WRITE_TOKEN=TODO_WRITE_TOKEN_FROM_https://huggingface.co/settings/token
80
- python -m cli.convert_model --model bigscience/bloom-6b3 \
81
- --output_path ./converted_model --output_repo bigscience/test-bloomd-6b3 \
82
- --use_auth_token $MY_WRITE_TOKEN # ^-- todo replace output repo with something you have access to
83
- ```
84
-
85
-
86
- ### test local vs remote block (allclose)
87
-
88
- To test distributed inference, run one or more servers, then open a new shell and run pytest with environment variables:
89
- ```bash
90
- # shell A: serve blocks 3 and 4
91
- python -m cli.run_server --converted_model_name_or_path bigscience/test-bloomd-6b3 \
92
- --block_indices 3:5 --torch_dtype float32 --identity_path ./server1.id --host_maddrs /ip4/127.0.0.1/tcp/31337
93
-
94
- # shell B: connect to the swarm and test individual blocks for exact match
95
- export PYTHONPATH=. INITIAL_PEERS="/ip4/TODO_COPY_INITIAL_PEERS_FROM_SERVER_OUTPUT"
96
- BLOCK_UID=bigscience/test-bloomd-6b3.3 pytest tests/test_block_exact_match.py
97
- BLOCK_UID=bigscience/test-bloomd-6b3.4 pytest tests/test_block_exact_match.py
98
-
99
- # the test below will fail because there is no server that serves layer 7
100
- # BLOCK_UID=bigscience/test-bloomd-6b3.7 pytest tests/test_block_exact_match.py
101
-
102
-
103
- BLOCK_UID=bigscience/test-bloomd-6b3.4 pytest tests/test_block_exact_match.py
104
- ```
 
1
+ ---
2
+ title: {{title}}
3
+ emoji: {{emoji}}
4
+ colorFrom: {{colorFrom}}
5
+ colorTo: {{colorTo}}
6
+ sdk: {{sdk}}
7
+ sdk_version: {{sdkVersion}}
8
+ app_file: app.py
9
+ pinned: false
10
+ ---