-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquant_queue.sh
More file actions
59 lines (48 loc) · 2.02 KB
/
quant_queue.sh
File metadata and controls
59 lines (48 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
USER=""
. ./venv/bin/activate
quant() {
BPW="$2"
mkdir -p ./output/$1/temp || exit
if [ ! -f "./output/$1/measurement.json" ]; then
python convert.py \
-i ./models/$1/ \
-o ./output/$1/temp/ \
-nr \
-om ./output/$1/measurement.json || exit
fi
OUTPUT_DIRECTORY="./output/$1/output-${BPW}"
if [ ! -f "${OUTPUT_DIRECTORY}/config.json" ]; then
python convert.py \
-i ./models/$1/ \
-o ./output/$1/temp/ \
-nr \
-m ./output/$1/measurement.json \
-cf "$OUTPUT_DIRECTORY" \
-b $BPW || exit
fi
cat "./models/${1}/README.md" | sed -z "s/---/---\n### exl2 quant (measurement.json in main branch)\n---\n### check revisions for quants\n---\n/2" > "${OUTPUT_DIRECTORY}/README.md"
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli upload --private --revision ${BPW}bpw "${USER}/${1}-exl2" "${OUTPUT_DIRECTORY}" || return 0
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli upload --private "${USER}/${1}-exl2" ${OUTPUT_DIRECTORY}/README.md ./README.md || return 0
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli upload --private "${USER}/${1}-exl2" ./output/$1/measurement.json ./measurement.json || return 0
}
while IFS= read -r line || [[ -n "$line" ]]; do
modified_line="${line#https://}"
IFS="/" read -ra parts <<< "$modified_line"
x="${parts[-3]}"
y="${parts[-2]}"
BPW="${parts[-1]}"
response_code=$(curl --write-out '%{http_code}' --silent --output /dev/null "https://huggingface.co/${USER}/${x}_${y}-exl2/tree/${BPW}bpw")
#if [ $response_code -eq 200 ]; then
#continue
#fi
#if [ ! -f "./output/${x}_${y}/output/output.safetensors" ]; then
if [ ! -f "./models/${x}_${y}/config.json" ]; then
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "${x}/${y}" --exclude "*checkpoint*" "*global_state*" "*.pth" "*.pt" "*.nemo" --local-dir="./models/${x}_${y}"
python ./util/convert_safetensors.py ./models/${x}_${y}/*.bin
rm ./models/${x}_${y}/*.bin
rm ./models/${x}_${y}/*.pth
fi
quant "${x}_${y}" "$BPW"
#fi
done < "queue.txt"