File size: 2,860 Bytes
64ddf8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import os

from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE

LLAMA_MODELS = {
    "meta-llama/Llama-2-7b-hf": {
        "layers": 32,
        "experiment": True,
    },
    "meta-llama/Llama-2-13b-hf": {
        "layers": 40,
        "experiment": True,
    },
    "meta-llama/Meta-Llama-3-8B": {
        "layers": 32,
        "llama2": False,
        "experiment": True,
    },
    "meta-llama/Llama-3.1-8B": {
        "layers": 32,
        "llama2": False,
        "experiment": False,
    },
    "meta-llama/Meta-Llama-3-70B": {
        "layers": 80,
        "llama2": False,
        "base_dir": "/data/hugginface/hub",
    },
    "meta-llama/Llama-2-70b-hf": {
        "layers": 80,
        "base_dir": "/data/hugginface/hub",
    },
    "meta-llama/Meta-Llama-3-70B-Instruct": {
        "layers": 80,
        "base_dir": "/data/hugginface/hub",
        "llama2": False,
    },
    "meta-llama/Meta-Llama-3.1-405B-Instruct": {
        "layers": 126,
        "base_dir": "/data/hugginface/hub",
        "llama2": False,
    },
    "../models/Llama-2-13b-hf": {
        "layers": 40,
        "base_dir": "../models/Llama-2-13b-hf",
        "llama2": False,
    },
    "../models/Qwen3-8B": {
        "layers": 36,
        "base_dir": "../models/Qwen3-8B",
        "llama2": False,
    },
    "../models/Qwen3-4B": {
        "layers": 36,
        "base_dir": "../models/Qwen3-4B",
        "llama2": False,
    },
    "../models/Llama-3.2-3B-Instruct": {
        "layers": 28,
        "base_dir": "../models/Llama-3.2-3B-Instruct",
        "llama2": False,
    },
    "../models/Mistral-7B-Instruct-v0.3": {
        "layers": 32,
        "base_dir": "../models/Mistral-7B-Instruct-v0.3",
        "llama2": False,
    },
    "../models/Llama-3.1-70B-Instruct": {
        "layers": 80,
        "base_dir": "../models/Llama-3.1-70B-Instruct",
        "llama2": False,
    },

}

VIT_OPENCLIP_MODELS = {
    "laion/CLIP-ViT-B-32-laion2B-s34B-b79K": {"vlayers": 12, "tlayers": 12},
    "laion/CLIP-ViT-H-14-laion2B-s32B-b79K": {"vlayers": 32, "tlayers": 24},
    "laion/CLIP-ViT-L-14-laion2B-s32B-b82K": {"vlayers": 24, "tlayers": 12},
}

SENSITIVITY_MODELS = [
    "meta-llama/Llama-2-7b-hf",
    "meta-llama/Llama-2-7b-chat-hf",
    "epfl-llm/meditron-7b",
    "meta-llama/Llama-3.1-8B",
    "meta-llama/Llama-3.1-8B-Instruct",
]


def get_hf_model_storge_base_dir(model_id, hf_hub_dir=None):
    # model_id_x = model_id.replace("/", "--")
    # cache_dir = hf_hub_dir if hf_hub_dir else HUGGINGFACE_HUB_CACHE
    # hf_model_dir = os.path.join(cache_dir, f"models--{model_id_x}")
    # ref_main_fp = os.path.join(hf_model_dir, "refs", "main")
    # with open(ref_main_fp) as fh:
    #     commit_sha = fh.read().strip()
    # return os.path.join(hf_model_dir, "snapshots", commit_sha)
    return os.path.join('../models', model_id.split("/")[-1])