Rhett1 commited on
Commit
3e772d2
·
verified ·
1 Parent(s): e41e79a

Add LLaMA-2-13B SVD-LLM / SVD-LLM V2 baselines (healed 60M and unhealed)

Browse files
README.md CHANGED
@@ -80,3 +80,16 @@ License. Do not assume one subdirectory's terms apply to another.
80
  requires rebuilding the architecture with the layer classes shipped in each directory, using
81
  that directory's `ranks.json`. `AutoModelForCausalLM.from_pretrained()` will **not** work.
82
  Each subdirectory's README carries a complete loading recipe.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  requires rebuilding the architecture with the layer classes shipped in each directory, using
81
  that directory's `ranks.json`. `AutoModelForCausalLM.from_pretrained()` will **not** work.
82
  Each subdirectory's README carries a complete loading recipe.
83
+
84
+ ## LLaMA-2-13B SVD baselines (healed vs unhealed)
85
+
86
+ 13B counterparts of the 7B SVD baselines at the matched 13B budget (7.7403B, 59.47% kept —
87
+ same as TR-3 13B), KD-healed with the identical 60M-token protocol. `*-unhealed` dirs hold the
88
+ raw compression weights (no distillation) so the healing delta is directly measurable:
89
+
90
+ | Directory | Stage | Method | Params |
91
+ |---|---|---|---:|
92
+ | [`svd-llm-13b/`](./svd-llm-13b) | KD-healed | SVD-LLM | 7.738B |
93
+ | [`svd-llm-13b-unhealed/`](./svd-llm-13b-unhealed) | raw compression | SVD-LLM | 7.738B |
94
+ | [`svd-llm-v2-13b/`](./svd-llm-v2-13b) | KD-healed | SVD-LLM V2 ‡ | 7.7403B |
95
+ | [`svd-llm-v2-13b-unhealed/`](./svd-llm-v2-13b-unhealed) | raw compression | SVD-LLM V2 ‡ | 7.7403B |
svd-llm-13b-unhealed/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ base_model: NousResearch/Llama-2-13b-chat-hf
4
+ tags: [svd, low-rank, model-compression, llama2]
5
+ ---
6
+
7
+ # SVD-LLM @ 7.74B (59.47% kept of LLaMA-2-13B-chat), UNHEALED
8
+
9
+ SVD-LLM (ICLR 2025): truncation-aware data whitening + closed-form parameter update, official code (@ 7538cca), uniform 41.58% removal across all 7 projection types of all 40 layers.
10
+
11
+ - **UNHEALED checkpoint**: raw post-training compression weights, NO distillation. The KD-healed
12
+ counterpart is in `svd-llm-13b/`. This dir exists so the healing delta is
13
+ measurable; use it as the compression-stage artifact, not as a deployable model.
14
+ - Same `ranks.json` as the healed dir; weights differ (see `provenance.json` SHA256).
15
+
16
+ Load exactly as in the sibling dir (`lowrank_linear.py`).
svd-llm-13b-unhealed/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": null,
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 5120,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 13824,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 40,
15
+ "num_hidden_layers": 40,
16
+ "num_key_value_heads": 40,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "float16",
23
+ "transformers_version": "4.31.0.dev0",
24
+ "use_cache": true,
25
+ "vocab_size": 32000
26
+ }
svd-llm-13b-unhealed/lowrank_linear.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal standalone loader for the SVD-baseline compressed LLaMA-2-7B checkpoints.
2
+
3
+ No dependency beyond torch + transformers. The state_dict stores every compressed
4
+ projection as two factors of a LowRankLinear (A: out x k, B: k x in); ranks.json
5
+ holds the per-layer integer rank of each projection. Untouched parameters
6
+ (embeddings, norms) keep their stock transformers names.
7
+
8
+ Usage:
9
+ import json, torch
10
+ from lowrank_linear import build
11
+ model = build(
12
+ base_id="NousResearch/Llama-2-7b-chat-hf",
13
+ ranks=json.load(open("ranks.json")),
14
+ state_dict_path="state_dict_fp16.pt",
15
+ device="cuda", dtype=torch.float16,
16
+ )
17
+ tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
18
+ out = model.generate(tokenizer("2+2=", return_tensors="pt").to("cuda").input_ids,
19
+ max_new_tokens=16, do_sample=False)
20
+ print(tokenizer.decode(out[0]))
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import torch
26
+ import torch.nn as nn
27
+ import torch.nn.functional as F
28
+
29
+
30
+ class LowRankLinear(nn.Module):
31
+ """y = A (B x). A: out x r, B: r x in. (LLaMA projections carry no bias.)"""
32
+
33
+ def __init__(self, A: torch.Tensor, B: torch.Tensor):
34
+ super().__init__()
35
+ self.A = nn.Parameter(A)
36
+ self.B = nn.Parameter(B)
37
+
38
+ def forward(self, x):
39
+ return F.linear(F.linear(x, self.B), self.A)
40
+
41
+ @torch.no_grad()
42
+ def materialize_(self) -> nn.Linear:
43
+ """Replace this module with the dense W = A @ B (inference only; never call
44
+ while training -- it cuts the gradient path)."""
45
+ W = (self.A @ self.B).to(self.A.dtype)
46
+ dense = nn.Linear(self.B.shape[1], self.A.shape[0], bias=False,
47
+ device=W.device, dtype=W.dtype)
48
+ dense.weight.data = W
49
+ return dense
50
+
51
+
52
+ def build(base_id: str, ranks: dict, state_dict_path: str,
53
+ device: str = "cuda", dtype=torch.float16):
54
+ from transformers import AutoModelForCausalLM
55
+
56
+ model = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=dtype)
57
+ search = {}
58
+ for name, mod in model.named_modules():
59
+ if isinstance(mod, nn.Linear):
60
+ search[name] = mod
61
+ for path, k in ranks.items():
62
+ out_f, in_f = search[path].weight.shape
63
+ model_mod = model
64
+ for p in path.split(".")[:-1]:
65
+ model_mod = getattr(model_mod, p)
66
+ setattr(model_mod, path.split(".")[-1],
67
+ LowRankLinear(torch.zeros(out_f, int(k), dtype=dtype),
68
+ torch.zeros(int(k), in_f, dtype=dtype)))
69
+ sd = torch.load(state_dict_path, map_location="cpu", weights_only=True)
70
+ model.load_state_dict(sd, strict=True)
71
+ del sd
72
+ return model.to(device)
73
+
74
+
75
+ def materialize_all(model):
76
+ """Fuse every LowRankLinear back into a dense nn.Linear in place."""
77
+ for name, mod in list(model.named_modules()):
78
+ if isinstance(mod, LowRankLinear):
79
+ parent = model
80
+ for p in name.split(".")[:-1]:
81
+ parent = getattr(parent, p)
82
+ setattr(parent, name.split(".")[-1], mod.materialize_())
83
+ return model
svd-llm-13b-unhealed/provenance.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "kind": "unhealed SVD compression (TR3-format conversion, verified pure re-keying)",
3
+ "source_ckpt": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm1_llama2_13b_chat_r04158/NousResearch_Llama_2_13b_chat_hf_whitening_then_update_0.5842.pt",
4
+ "converted_state_dict": "/data1/rkp00022/zixuan/projects/TR3_main/scratch/hf_push_13b/svd-llm-13b-unhealed/state_dict_fp16.pt",
5
+ "state_dict_sha256": "5625041bed874f21664b6a2bff3ce4722612302630028c9b60ac7f2cb8d7c605",
6
+ "healed_counterpart": "svd-llm-13b/state_dict_fp16.pt"
7
+ }
svd-llm-13b-unhealed/ranks.json ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model.layers.0.self_attn.q_proj": 1495,
3
+ "model.layers.0.self_attn.k_proj": 1495,
4
+ "model.layers.0.self_attn.v_proj": 1495,
5
+ "model.layers.0.self_attn.o_proj": 1495,
6
+ "model.layers.0.mlp.gate_proj": 2182,
7
+ "model.layers.0.mlp.up_proj": 2182,
8
+ "model.layers.0.mlp.down_proj": 2182,
9
+ "model.layers.1.self_attn.q_proj": 1495,
10
+ "model.layers.1.self_attn.k_proj": 1495,
11
+ "model.layers.1.self_attn.v_proj": 1495,
12
+ "model.layers.1.self_attn.o_proj": 1495,
13
+ "model.layers.1.mlp.gate_proj": 2182,
14
+ "model.layers.1.mlp.up_proj": 2182,
15
+ "model.layers.1.mlp.down_proj": 2182,
16
+ "model.layers.2.self_attn.q_proj": 1495,
17
+ "model.layers.2.self_attn.k_proj": 1495,
18
+ "model.layers.2.self_attn.v_proj": 1495,
19
+ "model.layers.2.self_attn.o_proj": 1495,
20
+ "model.layers.2.mlp.gate_proj": 2182,
21
+ "model.layers.2.mlp.up_proj": 2182,
22
+ "model.layers.2.mlp.down_proj": 2182,
23
+ "model.layers.3.self_attn.q_proj": 1495,
24
+ "model.layers.3.self_attn.k_proj": 1495,
25
+ "model.layers.3.self_attn.v_proj": 1495,
26
+ "model.layers.3.self_attn.o_proj": 1495,
27
+ "model.layers.3.mlp.gate_proj": 2182,
28
+ "model.layers.3.mlp.up_proj": 2182,
29
+ "model.layers.3.mlp.down_proj": 2182,
30
+ "model.layers.4.self_attn.q_proj": 1495,
31
+ "model.layers.4.self_attn.k_proj": 1495,
32
+ "model.layers.4.self_attn.v_proj": 1495,
33
+ "model.layers.4.self_attn.o_proj": 1495,
34
+ "model.layers.4.mlp.gate_proj": 2182,
35
+ "model.layers.4.mlp.up_proj": 2182,
36
+ "model.layers.4.mlp.down_proj": 2182,
37
+ "model.layers.5.self_attn.q_proj": 1495,
38
+ "model.layers.5.self_attn.k_proj": 1495,
39
+ "model.layers.5.self_attn.v_proj": 1495,
40
+ "model.layers.5.self_attn.o_proj": 1495,
41
+ "model.layers.5.mlp.gate_proj": 2182,
42
+ "model.layers.5.mlp.up_proj": 2182,
43
+ "model.layers.5.mlp.down_proj": 2182,
44
+ "model.layers.6.self_attn.q_proj": 1495,
45
+ "model.layers.6.self_attn.k_proj": 1495,
46
+ "model.layers.6.self_attn.v_proj": 1495,
47
+ "model.layers.6.self_attn.o_proj": 1495,
48
+ "model.layers.6.mlp.gate_proj": 2182,
49
+ "model.layers.6.mlp.up_proj": 2182,
50
+ "model.layers.6.mlp.down_proj": 2182,
51
+ "model.layers.7.self_attn.q_proj": 1495,
52
+ "model.layers.7.self_attn.k_proj": 1495,
53
+ "model.layers.7.self_attn.v_proj": 1495,
54
+ "model.layers.7.self_attn.o_proj": 1495,
55
+ "model.layers.7.mlp.gate_proj": 2182,
56
+ "model.layers.7.mlp.up_proj": 2182,
57
+ "model.layers.7.mlp.down_proj": 2182,
58
+ "model.layers.8.self_attn.q_proj": 1495,
59
+ "model.layers.8.self_attn.k_proj": 1495,
60
+ "model.layers.8.self_attn.v_proj": 1495,
61
+ "model.layers.8.self_attn.o_proj": 1495,
62
+ "model.layers.8.mlp.gate_proj": 2182,
63
+ "model.layers.8.mlp.up_proj": 2182,
64
+ "model.layers.8.mlp.down_proj": 2182,
65
+ "model.layers.9.self_attn.q_proj": 1495,
66
+ "model.layers.9.self_attn.k_proj": 1495,
67
+ "model.layers.9.self_attn.v_proj": 1495,
68
+ "model.layers.9.self_attn.o_proj": 1495,
69
+ "model.layers.9.mlp.gate_proj": 2182,
70
+ "model.layers.9.mlp.up_proj": 2182,
71
+ "model.layers.9.mlp.down_proj": 2182,
72
+ "model.layers.10.self_attn.q_proj": 1495,
73
+ "model.layers.10.self_attn.k_proj": 1495,
74
+ "model.layers.10.self_attn.v_proj": 1495,
75
+ "model.layers.10.self_attn.o_proj": 1495,
76
+ "model.layers.10.mlp.gate_proj": 2182,
77
+ "model.layers.10.mlp.up_proj": 2182,
78
+ "model.layers.10.mlp.down_proj": 2182,
79
+ "model.layers.11.self_attn.q_proj": 1495,
80
+ "model.layers.11.self_attn.k_proj": 1495,
81
+ "model.layers.11.self_attn.v_proj": 1495,
82
+ "model.layers.11.self_attn.o_proj": 1495,
83
+ "model.layers.11.mlp.gate_proj": 2182,
84
+ "model.layers.11.mlp.up_proj": 2182,
85
+ "model.layers.11.mlp.down_proj": 2182,
86
+ "model.layers.12.self_attn.q_proj": 1495,
87
+ "model.layers.12.self_attn.k_proj": 1495,
88
+ "model.layers.12.self_attn.v_proj": 1495,
89
+ "model.layers.12.self_attn.o_proj": 1495,
90
+ "model.layers.12.mlp.gate_proj": 2182,
91
+ "model.layers.12.mlp.up_proj": 2182,
92
+ "model.layers.12.mlp.down_proj": 2182,
93
+ "model.layers.13.self_attn.q_proj": 1495,
94
+ "model.layers.13.self_attn.k_proj": 1495,
95
+ "model.layers.13.self_attn.v_proj": 1495,
96
+ "model.layers.13.self_attn.o_proj": 1495,
97
+ "model.layers.13.mlp.gate_proj": 2182,
98
+ "model.layers.13.mlp.up_proj": 2182,
99
+ "model.layers.13.mlp.down_proj": 2182,
100
+ "model.layers.14.self_attn.q_proj": 1495,
101
+ "model.layers.14.self_attn.k_proj": 1495,
102
+ "model.layers.14.self_attn.v_proj": 1495,
103
+ "model.layers.14.self_attn.o_proj": 1495,
104
+ "model.layers.14.mlp.gate_proj": 2182,
105
+ "model.layers.14.mlp.up_proj": 2182,
106
+ "model.layers.14.mlp.down_proj": 2182,
107
+ "model.layers.15.self_attn.q_proj": 1495,
108
+ "model.layers.15.self_attn.k_proj": 1495,
109
+ "model.layers.15.self_attn.v_proj": 1495,
110
+ "model.layers.15.self_attn.o_proj": 1495,
111
+ "model.layers.15.mlp.gate_proj": 2182,
112
+ "model.layers.15.mlp.up_proj": 2182,
113
+ "model.layers.15.mlp.down_proj": 2182,
114
+ "model.layers.16.self_attn.q_proj": 1495,
115
+ "model.layers.16.self_attn.k_proj": 1495,
116
+ "model.layers.16.self_attn.v_proj": 1495,
117
+ "model.layers.16.self_attn.o_proj": 1495,
118
+ "model.layers.16.mlp.gate_proj": 2182,
119
+ "model.layers.16.mlp.up_proj": 2182,
120
+ "model.layers.16.mlp.down_proj": 2182,
121
+ "model.layers.17.self_attn.q_proj": 1495,
122
+ "model.layers.17.self_attn.k_proj": 1495,
123
+ "model.layers.17.self_attn.v_proj": 1495,
124
+ "model.layers.17.self_attn.o_proj": 1495,
125
+ "model.layers.17.mlp.gate_proj": 2182,
126
+ "model.layers.17.mlp.up_proj": 2182,
127
+ "model.layers.17.mlp.down_proj": 2182,
128
+ "model.layers.18.self_attn.q_proj": 1495,
129
+ "model.layers.18.self_attn.k_proj": 1495,
130
+ "model.layers.18.self_attn.v_proj": 1495,
131
+ "model.layers.18.self_attn.o_proj": 1495,
132
+ "model.layers.18.mlp.gate_proj": 2182,
133
+ "model.layers.18.mlp.up_proj": 2182,
134
+ "model.layers.18.mlp.down_proj": 2182,
135
+ "model.layers.19.self_attn.q_proj": 1495,
136
+ "model.layers.19.self_attn.k_proj": 1495,
137
+ "model.layers.19.self_attn.v_proj": 1495,
138
+ "model.layers.19.self_attn.o_proj": 1495,
139
+ "model.layers.19.mlp.gate_proj": 2182,
140
+ "model.layers.19.mlp.up_proj": 2182,
141
+ "model.layers.19.mlp.down_proj": 2182,
142
+ "model.layers.20.self_attn.q_proj": 1495,
143
+ "model.layers.20.self_attn.k_proj": 1495,
144
+ "model.layers.20.self_attn.v_proj": 1495,
145
+ "model.layers.20.self_attn.o_proj": 1495,
146
+ "model.layers.20.mlp.gate_proj": 2182,
147
+ "model.layers.20.mlp.up_proj": 2182,
148
+ "model.layers.20.mlp.down_proj": 2182,
149
+ "model.layers.21.self_attn.q_proj": 1495,
150
+ "model.layers.21.self_attn.k_proj": 1495,
151
+ "model.layers.21.self_attn.v_proj": 1495,
152
+ "model.layers.21.self_attn.o_proj": 1495,
153
+ "model.layers.21.mlp.gate_proj": 2182,
154
+ "model.layers.21.mlp.up_proj": 2182,
155
+ "model.layers.21.mlp.down_proj": 2182,
156
+ "model.layers.22.self_attn.q_proj": 1495,
157
+ "model.layers.22.self_attn.k_proj": 1495,
158
+ "model.layers.22.self_attn.v_proj": 1495,
159
+ "model.layers.22.self_attn.o_proj": 1495,
160
+ "model.layers.22.mlp.gate_proj": 2182,
161
+ "model.layers.22.mlp.up_proj": 2182,
162
+ "model.layers.22.mlp.down_proj": 2182,
163
+ "model.layers.23.self_attn.q_proj": 1495,
164
+ "model.layers.23.self_attn.k_proj": 1495,
165
+ "model.layers.23.self_attn.v_proj": 1495,
166
+ "model.layers.23.self_attn.o_proj": 1495,
167
+ "model.layers.23.mlp.gate_proj": 2182,
168
+ "model.layers.23.mlp.up_proj": 2182,
169
+ "model.layers.23.mlp.down_proj": 2182,
170
+ "model.layers.24.self_attn.q_proj": 1495,
171
+ "model.layers.24.self_attn.k_proj": 1495,
172
+ "model.layers.24.self_attn.v_proj": 1495,
173
+ "model.layers.24.self_attn.o_proj": 1495,
174
+ "model.layers.24.mlp.gate_proj": 2182,
175
+ "model.layers.24.mlp.up_proj": 2182,
176
+ "model.layers.24.mlp.down_proj": 2182,
177
+ "model.layers.25.self_attn.q_proj": 1495,
178
+ "model.layers.25.self_attn.k_proj": 1495,
179
+ "model.layers.25.self_attn.v_proj": 1495,
180
+ "model.layers.25.self_attn.o_proj": 1495,
181
+ "model.layers.25.mlp.gate_proj": 2182,
182
+ "model.layers.25.mlp.up_proj": 2182,
183
+ "model.layers.25.mlp.down_proj": 2182,
184
+ "model.layers.26.self_attn.q_proj": 1495,
185
+ "model.layers.26.self_attn.k_proj": 1495,
186
+ "model.layers.26.self_attn.v_proj": 1495,
187
+ "model.layers.26.self_attn.o_proj": 1495,
188
+ "model.layers.26.mlp.gate_proj": 2182,
189
+ "model.layers.26.mlp.up_proj": 2182,
190
+ "model.layers.26.mlp.down_proj": 2182,
191
+ "model.layers.27.self_attn.q_proj": 1495,
192
+ "model.layers.27.self_attn.k_proj": 1495,
193
+ "model.layers.27.self_attn.v_proj": 1495,
194
+ "model.layers.27.self_attn.o_proj": 1495,
195
+ "model.layers.27.mlp.gate_proj": 2182,
196
+ "model.layers.27.mlp.up_proj": 2182,
197
+ "model.layers.27.mlp.down_proj": 2182,
198
+ "model.layers.28.self_attn.q_proj": 1495,
199
+ "model.layers.28.self_attn.k_proj": 1495,
200
+ "model.layers.28.self_attn.v_proj": 1495,
201
+ "model.layers.28.self_attn.o_proj": 1495,
202
+ "model.layers.28.mlp.gate_proj": 2182,
203
+ "model.layers.28.mlp.up_proj": 2182,
204
+ "model.layers.28.mlp.down_proj": 2182,
205
+ "model.layers.29.self_attn.q_proj": 1495,
206
+ "model.layers.29.self_attn.k_proj": 1495,
207
+ "model.layers.29.self_attn.v_proj": 1495,
208
+ "model.layers.29.self_attn.o_proj": 1495,
209
+ "model.layers.29.mlp.gate_proj": 2182,
210
+ "model.layers.29.mlp.up_proj": 2182,
211
+ "model.layers.29.mlp.down_proj": 2182,
212
+ "model.layers.30.self_attn.q_proj": 1495,
213
+ "model.layers.30.self_attn.k_proj": 1495,
214
+ "model.layers.30.self_attn.v_proj": 1495,
215
+ "model.layers.30.self_attn.o_proj": 1495,
216
+ "model.layers.30.mlp.gate_proj": 2182,
217
+ "model.layers.30.mlp.up_proj": 2182,
218
+ "model.layers.30.mlp.down_proj": 2182,
219
+ "model.layers.31.self_attn.q_proj": 1495,
220
+ "model.layers.31.self_attn.k_proj": 1495,
221
+ "model.layers.31.self_attn.v_proj": 1495,
222
+ "model.layers.31.self_attn.o_proj": 1495,
223
+ "model.layers.31.mlp.gate_proj": 2182,
224
+ "model.layers.31.mlp.up_proj": 2182,
225
+ "model.layers.31.mlp.down_proj": 2182,
226
+ "model.layers.32.self_attn.q_proj": 1495,
227
+ "model.layers.32.self_attn.k_proj": 1495,
228
+ "model.layers.32.self_attn.v_proj": 1495,
229
+ "model.layers.32.self_attn.o_proj": 1495,
230
+ "model.layers.32.mlp.gate_proj": 2182,
231
+ "model.layers.32.mlp.up_proj": 2182,
232
+ "model.layers.32.mlp.down_proj": 2182,
233
+ "model.layers.33.self_attn.q_proj": 1495,
234
+ "model.layers.33.self_attn.k_proj": 1495,
235
+ "model.layers.33.self_attn.v_proj": 1495,
236
+ "model.layers.33.self_attn.o_proj": 1495,
237
+ "model.layers.33.mlp.gate_proj": 2182,
238
+ "model.layers.33.mlp.up_proj": 2182,
239
+ "model.layers.33.mlp.down_proj": 2182,
240
+ "model.layers.34.self_attn.q_proj": 1495,
241
+ "model.layers.34.self_attn.k_proj": 1495,
242
+ "model.layers.34.self_attn.v_proj": 1495,
243
+ "model.layers.34.self_attn.o_proj": 1495,
244
+ "model.layers.34.mlp.gate_proj": 2182,
245
+ "model.layers.34.mlp.up_proj": 2182,
246
+ "model.layers.34.mlp.down_proj": 2182,
247
+ "model.layers.35.self_attn.q_proj": 1495,
248
+ "model.layers.35.self_attn.k_proj": 1495,
249
+ "model.layers.35.self_attn.v_proj": 1495,
250
+ "model.layers.35.self_attn.o_proj": 1495,
251
+ "model.layers.35.mlp.gate_proj": 2182,
252
+ "model.layers.35.mlp.up_proj": 2182,
253
+ "model.layers.35.mlp.down_proj": 2182,
254
+ "model.layers.36.self_attn.q_proj": 1495,
255
+ "model.layers.36.self_attn.k_proj": 1495,
256
+ "model.layers.36.self_attn.v_proj": 1495,
257
+ "model.layers.36.self_attn.o_proj": 1495,
258
+ "model.layers.36.mlp.gate_proj": 2182,
259
+ "model.layers.36.mlp.up_proj": 2182,
260
+ "model.layers.36.mlp.down_proj": 2182,
261
+ "model.layers.37.self_attn.q_proj": 1495,
262
+ "model.layers.37.self_attn.k_proj": 1495,
263
+ "model.layers.37.self_attn.v_proj": 1495,
264
+ "model.layers.37.self_attn.o_proj": 1495,
265
+ "model.layers.37.mlp.gate_proj": 2182,
266
+ "model.layers.37.mlp.up_proj": 2182,
267
+ "model.layers.37.mlp.down_proj": 2182,
268
+ "model.layers.38.self_attn.q_proj": 1495,
269
+ "model.layers.38.self_attn.k_proj": 1495,
270
+ "model.layers.38.self_attn.v_proj": 1495,
271
+ "model.layers.38.self_attn.o_proj": 1495,
272
+ "model.layers.38.mlp.gate_proj": 2182,
273
+ "model.layers.38.mlp.up_proj": 2182,
274
+ "model.layers.38.mlp.down_proj": 2182,
275
+ "model.layers.39.self_attn.q_proj": 1495,
276
+ "model.layers.39.self_attn.k_proj": 1495,
277
+ "model.layers.39.self_attn.v_proj": 1495,
278
+ "model.layers.39.self_attn.o_proj": 1495,
279
+ "model.layers.39.mlp.gate_proj": 2182,
280
+ "model.layers.39.mlp.up_proj": 2182,
281
+ "model.layers.39.mlp.down_proj": 2182
282
+ }
svd-llm-13b-unhealed/state_dict_fp16.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5625041bed874f21664b6a2bff3ce4722612302630028c9b60ac7f2cb8d7c605
3
+ size 15475812809
svd-llm-13b/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ base_model: NousResearch/Llama-2-13b-chat-hf
4
+ tags: [svd, low-rank, model-compression, llama2, knowledge-distillation]
5
+ ---
6
+
7
+ # SVD-LLM @ 7.74B (59.47% kept of LLaMA-2-13B-chat), KD-healed 60M tokens
8
+
9
+ SVD-LLM (ICLR 2025): truncation-aware data whitening + closed-form parameter update, official code (@ 7538cca), uniform 41.58% removal across all 7 projection types of all 40 layers.
10
+
11
+ - **HEALED checkpoint** (this dir). The matching **UNHEALED** pre-distillation weights are in
12
+ `svd-llm-13b-unhealed/` — do not mix them up: same `ranks.json`, different `state_dict_fp16.pt` (see
13
+ `provenance.json` SHA256 here vs the unhealed dir's record).
14
+ - Healing: pure forward-KL distillation from frozen NousResearch/Llama-2-13b-chat-hf teacher,
15
+ 60M tokens, held-out KL **2.0904 -> 0.3007**, probe MMLU (5-shot, limit 40) **24.56% -> 46.54%**.
16
+ - Identical recipe/protocol to the TR-3 13B and the 7B SVD baselines (see their dirs).
17
+
18
+ ## Load
19
+
20
+ ```python
21
+ import json
22
+ from lowrank_linear import build, materialize_all
23
+ model = build("NousResearch/Llama-2-13b-chat-hf", json.load(open("ranks.json")),
24
+ "state_dict_fp16.pt", device="cuda")
25
+ materialize_all(model) # inference-only fusion U@V
26
+ ```
27
+
28
+ Full provenance (data mixture + revisions, decontamination, SHA256 of every input and
29
+ checkpoint, 12 x 5M milestone trajectory) in `provenance.json`.
svd-llm-13b/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": null,
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 5120,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 13824,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 40,
15
+ "num_hidden_layers": 40,
16
+ "num_key_value_heads": 40,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "float16",
23
+ "transformers_version": "4.31.0.dev0",
24
+ "use_cache": true,
25
+ "vocab_size": 32000
26
+ }
svd-llm-13b/lowrank_linear.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal standalone loader for the SVD-baseline compressed LLaMA-2-7B checkpoints.
2
+
3
+ No dependency beyond torch + transformers. The state_dict stores every compressed
4
+ projection as two factors of a LowRankLinear (A: out x k, B: k x in); ranks.json
5
+ holds the per-layer integer rank of each projection. Untouched parameters
6
+ (embeddings, norms) keep their stock transformers names.
7
+
8
+ Usage:
9
+ import json, torch
10
+ from lowrank_linear import build
11
+ model = build(
12
+ base_id="NousResearch/Llama-2-7b-chat-hf",
13
+ ranks=json.load(open("ranks.json")),
14
+ state_dict_path="state_dict_fp16.pt",
15
+ device="cuda", dtype=torch.float16,
16
+ )
17
+ tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
18
+ out = model.generate(tokenizer("2+2=", return_tensors="pt").to("cuda").input_ids,
19
+ max_new_tokens=16, do_sample=False)
20
+ print(tokenizer.decode(out[0]))
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import torch
26
+ import torch.nn as nn
27
+ import torch.nn.functional as F
28
+
29
+
30
+ class LowRankLinear(nn.Module):
31
+ """y = A (B x). A: out x r, B: r x in. (LLaMA projections carry no bias.)"""
32
+
33
+ def __init__(self, A: torch.Tensor, B: torch.Tensor):
34
+ super().__init__()
35
+ self.A = nn.Parameter(A)
36
+ self.B = nn.Parameter(B)
37
+
38
+ def forward(self, x):
39
+ return F.linear(F.linear(x, self.B), self.A)
40
+
41
+ @torch.no_grad()
42
+ def materialize_(self) -> nn.Linear:
43
+ """Replace this module with the dense W = A @ B (inference only; never call
44
+ while training -- it cuts the gradient path)."""
45
+ W = (self.A @ self.B).to(self.A.dtype)
46
+ dense = nn.Linear(self.B.shape[1], self.A.shape[0], bias=False,
47
+ device=W.device, dtype=W.dtype)
48
+ dense.weight.data = W
49
+ return dense
50
+
51
+
52
+ def build(base_id: str, ranks: dict, state_dict_path: str,
53
+ device: str = "cuda", dtype=torch.float16):
54
+ from transformers import AutoModelForCausalLM
55
+
56
+ model = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=dtype)
57
+ search = {}
58
+ for name, mod in model.named_modules():
59
+ if isinstance(mod, nn.Linear):
60
+ search[name] = mod
61
+ for path, k in ranks.items():
62
+ out_f, in_f = search[path].weight.shape
63
+ model_mod = model
64
+ for p in path.split(".")[:-1]:
65
+ model_mod = getattr(model_mod, p)
66
+ setattr(model_mod, path.split(".")[-1],
67
+ LowRankLinear(torch.zeros(out_f, int(k), dtype=dtype),
68
+ torch.zeros(int(k), in_f, dtype=dtype)))
69
+ sd = torch.load(state_dict_path, map_location="cpu", weights_only=True)
70
+ model.load_state_dict(sd, strict=True)
71
+ del sd
72
+ return model.to(device)
73
+
74
+
75
+ def materialize_all(model):
76
+ """Fuse every LowRankLinear back into a dense nn.Linear in place."""
77
+ for name, mod in list(model.named_modules()):
78
+ if isinstance(mod, LowRankLinear):
79
+ parent = model
80
+ for p in name.split(".")[:-1]:
81
+ parent = getattr(parent, p)
82
+ setattr(parent, name.split(".")[-1], mod.materialize_())
83
+ return model
svd-llm-13b/provenance.json ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "method": "KD healing: alpha*T^2*KL(teacher||student) + (1-alpha)*CE",
3
+ "student_init": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm1_r04158_tr3fmt/state_dict_fp16.pt",
4
+ "teacher": "NousResearch/Llama-2-13b-chat-hf",
5
+ "alpha": 1.0,
6
+ "temperature": 1.0,
7
+ "lr": 2e-05,
8
+ "tokens_seen": 59998208,
9
+ "epochs": 0.228,
10
+ "global_batch_tokens": 32768,
11
+ "dataset_mixture_pre_exclusion": {
12
+ "alpaca": 50000,
13
+ "openhermes": 200000,
14
+ "ultrachat": 100000
15
+ },
16
+ "dataset_revisions": {
17
+ "tatsu-lab/alpaca": "dce01c9b08f87459cf36a430d809084718273017",
18
+ "teknium/OpenHermes-2.5": "b82037821055c377bed0d495e72e46de3bc72e84",
19
+ "HuggingFaceH4/ultrachat_200k": "8049631c405ae6576f93f445c6b8166f76f5505a"
20
+ },
21
+ "canonical_pool_excluded_texts": 10000,
22
+ "train_texts_after_exclusion": 356000,
23
+ "chat_texts": 340000,
24
+ "mmlu_aux_texts_kept": 16000,
25
+ "mmlu_aux_split": "cais/mmlu auxiliary_train (official TRAIN split, disjoint from the evaluated test split; audit verified 0/99842 exact overlap)",
26
+ "mmlu_aux_stats": {
27
+ "requested_groups": 16000,
28
+ "rendered_groups": 16000,
29
+ "shots": 5,
30
+ "rows_total": 99842,
31
+ "rows_dropped_by_decontam": 71,
32
+ "rows_clean": 99771,
33
+ "revision": "c30699e8356da336a370243923dbaf21066bb9fe",
34
+ "format": "MMLU-shaped (NOT byte-identical to lm-eval; auxiliary_train has no subject)"
35
+ },
36
+ "gold_label_supervision": false,
37
+ "attribution_note": "alpha=1.0 => pure KD, no gold-label CE, so any MMLU change is attributable to distillation on in-domain text. alpha<1 adds CE on text containing answers = labeled MCQ training, which is a DIFFERENT and weaker claim.",
38
+ "train_tokens_total": 263112704,
39
+ "decontamination": {
40
+ "removed": {
41
+ "alpaca": 11,
42
+ "openhermes": 120,
43
+ "ultrachat": 33
44
+ }
45
+ },
46
+ "start_kl": 2.0904040336608887,
47
+ "final_kl": 0.30065654776990414,
48
+ "start_mmlu": 0.24561403508771928,
49
+ "final_mmlu": 0.46535087719298246,
50
+ "history": [
51
+ {
52
+ "tokens_m": 5.01,
53
+ "step": 153,
54
+ "held_out_kl": 0.5967434793710709,
55
+ "mmlu": 0.3929824561403509
56
+ },
57
+ {
58
+ "tokens_m": 10.03,
59
+ "step": 306,
60
+ "held_out_kl": 0.5406020767986774,
61
+ "mmlu": 0.3956140350877193
62
+ },
63
+ {
64
+ "tokens_m": 15.01,
65
+ "step": 458,
66
+ "held_out_kl": 0.5206542909145355,
67
+ "mmlu": 0.4083333333333333
68
+ },
69
+ {
70
+ "tokens_m": 20.02,
71
+ "step": 611,
72
+ "held_out_kl": 0.4988052695989609,
73
+ "mmlu": 0.40087719298245617
74
+ },
75
+ {
76
+ "tokens_m": 25.0,
77
+ "step": 763,
78
+ "held_out_kl": 0.4575178399682045,
79
+ "mmlu": 0.40350877192982454
80
+ },
81
+ {
82
+ "tokens_m": 30.02,
83
+ "step": 916,
84
+ "held_out_kl": 0.4198819752782583,
85
+ "mmlu": 0.4298245614035088
86
+ },
87
+ {
88
+ "tokens_m": 35.03,
89
+ "step": 1069,
90
+ "held_out_kl": 0.38331497088074684,
91
+ "mmlu": 0.43157894736842106
92
+ },
93
+ {
94
+ "tokens_m": 40.01,
95
+ "step": 1221,
96
+ "held_out_kl": 0.34914770163595676,
97
+ "mmlu": 0.4425438596491228
98
+ },
99
+ {
100
+ "tokens_m": 45.02,
101
+ "step": 1374,
102
+ "held_out_kl": 0.32529739663004875,
103
+ "mmlu": 0.44956140350877194
104
+ },
105
+ {
106
+ "tokens_m": 50.0,
107
+ "step": 1526,
108
+ "held_out_kl": 0.31298027001321316,
109
+ "mmlu": 0.4587719298245614
110
+ },
111
+ {
112
+ "tokens_m": 55.02,
113
+ "step": 1679,
114
+ "held_out_kl": 0.30493565648794174,
115
+ "mmlu": 0.46403508771929824
116
+ },
117
+ {
118
+ "tokens_m": 60.0,
119
+ "step": 1831,
120
+ "held_out_kl": 0.30065654776990414,
121
+ "mmlu": 0.46535087719298246,
122
+ "final": true
123
+ }
124
+ ],
125
+ "teacher_mmlu_same_limit": 0.5442982456140351,
126
+ "checkpoint": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1/state_dict_fp16.pt",
127
+ "sha256": "42b2f5c959e8fdd07ef526e6d182cab2f7685354859e1262b035eef39ba98387",
128
+ "seed": 1234,
129
+ "mmlu_limit_per_subtask": 40,
130
+ "teacher_revision": "d73f5fa9c4bc135502e04c27b39660747172d76b",
131
+ "student_init_sha256": "5625041bed874f21664b6a2bff3ce4722612302630028c9b60ac7f2cb8d7c605",
132
+ "ranks_file": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm1_r04158_tr3fmt/ranks.json",
133
+ "ranks_sha256": "5c9ed0db91c9c81c51e62e6f82c7c2772478cc353c6f28040164843e64219b55",
134
+ "input_identity_gate": {
135
+ "student_ckpt": {
136
+ "key": "svdllm1_r04158_tr3fmt",
137
+ "sha256": "5625041bed874f21664b6a2bff3ce4722612302630028c9b60ac7f2cb8d7c605",
138
+ "status": "unregistered_allowed"
139
+ },
140
+ "ranks": {
141
+ "key": "svdllm1_r04158_tr3fmt",
142
+ "sha256": "5c9ed0db91c9c81c51e62e6f82c7c2772478cc353c6f28040164843e64219b55",
143
+ "status": "unregistered_allowed"
144
+ }
145
+ },
146
+ "train_seed": 1234,
147
+ "mmlu_seed": 1234,
148
+ "dynamic_batch": false,
149
+ "dbl": null,
150
+ "snapshot_milestones": true,
151
+ "snapshots": [
152
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1_snap15m'), 15.007744)",
153
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1_snap30m'), 30.015488)",
154
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1_snap45m'), 45.023232)",
155
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1_snap50m'), 50.003968)",
156
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm1r04158_h1_snap55m'), 55.017472)"
157
+ ],
158
+ "stream_skip_tokens_m": 0.0,
159
+ "stream_blocks_consumed": [
160
+ 0,
161
+ 58592
162
+ ],
163
+ "stream_note": "the block order is a seeded permutation consumed from index 0; stages sharing a --seed with stream_skip=0 re-train on the SAME blocks. [start, end] block indices are recorded so any continuation can be checked for overlap with what earlier stages consumed.",
164
+ "student_master_dtype": "bf16",
165
+ "fake_quant": null,
166
+ "rebalance_report": null,
167
+ "student_param_count": 7737799680,
168
+ "micro": 8,
169
+ "grad_accum": 4,
170
+ "seq_len": 1024,
171
+ "held_out_source": "canonical: mixture 2000/4000/4000, seed 1234, seq 1024, blocks 256:264 (identical to the compression gates)",
172
+ "decontam_stats": {
173
+ "mmlu": {
174
+ "items": 14042,
175
+ "new_ngrams": 764261,
176
+ "revision": "c30699e8356da336a370243923dbaf21066bb9fe"
177
+ },
178
+ "hellaswag": {
179
+ "items": 10042,
180
+ "new_ngrams": 1334302,
181
+ "revision": "218ec52e09a7e7462a5400043bb9a69a41d06b76"
182
+ },
183
+ "boolq": {
184
+ "items": 3270,
185
+ "new_ngrams": 276806,
186
+ "revision": "3de24cf8022e94f4ee4b9d55a6f539891524d646"
187
+ },
188
+ "triviaqa": {
189
+ "items": 17944,
190
+ "new_ngrams": 32608,
191
+ "revision": "0f7faf33a3908546c6fd5b73a660e0f8ff173c2f"
192
+ },
193
+ "gsm8k": {
194
+ "items": 1319,
195
+ "new_ngrams": 46281,
196
+ "revision": "740312add88f781978c0658806c59bc2815b9866"
197
+ }
198
+ }
199
+ }
svd-llm-13b/ranks.json ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model.layers.0.self_attn.q_proj": 1495,
3
+ "model.layers.0.self_attn.k_proj": 1495,
4
+ "model.layers.0.self_attn.v_proj": 1495,
5
+ "model.layers.0.self_attn.o_proj": 1495,
6
+ "model.layers.0.mlp.gate_proj": 2182,
7
+ "model.layers.0.mlp.up_proj": 2182,
8
+ "model.layers.0.mlp.down_proj": 2182,
9
+ "model.layers.1.self_attn.q_proj": 1495,
10
+ "model.layers.1.self_attn.k_proj": 1495,
11
+ "model.layers.1.self_attn.v_proj": 1495,
12
+ "model.layers.1.self_attn.o_proj": 1495,
13
+ "model.layers.1.mlp.gate_proj": 2182,
14
+ "model.layers.1.mlp.up_proj": 2182,
15
+ "model.layers.1.mlp.down_proj": 2182,
16
+ "model.layers.2.self_attn.q_proj": 1495,
17
+ "model.layers.2.self_attn.k_proj": 1495,
18
+ "model.layers.2.self_attn.v_proj": 1495,
19
+ "model.layers.2.self_attn.o_proj": 1495,
20
+ "model.layers.2.mlp.gate_proj": 2182,
21
+ "model.layers.2.mlp.up_proj": 2182,
22
+ "model.layers.2.mlp.down_proj": 2182,
23
+ "model.layers.3.self_attn.q_proj": 1495,
24
+ "model.layers.3.self_attn.k_proj": 1495,
25
+ "model.layers.3.self_attn.v_proj": 1495,
26
+ "model.layers.3.self_attn.o_proj": 1495,
27
+ "model.layers.3.mlp.gate_proj": 2182,
28
+ "model.layers.3.mlp.up_proj": 2182,
29
+ "model.layers.3.mlp.down_proj": 2182,
30
+ "model.layers.4.self_attn.q_proj": 1495,
31
+ "model.layers.4.self_attn.k_proj": 1495,
32
+ "model.layers.4.self_attn.v_proj": 1495,
33
+ "model.layers.4.self_attn.o_proj": 1495,
34
+ "model.layers.4.mlp.gate_proj": 2182,
35
+ "model.layers.4.mlp.up_proj": 2182,
36
+ "model.layers.4.mlp.down_proj": 2182,
37
+ "model.layers.5.self_attn.q_proj": 1495,
38
+ "model.layers.5.self_attn.k_proj": 1495,
39
+ "model.layers.5.self_attn.v_proj": 1495,
40
+ "model.layers.5.self_attn.o_proj": 1495,
41
+ "model.layers.5.mlp.gate_proj": 2182,
42
+ "model.layers.5.mlp.up_proj": 2182,
43
+ "model.layers.5.mlp.down_proj": 2182,
44
+ "model.layers.6.self_attn.q_proj": 1495,
45
+ "model.layers.6.self_attn.k_proj": 1495,
46
+ "model.layers.6.self_attn.v_proj": 1495,
47
+ "model.layers.6.self_attn.o_proj": 1495,
48
+ "model.layers.6.mlp.gate_proj": 2182,
49
+ "model.layers.6.mlp.up_proj": 2182,
50
+ "model.layers.6.mlp.down_proj": 2182,
51
+ "model.layers.7.self_attn.q_proj": 1495,
52
+ "model.layers.7.self_attn.k_proj": 1495,
53
+ "model.layers.7.self_attn.v_proj": 1495,
54
+ "model.layers.7.self_attn.o_proj": 1495,
55
+ "model.layers.7.mlp.gate_proj": 2182,
56
+ "model.layers.7.mlp.up_proj": 2182,
57
+ "model.layers.7.mlp.down_proj": 2182,
58
+ "model.layers.8.self_attn.q_proj": 1495,
59
+ "model.layers.8.self_attn.k_proj": 1495,
60
+ "model.layers.8.self_attn.v_proj": 1495,
61
+ "model.layers.8.self_attn.o_proj": 1495,
62
+ "model.layers.8.mlp.gate_proj": 2182,
63
+ "model.layers.8.mlp.up_proj": 2182,
64
+ "model.layers.8.mlp.down_proj": 2182,
65
+ "model.layers.9.self_attn.q_proj": 1495,
66
+ "model.layers.9.self_attn.k_proj": 1495,
67
+ "model.layers.9.self_attn.v_proj": 1495,
68
+ "model.layers.9.self_attn.o_proj": 1495,
69
+ "model.layers.9.mlp.gate_proj": 2182,
70
+ "model.layers.9.mlp.up_proj": 2182,
71
+ "model.layers.9.mlp.down_proj": 2182,
72
+ "model.layers.10.self_attn.q_proj": 1495,
73
+ "model.layers.10.self_attn.k_proj": 1495,
74
+ "model.layers.10.self_attn.v_proj": 1495,
75
+ "model.layers.10.self_attn.o_proj": 1495,
76
+ "model.layers.10.mlp.gate_proj": 2182,
77
+ "model.layers.10.mlp.up_proj": 2182,
78
+ "model.layers.10.mlp.down_proj": 2182,
79
+ "model.layers.11.self_attn.q_proj": 1495,
80
+ "model.layers.11.self_attn.k_proj": 1495,
81
+ "model.layers.11.self_attn.v_proj": 1495,
82
+ "model.layers.11.self_attn.o_proj": 1495,
83
+ "model.layers.11.mlp.gate_proj": 2182,
84
+ "model.layers.11.mlp.up_proj": 2182,
85
+ "model.layers.11.mlp.down_proj": 2182,
86
+ "model.layers.12.self_attn.q_proj": 1495,
87
+ "model.layers.12.self_attn.k_proj": 1495,
88
+ "model.layers.12.self_attn.v_proj": 1495,
89
+ "model.layers.12.self_attn.o_proj": 1495,
90
+ "model.layers.12.mlp.gate_proj": 2182,
91
+ "model.layers.12.mlp.up_proj": 2182,
92
+ "model.layers.12.mlp.down_proj": 2182,
93
+ "model.layers.13.self_attn.q_proj": 1495,
94
+ "model.layers.13.self_attn.k_proj": 1495,
95
+ "model.layers.13.self_attn.v_proj": 1495,
96
+ "model.layers.13.self_attn.o_proj": 1495,
97
+ "model.layers.13.mlp.gate_proj": 2182,
98
+ "model.layers.13.mlp.up_proj": 2182,
99
+ "model.layers.13.mlp.down_proj": 2182,
100
+ "model.layers.14.self_attn.q_proj": 1495,
101
+ "model.layers.14.self_attn.k_proj": 1495,
102
+ "model.layers.14.self_attn.v_proj": 1495,
103
+ "model.layers.14.self_attn.o_proj": 1495,
104
+ "model.layers.14.mlp.gate_proj": 2182,
105
+ "model.layers.14.mlp.up_proj": 2182,
106
+ "model.layers.14.mlp.down_proj": 2182,
107
+ "model.layers.15.self_attn.q_proj": 1495,
108
+ "model.layers.15.self_attn.k_proj": 1495,
109
+ "model.layers.15.self_attn.v_proj": 1495,
110
+ "model.layers.15.self_attn.o_proj": 1495,
111
+ "model.layers.15.mlp.gate_proj": 2182,
112
+ "model.layers.15.mlp.up_proj": 2182,
113
+ "model.layers.15.mlp.down_proj": 2182,
114
+ "model.layers.16.self_attn.q_proj": 1495,
115
+ "model.layers.16.self_attn.k_proj": 1495,
116
+ "model.layers.16.self_attn.v_proj": 1495,
117
+ "model.layers.16.self_attn.o_proj": 1495,
118
+ "model.layers.16.mlp.gate_proj": 2182,
119
+ "model.layers.16.mlp.up_proj": 2182,
120
+ "model.layers.16.mlp.down_proj": 2182,
121
+ "model.layers.17.self_attn.q_proj": 1495,
122
+ "model.layers.17.self_attn.k_proj": 1495,
123
+ "model.layers.17.self_attn.v_proj": 1495,
124
+ "model.layers.17.self_attn.o_proj": 1495,
125
+ "model.layers.17.mlp.gate_proj": 2182,
126
+ "model.layers.17.mlp.up_proj": 2182,
127
+ "model.layers.17.mlp.down_proj": 2182,
128
+ "model.layers.18.self_attn.q_proj": 1495,
129
+ "model.layers.18.self_attn.k_proj": 1495,
130
+ "model.layers.18.self_attn.v_proj": 1495,
131
+ "model.layers.18.self_attn.o_proj": 1495,
132
+ "model.layers.18.mlp.gate_proj": 2182,
133
+ "model.layers.18.mlp.up_proj": 2182,
134
+ "model.layers.18.mlp.down_proj": 2182,
135
+ "model.layers.19.self_attn.q_proj": 1495,
136
+ "model.layers.19.self_attn.k_proj": 1495,
137
+ "model.layers.19.self_attn.v_proj": 1495,
138
+ "model.layers.19.self_attn.o_proj": 1495,
139
+ "model.layers.19.mlp.gate_proj": 2182,
140
+ "model.layers.19.mlp.up_proj": 2182,
141
+ "model.layers.19.mlp.down_proj": 2182,
142
+ "model.layers.20.self_attn.q_proj": 1495,
143
+ "model.layers.20.self_attn.k_proj": 1495,
144
+ "model.layers.20.self_attn.v_proj": 1495,
145
+ "model.layers.20.self_attn.o_proj": 1495,
146
+ "model.layers.20.mlp.gate_proj": 2182,
147
+ "model.layers.20.mlp.up_proj": 2182,
148
+ "model.layers.20.mlp.down_proj": 2182,
149
+ "model.layers.21.self_attn.q_proj": 1495,
150
+ "model.layers.21.self_attn.k_proj": 1495,
151
+ "model.layers.21.self_attn.v_proj": 1495,
152
+ "model.layers.21.self_attn.o_proj": 1495,
153
+ "model.layers.21.mlp.gate_proj": 2182,
154
+ "model.layers.21.mlp.up_proj": 2182,
155
+ "model.layers.21.mlp.down_proj": 2182,
156
+ "model.layers.22.self_attn.q_proj": 1495,
157
+ "model.layers.22.self_attn.k_proj": 1495,
158
+ "model.layers.22.self_attn.v_proj": 1495,
159
+ "model.layers.22.self_attn.o_proj": 1495,
160
+ "model.layers.22.mlp.gate_proj": 2182,
161
+ "model.layers.22.mlp.up_proj": 2182,
162
+ "model.layers.22.mlp.down_proj": 2182,
163
+ "model.layers.23.self_attn.q_proj": 1495,
164
+ "model.layers.23.self_attn.k_proj": 1495,
165
+ "model.layers.23.self_attn.v_proj": 1495,
166
+ "model.layers.23.self_attn.o_proj": 1495,
167
+ "model.layers.23.mlp.gate_proj": 2182,
168
+ "model.layers.23.mlp.up_proj": 2182,
169
+ "model.layers.23.mlp.down_proj": 2182,
170
+ "model.layers.24.self_attn.q_proj": 1495,
171
+ "model.layers.24.self_attn.k_proj": 1495,
172
+ "model.layers.24.self_attn.v_proj": 1495,
173
+ "model.layers.24.self_attn.o_proj": 1495,
174
+ "model.layers.24.mlp.gate_proj": 2182,
175
+ "model.layers.24.mlp.up_proj": 2182,
176
+ "model.layers.24.mlp.down_proj": 2182,
177
+ "model.layers.25.self_attn.q_proj": 1495,
178
+ "model.layers.25.self_attn.k_proj": 1495,
179
+ "model.layers.25.self_attn.v_proj": 1495,
180
+ "model.layers.25.self_attn.o_proj": 1495,
181
+ "model.layers.25.mlp.gate_proj": 2182,
182
+ "model.layers.25.mlp.up_proj": 2182,
183
+ "model.layers.25.mlp.down_proj": 2182,
184
+ "model.layers.26.self_attn.q_proj": 1495,
185
+ "model.layers.26.self_attn.k_proj": 1495,
186
+ "model.layers.26.self_attn.v_proj": 1495,
187
+ "model.layers.26.self_attn.o_proj": 1495,
188
+ "model.layers.26.mlp.gate_proj": 2182,
189
+ "model.layers.26.mlp.up_proj": 2182,
190
+ "model.layers.26.mlp.down_proj": 2182,
191
+ "model.layers.27.self_attn.q_proj": 1495,
192
+ "model.layers.27.self_attn.k_proj": 1495,
193
+ "model.layers.27.self_attn.v_proj": 1495,
194
+ "model.layers.27.self_attn.o_proj": 1495,
195
+ "model.layers.27.mlp.gate_proj": 2182,
196
+ "model.layers.27.mlp.up_proj": 2182,
197
+ "model.layers.27.mlp.down_proj": 2182,
198
+ "model.layers.28.self_attn.q_proj": 1495,
199
+ "model.layers.28.self_attn.k_proj": 1495,
200
+ "model.layers.28.self_attn.v_proj": 1495,
201
+ "model.layers.28.self_attn.o_proj": 1495,
202
+ "model.layers.28.mlp.gate_proj": 2182,
203
+ "model.layers.28.mlp.up_proj": 2182,
204
+ "model.layers.28.mlp.down_proj": 2182,
205
+ "model.layers.29.self_attn.q_proj": 1495,
206
+ "model.layers.29.self_attn.k_proj": 1495,
207
+ "model.layers.29.self_attn.v_proj": 1495,
208
+ "model.layers.29.self_attn.o_proj": 1495,
209
+ "model.layers.29.mlp.gate_proj": 2182,
210
+ "model.layers.29.mlp.up_proj": 2182,
211
+ "model.layers.29.mlp.down_proj": 2182,
212
+ "model.layers.30.self_attn.q_proj": 1495,
213
+ "model.layers.30.self_attn.k_proj": 1495,
214
+ "model.layers.30.self_attn.v_proj": 1495,
215
+ "model.layers.30.self_attn.o_proj": 1495,
216
+ "model.layers.30.mlp.gate_proj": 2182,
217
+ "model.layers.30.mlp.up_proj": 2182,
218
+ "model.layers.30.mlp.down_proj": 2182,
219
+ "model.layers.31.self_attn.q_proj": 1495,
220
+ "model.layers.31.self_attn.k_proj": 1495,
221
+ "model.layers.31.self_attn.v_proj": 1495,
222
+ "model.layers.31.self_attn.o_proj": 1495,
223
+ "model.layers.31.mlp.gate_proj": 2182,
224
+ "model.layers.31.mlp.up_proj": 2182,
225
+ "model.layers.31.mlp.down_proj": 2182,
226
+ "model.layers.32.self_attn.q_proj": 1495,
227
+ "model.layers.32.self_attn.k_proj": 1495,
228
+ "model.layers.32.self_attn.v_proj": 1495,
229
+ "model.layers.32.self_attn.o_proj": 1495,
230
+ "model.layers.32.mlp.gate_proj": 2182,
231
+ "model.layers.32.mlp.up_proj": 2182,
232
+ "model.layers.32.mlp.down_proj": 2182,
233
+ "model.layers.33.self_attn.q_proj": 1495,
234
+ "model.layers.33.self_attn.k_proj": 1495,
235
+ "model.layers.33.self_attn.v_proj": 1495,
236
+ "model.layers.33.self_attn.o_proj": 1495,
237
+ "model.layers.33.mlp.gate_proj": 2182,
238
+ "model.layers.33.mlp.up_proj": 2182,
239
+ "model.layers.33.mlp.down_proj": 2182,
240
+ "model.layers.34.self_attn.q_proj": 1495,
241
+ "model.layers.34.self_attn.k_proj": 1495,
242
+ "model.layers.34.self_attn.v_proj": 1495,
243
+ "model.layers.34.self_attn.o_proj": 1495,
244
+ "model.layers.34.mlp.gate_proj": 2182,
245
+ "model.layers.34.mlp.up_proj": 2182,
246
+ "model.layers.34.mlp.down_proj": 2182,
247
+ "model.layers.35.self_attn.q_proj": 1495,
248
+ "model.layers.35.self_attn.k_proj": 1495,
249
+ "model.layers.35.self_attn.v_proj": 1495,
250
+ "model.layers.35.self_attn.o_proj": 1495,
251
+ "model.layers.35.mlp.gate_proj": 2182,
252
+ "model.layers.35.mlp.up_proj": 2182,
253
+ "model.layers.35.mlp.down_proj": 2182,
254
+ "model.layers.36.self_attn.q_proj": 1495,
255
+ "model.layers.36.self_attn.k_proj": 1495,
256
+ "model.layers.36.self_attn.v_proj": 1495,
257
+ "model.layers.36.self_attn.o_proj": 1495,
258
+ "model.layers.36.mlp.gate_proj": 2182,
259
+ "model.layers.36.mlp.up_proj": 2182,
260
+ "model.layers.36.mlp.down_proj": 2182,
261
+ "model.layers.37.self_attn.q_proj": 1495,
262
+ "model.layers.37.self_attn.k_proj": 1495,
263
+ "model.layers.37.self_attn.v_proj": 1495,
264
+ "model.layers.37.self_attn.o_proj": 1495,
265
+ "model.layers.37.mlp.gate_proj": 2182,
266
+ "model.layers.37.mlp.up_proj": 2182,
267
+ "model.layers.37.mlp.down_proj": 2182,
268
+ "model.layers.38.self_attn.q_proj": 1495,
269
+ "model.layers.38.self_attn.k_proj": 1495,
270
+ "model.layers.38.self_attn.v_proj": 1495,
271
+ "model.layers.38.self_attn.o_proj": 1495,
272
+ "model.layers.38.mlp.gate_proj": 2182,
273
+ "model.layers.38.mlp.up_proj": 2182,
274
+ "model.layers.38.mlp.down_proj": 2182,
275
+ "model.layers.39.self_attn.q_proj": 1495,
276
+ "model.layers.39.self_attn.k_proj": 1495,
277
+ "model.layers.39.self_attn.v_proj": 1495,
278
+ "model.layers.39.self_attn.o_proj": 1495,
279
+ "model.layers.39.mlp.gate_proj": 2182,
280
+ "model.layers.39.mlp.up_proj": 2182,
281
+ "model.layers.39.mlp.down_proj": 2182
282
+ }
svd-llm-13b/state_dict_fp16.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42b2f5c959e8fdd07ef526e6d182cab2f7685354859e1262b035eef39ba98387
3
+ size 15475814672
svd-llm-v2-13b-unhealed/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ base_model: NousResearch/Llama-2-13b-chat-hf
4
+ tags: [svd, low-rank, model-compression, llama2]
5
+ ---
6
+
7
+ # SVD-LLM V2 @ 7.74B (59.47% kept of LLaMA-2-13B-chat), UNHEALED
8
+
9
+ SVD-LLM V2 (NAACL 2025): heterogeneous ratio allocation (Alg. 1) + loss-optimized truncation (Alg. 2). Official code never released; our faithful implementation (see per-layer ranks in ranks.json). Exact budget match: 7,740,286,464 vs target 7,740,282,880.
10
+
11
+ - **UNHEALED checkpoint**: raw post-training compression weights, NO distillation. The KD-healed
12
+ counterpart is in `svd-llm-v2-13b/`. This dir exists so the healing delta is
13
+ measurable; use it as the compression-stage artifact, not as a deployable model.
14
+ - Same `ranks.json` as the healed dir; weights differ (see `provenance.json` SHA256).
15
+
16
+ Load exactly as in the sibling dir (`lowrank_linear.py`).
svd-llm-v2-13b-unhealed/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": null,
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 5120,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 13824,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 40,
15
+ "num_hidden_layers": 40,
16
+ "num_key_value_heads": 40,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "float16",
23
+ "transformers_version": "4.31.0.dev0",
24
+ "use_cache": true,
25
+ "vocab_size": 32000
26
+ }
svd-llm-v2-13b-unhealed/lowrank_linear.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal standalone loader for the SVD-baseline compressed LLaMA-2-7B checkpoints.
2
+
3
+ No dependency beyond torch + transformers. The state_dict stores every compressed
4
+ projection as two factors of a LowRankLinear (A: out x k, B: k x in); ranks.json
5
+ holds the per-layer integer rank of each projection. Untouched parameters
6
+ (embeddings, norms) keep their stock transformers names.
7
+
8
+ Usage:
9
+ import json, torch
10
+ from lowrank_linear import build
11
+ model = build(
12
+ base_id="NousResearch/Llama-2-7b-chat-hf",
13
+ ranks=json.load(open("ranks.json")),
14
+ state_dict_path="state_dict_fp16.pt",
15
+ device="cuda", dtype=torch.float16,
16
+ )
17
+ tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
18
+ out = model.generate(tokenizer("2+2=", return_tensors="pt").to("cuda").input_ids,
19
+ max_new_tokens=16, do_sample=False)
20
+ print(tokenizer.decode(out[0]))
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import torch
26
+ import torch.nn as nn
27
+ import torch.nn.functional as F
28
+
29
+
30
+ class LowRankLinear(nn.Module):
31
+ """y = A (B x). A: out x r, B: r x in. (LLaMA projections carry no bias.)"""
32
+
33
+ def __init__(self, A: torch.Tensor, B: torch.Tensor):
34
+ super().__init__()
35
+ self.A = nn.Parameter(A)
36
+ self.B = nn.Parameter(B)
37
+
38
+ def forward(self, x):
39
+ return F.linear(F.linear(x, self.B), self.A)
40
+
41
+ @torch.no_grad()
42
+ def materialize_(self) -> nn.Linear:
43
+ """Replace this module with the dense W = A @ B (inference only; never call
44
+ while training -- it cuts the gradient path)."""
45
+ W = (self.A @ self.B).to(self.A.dtype)
46
+ dense = nn.Linear(self.B.shape[1], self.A.shape[0], bias=False,
47
+ device=W.device, dtype=W.dtype)
48
+ dense.weight.data = W
49
+ return dense
50
+
51
+
52
+ def build(base_id: str, ranks: dict, state_dict_path: str,
53
+ device: str = "cuda", dtype=torch.float16):
54
+ from transformers import AutoModelForCausalLM
55
+
56
+ model = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=dtype)
57
+ search = {}
58
+ for name, mod in model.named_modules():
59
+ if isinstance(mod, nn.Linear):
60
+ search[name] = mod
61
+ for path, k in ranks.items():
62
+ out_f, in_f = search[path].weight.shape
63
+ model_mod = model
64
+ for p in path.split(".")[:-1]:
65
+ model_mod = getattr(model_mod, p)
66
+ setattr(model_mod, path.split(".")[-1],
67
+ LowRankLinear(torch.zeros(out_f, int(k), dtype=dtype),
68
+ torch.zeros(int(k), in_f, dtype=dtype)))
69
+ sd = torch.load(state_dict_path, map_location="cpu", weights_only=True)
70
+ model.load_state_dict(sd, strict=True)
71
+ del sd
72
+ return model.to(device)
73
+
74
+
75
+ def materialize_all(model):
76
+ """Fuse every LowRankLinear back into a dense nn.Linear in place."""
77
+ for name, mod in list(model.named_modules()):
78
+ if isinstance(mod, LowRankLinear):
79
+ parent = model
80
+ for p in name.split(".")[:-1]:
81
+ parent = getattr(parent, p)
82
+ setattr(parent, name.split(".")[-1], mod.materialize_())
83
+ return model
svd-llm-v2-13b-unhealed/provenance.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "kind": "unhealed SVD compression (TR3-format conversion, verified pure re-keying)",
3
+ "source_ckpt": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm2_llama2_13b_chat_r04158/NousResearch_Llama_2_13b_chat_hf_svdllmv2_keep_0.5740.pt",
4
+ "converted_state_dict": "/data1/rkp00022/zixuan/projects/TR3_main/scratch/hf_push_13b/svd-llm-v2-13b-unhealed/state_dict_fp16.pt",
5
+ "state_dict_sha256": "f0dbe9c89696d52b78344dc7564c8c5bc6bb57ecf7cd95edaa26e6738db87e23",
6
+ "healed_counterpart": "svd-llm-v2-13b/state_dict_fp16.pt"
7
+ }
svd-llm-v2-13b-unhealed/ranks.json ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model.layers.0.self_attn.q_proj": 2560,
3
+ "model.layers.0.self_attn.k_proj": 2560,
4
+ "model.layers.0.self_attn.v_proj": 2560,
5
+ "model.layers.0.self_attn.o_proj": 2560,
6
+ "model.layers.0.mlp.gate_proj": 3237,
7
+ "model.layers.0.mlp.up_proj": 3231,
8
+ "model.layers.0.mlp.down_proj": 3674,
9
+ "model.layers.1.self_attn.q_proj": 2514,
10
+ "model.layers.1.self_attn.k_proj": 2553,
11
+ "model.layers.1.self_attn.v_proj": 2288,
12
+ "model.layers.1.self_attn.o_proj": 2560,
13
+ "model.layers.1.mlp.gate_proj": 2862,
14
+ "model.layers.1.mlp.up_proj": 2816,
15
+ "model.layers.1.mlp.down_proj": 2909,
16
+ "model.layers.2.self_attn.q_proj": 1842,
17
+ "model.layers.2.self_attn.k_proj": 1847,
18
+ "model.layers.2.self_attn.v_proj": 1839,
19
+ "model.layers.2.self_attn.o_proj": 2126,
20
+ "model.layers.2.mlp.gate_proj": 2506,
21
+ "model.layers.2.mlp.up_proj": 2500,
22
+ "model.layers.2.mlp.down_proj": 2665,
23
+ "model.layers.3.self_attn.q_proj": 1735,
24
+ "model.layers.3.self_attn.k_proj": 1735,
25
+ "model.layers.3.self_attn.v_proj": 1742,
26
+ "model.layers.3.self_attn.o_proj": 2020,
27
+ "model.layers.3.mlp.gate_proj": 2363,
28
+ "model.layers.3.mlp.up_proj": 2369,
29
+ "model.layers.3.mlp.down_proj": 2569,
30
+ "model.layers.4.self_attn.q_proj": 1618,
31
+ "model.layers.4.self_attn.k_proj": 1618,
32
+ "model.layers.4.self_attn.v_proj": 1651,
33
+ "model.layers.4.self_attn.o_proj": 1888,
34
+ "model.layers.4.mlp.gate_proj": 2302,
35
+ "model.layers.4.mlp.up_proj": 2310,
36
+ "model.layers.4.mlp.down_proj": 2471,
37
+ "model.layers.5.self_attn.q_proj": 1603,
38
+ "model.layers.5.self_attn.k_proj": 1601,
39
+ "model.layers.5.self_attn.v_proj": 1624,
40
+ "model.layers.5.self_attn.o_proj": 1818,
41
+ "model.layers.5.mlp.gate_proj": 2253,
42
+ "model.layers.5.mlp.up_proj": 2262,
43
+ "model.layers.5.mlp.down_proj": 2388,
44
+ "model.layers.6.self_attn.q_proj": 1555,
45
+ "model.layers.6.self_attn.k_proj": 1551,
46
+ "model.layers.6.self_attn.v_proj": 1588,
47
+ "model.layers.6.self_attn.o_proj": 1778,
48
+ "model.layers.6.mlp.gate_proj": 2218,
49
+ "model.layers.6.mlp.up_proj": 2227,
50
+ "model.layers.6.mlp.down_proj": 2327,
51
+ "model.layers.7.self_attn.q_proj": 1556,
52
+ "model.layers.7.self_attn.k_proj": 1552,
53
+ "model.layers.7.self_attn.v_proj": 1590,
54
+ "model.layers.7.self_attn.o_proj": 1701,
55
+ "model.layers.7.mlp.gate_proj": 2199,
56
+ "model.layers.7.mlp.up_proj": 2208,
57
+ "model.layers.7.mlp.down_proj": 2277,
58
+ "model.layers.8.self_attn.q_proj": 1535,
59
+ "model.layers.8.self_attn.k_proj": 1531,
60
+ "model.layers.8.self_attn.v_proj": 1565,
61
+ "model.layers.8.self_attn.o_proj": 1663,
62
+ "model.layers.8.mlp.gate_proj": 2184,
63
+ "model.layers.8.mlp.up_proj": 2190,
64
+ "model.layers.8.mlp.down_proj": 2244,
65
+ "model.layers.9.self_attn.q_proj": 1504,
66
+ "model.layers.9.self_attn.k_proj": 1501,
67
+ "model.layers.9.self_attn.v_proj": 1544,
68
+ "model.layers.9.self_attn.o_proj": 1630,
69
+ "model.layers.9.mlp.gate_proj": 2169,
70
+ "model.layers.9.mlp.up_proj": 2170,
71
+ "model.layers.9.mlp.down_proj": 2219,
72
+ "model.layers.10.self_attn.q_proj": 1507,
73
+ "model.layers.10.self_attn.k_proj": 1506,
74
+ "model.layers.10.self_attn.v_proj": 1551,
75
+ "model.layers.10.self_attn.o_proj": 1583,
76
+ "model.layers.10.mlp.gate_proj": 2166,
77
+ "model.layers.10.mlp.up_proj": 2164,
78
+ "model.layers.10.mlp.down_proj": 2197,
79
+ "model.layers.11.self_attn.q_proj": 1509,
80
+ "model.layers.11.self_attn.k_proj": 1503,
81
+ "model.layers.11.self_attn.v_proj": 1554,
82
+ "model.layers.11.self_attn.o_proj": 1577,
83
+ "model.layers.11.mlp.gate_proj": 2165,
84
+ "model.layers.11.mlp.up_proj": 2159,
85
+ "model.layers.11.mlp.down_proj": 2180,
86
+ "model.layers.12.self_attn.q_proj": 1501,
87
+ "model.layers.12.self_attn.k_proj": 1495,
88
+ "model.layers.12.self_attn.v_proj": 1534,
89
+ "model.layers.12.self_attn.o_proj": 1552,
90
+ "model.layers.12.mlp.gate_proj": 2158,
91
+ "model.layers.12.mlp.up_proj": 2148,
92
+ "model.layers.12.mlp.down_proj": 2164,
93
+ "model.layers.13.self_attn.q_proj": 1494,
94
+ "model.layers.13.self_attn.k_proj": 1494,
95
+ "model.layers.13.self_attn.v_proj": 1514,
96
+ "model.layers.13.self_attn.o_proj": 1534,
97
+ "model.layers.13.mlp.gate_proj": 2149,
98
+ "model.layers.13.mlp.up_proj": 2138,
99
+ "model.layers.13.mlp.down_proj": 2142,
100
+ "model.layers.14.self_attn.q_proj": 1482,
101
+ "model.layers.14.self_attn.k_proj": 1480,
102
+ "model.layers.14.self_attn.v_proj": 1512,
103
+ "model.layers.14.self_attn.o_proj": 1499,
104
+ "model.layers.14.mlp.gate_proj": 2141,
105
+ "model.layers.14.mlp.up_proj": 2129,
106
+ "model.layers.14.mlp.down_proj": 2122,
107
+ "model.layers.15.self_attn.q_proj": 1486,
108
+ "model.layers.15.self_attn.k_proj": 1482,
109
+ "model.layers.15.self_attn.v_proj": 1507,
110
+ "model.layers.15.self_attn.o_proj": 1512,
111
+ "model.layers.15.mlp.gate_proj": 2131,
112
+ "model.layers.15.mlp.up_proj": 2117,
113
+ "model.layers.15.mlp.down_proj": 2103,
114
+ "model.layers.16.self_attn.q_proj": 1476,
115
+ "model.layers.16.self_attn.k_proj": 1471,
116
+ "model.layers.16.self_attn.v_proj": 1490,
117
+ "model.layers.16.self_attn.o_proj": 1504,
118
+ "model.layers.16.mlp.gate_proj": 2121,
119
+ "model.layers.16.mlp.up_proj": 2107,
120
+ "model.layers.16.mlp.down_proj": 2077,
121
+ "model.layers.17.self_attn.q_proj": 1468,
122
+ "model.layers.17.self_attn.k_proj": 1466,
123
+ "model.layers.17.self_attn.v_proj": 1482,
124
+ "model.layers.17.self_attn.o_proj": 1491,
125
+ "model.layers.17.mlp.gate_proj": 2108,
126
+ "model.layers.17.mlp.up_proj": 2098,
127
+ "model.layers.17.mlp.down_proj": 2066,
128
+ "model.layers.18.self_attn.q_proj": 1455,
129
+ "model.layers.18.self_attn.k_proj": 1453,
130
+ "model.layers.18.self_attn.v_proj": 1469,
131
+ "model.layers.18.self_attn.o_proj": 1498,
132
+ "model.layers.18.mlp.gate_proj": 2094,
133
+ "model.layers.18.mlp.up_proj": 2088,
134
+ "model.layers.18.mlp.down_proj": 2058,
135
+ "model.layers.19.self_attn.q_proj": 1461,
136
+ "model.layers.19.self_attn.k_proj": 1460,
137
+ "model.layers.19.self_attn.v_proj": 1468,
138
+ "model.layers.19.self_attn.o_proj": 1499,
139
+ "model.layers.19.mlp.gate_proj": 2083,
140
+ "model.layers.19.mlp.up_proj": 2079,
141
+ "model.layers.19.mlp.down_proj": 2044,
142
+ "model.layers.20.self_attn.q_proj": 1462,
143
+ "model.layers.20.self_attn.k_proj": 1462,
144
+ "model.layers.20.self_attn.v_proj": 1474,
145
+ "model.layers.20.self_attn.o_proj": 1480,
146
+ "model.layers.20.mlp.gate_proj": 2077,
147
+ "model.layers.20.mlp.up_proj": 2074,
148
+ "model.layers.20.mlp.down_proj": 2030,
149
+ "model.layers.21.self_attn.q_proj": 1464,
150
+ "model.layers.21.self_attn.k_proj": 1464,
151
+ "model.layers.21.self_attn.v_proj": 1463,
152
+ "model.layers.21.self_attn.o_proj": 1460,
153
+ "model.layers.21.mlp.gate_proj": 2072,
154
+ "model.layers.21.mlp.up_proj": 2072,
155
+ "model.layers.21.mlp.down_proj": 2010,
156
+ "model.layers.22.self_attn.q_proj": 1436,
157
+ "model.layers.22.self_attn.k_proj": 1437,
158
+ "model.layers.22.self_attn.v_proj": 1442,
159
+ "model.layers.22.self_attn.o_proj": 1491,
160
+ "model.layers.22.mlp.gate_proj": 2061,
161
+ "model.layers.22.mlp.up_proj": 2063,
162
+ "model.layers.22.mlp.down_proj": 2003,
163
+ "model.layers.23.self_attn.q_proj": 1442,
164
+ "model.layers.23.self_attn.k_proj": 1443,
165
+ "model.layers.23.self_attn.v_proj": 1442,
166
+ "model.layers.23.self_attn.o_proj": 1488,
167
+ "model.layers.23.mlp.gate_proj": 2051,
168
+ "model.layers.23.mlp.up_proj": 2056,
169
+ "model.layers.23.mlp.down_proj": 1994,
170
+ "model.layers.24.self_attn.q_proj": 1433,
171
+ "model.layers.24.self_attn.k_proj": 1435,
172
+ "model.layers.24.self_attn.v_proj": 1436,
173
+ "model.layers.24.self_attn.o_proj": 1495,
174
+ "model.layers.24.mlp.gate_proj": 2044,
175
+ "model.layers.24.mlp.up_proj": 2050,
176
+ "model.layers.24.mlp.down_proj": 1988,
177
+ "model.layers.25.self_attn.q_proj": 1428,
178
+ "model.layers.25.self_attn.k_proj": 1428,
179
+ "model.layers.25.self_attn.v_proj": 1425,
180
+ "model.layers.25.self_attn.o_proj": 1475,
181
+ "model.layers.25.mlp.gate_proj": 2035,
182
+ "model.layers.25.mlp.up_proj": 2042,
183
+ "model.layers.25.mlp.down_proj": 1978,
184
+ "model.layers.26.self_attn.q_proj": 1424,
185
+ "model.layers.26.self_attn.k_proj": 1424,
186
+ "model.layers.26.self_attn.v_proj": 1421,
187
+ "model.layers.26.self_attn.o_proj": 1474,
188
+ "model.layers.26.mlp.gate_proj": 2027,
189
+ "model.layers.26.mlp.up_proj": 2035,
190
+ "model.layers.26.mlp.down_proj": 1969,
191
+ "model.layers.27.self_attn.q_proj": 1408,
192
+ "model.layers.27.self_attn.k_proj": 1409,
193
+ "model.layers.27.self_attn.v_proj": 1410,
194
+ "model.layers.27.self_attn.o_proj": 1474,
195
+ "model.layers.27.mlp.gate_proj": 2019,
196
+ "model.layers.27.mlp.up_proj": 2027,
197
+ "model.layers.27.mlp.down_proj": 1963,
198
+ "model.layers.28.self_attn.q_proj": 1409,
199
+ "model.layers.28.self_attn.k_proj": 1410,
200
+ "model.layers.28.self_attn.v_proj": 1408,
201
+ "model.layers.28.self_attn.o_proj": 1473,
202
+ "model.layers.28.mlp.gate_proj": 2010,
203
+ "model.layers.28.mlp.up_proj": 2017,
204
+ "model.layers.28.mlp.down_proj": 1955,
205
+ "model.layers.29.self_attn.q_proj": 1397,
206
+ "model.layers.29.self_attn.k_proj": 1398,
207
+ "model.layers.29.self_attn.v_proj": 1399,
208
+ "model.layers.29.self_attn.o_proj": 1464,
209
+ "model.layers.29.mlp.gate_proj": 2002,
210
+ "model.layers.29.mlp.up_proj": 2009,
211
+ "model.layers.29.mlp.down_proj": 1948,
212
+ "model.layers.30.self_attn.q_proj": 1389,
213
+ "model.layers.30.self_attn.k_proj": 1391,
214
+ "model.layers.30.self_attn.v_proj": 1385,
215
+ "model.layers.30.self_attn.o_proj": 1436,
216
+ "model.layers.30.mlp.gate_proj": 1993,
217
+ "model.layers.30.mlp.up_proj": 2001,
218
+ "model.layers.30.mlp.down_proj": 1941,
219
+ "model.layers.31.self_attn.q_proj": 1396,
220
+ "model.layers.31.self_attn.k_proj": 1396,
221
+ "model.layers.31.self_attn.v_proj": 1395,
222
+ "model.layers.31.self_attn.o_proj": 1446,
223
+ "model.layers.31.mlp.gate_proj": 1985,
224
+ "model.layers.31.mlp.up_proj": 1993,
225
+ "model.layers.31.mlp.down_proj": 1936,
226
+ "model.layers.32.self_attn.q_proj": 1393,
227
+ "model.layers.32.self_attn.k_proj": 1395,
228
+ "model.layers.32.self_attn.v_proj": 1383,
229
+ "model.layers.32.self_attn.o_proj": 1429,
230
+ "model.layers.32.mlp.gate_proj": 1979,
231
+ "model.layers.32.mlp.up_proj": 1985,
232
+ "model.layers.32.mlp.down_proj": 1929,
233
+ "model.layers.33.self_attn.q_proj": 1399,
234
+ "model.layers.33.self_attn.k_proj": 1400,
235
+ "model.layers.33.self_attn.v_proj": 1390,
236
+ "model.layers.33.self_attn.o_proj": 1430,
237
+ "model.layers.33.mlp.gate_proj": 1973,
238
+ "model.layers.33.mlp.up_proj": 1978,
239
+ "model.layers.33.mlp.down_proj": 1921,
240
+ "model.layers.34.self_attn.q_proj": 1401,
241
+ "model.layers.34.self_attn.k_proj": 1401,
242
+ "model.layers.34.self_attn.v_proj": 1383,
243
+ "model.layers.34.self_attn.o_proj": 1424,
244
+ "model.layers.34.mlp.gate_proj": 1968,
245
+ "model.layers.34.mlp.up_proj": 1972,
246
+ "model.layers.34.mlp.down_proj": 1910,
247
+ "model.layers.35.self_attn.q_proj": 1407,
248
+ "model.layers.35.self_attn.k_proj": 1407,
249
+ "model.layers.35.self_attn.v_proj": 1388,
250
+ "model.layers.35.self_attn.o_proj": 1412,
251
+ "model.layers.35.mlp.gate_proj": 1964,
252
+ "model.layers.35.mlp.up_proj": 1966,
253
+ "model.layers.35.mlp.down_proj": 1897,
254
+ "model.layers.36.self_attn.q_proj": 1417,
255
+ "model.layers.36.self_attn.k_proj": 1416,
256
+ "model.layers.36.self_attn.v_proj": 1392,
257
+ "model.layers.36.self_attn.o_proj": 1380,
258
+ "model.layers.36.mlp.gate_proj": 1962,
259
+ "model.layers.36.mlp.up_proj": 1963,
260
+ "model.layers.36.mlp.down_proj": 1882,
261
+ "model.layers.37.self_attn.q_proj": 1438,
262
+ "model.layers.37.self_attn.k_proj": 1436,
263
+ "model.layers.37.self_attn.v_proj": 1398,
264
+ "model.layers.37.self_attn.o_proj": 1391,
265
+ "model.layers.37.mlp.gate_proj": 1964,
266
+ "model.layers.37.mlp.up_proj": 1966,
267
+ "model.layers.37.mlp.down_proj": 1877,
268
+ "model.layers.38.self_attn.q_proj": 1446,
269
+ "model.layers.38.self_attn.k_proj": 1442,
270
+ "model.layers.38.self_attn.v_proj": 1392,
271
+ "model.layers.38.self_attn.o_proj": 1376,
272
+ "model.layers.38.mlp.gate_proj": 1971,
273
+ "model.layers.38.mlp.up_proj": 1978,
274
+ "model.layers.38.mlp.down_proj": 1877,
275
+ "model.layers.39.self_attn.q_proj": 1470,
276
+ "model.layers.39.self_attn.k_proj": 1466,
277
+ "model.layers.39.self_attn.v_proj": 1423,
278
+ "model.layers.39.self_attn.o_proj": 1389,
279
+ "model.layers.39.mlp.gate_proj": 1998,
280
+ "model.layers.39.mlp.up_proj": 2011,
281
+ "model.layers.39.mlp.down_proj": 1865
282
+ }
svd-llm-v2-13b-unhealed/state_dict_fp16.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0dbe9c89696d52b78344dc7564c8c5bc6bb57ecf7cd95edaa26e6738db87e23
3
+ size 15480786677
svd-llm-v2-13b/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ base_model: NousResearch/Llama-2-13b-chat-hf
4
+ tags: [svd, low-rank, model-compression, llama2, knowledge-distillation]
5
+ ---
6
+
7
+ # SVD-LLM V2 @ 7.74B (59.47% kept of LLaMA-2-13B-chat), KD-healed 60M tokens
8
+
9
+ SVD-LLM V2 (NAACL 2025): heterogeneous ratio allocation (Alg. 1) + loss-optimized truncation (Alg. 2). Official code never released; our faithful implementation (see per-layer ranks in ranks.json). Exact budget match: 7,740,286,464 vs target 7,740,282,880.
10
+
11
+ - **HEALED checkpoint** (this dir). The matching **UNHEALED** pre-distillation weights are in
12
+ `svd-llm-v2-13b-unhealed/` — do not mix them up: same `ranks.json`, different `state_dict_fp16.pt` (see
13
+ `provenance.json` SHA256 here vs the unhealed dir's record).
14
+ - Healing: pure forward-KL distillation from frozen NousResearch/Llama-2-13b-chat-hf teacher,
15
+ 60M tokens, held-out KL **2.0268 -> 0.2858**, probe MMLU (5-shot, limit 40) **26.89% -> 44.96%**.
16
+ - Identical recipe/protocol to the TR-3 13B and the 7B SVD baselines (see their dirs).
17
+
18
+ ## Load
19
+
20
+ ```python
21
+ import json
22
+ from lowrank_linear import build, materialize_all
23
+ model = build("NousResearch/Llama-2-13b-chat-hf", json.load(open("ranks.json")),
24
+ "state_dict_fp16.pt", device="cuda")
25
+ materialize_all(model) # inference-only fusion U@V
26
+ ```
27
+
28
+ Full provenance (data mixture + revisions, decontamination, SHA256 of every input and
29
+ checkpoint, 12 x 5M milestone trajectory) in `provenance.json`.
svd-llm-v2-13b/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": null,
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 5120,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 13824,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 40,
15
+ "num_hidden_layers": 40,
16
+ "num_key_value_heads": 40,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "float16",
23
+ "transformers_version": "4.31.0.dev0",
24
+ "use_cache": true,
25
+ "vocab_size": 32000
26
+ }
svd-llm-v2-13b/lowrank_linear.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal standalone loader for the SVD-baseline compressed LLaMA-2-7B checkpoints.
2
+
3
+ No dependency beyond torch + transformers. The state_dict stores every compressed
4
+ projection as two factors of a LowRankLinear (A: out x k, B: k x in); ranks.json
5
+ holds the per-layer integer rank of each projection. Untouched parameters
6
+ (embeddings, norms) keep their stock transformers names.
7
+
8
+ Usage:
9
+ import json, torch
10
+ from lowrank_linear import build
11
+ model = build(
12
+ base_id="NousResearch/Llama-2-7b-chat-hf",
13
+ ranks=json.load(open("ranks.json")),
14
+ state_dict_path="state_dict_fp16.pt",
15
+ device="cuda", dtype=torch.float16,
16
+ )
17
+ tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
18
+ out = model.generate(tokenizer("2+2=", return_tensors="pt").to("cuda").input_ids,
19
+ max_new_tokens=16, do_sample=False)
20
+ print(tokenizer.decode(out[0]))
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import torch
26
+ import torch.nn as nn
27
+ import torch.nn.functional as F
28
+
29
+
30
+ class LowRankLinear(nn.Module):
31
+ """y = A (B x). A: out x r, B: r x in. (LLaMA projections carry no bias.)"""
32
+
33
+ def __init__(self, A: torch.Tensor, B: torch.Tensor):
34
+ super().__init__()
35
+ self.A = nn.Parameter(A)
36
+ self.B = nn.Parameter(B)
37
+
38
+ def forward(self, x):
39
+ return F.linear(F.linear(x, self.B), self.A)
40
+
41
+ @torch.no_grad()
42
+ def materialize_(self) -> nn.Linear:
43
+ """Replace this module with the dense W = A @ B (inference only; never call
44
+ while training -- it cuts the gradient path)."""
45
+ W = (self.A @ self.B).to(self.A.dtype)
46
+ dense = nn.Linear(self.B.shape[1], self.A.shape[0], bias=False,
47
+ device=W.device, dtype=W.dtype)
48
+ dense.weight.data = W
49
+ return dense
50
+
51
+
52
+ def build(base_id: str, ranks: dict, state_dict_path: str,
53
+ device: str = "cuda", dtype=torch.float16):
54
+ from transformers import AutoModelForCausalLM
55
+
56
+ model = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=dtype)
57
+ search = {}
58
+ for name, mod in model.named_modules():
59
+ if isinstance(mod, nn.Linear):
60
+ search[name] = mod
61
+ for path, k in ranks.items():
62
+ out_f, in_f = search[path].weight.shape
63
+ model_mod = model
64
+ for p in path.split(".")[:-1]:
65
+ model_mod = getattr(model_mod, p)
66
+ setattr(model_mod, path.split(".")[-1],
67
+ LowRankLinear(torch.zeros(out_f, int(k), dtype=dtype),
68
+ torch.zeros(int(k), in_f, dtype=dtype)))
69
+ sd = torch.load(state_dict_path, map_location="cpu", weights_only=True)
70
+ model.load_state_dict(sd, strict=True)
71
+ del sd
72
+ return model.to(device)
73
+
74
+
75
+ def materialize_all(model):
76
+ """Fuse every LowRankLinear back into a dense nn.Linear in place."""
77
+ for name, mod in list(model.named_modules()):
78
+ if isinstance(mod, LowRankLinear):
79
+ parent = model
80
+ for p in name.split(".")[:-1]:
81
+ parent = getattr(parent, p)
82
+ setattr(parent, name.split(".")[-1], mod.materialize_())
83
+ return model
svd-llm-v2-13b/provenance.json ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "method": "KD healing: alpha*T^2*KL(teacher||student) + (1-alpha)*CE",
3
+ "student_init": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm2_r04158_tr3fmt/state_dict_fp16.pt",
4
+ "teacher": "NousResearch/Llama-2-13b-chat-hf",
5
+ "alpha": 1.0,
6
+ "temperature": 1.0,
7
+ "lr": 2e-05,
8
+ "tokens_seen": 59998208,
9
+ "epochs": 0.228,
10
+ "global_batch_tokens": 32768,
11
+ "dataset_mixture_pre_exclusion": {
12
+ "alpaca": 50000,
13
+ "openhermes": 200000,
14
+ "ultrachat": 100000
15
+ },
16
+ "dataset_revisions": {
17
+ "tatsu-lab/alpaca": "dce01c9b08f87459cf36a430d809084718273017",
18
+ "teknium/OpenHermes-2.5": "b82037821055c377bed0d495e72e46de3bc72e84",
19
+ "HuggingFaceH4/ultrachat_200k": "8049631c405ae6576f93f445c6b8166f76f5505a"
20
+ },
21
+ "canonical_pool_excluded_texts": 10000,
22
+ "train_texts_after_exclusion": 356000,
23
+ "chat_texts": 340000,
24
+ "mmlu_aux_texts_kept": 16000,
25
+ "mmlu_aux_split": "cais/mmlu auxiliary_train (official TRAIN split, disjoint from the evaluated test split; audit verified 0/99842 exact overlap)",
26
+ "mmlu_aux_stats": {
27
+ "requested_groups": 16000,
28
+ "rendered_groups": 16000,
29
+ "shots": 5,
30
+ "rows_total": 99842,
31
+ "rows_dropped_by_decontam": 71,
32
+ "rows_clean": 99771,
33
+ "revision": "c30699e8356da336a370243923dbaf21066bb9fe",
34
+ "format": "MMLU-shaped (NOT byte-identical to lm-eval; auxiliary_train has no subject)"
35
+ },
36
+ "gold_label_supervision": false,
37
+ "attribution_note": "alpha=1.0 => pure KD, no gold-label CE, so any MMLU change is attributable to distillation on in-domain text. alpha<1 adds CE on text containing answers = labeled MCQ training, which is a DIFFERENT and weaker claim.",
38
+ "train_tokens_total": 263112704,
39
+ "decontamination": {
40
+ "removed": {
41
+ "alpaca": 11,
42
+ "openhermes": 120,
43
+ "ultrachat": 33
44
+ }
45
+ },
46
+ "start_kl": 2.026848241686821,
47
+ "final_kl": 0.28583861887454987,
48
+ "start_mmlu": 0.268859649122807,
49
+ "final_mmlu": 0.44956140350877194,
50
+ "history": [
51
+ {
52
+ "tokens_m": 5.01,
53
+ "step": 153,
54
+ "held_out_kl": 0.5490630865097046,
55
+ "mmlu": 0.42105263157894735
56
+ },
57
+ {
58
+ "tokens_m": 10.03,
59
+ "step": 306,
60
+ "held_out_kl": 0.5244443118572235,
61
+ "mmlu": 0.4337719298245614
62
+ },
63
+ {
64
+ "tokens_m": 15.01,
65
+ "step": 458,
66
+ "held_out_kl": 0.49302633106708527,
67
+ "mmlu": 0.4337719298245614
68
+ },
69
+ {
70
+ "tokens_m": 20.02,
71
+ "step": 611,
72
+ "held_out_kl": 0.47258753702044487,
73
+ "mmlu": 0.40964912280701754
74
+ },
75
+ {
76
+ "tokens_m": 25.0,
77
+ "step": 763,
78
+ "held_out_kl": 0.4351510964334011,
79
+ "mmlu": 0.4236842105263158
80
+ },
81
+ {
82
+ "tokens_m": 30.02,
83
+ "step": 916,
84
+ "held_out_kl": 0.39489416405558586,
85
+ "mmlu": 0.42412280701754385
86
+ },
87
+ {
88
+ "tokens_m": 35.03,
89
+ "step": 1069,
90
+ "held_out_kl": 0.36299458146095276,
91
+ "mmlu": 0.4359649122807018
92
+ },
93
+ {
94
+ "tokens_m": 40.01,
95
+ "step": 1221,
96
+ "held_out_kl": 0.33124174922704697,
97
+ "mmlu": 0.4219298245614035
98
+ },
99
+ {
100
+ "tokens_m": 45.02,
101
+ "step": 1374,
102
+ "held_out_kl": 0.30896387435495853,
103
+ "mmlu": 0.4355263157894737
104
+ },
105
+ {
106
+ "tokens_m": 50.0,
107
+ "step": 1526,
108
+ "held_out_kl": 0.2978489622473717,
109
+ "mmlu": 0.44605263157894737
110
+ },
111
+ {
112
+ "tokens_m": 55.02,
113
+ "step": 1679,
114
+ "held_out_kl": 0.28977251797914505,
115
+ "mmlu": 0.44605263157894737
116
+ },
117
+ {
118
+ "tokens_m": 60.0,
119
+ "step": 1831,
120
+ "held_out_kl": 0.28583861887454987,
121
+ "mmlu": 0.44956140350877194,
122
+ "final": true
123
+ }
124
+ ],
125
+ "teacher_mmlu_same_limit": 0.5442982456140351,
126
+ "checkpoint": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1/state_dict_fp16.pt",
127
+ "sha256": "1d7cee642e764d6041c21aa1c9177635d9dcc48da03de3d0869c834348a4a676",
128
+ "seed": 1234,
129
+ "mmlu_limit_per_subtask": 40,
130
+ "teacher_revision": "d73f5fa9c4bc135502e04c27b39660747172d76b",
131
+ "student_init_sha256": "f0dbe9c89696d52b78344dc7564c8c5bc6bb57ecf7cd95edaa26e6738db87e23",
132
+ "ranks_file": "/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/svdllm2_r04158_tr3fmt/ranks.json",
133
+ "ranks_sha256": "deedef0f4a8e33a06a5584b6e5417b5b8262342a1cfbcf797afe12e2fbfb9cc5",
134
+ "input_identity_gate": {
135
+ "student_ckpt": {
136
+ "key": "svdllm2_r04158_tr3fmt",
137
+ "sha256": "f0dbe9c89696d52b78344dc7564c8c5bc6bb57ecf7cd95edaa26e6738db87e23",
138
+ "status": "unregistered_allowed"
139
+ },
140
+ "ranks": {
141
+ "key": "svdllm2_r04158_tr3fmt",
142
+ "sha256": "deedef0f4a8e33a06a5584b6e5417b5b8262342a1cfbcf797afe12e2fbfb9cc5",
143
+ "status": "unregistered_allowed"
144
+ }
145
+ },
146
+ "train_seed": 1234,
147
+ "mmlu_seed": 1234,
148
+ "dynamic_batch": false,
149
+ "dbl": null,
150
+ "snapshot_milestones": true,
151
+ "snapshots": [
152
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1_snap15m'), 15.007744)",
153
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1_snap30m'), 30.015488)",
154
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1_snap45m'), 45.023232)",
155
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1_snap50m'), 50.003968)",
156
+ "(PosixPath('/data1/rkp00022/zixuan/projects/TR3_main/checkpoints/kdheal_svdllm2r04158_h1_snap55m'), 55.017472)"
157
+ ],
158
+ "stream_skip_tokens_m": 0.0,
159
+ "stream_blocks_consumed": [
160
+ 0,
161
+ 58592
162
+ ],
163
+ "stream_note": "the block order is a seeded permutation consumed from index 0; stages sharing a --seed with stream_skip=0 re-train on the SAME blocks. [start, end] block indices are recorded so any continuation can be checked for overlap with what earlier stages consumed.",
164
+ "student_master_dtype": "bf16",
165
+ "fake_quant": null,
166
+ "rebalance_report": null,
167
+ "student_param_count": 7740286464,
168
+ "micro": 8,
169
+ "grad_accum": 4,
170
+ "seq_len": 1024,
171
+ "held_out_source": "canonical: mixture 2000/4000/4000, seed 1234, seq 1024, blocks 256:264 (identical to the compression gates)",
172
+ "decontam_stats": {
173
+ "mmlu": {
174
+ "items": 14042,
175
+ "new_ngrams": 764261,
176
+ "revision": "c30699e8356da336a370243923dbaf21066bb9fe"
177
+ },
178
+ "hellaswag": {
179
+ "items": 10042,
180
+ "new_ngrams": 1334302,
181
+ "revision": "218ec52e09a7e7462a5400043bb9a69a41d06b76"
182
+ },
183
+ "boolq": {
184
+ "items": 3270,
185
+ "new_ngrams": 276806,
186
+ "revision": "3de24cf8022e94f4ee4b9d55a6f539891524d646"
187
+ },
188
+ "triviaqa": {
189
+ "items": 17944,
190
+ "new_ngrams": 32608,
191
+ "revision": "0f7faf33a3908546c6fd5b73a660e0f8ff173c2f"
192
+ },
193
+ "gsm8k": {
194
+ "items": 1319,
195
+ "new_ngrams": 46281,
196
+ "revision": "740312add88f781978c0658806c59bc2815b9866"
197
+ }
198
+ }
199
+ }
svd-llm-v2-13b/ranks.json ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model.layers.0.self_attn.q_proj": 2560,
3
+ "model.layers.0.self_attn.k_proj": 2560,
4
+ "model.layers.0.self_attn.v_proj": 2560,
5
+ "model.layers.0.self_attn.o_proj": 2560,
6
+ "model.layers.0.mlp.gate_proj": 3237,
7
+ "model.layers.0.mlp.up_proj": 3231,
8
+ "model.layers.0.mlp.down_proj": 3674,
9
+ "model.layers.1.self_attn.q_proj": 2514,
10
+ "model.layers.1.self_attn.k_proj": 2553,
11
+ "model.layers.1.self_attn.v_proj": 2288,
12
+ "model.layers.1.self_attn.o_proj": 2560,
13
+ "model.layers.1.mlp.gate_proj": 2862,
14
+ "model.layers.1.mlp.up_proj": 2816,
15
+ "model.layers.1.mlp.down_proj": 2909,
16
+ "model.layers.2.self_attn.q_proj": 1842,
17
+ "model.layers.2.self_attn.k_proj": 1847,
18
+ "model.layers.2.self_attn.v_proj": 1839,
19
+ "model.layers.2.self_attn.o_proj": 2126,
20
+ "model.layers.2.mlp.gate_proj": 2506,
21
+ "model.layers.2.mlp.up_proj": 2500,
22
+ "model.layers.2.mlp.down_proj": 2665,
23
+ "model.layers.3.self_attn.q_proj": 1735,
24
+ "model.layers.3.self_attn.k_proj": 1735,
25
+ "model.layers.3.self_attn.v_proj": 1742,
26
+ "model.layers.3.self_attn.o_proj": 2020,
27
+ "model.layers.3.mlp.gate_proj": 2363,
28
+ "model.layers.3.mlp.up_proj": 2369,
29
+ "model.layers.3.mlp.down_proj": 2569,
30
+ "model.layers.4.self_attn.q_proj": 1618,
31
+ "model.layers.4.self_attn.k_proj": 1618,
32
+ "model.layers.4.self_attn.v_proj": 1651,
33
+ "model.layers.4.self_attn.o_proj": 1888,
34
+ "model.layers.4.mlp.gate_proj": 2302,
35
+ "model.layers.4.mlp.up_proj": 2310,
36
+ "model.layers.4.mlp.down_proj": 2471,
37
+ "model.layers.5.self_attn.q_proj": 1603,
38
+ "model.layers.5.self_attn.k_proj": 1601,
39
+ "model.layers.5.self_attn.v_proj": 1624,
40
+ "model.layers.5.self_attn.o_proj": 1818,
41
+ "model.layers.5.mlp.gate_proj": 2253,
42
+ "model.layers.5.mlp.up_proj": 2262,
43
+ "model.layers.5.mlp.down_proj": 2388,
44
+ "model.layers.6.self_attn.q_proj": 1555,
45
+ "model.layers.6.self_attn.k_proj": 1551,
46
+ "model.layers.6.self_attn.v_proj": 1588,
47
+ "model.layers.6.self_attn.o_proj": 1778,
48
+ "model.layers.6.mlp.gate_proj": 2218,
49
+ "model.layers.6.mlp.up_proj": 2227,
50
+ "model.layers.6.mlp.down_proj": 2327,
51
+ "model.layers.7.self_attn.q_proj": 1556,
52
+ "model.layers.7.self_attn.k_proj": 1552,
53
+ "model.layers.7.self_attn.v_proj": 1590,
54
+ "model.layers.7.self_attn.o_proj": 1701,
55
+ "model.layers.7.mlp.gate_proj": 2199,
56
+ "model.layers.7.mlp.up_proj": 2208,
57
+ "model.layers.7.mlp.down_proj": 2277,
58
+ "model.layers.8.self_attn.q_proj": 1535,
59
+ "model.layers.8.self_attn.k_proj": 1531,
60
+ "model.layers.8.self_attn.v_proj": 1565,
61
+ "model.layers.8.self_attn.o_proj": 1663,
62
+ "model.layers.8.mlp.gate_proj": 2184,
63
+ "model.layers.8.mlp.up_proj": 2190,
64
+ "model.layers.8.mlp.down_proj": 2244,
65
+ "model.layers.9.self_attn.q_proj": 1504,
66
+ "model.layers.9.self_attn.k_proj": 1501,
67
+ "model.layers.9.self_attn.v_proj": 1544,
68
+ "model.layers.9.self_attn.o_proj": 1630,
69
+ "model.layers.9.mlp.gate_proj": 2169,
70
+ "model.layers.9.mlp.up_proj": 2170,
71
+ "model.layers.9.mlp.down_proj": 2219,
72
+ "model.layers.10.self_attn.q_proj": 1507,
73
+ "model.layers.10.self_attn.k_proj": 1506,
74
+ "model.layers.10.self_attn.v_proj": 1551,
75
+ "model.layers.10.self_attn.o_proj": 1583,
76
+ "model.layers.10.mlp.gate_proj": 2166,
77
+ "model.layers.10.mlp.up_proj": 2164,
78
+ "model.layers.10.mlp.down_proj": 2197,
79
+ "model.layers.11.self_attn.q_proj": 1509,
80
+ "model.layers.11.self_attn.k_proj": 1503,
81
+ "model.layers.11.self_attn.v_proj": 1554,
82
+ "model.layers.11.self_attn.o_proj": 1577,
83
+ "model.layers.11.mlp.gate_proj": 2165,
84
+ "model.layers.11.mlp.up_proj": 2159,
85
+ "model.layers.11.mlp.down_proj": 2180,
86
+ "model.layers.12.self_attn.q_proj": 1501,
87
+ "model.layers.12.self_attn.k_proj": 1495,
88
+ "model.layers.12.self_attn.v_proj": 1534,
89
+ "model.layers.12.self_attn.o_proj": 1552,
90
+ "model.layers.12.mlp.gate_proj": 2158,
91
+ "model.layers.12.mlp.up_proj": 2148,
92
+ "model.layers.12.mlp.down_proj": 2164,
93
+ "model.layers.13.self_attn.q_proj": 1494,
94
+ "model.layers.13.self_attn.k_proj": 1494,
95
+ "model.layers.13.self_attn.v_proj": 1514,
96
+ "model.layers.13.self_attn.o_proj": 1534,
97
+ "model.layers.13.mlp.gate_proj": 2149,
98
+ "model.layers.13.mlp.up_proj": 2138,
99
+ "model.layers.13.mlp.down_proj": 2142,
100
+ "model.layers.14.self_attn.q_proj": 1482,
101
+ "model.layers.14.self_attn.k_proj": 1480,
102
+ "model.layers.14.self_attn.v_proj": 1512,
103
+ "model.layers.14.self_attn.o_proj": 1499,
104
+ "model.layers.14.mlp.gate_proj": 2141,
105
+ "model.layers.14.mlp.up_proj": 2129,
106
+ "model.layers.14.mlp.down_proj": 2122,
107
+ "model.layers.15.self_attn.q_proj": 1486,
108
+ "model.layers.15.self_attn.k_proj": 1482,
109
+ "model.layers.15.self_attn.v_proj": 1507,
110
+ "model.layers.15.self_attn.o_proj": 1512,
111
+ "model.layers.15.mlp.gate_proj": 2131,
112
+ "model.layers.15.mlp.up_proj": 2117,
113
+ "model.layers.15.mlp.down_proj": 2103,
114
+ "model.layers.16.self_attn.q_proj": 1476,
115
+ "model.layers.16.self_attn.k_proj": 1471,
116
+ "model.layers.16.self_attn.v_proj": 1490,
117
+ "model.layers.16.self_attn.o_proj": 1504,
118
+ "model.layers.16.mlp.gate_proj": 2121,
119
+ "model.layers.16.mlp.up_proj": 2107,
120
+ "model.layers.16.mlp.down_proj": 2077,
121
+ "model.layers.17.self_attn.q_proj": 1468,
122
+ "model.layers.17.self_attn.k_proj": 1466,
123
+ "model.layers.17.self_attn.v_proj": 1482,
124
+ "model.layers.17.self_attn.o_proj": 1491,
125
+ "model.layers.17.mlp.gate_proj": 2108,
126
+ "model.layers.17.mlp.up_proj": 2098,
127
+ "model.layers.17.mlp.down_proj": 2066,
128
+ "model.layers.18.self_attn.q_proj": 1455,
129
+ "model.layers.18.self_attn.k_proj": 1453,
130
+ "model.layers.18.self_attn.v_proj": 1469,
131
+ "model.layers.18.self_attn.o_proj": 1498,
132
+ "model.layers.18.mlp.gate_proj": 2094,
133
+ "model.layers.18.mlp.up_proj": 2088,
134
+ "model.layers.18.mlp.down_proj": 2058,
135
+ "model.layers.19.self_attn.q_proj": 1461,
136
+ "model.layers.19.self_attn.k_proj": 1460,
137
+ "model.layers.19.self_attn.v_proj": 1468,
138
+ "model.layers.19.self_attn.o_proj": 1499,
139
+ "model.layers.19.mlp.gate_proj": 2083,
140
+ "model.layers.19.mlp.up_proj": 2079,
141
+ "model.layers.19.mlp.down_proj": 2044,
142
+ "model.layers.20.self_attn.q_proj": 1462,
143
+ "model.layers.20.self_attn.k_proj": 1462,
144
+ "model.layers.20.self_attn.v_proj": 1474,
145
+ "model.layers.20.self_attn.o_proj": 1480,
146
+ "model.layers.20.mlp.gate_proj": 2077,
147
+ "model.layers.20.mlp.up_proj": 2074,
148
+ "model.layers.20.mlp.down_proj": 2030,
149
+ "model.layers.21.self_attn.q_proj": 1464,
150
+ "model.layers.21.self_attn.k_proj": 1464,
151
+ "model.layers.21.self_attn.v_proj": 1463,
152
+ "model.layers.21.self_attn.o_proj": 1460,
153
+ "model.layers.21.mlp.gate_proj": 2072,
154
+ "model.layers.21.mlp.up_proj": 2072,
155
+ "model.layers.21.mlp.down_proj": 2010,
156
+ "model.layers.22.self_attn.q_proj": 1436,
157
+ "model.layers.22.self_attn.k_proj": 1437,
158
+ "model.layers.22.self_attn.v_proj": 1442,
159
+ "model.layers.22.self_attn.o_proj": 1491,
160
+ "model.layers.22.mlp.gate_proj": 2061,
161
+ "model.layers.22.mlp.up_proj": 2063,
162
+ "model.layers.22.mlp.down_proj": 2003,
163
+ "model.layers.23.self_attn.q_proj": 1442,
164
+ "model.layers.23.self_attn.k_proj": 1443,
165
+ "model.layers.23.self_attn.v_proj": 1442,
166
+ "model.layers.23.self_attn.o_proj": 1488,
167
+ "model.layers.23.mlp.gate_proj": 2051,
168
+ "model.layers.23.mlp.up_proj": 2056,
169
+ "model.layers.23.mlp.down_proj": 1994,
170
+ "model.layers.24.self_attn.q_proj": 1433,
171
+ "model.layers.24.self_attn.k_proj": 1435,
172
+ "model.layers.24.self_attn.v_proj": 1436,
173
+ "model.layers.24.self_attn.o_proj": 1495,
174
+ "model.layers.24.mlp.gate_proj": 2044,
175
+ "model.layers.24.mlp.up_proj": 2050,
176
+ "model.layers.24.mlp.down_proj": 1988,
177
+ "model.layers.25.self_attn.q_proj": 1428,
178
+ "model.layers.25.self_attn.k_proj": 1428,
179
+ "model.layers.25.self_attn.v_proj": 1425,
180
+ "model.layers.25.self_attn.o_proj": 1475,
181
+ "model.layers.25.mlp.gate_proj": 2035,
182
+ "model.layers.25.mlp.up_proj": 2042,
183
+ "model.layers.25.mlp.down_proj": 1978,
184
+ "model.layers.26.self_attn.q_proj": 1424,
185
+ "model.layers.26.self_attn.k_proj": 1424,
186
+ "model.layers.26.self_attn.v_proj": 1421,
187
+ "model.layers.26.self_attn.o_proj": 1474,
188
+ "model.layers.26.mlp.gate_proj": 2027,
189
+ "model.layers.26.mlp.up_proj": 2035,
190
+ "model.layers.26.mlp.down_proj": 1969,
191
+ "model.layers.27.self_attn.q_proj": 1408,
192
+ "model.layers.27.self_attn.k_proj": 1409,
193
+ "model.layers.27.self_attn.v_proj": 1410,
194
+ "model.layers.27.self_attn.o_proj": 1474,
195
+ "model.layers.27.mlp.gate_proj": 2019,
196
+ "model.layers.27.mlp.up_proj": 2027,
197
+ "model.layers.27.mlp.down_proj": 1963,
198
+ "model.layers.28.self_attn.q_proj": 1409,
199
+ "model.layers.28.self_attn.k_proj": 1410,
200
+ "model.layers.28.self_attn.v_proj": 1408,
201
+ "model.layers.28.self_attn.o_proj": 1473,
202
+ "model.layers.28.mlp.gate_proj": 2010,
203
+ "model.layers.28.mlp.up_proj": 2017,
204
+ "model.layers.28.mlp.down_proj": 1955,
205
+ "model.layers.29.self_attn.q_proj": 1397,
206
+ "model.layers.29.self_attn.k_proj": 1398,
207
+ "model.layers.29.self_attn.v_proj": 1399,
208
+ "model.layers.29.self_attn.o_proj": 1464,
209
+ "model.layers.29.mlp.gate_proj": 2002,
210
+ "model.layers.29.mlp.up_proj": 2009,
211
+ "model.layers.29.mlp.down_proj": 1948,
212
+ "model.layers.30.self_attn.q_proj": 1389,
213
+ "model.layers.30.self_attn.k_proj": 1391,
214
+ "model.layers.30.self_attn.v_proj": 1385,
215
+ "model.layers.30.self_attn.o_proj": 1436,
216
+ "model.layers.30.mlp.gate_proj": 1993,
217
+ "model.layers.30.mlp.up_proj": 2001,
218
+ "model.layers.30.mlp.down_proj": 1941,
219
+ "model.layers.31.self_attn.q_proj": 1396,
220
+ "model.layers.31.self_attn.k_proj": 1396,
221
+ "model.layers.31.self_attn.v_proj": 1395,
222
+ "model.layers.31.self_attn.o_proj": 1446,
223
+ "model.layers.31.mlp.gate_proj": 1985,
224
+ "model.layers.31.mlp.up_proj": 1993,
225
+ "model.layers.31.mlp.down_proj": 1936,
226
+ "model.layers.32.self_attn.q_proj": 1393,
227
+ "model.layers.32.self_attn.k_proj": 1395,
228
+ "model.layers.32.self_attn.v_proj": 1383,
229
+ "model.layers.32.self_attn.o_proj": 1429,
230
+ "model.layers.32.mlp.gate_proj": 1979,
231
+ "model.layers.32.mlp.up_proj": 1985,
232
+ "model.layers.32.mlp.down_proj": 1929,
233
+ "model.layers.33.self_attn.q_proj": 1399,
234
+ "model.layers.33.self_attn.k_proj": 1400,
235
+ "model.layers.33.self_attn.v_proj": 1390,
236
+ "model.layers.33.self_attn.o_proj": 1430,
237
+ "model.layers.33.mlp.gate_proj": 1973,
238
+ "model.layers.33.mlp.up_proj": 1978,
239
+ "model.layers.33.mlp.down_proj": 1921,
240
+ "model.layers.34.self_attn.q_proj": 1401,
241
+ "model.layers.34.self_attn.k_proj": 1401,
242
+ "model.layers.34.self_attn.v_proj": 1383,
243
+ "model.layers.34.self_attn.o_proj": 1424,
244
+ "model.layers.34.mlp.gate_proj": 1968,
245
+ "model.layers.34.mlp.up_proj": 1972,
246
+ "model.layers.34.mlp.down_proj": 1910,
247
+ "model.layers.35.self_attn.q_proj": 1407,
248
+ "model.layers.35.self_attn.k_proj": 1407,
249
+ "model.layers.35.self_attn.v_proj": 1388,
250
+ "model.layers.35.self_attn.o_proj": 1412,
251
+ "model.layers.35.mlp.gate_proj": 1964,
252
+ "model.layers.35.mlp.up_proj": 1966,
253
+ "model.layers.35.mlp.down_proj": 1897,
254
+ "model.layers.36.self_attn.q_proj": 1417,
255
+ "model.layers.36.self_attn.k_proj": 1416,
256
+ "model.layers.36.self_attn.v_proj": 1392,
257
+ "model.layers.36.self_attn.o_proj": 1380,
258
+ "model.layers.36.mlp.gate_proj": 1962,
259
+ "model.layers.36.mlp.up_proj": 1963,
260
+ "model.layers.36.mlp.down_proj": 1882,
261
+ "model.layers.37.self_attn.q_proj": 1438,
262
+ "model.layers.37.self_attn.k_proj": 1436,
263
+ "model.layers.37.self_attn.v_proj": 1398,
264
+ "model.layers.37.self_attn.o_proj": 1391,
265
+ "model.layers.37.mlp.gate_proj": 1964,
266
+ "model.layers.37.mlp.up_proj": 1966,
267
+ "model.layers.37.mlp.down_proj": 1877,
268
+ "model.layers.38.self_attn.q_proj": 1446,
269
+ "model.layers.38.self_attn.k_proj": 1442,
270
+ "model.layers.38.self_attn.v_proj": 1392,
271
+ "model.layers.38.self_attn.o_proj": 1376,
272
+ "model.layers.38.mlp.gate_proj": 1971,
273
+ "model.layers.38.mlp.up_proj": 1978,
274
+ "model.layers.38.mlp.down_proj": 1877,
275
+ "model.layers.39.self_attn.q_proj": 1470,
276
+ "model.layers.39.self_attn.k_proj": 1466,
277
+ "model.layers.39.self_attn.v_proj": 1423,
278
+ "model.layers.39.self_attn.o_proj": 1389,
279
+ "model.layers.39.mlp.gate_proj": 1998,
280
+ "model.layers.39.mlp.up_proj": 2011,
281
+ "model.layers.39.mlp.down_proj": 1865
282
+ }
svd-llm-v2-13b/state_dict_fp16.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d7cee642e764d6041c21aa1c9177635d9dcc48da03de3d0869c834348a4a676
3
+ size 15480788552