Skip to content

Commit afbbf4c

Browse files
ℹ️ Codacy found a Code Style issues
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
1 parent db2fa9d commit afbbf4c

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

app/models/llama/llama.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,65 @@
1212
import functools, sys, argparse, json, os
1313
import numpy as np
1414
np.set_printoptions(linewidth=200)
15+
from typing import Tuple, Dict
16+
17+
from tinygrad.helpers import Timing, DEBUG, dtypes, CI
18+
from tinygrad.ops import Device
19+
from tinygrad.tensor import Tensor
20+
from tinygrad.nn import Embedding, Linear
21+
import functools, sys, argparse, json, os
22+
import numpy as np
23+
np.set_printoptions(linewidth=200)
1524
from typing import Optional, Tuple, Dict
1625

1726
from tinygrad.helpers import Timing, DEBUG, dtypes, CI
1827
from tinygrad.ops import Device
1928
from tinygrad.tensor import Tensor
2029
from tinygrad.nn import Embedding, Linear
2130
from tinygrad.ops import GlobalCounters
31+
import functools, sys, argparse, json, os
32+
import numpy as np
33+
np.set_printoptions(linewidth=200)
34+
from typing import Tuple, Dict
35+
36+
from tinygrad.helpers import Timing, DEBUG, dtypes, CI
37+
from tinygrad.ops import Device
38+
from tinygrad.tensor import Tensor
39+
from tinygrad.nn import Embedding, Linear
40+
from pathlib import Path
41+
import functools, sys, argparse, json, os
42+
import numpy as np
43+
np.set_printoptions(linewidth=200)
44+
from typing import Tuple, Dict
45+
46+
from tinygrad.helpers import Timing, DEBUG, dtypes, CI
47+
from tinygrad.ops import Device
48+
from tinygrad.tensor import Tensor
49+
from tinygrad.nn import Embedding, Linear
50+
from tinygrad.ops import GlobalCounters
51+
from tinygrad.jit import TinyJit, JIT_SUPPORTED_DEVICE
52+
from tinygrad.shape.symbolic import Variable, sym_infer
53+
54+
from tinygrad.helpers import Timing, DEBUG, dtypes, CI
55+
from tinygrad.ops import Device
56+
from tinygrad.tensor import Tensor
57+
from tinygrad.nn import Embedding, Linear
58+
from pathlib import Path
59+
import functools, sys, argparse, json, os
60+
import numpy as np
61+
np.set_printoptions(linewidth=200)
62+
from typing import Optional, Tuple, Dict
63+
64+
from tinygrad.ops import GlobalCounters
65+
from tinygrad.jit import TinyJit, JIT_SUPPORTED_DEVICE
66+
from tinygrad.shape.symbolic import Variable, sym_infer
67+
68+
from sentencepiece import SentencePieceProcessor
69+
from tinygrad.tensor import Tensor
70+
from tinygrad.ops import Device
71+
from tinygrad.tensor import Tensor
72+
from tinygrad.nn import Embedding
73+
from tinygrad.ops import GlobalCounters
2274
from tinygrad.jit import TinyJit, JIT_SUPPORTED_DEVICE
2375
from tinygrad.shape.symbolic import Variable, sym_infer
2476

app/models/llama/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ def convert_from_huggingface(weights, model):
152152
"""
153153
keymap = {
154154
"model.embed_tokens.weight": "tok_embeddings.weight",
155-
**{f"model.layers.{l}.input_layernorm.weight": f"layers.{l}.attention_norm.weight" for l in range(len(model.layers))},
155+
**{f"model.layers.{layer_index}.input_layernorm.weight": f"layers.{layer_index}.attention_norm.weight" for layer_index in range(len(model.layers))},
156156
**{f"model.layers.{l}.self_attn.{x}_proj.weight": f"layers.{l}.attention.w{x}.weight" for x in ["q", "k", "v", "o"] for l in range(len(model.layers))},
157157
**{f"model.layers.{l}.post_attention_layernorm.weight": f"layers.{l}.ffn_norm.weight" for l in range(len(model.layers))},
158-
**{f"model.layers.{layer_index}.mlp.{x}_proj.weight": f"layers.{layer_index}.feed_forward.w{y}.weight" for x, y in {"gate": "1", "down": "2", "up": "3"}.items() for layer_index in range(len(model.layers))},
158+
**{f"model.layers.{layer_index}.mlp.{x}_proj.weight": f"layers.{layer_index}.feed_forward.w{y}.weight"
159+
for x, y in {"gate": "1", "down": "2", "up": "3"}.items()
160+
for layer_index in range(len(model.layers))},
159161
"model.norm.weight": "norm.weight",
160162
"lm_head.weight": "output.weight",
161163
}

app/models/llama/weights/pull_llama.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
PRESIGNED_URL="https://agi.gpt4.org/llama/LLaMA/*"
24

35
# ,30B,65B
@@ -6,6 +8,16 @@ TARGET_FOLDER="./" # where all files should end up
68

79
declare -A N_SHARD_DICT
810

11+
N_SHARD_DICT["7B"]="0"
12+
N_SHARD_DICT["13B"]="1"
13+
N_SHARD_DICT["30B"]="3"
14+
15+
# ,30B,65B
16+
MODEL_SIZE="7B,13B" # edit this list with the model sizes you wish to download
17+
TARGET_FOLDER="./" # where all files should end up
18+
19+
declare -A N_SHARD_DICT
20+
921
N_SHARD_DICT["7B"]="0"
1022
N_SHARD_DICT["13B"]="1"
1123
N_SHARD_DICT["30B"]="3"
@@ -23,7 +35,7 @@ do
2335
mkdir -p ${TARGET_FOLDER}"/${i}"
2436
for s in $(seq -f "0%g" 0 ${N_SHARD_DICT[$i]})
2537
do
26-
wget ${PRESIGNED_URL/'*'/"${i}/consolidated.${s}.pth"} -O ${TARGET_FOLDER}"/${i}/consolidated.${s}.pth"
38+
wget "${PRESIGNED_URL/'*'/"${i}/consolidated.${s}.pth"}" -O "${TARGET_FOLDER}/${i}/consolidated.${s}.pth"
2739
done
2840
wget ${PRESIGNED_URL/'*'/"${i}/params.json"} -O ${TARGET_FOLDER}"/${i}/params.json"
2941
wget ${PRESIGNED_URL/'*'/"${i}/checklist.chk"} -O ${TARGET_FOLDER}"/${i}/checklist.chk"

0 commit comments

Comments
 (0)