Rhett1 commited on
Commit
c2be3ae
·
verified ·
1 Parent(s): 6a72563

Add TR-3 Qwen2.5-7B (31.89% reduction, healed on 60M tokens)

Browse files

Qwen2.5-7B-Instruct compressed to 5.19B and healed: KL 0.4965 -> 0.1397, MMLU 61.67% -> 67.11% against a 75.35% teacher (89.1% retained). Apache 2.0, unlike the 3B's research licence -- the root README now states that the two Qwen sizes carry different terms. Full five-task benchmark for this checkpoint is not yet measured and the card says so.

README.md CHANGED
@@ -18,19 +18,41 @@ with pure forward-KL knowledge distillation from the corresponding dense teacher
18
  |---|---|---:|---:|---|
19
  | [`llama2-7b/`](./llama2-7b) | NousResearch/Llama-2-7b-chat-hf | 6.74B → 4.02B | 40.30% | `llama2` |
20
  | [`qwen2.5-3b/`](./qwen2.5-3b) | Qwen/Qwen2.5-3B-Instruct | 3.09B → 2.08B | 32.65% | `qwen-research` — **non-commercial only** |
 
21
 
22
  ## ⚠️ Licences differ per subdirectory — check before use
23
 
24
  There is no single licence for this repository. The Hub can only display one `license` field,
25
  so it is set to `other`; **the binding terms are the ones in each subdirectory**:
26
 
27
- - `llama2-7b/` is derived from Llama 2 and carries the **Llama 2 Community License**.
28
- - `qwen2.5-3b/` is derived from Qwen2.5-3B-Instruct and carries the **Qwen RESEARCH LICENSE
29
- AGREEMENT**, which permits **research and evaluation only**. Commercial use requires a
30
- separate licence from Alibaba Cloud. See `qwen2.5-3b/LICENSE` and `qwen2.5-3b/NOTICE`.
 
 
31
 
32
  Do not assume the terms of one subdirectory apply to another.
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  ## ⚠️ These are NOT standard `transformers` checkpoints
35
 
36
  `state_dict_fp16.pt` holds **ring cores**, not dense `nn.Linear` weights. Loading requires
@@ -38,26 +60,3 @@ rebuilding the architecture with the `TRLinear`/`SparseAugTRLinear` layers from
38
  `tensor_formats.py` shipped in each directory, using that directory's `ranks.json` for the
39
  per-layer topology. `AutoModelForCausalLM.from_pretrained()` will **not** work. Each
40
  subdirectory's README carries a complete loading recipe.
41
-
42
- ## Why the compression rates differ
43
-
44
- They are matched by the **damage compression inflicts**, not by the nominal rate. A measured
45
- budget sweep on Qwen2.5-3B shows that model collapses to chance at the ~40% used for the
46
- LLaMA-2 rows, so it is compressed to 32.65%, where its pre-heal KL (0.8882) sits in the same
47
- range as LLaMA-2-7B's at 40.30% (0.6915). Details and the full sweep are in
48
- `qwen2.5-3b/README.md`.
49
-
50
- ## Matched-budget SVD baselines (for the paper's Table 2)
51
-
52
- Two reference columns used in the study, compressed with **SVD-LLM / SVD-LLM V2** at the
53
- *same* LLaMA-2-7B budget as [`llama2-7b/`](./llama2-7b) (4.02B, 40.3% removed) and healed
54
- with the *identical* KD protocol, so structure — not recovery effort — explains the gap:
55
-
56
- | Directory | Method | Params | Licence |
57
- |---|---|---:|---|
58
- | [`svd-llm/`](./svd-llm) | SVD-LLM (ICLR 2025, official code) | 6.74B → 4.022B | `llama2` |
59
- | [`svd-llm-v2/`](./svd-llm-v2) | SVD-LLM V2 ‡ | 6.74B → 4.023B | `llama2` |
60
-
61
- ‡ Official V2 code was never released; this checkpoint is our faithful implementation of the
62
- published algorithms. Same non-standard format as the TR-3 directories: factors, not dense
63
- weights — load with the included `lowrank_linear.py`, see each subdirectory README.
 
18
  |---|---|---:|---:|---|
19
  | [`llama2-7b/`](./llama2-7b) | NousResearch/Llama-2-7b-chat-hf | 6.74B → 4.02B | 40.30% | `llama2` |
20
  | [`qwen2.5-3b/`](./qwen2.5-3b) | Qwen/Qwen2.5-3B-Instruct | 3.09B → 2.08B | 32.65% | `qwen-research` — **non-commercial only** |
21
+ | [`qwen2.5-7b/`](./qwen2.5-7b) | Qwen/Qwen2.5-7B-Instruct | 7.62B → 5.19B | 31.89% | `apache-2.0` |
22
 
23
  ## ⚠️ Licences differ per subdirectory — check before use
24
 
25
  There is no single licence for this repository. The Hub can only display one `license` field,
26
  so it is set to `other`; **the binding terms are the ones in each subdirectory**:
27
 
28
+ - `llama2-7b/` — **Llama 2 Community License**.
29
+ - `qwen2.5-3b/` — **Qwen RESEARCH LICENSE AGREEMENT**: research and evaluation only.
30
+ Commercial use requires a separate licence from Alibaba Cloud. See its `LICENSE` and `NOTICE`.
31
+ - `qwen2.5-7b/` — **Apache 2.0**. Note this differs from the 3B: Alibaba released the two
32
+ sizes under different terms, so the permissive licence here does **not** extend to
33
+ `qwen2.5-3b/`.
34
 
35
  Do not assume the terms of one subdirectory apply to another.
36
 
37
+ ## Why the compression rates differ
38
+
39
+ They are matched by the **damage compression inflicts**, not by the nominal rate. Measured
40
+ pre-heal held-out KL against each model's own dense teacher:
41
+
42
+ | Model | Reduction | pre-heal KL |
43
+ |---|---:|---:|
44
+ | Qwen2.5-7B | 31.89% | 0.4965 |
45
+ | LLaMA-2-7B | 40.30% | 0.6915 |
46
+ | Qwen2.5-3B | 32.65% | 0.8882 |
47
+ | Qwen2.5-7B | 40.60% | 2.0204 — collapses (MMLU below chance) |
48
+ | Qwen2.5-3B | 40.94% | 3.5810 — collapses |
49
+
50
+ Both Qwen2.5 sizes collapse to chance at the ~40% the LLaMA-2 rows tolerate, so they are
51
+ compressed less. Two effects are separable and both are real: damage falls with model size,
52
+ and at equal size and equal rate the Qwen2.5 architecture is harder to compress than LLaMA-2
53
+ (2.0204 vs 0.6915, both ~7B at ~40%). Scale mitigates the architecture effect but does not
54
+ remove it. Each subdirectory's README carries the budget sweep behind its own rate.
55
+
56
  ## ⚠️ These are NOT standard `transformers` checkpoints
57
 
58
  `state_dict_fp16.pt` holds **ring cores**, not dense `nn.Linear` weights. Loading requires
 
60
  `tensor_formats.py` shipped in each directory, using that directory's `ranks.json` for the
61
  per-layer topology. `AutoModelForCausalLM.from_pretrained()` will **not** work. Each
62
  subdirectory's README carries a complete loading recipe.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
qwen2.5-7b/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
qwen2.5-7b/README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-7B-Instruct
4
+ tags:
5
+ - tensor-decomposition
6
+ - tensor-ring
7
+ - model-compression
8
+ - qwen2
9
+ ---
10
+
11
+ # TR-3: Qwen2.5-7B-Instruct compressed with a Tensor Ring
12
+
13
+ Every attention and MLP projection replaced by a **3-site Tensor Ring** (a cyclic
14
+ tensor-network factorisation — the ring closes with a non-trivial boundary bond, so it is not
15
+ a train/TT) plus a 5% sparse residual, then healed with pure knowledge distillation.
16
+
17
+ - **5.187B parameters**, down from 7.616B — **31.89% reduction**
18
+ - **60M healing tokens**, pure forward-KL distillation from the unmodified 7B teacher (alpha=1, no gold labels)
19
+ - Held-out token-mean KL vs the teacher: **0.4965 → 0.1397**
20
+ - MMLU (5-shot, 40/subtask probe): **61.67% → 67.11%**, against the teacher's **75.35%** — **89.1% retained**
21
+
22
+ ## ⚠️ Full benchmark table not yet measured
23
+
24
+ The five-task evaluation (MMLU / HellaSwag / BoolQ / TriviaQA / GSM8K on the full benchmarks)
25
+ has **not been run on this checkpoint yet**. The numbers above come from healing-time probes:
26
+ KL on a held-out slice, and MMLU subsampled to 40 questions per subtask. They are internally
27
+ consistent and comparable to the other models in this study measured the same way, but they
28
+ are **not** the full-benchmark figures and should not be quoted as such.
29
+
30
+ For reference, the dense Qwen2.5-7B-Instruct teacher scores, on the full benchmarks under
31
+ `eval_protocol_qwen7b.json`:
32
+
33
+ | Task (shots) | Dense teacher |
34
+ |---|---:|
35
+ | MMLU (5-shot) | 74.25 |
36
+ | HellaSwag (10-shot) | 81.37 |
37
+ | BoolQ (0-shot) | 86.39 |
38
+ | TriviaQA (5-shot) | 53.19 |
39
+ | GSM8K (5-shot) | 75.51 |
40
+
41
+ This card will be updated when the compressed model's own row is measured.
42
+
43
+ ## Why 31.89% and not 40%
44
+
45
+ The LLaMA-2 rows of this study compress by ~40%. Qwen2.5 does not survive that:
46
+
47
+ | Model | Reduction | pre-heal KL | pre-heal MMLU |
48
+ |---|---:|---:|---:|
49
+ | Qwen2.5-7B | 40.60% | 2.0204 | 23.73% (below the 25% chance line) |
50
+ | **Qwen2.5-7B** | **31.89%** | **0.4965** | **61.67%** |
51
+ | Qwen2.5-3B | 40.94% | 3.5810 | 25.66% (chance) |
52
+ | LLaMA-2-7B | 40.30% | 0.6915 | 29.52% |
53
+
54
+ Rates are matched by the **damage compression inflicts**, not by the nominal percentage. At
55
+ 31.89% this model's pre-heal KL (0.4965) is *lower* than LLaMA-2-7B's at 40.30% (0.6915), so
56
+ it is if anything the more conservative of the two. Two measured points put the rate that
57
+ would match LLaMA-2-7B's KL exactly at ~33.95%.
58
+
59
+ Two effects are separable in this study and both are real: damage falls with model size
60
+ (Qwen2.5-3B 3.5810 → Qwen2.5-7B 2.0204 at ~40%), and at equal size and equal rate the
61
+ Qwen2.5 architecture is harder to compress than LLaMA-2 (2.0204 vs 0.6915, both ~7B at
62
+ ~40%). Scale mitigates but does not remove the architecture effect.
63
+
64
+ ## ⚠️ This is NOT a standard `transformers` checkpoint
65
+
66
+ `state_dict_fp16.pt` holds **ring cores**, not dense `nn.Linear` weights. Loading requires
67
+ rebuilding the architecture with the `TRLinear`/`SparseAugTRLinear` layers from
68
+ `tensor_formats.py` (included), using `ranks.json` for the per-layer topology. `config.json` is
69
+ the stock Qwen2.5-7B-Instruct config, included only as architecture metadata — you **cannot**
70
+ `AutoModelForCausalLM.from_pretrained()` this repository.
71
+
72
+ Three Qwen2 details the loader must respect, each verified against an instantiated model
73
+ rather than inferred from the config:
74
+
75
+ - **Grouped-query attention** — `k_proj`/`v_proj` emit 512, not 3584.
76
+ - **q/k/v biases** — Qwen2 hardcodes `bias=True` on these three projections and its config has
77
+ no `attention_bias` key at all, so reading the config alone reports "no bias" and is wrong.
78
+ The biases are preserved here; dropping them is silent, since the shapes still match.
79
+ - **Untied embeddings** — `tie_word_embeddings=false` on this model (unlike Qwen2.5-3B), so
80
+ input and output embeddings are stored separately.
81
+
82
+ ## How to load it
83
+
84
+ ```python
85
+ import json, torch
86
+ from transformers import AutoModelForCausalLM
87
+ from tensor_formats import TRLinear, SparseAugTRLinear
88
+
89
+ BASE = "Qwen/Qwen2.5-7B-Instruct"
90
+ m = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.float16)
91
+ ranks = json.load(open("ranks.json"))
92
+
93
+ def get_sub(root, path):
94
+ o = root
95
+ for p in path.split("."):
96
+ o = o[int(p)] if p.isdigit() else getattr(o, p)
97
+ return o
98
+
99
+ for path, spec in ranks.items():
100
+ parent = get_sub(m, path.rsplit(".", 1)[0])
101
+ leaf = path.rsplit(".", 1)[1]
102
+ osp = tuple(spec[k] for k in ("o1", "o2", "o3"))
103
+ isp = tuple(spec[k] for k in ("i1", "i2", "i3"))
104
+ rr = [spec[k] for k in ("r0", "r1", "r2")]
105
+ dims = [a * b for a, b in zip(osp, isp)]
106
+ cores = [torch.zeros(rr[k], dims[k], rr[(k + 1) % 3], dtype=torch.float16) for k in range(3)]
107
+ nnz = int(spec.get("nnz", 0))
108
+ old = getattr(parent, leaf) # q/k/v carry a bias in Qwen2; it must exist here
109
+ bias = torch.zeros(old.out_features, dtype=torch.float16) if old.bias is not None else None
110
+ if nnz:
111
+ layer = SparseAugTRLinear(cores, osp, isp, torch.zeros(nnz, dtype=torch.int64),
112
+ torch.zeros(nnz, dtype=torch.float16), bias=bias)
113
+ else:
114
+ layer = TRLinear(cores, osp, isp, bias=bias)
115
+ setattr(parent, leaf, layer)
116
+
117
+ sd = torch.load("state_dict_fp16.pt", map_location="cpu")
118
+ missing, unexpected = m.load_state_dict(sd, strict=False)
119
+ assert not missing and not unexpected, (len(missing), len(unexpected))
120
+ m.eval()
121
+
122
+ # INFERENCE ONLY. TRLinear.forward() re-contracts the ring on every call, which during
123
+ # generation happens once per layer per generated token. Caching the dense weight is far
124
+ # faster but cuts the gradient path, so never call this before or during training.
125
+ for mod in m.modules():
126
+ if isinstance(mod, TRLinear):
127
+ mod.materialize_()
128
+ ```
129
+
130
+ ## Reproduction notes
131
+
132
+ Protocol pinned in `eval_protocol_qwen7b.json` (shot counts, metric keys, dtype and seed are
133
+ identical to every other model in this study). Healing used `micro=16, grad_accum=1,
134
+ seq_len=1024` — `tokens_per_step = 16384`, the same global batch as every other run here;
135
+ only the split between micro-batch and accumulation differs, which changes float summation
136
+ order and nothing else.
qwen2.5-7b/config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151645,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 3584,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 18944,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 28,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 28,
16
+ "num_hidden_layers": 28,
17
+ "num_key_value_heads": 4,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_theta": 1000000.0,
20
+ "sliding_window": 131072,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "bfloat16",
23
+ "transformers_version": "4.43.1",
24
+ "use_cache": true,
25
+ "use_sliding_window": false,
26
+ "vocab_size": 152064
27
+ }
qwen2.5-7b/eval_protocol_qwen7b.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "Qwen/Qwen2.5-7B-Instruct",
3
+ "model_revision": "a09a35458c702b33eeacc393d103063234e8bc28",
4
+ "lm_eval_revision": "0.4.12",
5
+ "tasks": {
6
+ "mmlu": "mmlu",
7
+ "hellaswag": "hellaswag",
8
+ "boolq": "boolq",
9
+ "triviaqa": "triviaqa",
10
+ "gsm8k": "gsm8k"
11
+ },
12
+ "num_fewshot": {
13
+ "mmlu": 5,
14
+ "hellaswag": 10,
15
+ "boolq": 0,
16
+ "triviaqa": 5,
17
+ "gsm8k": 5
18
+ },
19
+ "apply_chat_template": false,
20
+ "batch_size": "auto",
21
+ "dtype": "float16",
22
+ "seed": 1234,
23
+ "score_scale": "fraction",
24
+ "result_parser": {
25
+ "mmlu": "acc,none",
26
+ "hellaswag": "acc_norm,none",
27
+ "boolq": "acc,none",
28
+ "triviaqa": "exact_match,remove_whitespace",
29
+ "gsm8k": "exact_match,strict-match"
30
+ },
31
+ "hardware": {
32
+ "gpus_max": 4,
33
+ "gpu_model": "NVIDIA GB200 (Grace-Blackwell NVL4, sm_100)",
34
+ "note": "RIKYU compute node, 4x GB200. Same stack as the other two protocols in this study."
35
+ },
36
+ "architecture": {
37
+ "model_type": "qwen2",
38
+ "hidden": 3584,
39
+ "intermediate": 18944,
40
+ "layers": 28,
41
+ "vocab": 152064,
42
+ "num_attention_heads": 28,
43
+ "num_key_value_heads": 4,
44
+ "head_dim": 128,
45
+ "q_out": 3584,
46
+ "kv_out": 512,
47
+ "tie_word_embeddings": false,
48
+ "qkv_bias": true,
49
+ "note": "Same three LLaMA departures the pipeline handles explicitly (GQA k/v=512 not 3584; q/k/v biases that Qwen2 hardcodes and its config does not advertise; here tie_word_embeddings is FALSE, unlike Qwen2.5-3B, so the embedding matrix is counted twice). Values are read from the model's own config at runtime, not from this file."
50
+ },
51
+ "parameter_budget": {
52
+ "dense_total": 7615616512,
53
+ "uncompressible_fraction": 0.1432,
54
+ "note": "HIGHEST uncompressible fraction of any model in this study: 14.32%, against Qwen2.5-3B's 10.09% and LLaMA-2-7B's 3.90%, because the vocabulary is 152064 and the embeddings are untied. Matching a 40.30% TOTAL reduction therefore requires removing 47.03% of the linear layers -- harder than the 44.82% that made the Qwen2.5-3B run collapse to chance. The MLP aspect ratio is also 5.29:1 (Qwen2.5-3B 5.38:1, LLaMA-2 2.70:1), the geometry that caps the ring rank. Which budget this model can actually take is measured, not assumed: see the sweep in artifacts/tr3_qwen7b_*.json.",
55
+ "candidate_budgets": {
56
+ "match_llama_40.30pct": {
57
+ "reduction": 0.403,
58
+ "target_params_b_flag": 4.2206
59
+ },
60
+ "match_qwen3b_31.82pct": {
61
+ "reduction": 0.3182,
62
+ "target_params_b_flag": 4.8661
63
+ }
64
+ }
65
+ },
66
+ "torch_deviation": {
67
+ "locked": "torch==2.4.1+cu121",
68
+ "actual": "torch==2.7.1+cu128",
69
+ "reason": "requirements.compactifai.lock.txt was exported from an x86_64 box. torch 2.4.1+cu121 ships no aarch64 wheel and its whole nvidia-*-cu12==12.1.x dependency stack is x86_64/win_amd64 only; independently, CUDA 12.1 predates Blackwell and GB200 is sm_100, needing CUDA 12.8+. Every other locked package is at its locked version. Forced, not chosen.",
70
+ "added_packages": {
71
+ "sentencepiece": "0.2.2",
72
+ "protobuf": "7.36.1",
73
+ "note": "Not in the lock at any version. Needed to convert tokenizer.model where a repo ships no prebuilt tokenizer.json."
74
+ }
75
+ },
76
+ "assumptions": [
77
+ "Model source: Qwen/Qwen2.5-7B-Instruct is not gated; pinned at a09a35458c702b33eeacc393d103063234e8bc28. Official repository, not a mirror.",
78
+ "Every protocol field except model_id/model_revision/hardware/architecture/parameter_budget is copied UNCHANGED from eval_protocol.json. Shot counts, metric keys, dtype, seed, batch_size and score_scale are identical across all three protocols, so rows differ in the model and the compression budget and nothing else.",
79
+ "apply_chat_template=false is kept for consistency with the LLaMA protocols even though Qwen2.5-3B-Instruct is instruction-tuned. This is a CONSISTENCY choice, not a claim that it is optimal for this model; an instruct model evaluated without its template will generally score below its templated number, and that affects the dense baseline and the compressed model alike.",
80
+ "Healing uses micro=8/grad_accum=2 where the LLaMA-2-7B run used 2/8. tokens_per_step = micro*grad_accum*seq_len = 16384 in both cases, so the global batch, step count and LR schedule are identical; only float summation order differs.",
81
+ "TriviaQA remains the least certain task, exactly as documented in the 7B protocol; the same 5-shot exact_match (remove_whitespace) convention is locked here."
82
+ ],
83
+ "gsm8k_artifact_caveat": {
84
+ "status": "EXPECTED BUT NOT YET MEASURED for this model.",
85
+ "why": "Qwen2.5-3B-Instruct scored 10.16% dense vs 41.77% compressed on GSM8K under apply_chat_template=false, an artifact of the dense instruct model being unable to emit a strict-match-extractable answer without its template while the healed model, distilled on 340k plain-text instruction examples, can. Qwen2.5-7B-Instruct is the same model family with the same template dependence, so the same distortion should be expected here.",
86
+ "instruction": "Do NOT report any GSM8K gain on this model as a capability improvement from compression. See eval_protocol_qwen3b.json gsm8k_artifact_caveat for the full evidence and the four-task average that shows the real degradation."
87
+ }
88
+ }
qwen2.5-7b/ranks.json ADDED
@@ -0,0 +1,2354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model.layers.0.self_attn.q_proj": {
3
+ "o1": 14,
4
+ "o2": 16,
5
+ "o3": 16,
6
+ "i1": 14,
7
+ "i2": 16,
8
+ "i3": 16,
9
+ "r0": 102,
10
+ "r1": 102,
11
+ "r2": 102,
12
+ "nnz": 642252
13
+ },
14
+ "model.layers.0.self_attn.k_proj": {
15
+ "o1": 8,
16
+ "o2": 8,
17
+ "o3": 8,
18
+ "i1": 14,
19
+ "i2": 16,
20
+ "i3": 16,
21
+ "r0": 53,
22
+ "r1": 53,
23
+ "r2": 53,
24
+ "nnz": 91750
25
+ },
26
+ "model.layers.0.self_attn.v_proj": {
27
+ "o1": 8,
28
+ "o2": 8,
29
+ "o3": 8,
30
+ "i1": 14,
31
+ "i2": 16,
32
+ "i3": 16,
33
+ "r0": 53,
34
+ "r1": 53,
35
+ "r2": 53,
36
+ "nnz": 91750
37
+ },
38
+ "model.layers.0.self_attn.o_proj": {
39
+ "o1": 14,
40
+ "o2": 16,
41
+ "o3": 16,
42
+ "i1": 14,
43
+ "i2": 16,
44
+ "i3": 16,
45
+ "r0": 102,
46
+ "r1": 102,
47
+ "r2": 102,
48
+ "nnz": 642252
49
+ },
50
+ "model.layers.0.mlp.gate_proj": {
51
+ "o1": 16,
52
+ "o2": 32,
53
+ "o3": 37,
54
+ "i1": 14,
55
+ "i2": 16,
56
+ "i3": 16,
57
+ "r0": 172,
58
+ "r1": 172,
59
+ "r2": 172,
60
+ "nnz": 3394764
61
+ },
62
+ "model.layers.0.mlp.up_proj": {
63
+ "o1": 16,
64
+ "o2": 32,
65
+ "o3": 37,
66
+ "i1": 14,
67
+ "i2": 16,
68
+ "i3": 16,
69
+ "r0": 172,
70
+ "r1": 172,
71
+ "r2": 172,
72
+ "nnz": 3394764
73
+ },
74
+ "model.layers.0.mlp.down_proj": {
75
+ "o1": 14,
76
+ "o2": 16,
77
+ "o3": 16,
78
+ "i1": 16,
79
+ "i2": 32,
80
+ "i3": 37,
81
+ "r0": 172,
82
+ "r1": 172,
83
+ "r2": 172,
84
+ "nnz": 3394764
85
+ },
86
+ "model.layers.1.self_attn.q_proj": {
87
+ "o1": 14,
88
+ "o2": 16,
89
+ "o3": 16,
90
+ "i1": 14,
91
+ "i2": 16,
92
+ "i3": 16,
93
+ "r0": 102,
94
+ "r1": 102,
95
+ "r2": 102,
96
+ "nnz": 642252
97
+ },
98
+ "model.layers.1.self_attn.k_proj": {
99
+ "o1": 8,
100
+ "o2": 8,
101
+ "o3": 8,
102
+ "i1": 14,
103
+ "i2": 16,
104
+ "i3": 16,
105
+ "r0": 53,
106
+ "r1": 53,
107
+ "r2": 53,
108
+ "nnz": 91750
109
+ },
110
+ "model.layers.1.self_attn.v_proj": {
111
+ "o1": 8,
112
+ "o2": 8,
113
+ "o3": 8,
114
+ "i1": 14,
115
+ "i2": 16,
116
+ "i3": 16,
117
+ "r0": 53,
118
+ "r1": 53,
119
+ "r2": 53,
120
+ "nnz": 91750
121
+ },
122
+ "model.layers.1.self_attn.o_proj": {
123
+ "o1": 14,
124
+ "o2": 16,
125
+ "o3": 16,
126
+ "i1": 14,
127
+ "i2": 16,
128
+ "i3": 16,
129
+ "r0": 102,
130
+ "r1": 102,
131
+ "r2": 102,
132
+ "nnz": 642252
133
+ },
134
+ "model.layers.1.mlp.gate_proj": {
135
+ "o1": 16,
136
+ "o2": 32,
137
+ "o3": 37,
138
+ "i1": 14,
139
+ "i2": 16,
140
+ "i3": 16,
141
+ "r0": 172,
142
+ "r1": 172,
143
+ "r2": 172,
144
+ "nnz": 3394764
145
+ },
146
+ "model.layers.1.mlp.up_proj": {
147
+ "o1": 16,
148
+ "o2": 32,
149
+ "o3": 37,
150
+ "i1": 14,
151
+ "i2": 16,
152
+ "i3": 16,
153
+ "r0": 172,
154
+ "r1": 172,
155
+ "r2": 172,
156
+ "nnz": 3394764
157
+ },
158
+ "model.layers.1.mlp.down_proj": {
159
+ "o1": 14,
160
+ "o2": 16,
161
+ "o3": 16,
162
+ "i1": 16,
163
+ "i2": 32,
164
+ "i3": 37,
165
+ "r0": 172,
166
+ "r1": 172,
167
+ "r2": 172,
168
+ "nnz": 3394764
169
+ },
170
+ "model.layers.2.self_attn.q_proj": {
171
+ "o1": 14,
172
+ "o2": 16,
173
+ "o3": 16,
174
+ "i1": 14,
175
+ "i2": 16,
176
+ "i3": 16,
177
+ "r0": 102,
178
+ "r1": 102,
179
+ "r2": 102,
180
+ "nnz": 642252
181
+ },
182
+ "model.layers.2.self_attn.k_proj": {
183
+ "o1": 8,
184
+ "o2": 8,
185
+ "o3": 8,
186
+ "i1": 14,
187
+ "i2": 16,
188
+ "i3": 16,
189
+ "r0": 53,
190
+ "r1": 53,
191
+ "r2": 53,
192
+ "nnz": 91750
193
+ },
194
+ "model.layers.2.self_attn.v_proj": {
195
+ "o1": 8,
196
+ "o2": 8,
197
+ "o3": 8,
198
+ "i1": 14,
199
+ "i2": 16,
200
+ "i3": 16,
201
+ "r0": 53,
202
+ "r1": 53,
203
+ "r2": 53,
204
+ "nnz": 91750
205
+ },
206
+ "model.layers.2.self_attn.o_proj": {
207
+ "o1": 14,
208
+ "o2": 16,
209
+ "o3": 16,
210
+ "i1": 14,
211
+ "i2": 16,
212
+ "i3": 16,
213
+ "r0": 102,
214
+ "r1": 102,
215
+ "r2": 102,
216
+ "nnz": 642252
217
+ },
218
+ "model.layers.2.mlp.gate_proj": {
219
+ "o1": 16,
220
+ "o2": 32,
221
+ "o3": 37,
222
+ "i1": 14,
223
+ "i2": 16,
224
+ "i3": 16,
225
+ "r0": 172,
226
+ "r1": 172,
227
+ "r2": 172,
228
+ "nnz": 3394764
229
+ },
230
+ "model.layers.2.mlp.up_proj": {
231
+ "o1": 16,
232
+ "o2": 32,
233
+ "o3": 37,
234
+ "i1": 14,
235
+ "i2": 16,
236
+ "i3": 16,
237
+ "r0": 172,
238
+ "r1": 172,
239
+ "r2": 172,
240
+ "nnz": 3394764
241
+ },
242
+ "model.layers.2.mlp.down_proj": {
243
+ "o1": 14,
244
+ "o2": 16,
245
+ "o3": 16,
246
+ "i1": 16,
247
+ "i2": 32,
248
+ "i3": 37,
249
+ "r0": 172,
250
+ "r1": 172,
251
+ "r2": 172,
252
+ "nnz": 3394764
253
+ },
254
+ "model.layers.3.self_attn.q_proj": {
255
+ "o1": 14,
256
+ "o2": 16,
257
+ "o3": 16,
258
+ "i1": 14,
259
+ "i2": 16,
260
+ "i3": 16,
261
+ "r0": 102,
262
+ "r1": 102,
263
+ "r2": 102,
264
+ "nnz": 642252
265
+ },
266
+ "model.layers.3.self_attn.k_proj": {
267
+ "o1": 8,
268
+ "o2": 8,
269
+ "o3": 8,
270
+ "i1": 14,
271
+ "i2": 16,
272
+ "i3": 16,
273
+ "r0": 53,
274
+ "r1": 53,
275
+ "r2": 53,
276
+ "nnz": 91750
277
+ },
278
+ "model.layers.3.self_attn.v_proj": {
279
+ "o1": 8,
280
+ "o2": 8,
281
+ "o3": 8,
282
+ "i1": 14,
283
+ "i2": 16,
284
+ "i3": 16,
285
+ "r0": 53,
286
+ "r1": 53,
287
+ "r2": 53,
288
+ "nnz": 91750
289
+ },
290
+ "model.layers.3.self_attn.o_proj": {
291
+ "o1": 14,
292
+ "o2": 16,
293
+ "o3": 16,
294
+ "i1": 14,
295
+ "i2": 16,
296
+ "i3": 16,
297
+ "r0": 102,
298
+ "r1": 102,
299
+ "r2": 102,
300
+ "nnz": 642252
301
+ },
302
+ "model.layers.3.mlp.gate_proj": {
303
+ "o1": 16,
304
+ "o2": 32,
305
+ "o3": 37,
306
+ "i1": 14,
307
+ "i2": 16,
308
+ "i3": 16,
309
+ "r0": 172,
310
+ "r1": 172,
311
+ "r2": 172,
312
+ "nnz": 3394764
313
+ },
314
+ "model.layers.3.mlp.up_proj": {
315
+ "o1": 16,
316
+ "o2": 32,
317
+ "o3": 37,
318
+ "i1": 14,
319
+ "i2": 16,
320
+ "i3": 16,
321
+ "r0": 172,
322
+ "r1": 172,
323
+ "r2": 172,
324
+ "nnz": 3394764
325
+ },
326
+ "model.layers.3.mlp.down_proj": {
327
+ "o1": 14,
328
+ "o2": 16,
329
+ "o3": 16,
330
+ "i1": 16,
331
+ "i2": 32,
332
+ "i3": 37,
333
+ "r0": 172,
334
+ "r1": 172,
335
+ "r2": 172,
336
+ "nnz": 3394764
337
+ },
338
+ "model.layers.4.self_attn.q_proj": {
339
+ "o1": 14,
340
+ "o2": 16,
341
+ "o3": 16,
342
+ "i1": 14,
343
+ "i2": 16,
344
+ "i3": 16,
345
+ "r0": 102,
346
+ "r1": 102,
347
+ "r2": 102,
348
+ "nnz": 642252
349
+ },
350
+ "model.layers.4.self_attn.k_proj": {
351
+ "o1": 8,
352
+ "o2": 8,
353
+ "o3": 8,
354
+ "i1": 14,
355
+ "i2": 16,
356
+ "i3": 16,
357
+ "r0": 53,
358
+ "r1": 53,
359
+ "r2": 53,
360
+ "nnz": 91750
361
+ },
362
+ "model.layers.4.self_attn.v_proj": {
363
+ "o1": 8,
364
+ "o2": 8,
365
+ "o3": 8,
366
+ "i1": 14,
367
+ "i2": 16,
368
+ "i3": 16,
369
+ "r0": 53,
370
+ "r1": 53,
371
+ "r2": 53,
372
+ "nnz": 91750
373
+ },
374
+ "model.layers.4.self_attn.o_proj": {
375
+ "o1": 14,
376
+ "o2": 16,
377
+ "o3": 16,
378
+ "i1": 14,
379
+ "i2": 16,
380
+ "i3": 16,
381
+ "r0": 102,
382
+ "r1": 102,
383
+ "r2": 102,
384
+ "nnz": 642252
385
+ },
386
+ "model.layers.4.mlp.gate_proj": {
387
+ "o1": 16,
388
+ "o2": 32,
389
+ "o3": 37,
390
+ "i1": 14,
391
+ "i2": 16,
392
+ "i3": 16,
393
+ "r0": 172,
394
+ "r1": 172,
395
+ "r2": 172,
396
+ "nnz": 3394764
397
+ },
398
+ "model.layers.4.mlp.up_proj": {
399
+ "o1": 16,
400
+ "o2": 32,
401
+ "o3": 37,
402
+ "i1": 14,
403
+ "i2": 16,
404
+ "i3": 16,
405
+ "r0": 172,
406
+ "r1": 172,
407
+ "r2": 172,
408
+ "nnz": 3394764
409
+ },
410
+ "model.layers.4.mlp.down_proj": {
411
+ "o1": 14,
412
+ "o2": 16,
413
+ "o3": 16,
414
+ "i1": 16,
415
+ "i2": 32,
416
+ "i3": 37,
417
+ "r0": 172,
418
+ "r1": 172,
419
+ "r2": 172,
420
+ "nnz": 3394764
421
+ },
422
+ "model.layers.5.self_attn.q_proj": {
423
+ "o1": 14,
424
+ "o2": 16,
425
+ "o3": 16,
426
+ "i1": 14,
427
+ "i2": 16,
428
+ "i3": 16,
429
+ "r0": 102,
430
+ "r1": 102,
431
+ "r2": 102,
432
+ "nnz": 642252
433
+ },
434
+ "model.layers.5.self_attn.k_proj": {
435
+ "o1": 8,
436
+ "o2": 8,
437
+ "o3": 8,
438
+ "i1": 14,
439
+ "i2": 16,
440
+ "i3": 16,
441
+ "r0": 53,
442
+ "r1": 53,
443
+ "r2": 53,
444
+ "nnz": 91750
445
+ },
446
+ "model.layers.5.self_attn.v_proj": {
447
+ "o1": 8,
448
+ "o2": 8,
449
+ "o3": 8,
450
+ "i1": 14,
451
+ "i2": 16,
452
+ "i3": 16,
453
+ "r0": 53,
454
+ "r1": 53,
455
+ "r2": 53,
456
+ "nnz": 91750
457
+ },
458
+ "model.layers.5.self_attn.o_proj": {
459
+ "o1": 14,
460
+ "o2": 16,
461
+ "o3": 16,
462
+ "i1": 14,
463
+ "i2": 16,
464
+ "i3": 16,
465
+ "r0": 102,
466
+ "r1": 102,
467
+ "r2": 102,
468
+ "nnz": 642252
469
+ },
470
+ "model.layers.5.mlp.gate_proj": {
471
+ "o1": 16,
472
+ "o2": 32,
473
+ "o3": 37,
474
+ "i1": 14,
475
+ "i2": 16,
476
+ "i3": 16,
477
+ "r0": 172,
478
+ "r1": 172,
479
+ "r2": 172,
480
+ "nnz": 3394764
481
+ },
482
+ "model.layers.5.mlp.up_proj": {
483
+ "o1": 16,
484
+ "o2": 32,
485
+ "o3": 37,
486
+ "i1": 14,
487
+ "i2": 16,
488
+ "i3": 16,
489
+ "r0": 172,
490
+ "r1": 172,
491
+ "r2": 172,
492
+ "nnz": 3394764
493
+ },
494
+ "model.layers.5.mlp.down_proj": {
495
+ "o1": 14,
496
+ "o2": 16,
497
+ "o3": 16,
498
+ "i1": 16,
499
+ "i2": 32,
500
+ "i3": 37,
501
+ "r0": 172,
502
+ "r1": 172,
503
+ "r2": 172,
504
+ "nnz": 3394764
505
+ },
506
+ "model.layers.6.self_attn.q_proj": {
507
+ "o1": 14,
508
+ "o2": 16,
509
+ "o3": 16,
510
+ "i1": 14,
511
+ "i2": 16,
512
+ "i3": 16,
513
+ "r0": 102,
514
+ "r1": 102,
515
+ "r2": 102,
516
+ "nnz": 642252
517
+ },
518
+ "model.layers.6.self_attn.k_proj": {
519
+ "o1": 8,
520
+ "o2": 8,
521
+ "o3": 8,
522
+ "i1": 14,
523
+ "i2": 16,
524
+ "i3": 16,
525
+ "r0": 53,
526
+ "r1": 53,
527
+ "r2": 53,
528
+ "nnz": 91750
529
+ },
530
+ "model.layers.6.self_attn.v_proj": {
531
+ "o1": 8,
532
+ "o2": 8,
533
+ "o3": 8,
534
+ "i1": 14,
535
+ "i2": 16,
536
+ "i3": 16,
537
+ "r0": 53,
538
+ "r1": 53,
539
+ "r2": 53,
540
+ "nnz": 91750
541
+ },
542
+ "model.layers.6.self_attn.o_proj": {
543
+ "o1": 14,
544
+ "o2": 16,
545
+ "o3": 16,
546
+ "i1": 14,
547
+ "i2": 16,
548
+ "i3": 16,
549
+ "r0": 102,
550
+ "r1": 102,
551
+ "r2": 102,
552
+ "nnz": 642252
553
+ },
554
+ "model.layers.6.mlp.gate_proj": {
555
+ "o1": 16,
556
+ "o2": 32,
557
+ "o3": 37,
558
+ "i1": 14,
559
+ "i2": 16,
560
+ "i3": 16,
561
+ "r0": 172,
562
+ "r1": 172,
563
+ "r2": 172,
564
+ "nnz": 3394764
565
+ },
566
+ "model.layers.6.mlp.up_proj": {
567
+ "o1": 16,
568
+ "o2": 32,
569
+ "o3": 37,
570
+ "i1": 14,
571
+ "i2": 16,
572
+ "i3": 16,
573
+ "r0": 172,
574
+ "r1": 172,
575
+ "r2": 172,
576
+ "nnz": 3394764
577
+ },
578
+ "model.layers.6.mlp.down_proj": {
579
+ "o1": 14,
580
+ "o2": 16,
581
+ "o3": 16,
582
+ "i1": 16,
583
+ "i2": 32,
584
+ "i3": 37,
585
+ "r0": 172,
586
+ "r1": 172,
587
+ "r2": 172,
588
+ "nnz": 3394764
589
+ },
590
+ "model.layers.7.self_attn.q_proj": {
591
+ "o1": 14,
592
+ "o2": 16,
593
+ "o3": 16,
594
+ "i1": 14,
595
+ "i2": 16,
596
+ "i3": 16,
597
+ "r0": 102,
598
+ "r1": 102,
599
+ "r2": 102,
600
+ "nnz": 642252
601
+ },
602
+ "model.layers.7.self_attn.k_proj": {
603
+ "o1": 8,
604
+ "o2": 8,
605
+ "o3": 8,
606
+ "i1": 14,
607
+ "i2": 16,
608
+ "i3": 16,
609
+ "r0": 53,
610
+ "r1": 53,
611
+ "r2": 53,
612
+ "nnz": 91750
613
+ },
614
+ "model.layers.7.self_attn.v_proj": {
615
+ "o1": 8,
616
+ "o2": 8,
617
+ "o3": 8,
618
+ "i1": 14,
619
+ "i2": 16,
620
+ "i3": 16,
621
+ "r0": 53,
622
+ "r1": 53,
623
+ "r2": 53,
624
+ "nnz": 91750
625
+ },
626
+ "model.layers.7.self_attn.o_proj": {
627
+ "o1": 14,
628
+ "o2": 16,
629
+ "o3": 16,
630
+ "i1": 14,
631
+ "i2": 16,
632
+ "i3": 16,
633
+ "r0": 102,
634
+ "r1": 102,
635
+ "r2": 102,
636
+ "nnz": 642252
637
+ },
638
+ "model.layers.7.mlp.gate_proj": {
639
+ "o1": 16,
640
+ "o2": 32,
641
+ "o3": 37,
642
+ "i1": 14,
643
+ "i2": 16,
644
+ "i3": 16,
645
+ "r0": 172,
646
+ "r1": 172,
647
+ "r2": 172,
648
+ "nnz": 3394764
649
+ },
650
+ "model.layers.7.mlp.up_proj": {
651
+ "o1": 16,
652
+ "o2": 32,
653
+ "o3": 37,
654
+ "i1": 14,
655
+ "i2": 16,
656
+ "i3": 16,
657
+ "r0": 172,
658
+ "r1": 172,
659
+ "r2": 172,
660
+ "nnz": 3394764
661
+ },
662
+ "model.layers.7.mlp.down_proj": {
663
+ "o1": 14,
664
+ "o2": 16,
665
+ "o3": 16,
666
+ "i1": 16,
667
+ "i2": 32,
668
+ "i3": 37,
669
+ "r0": 172,
670
+ "r1": 172,
671
+ "r2": 172,
672
+ "nnz": 3394764
673
+ },
674
+ "model.layers.8.self_attn.q_proj": {
675
+ "o1": 14,
676
+ "o2": 16,
677
+ "o3": 16,
678
+ "i1": 14,
679
+ "i2": 16,
680
+ "i3": 16,
681
+ "r0": 102,
682
+ "r1": 102,
683
+ "r2": 102,
684
+ "nnz": 642252
685
+ },
686
+ "model.layers.8.self_attn.k_proj": {
687
+ "o1": 8,
688
+ "o2": 8,
689
+ "o3": 8,
690
+ "i1": 14,
691
+ "i2": 16,
692
+ "i3": 16,
693
+ "r0": 53,
694
+ "r1": 53,
695
+ "r2": 53,
696
+ "nnz": 91750
697
+ },
698
+ "model.layers.8.self_attn.v_proj": {
699
+ "o1": 8,
700
+ "o2": 8,
701
+ "o3": 8,
702
+ "i1": 14,
703
+ "i2": 16,
704
+ "i3": 16,
705
+ "r0": 53,
706
+ "r1": 53,
707
+ "r2": 53,
708
+ "nnz": 91750
709
+ },
710
+ "model.layers.8.self_attn.o_proj": {
711
+ "o1": 14,
712
+ "o2": 16,
713
+ "o3": 16,
714
+ "i1": 14,
715
+ "i2": 16,
716
+ "i3": 16,
717
+ "r0": 102,
718
+ "r1": 102,
719
+ "r2": 102,
720
+ "nnz": 642252
721
+ },
722
+ "model.layers.8.mlp.gate_proj": {
723
+ "o1": 16,
724
+ "o2": 32,
725
+ "o3": 37,
726
+ "i1": 14,
727
+ "i2": 16,
728
+ "i3": 16,
729
+ "r0": 172,
730
+ "r1": 172,
731
+ "r2": 172,
732
+ "nnz": 3394764
733
+ },
734
+ "model.layers.8.mlp.up_proj": {
735
+ "o1": 16,
736
+ "o2": 32,
737
+ "o3": 37,
738
+ "i1": 14,
739
+ "i2": 16,
740
+ "i3": 16,
741
+ "r0": 172,
742
+ "r1": 172,
743
+ "r2": 172,
744
+ "nnz": 3394764
745
+ },
746
+ "model.layers.8.mlp.down_proj": {
747
+ "o1": 14,
748
+ "o2": 16,
749
+ "o3": 16,
750
+ "i1": 16,
751
+ "i2": 32,
752
+ "i3": 37,
753
+ "r0": 172,
754
+ "r1": 172,
755
+ "r2": 172,
756
+ "nnz": 3394764
757
+ },
758
+ "model.layers.9.self_attn.q_proj": {
759
+ "o1": 14,
760
+ "o2": 16,
761
+ "o3": 16,
762
+ "i1": 14,
763
+ "i2": 16,
764
+ "i3": 16,
765
+ "r0": 102,
766
+ "r1": 102,
767
+ "r2": 102,
768
+ "nnz": 642252
769
+ },
770
+ "model.layers.9.self_attn.k_proj": {
771
+ "o1": 8,
772
+ "o2": 8,
773
+ "o3": 8,
774
+ "i1": 14,
775
+ "i2": 16,
776
+ "i3": 16,
777
+ "r0": 53,
778
+ "r1": 53,
779
+ "r2": 53,
780
+ "nnz": 91750
781
+ },
782
+ "model.layers.9.self_attn.v_proj": {
783
+ "o1": 8,
784
+ "o2": 8,
785
+ "o3": 8,
786
+ "i1": 14,
787
+ "i2": 16,
788
+ "i3": 16,
789
+ "r0": 53,
790
+ "r1": 53,
791
+ "r2": 53,
792
+ "nnz": 91750
793
+ },
794
+ "model.layers.9.self_attn.o_proj": {
795
+ "o1": 14,
796
+ "o2": 16,
797
+ "o3": 16,
798
+ "i1": 14,
799
+ "i2": 16,
800
+ "i3": 16,
801
+ "r0": 102,
802
+ "r1": 102,
803
+ "r2": 102,
804
+ "nnz": 642252
805
+ },
806
+ "model.layers.9.mlp.gate_proj": {
807
+ "o1": 16,
808
+ "o2": 32,
809
+ "o3": 37,
810
+ "i1": 14,
811
+ "i2": 16,
812
+ "i3": 16,
813
+ "r0": 172,
814
+ "r1": 172,
815
+ "r2": 172,
816
+ "nnz": 3394764
817
+ },
818
+ "model.layers.9.mlp.up_proj": {
819
+ "o1": 16,
820
+ "o2": 32,
821
+ "o3": 37,
822
+ "i1": 14,
823
+ "i2": 16,
824
+ "i3": 16,
825
+ "r0": 172,
826
+ "r1": 172,
827
+ "r2": 172,
828
+ "nnz": 3394764
829
+ },
830
+ "model.layers.9.mlp.down_proj": {
831
+ "o1": 14,
832
+ "o2": 16,
833
+ "o3": 16,
834
+ "i1": 16,
835
+ "i2": 32,
836
+ "i3": 37,
837
+ "r0": 172,
838
+ "r1": 172,
839
+ "r2": 172,
840
+ "nnz": 3394764
841
+ },
842
+ "model.layers.10.self_attn.q_proj": {
843
+ "o1": 14,
844
+ "o2": 16,
845
+ "o3": 16,
846
+ "i1": 14,
847
+ "i2": 16,
848
+ "i3": 16,
849
+ "r0": 102,
850
+ "r1": 102,
851
+ "r2": 102,
852
+ "nnz": 642252
853
+ },
854
+ "model.layers.10.self_attn.k_proj": {
855
+ "o1": 8,
856
+ "o2": 8,
857
+ "o3": 8,
858
+ "i1": 14,
859
+ "i2": 16,
860
+ "i3": 16,
861
+ "r0": 53,
862
+ "r1": 53,
863
+ "r2": 53,
864
+ "nnz": 91750
865
+ },
866
+ "model.layers.10.self_attn.v_proj": {
867
+ "o1": 8,
868
+ "o2": 8,
869
+ "o3": 8,
870
+ "i1": 14,
871
+ "i2": 16,
872
+ "i3": 16,
873
+ "r0": 53,
874
+ "r1": 53,
875
+ "r2": 53,
876
+ "nnz": 91750
877
+ },
878
+ "model.layers.10.self_attn.o_proj": {
879
+ "o1": 14,
880
+ "o2": 16,
881
+ "o3": 16,
882
+ "i1": 14,
883
+ "i2": 16,
884
+ "i3": 16,
885
+ "r0": 102,
886
+ "r1": 102,
887
+ "r2": 102,
888
+ "nnz": 642252
889
+ },
890
+ "model.layers.10.mlp.gate_proj": {
891
+ "o1": 16,
892
+ "o2": 32,
893
+ "o3": 37,
894
+ "i1": 14,
895
+ "i2": 16,
896
+ "i3": 16,
897
+ "r0": 172,
898
+ "r1": 172,
899
+ "r2": 172,
900
+ "nnz": 3394764
901
+ },
902
+ "model.layers.10.mlp.up_proj": {
903
+ "o1": 16,
904
+ "o2": 32,
905
+ "o3": 37,
906
+ "i1": 14,
907
+ "i2": 16,
908
+ "i3": 16,
909
+ "r0": 172,
910
+ "r1": 172,
911
+ "r2": 172,
912
+ "nnz": 3394764
913
+ },
914
+ "model.layers.10.mlp.down_proj": {
915
+ "o1": 14,
916
+ "o2": 16,
917
+ "o3": 16,
918
+ "i1": 16,
919
+ "i2": 32,
920
+ "i3": 37,
921
+ "r0": 172,
922
+ "r1": 172,
923
+ "r2": 172,
924
+ "nnz": 3394764
925
+ },
926
+ "model.layers.11.self_attn.q_proj": {
927
+ "o1": 14,
928
+ "o2": 16,
929
+ "o3": 16,
930
+ "i1": 14,
931
+ "i2": 16,
932
+ "i3": 16,
933
+ "r0": 102,
934
+ "r1": 102,
935
+ "r2": 102,
936
+ "nnz": 642252
937
+ },
938
+ "model.layers.11.self_attn.k_proj": {
939
+ "o1": 8,
940
+ "o2": 8,
941
+ "o3": 8,
942
+ "i1": 14,
943
+ "i2": 16,
944
+ "i3": 16,
945
+ "r0": 53,
946
+ "r1": 53,
947
+ "r2": 53,
948
+ "nnz": 91750
949
+ },
950
+ "model.layers.11.self_attn.v_proj": {
951
+ "o1": 8,
952
+ "o2": 8,
953
+ "o3": 8,
954
+ "i1": 14,
955
+ "i2": 16,
956
+ "i3": 16,
957
+ "r0": 53,
958
+ "r1": 53,
959
+ "r2": 53,
960
+ "nnz": 91750
961
+ },
962
+ "model.layers.11.self_attn.o_proj": {
963
+ "o1": 14,
964
+ "o2": 16,
965
+ "o3": 16,
966
+ "i1": 14,
967
+ "i2": 16,
968
+ "i3": 16,
969
+ "r0": 102,
970
+ "r1": 102,
971
+ "r2": 102,
972
+ "nnz": 642252
973
+ },
974
+ "model.layers.11.mlp.gate_proj": {
975
+ "o1": 16,
976
+ "o2": 32,
977
+ "o3": 37,
978
+ "i1": 14,
979
+ "i2": 16,
980
+ "i3": 16,
981
+ "r0": 172,
982
+ "r1": 172,
983
+ "r2": 172,
984
+ "nnz": 3394764
985
+ },
986
+ "model.layers.11.mlp.up_proj": {
987
+ "o1": 16,
988
+ "o2": 32,
989
+ "o3": 37,
990
+ "i1": 14,
991
+ "i2": 16,
992
+ "i3": 16,
993
+ "r0": 172,
994
+ "r1": 172,
995
+ "r2": 172,
996
+ "nnz": 3394764
997
+ },
998
+ "model.layers.11.mlp.down_proj": {
999
+ "o1": 14,
1000
+ "o2": 16,
1001
+ "o3": 16,
1002
+ "i1": 16,
1003
+ "i2": 32,
1004
+ "i3": 37,
1005
+ "r0": 172,
1006
+ "r1": 172,
1007
+ "r2": 172,
1008
+ "nnz": 3394764
1009
+ },
1010
+ "model.layers.12.self_attn.q_proj": {
1011
+ "o1": 14,
1012
+ "o2": 16,
1013
+ "o3": 16,
1014
+ "i1": 14,
1015
+ "i2": 16,
1016
+ "i3": 16,
1017
+ "r0": 102,
1018
+ "r1": 102,
1019
+ "r2": 102,
1020
+ "nnz": 642252
1021
+ },
1022
+ "model.layers.12.self_attn.k_proj": {
1023
+ "o1": 8,
1024
+ "o2": 8,
1025
+ "o3": 8,
1026
+ "i1": 14,
1027
+ "i2": 16,
1028
+ "i3": 16,
1029
+ "r0": 53,
1030
+ "r1": 53,
1031
+ "r2": 53,
1032
+ "nnz": 91750
1033
+ },
1034
+ "model.layers.12.self_attn.v_proj": {
1035
+ "o1": 8,
1036
+ "o2": 8,
1037
+ "o3": 8,
1038
+ "i1": 14,
1039
+ "i2": 16,
1040
+ "i3": 16,
1041
+ "r0": 53,
1042
+ "r1": 53,
1043
+ "r2": 53,
1044
+ "nnz": 91750
1045
+ },
1046
+ "model.layers.12.self_attn.o_proj": {
1047
+ "o1": 14,
1048
+ "o2": 16,
1049
+ "o3": 16,
1050
+ "i1": 14,
1051
+ "i2": 16,
1052
+ "i3": 16,
1053
+ "r0": 102,
1054
+ "r1": 102,
1055
+ "r2": 102,
1056
+ "nnz": 642252
1057
+ },
1058
+ "model.layers.12.mlp.gate_proj": {
1059
+ "o1": 16,
1060
+ "o2": 32,
1061
+ "o3": 37,
1062
+ "i1": 14,
1063
+ "i2": 16,
1064
+ "i3": 16,
1065
+ "r0": 172,
1066
+ "r1": 172,
1067
+ "r2": 172,
1068
+ "nnz": 3394764
1069
+ },
1070
+ "model.layers.12.mlp.up_proj": {
1071
+ "o1": 16,
1072
+ "o2": 32,
1073
+ "o3": 37,
1074
+ "i1": 14,
1075
+ "i2": 16,
1076
+ "i3": 16,
1077
+ "r0": 172,
1078
+ "r1": 172,
1079
+ "r2": 172,
1080
+ "nnz": 3394764
1081
+ },
1082
+ "model.layers.12.mlp.down_proj": {
1083
+ "o1": 14,
1084
+ "o2": 16,
1085
+ "o3": 16,
1086
+ "i1": 16,
1087
+ "i2": 32,
1088
+ "i3": 37,
1089
+ "r0": 172,
1090
+ "r1": 172,
1091
+ "r2": 172,
1092
+ "nnz": 3394764
1093
+ },
1094
+ "model.layers.13.self_attn.q_proj": {
1095
+ "o1": 14,
1096
+ "o2": 16,
1097
+ "o3": 16,
1098
+ "i1": 14,
1099
+ "i2": 16,
1100
+ "i3": 16,
1101
+ "r0": 102,
1102
+ "r1": 102,
1103
+ "r2": 102,
1104
+ "nnz": 642252
1105
+ },
1106
+ "model.layers.13.self_attn.k_proj": {
1107
+ "o1": 8,
1108
+ "o2": 8,
1109
+ "o3": 8,
1110
+ "i1": 14,
1111
+ "i2": 16,
1112
+ "i3": 16,
1113
+ "r0": 53,
1114
+ "r1": 53,
1115
+ "r2": 53,
1116
+ "nnz": 91750
1117
+ },
1118
+ "model.layers.13.self_attn.v_proj": {
1119
+ "o1": 8,
1120
+ "o2": 8,
1121
+ "o3": 8,
1122
+ "i1": 14,
1123
+ "i2": 16,
1124
+ "i3": 16,
1125
+ "r0": 53,
1126
+ "r1": 53,
1127
+ "r2": 53,
1128
+ "nnz": 91750
1129
+ },
1130
+ "model.layers.13.self_attn.o_proj": {
1131
+ "o1": 14,
1132
+ "o2": 16,
1133
+ "o3": 16,
1134
+ "i1": 14,
1135
+ "i2": 16,
1136
+ "i3": 16,
1137
+ "r0": 102,
1138
+ "r1": 102,
1139
+ "r2": 102,
1140
+ "nnz": 642252
1141
+ },
1142
+ "model.layers.13.mlp.gate_proj": {
1143
+ "o1": 16,
1144
+ "o2": 32,
1145
+ "o3": 37,
1146
+ "i1": 14,
1147
+ "i2": 16,
1148
+ "i3": 16,
1149
+ "r0": 172,
1150
+ "r1": 172,
1151
+ "r2": 172,
1152
+ "nnz": 3394764
1153
+ },
1154
+ "model.layers.13.mlp.up_proj": {
1155
+ "o1": 16,
1156
+ "o2": 32,
1157
+ "o3": 37,
1158
+ "i1": 14,
1159
+ "i2": 16,
1160
+ "i3": 16,
1161
+ "r0": 172,
1162
+ "r1": 172,
1163
+ "r2": 172,
1164
+ "nnz": 3394764
1165
+ },
1166
+ "model.layers.13.mlp.down_proj": {
1167
+ "o1": 14,
1168
+ "o2": 16,
1169
+ "o3": 16,
1170
+ "i1": 16,
1171
+ "i2": 32,
1172
+ "i3": 37,
1173
+ "r0": 172,
1174
+ "r1": 172,
1175
+ "r2": 172,
1176
+ "nnz": 3394764
1177
+ },
1178
+ "model.layers.14.self_attn.q_proj": {
1179
+ "o1": 14,
1180
+ "o2": 16,
1181
+ "o3": 16,
1182
+ "i1": 14,
1183
+ "i2": 16,
1184
+ "i3": 16,
1185
+ "r0": 102,
1186
+ "r1": 102,
1187
+ "r2": 102,
1188
+ "nnz": 642252
1189
+ },
1190
+ "model.layers.14.self_attn.k_proj": {
1191
+ "o1": 8,
1192
+ "o2": 8,
1193
+ "o3": 8,
1194
+ "i1": 14,
1195
+ "i2": 16,
1196
+ "i3": 16,
1197
+ "r0": 53,
1198
+ "r1": 53,
1199
+ "r2": 53,
1200
+ "nnz": 91750
1201
+ },
1202
+ "model.layers.14.self_attn.v_proj": {
1203
+ "o1": 8,
1204
+ "o2": 8,
1205
+ "o3": 8,
1206
+ "i1": 14,
1207
+ "i2": 16,
1208
+ "i3": 16,
1209
+ "r0": 53,
1210
+ "r1": 53,
1211
+ "r2": 53,
1212
+ "nnz": 91750
1213
+ },
1214
+ "model.layers.14.self_attn.o_proj": {
1215
+ "o1": 14,
1216
+ "o2": 16,
1217
+ "o3": 16,
1218
+ "i1": 14,
1219
+ "i2": 16,
1220
+ "i3": 16,
1221
+ "r0": 102,
1222
+ "r1": 102,
1223
+ "r2": 102,
1224
+ "nnz": 642252
1225
+ },
1226
+ "model.layers.14.mlp.gate_proj": {
1227
+ "o1": 16,
1228
+ "o2": 32,
1229
+ "o3": 37,
1230
+ "i1": 14,
1231
+ "i2": 16,
1232
+ "i3": 16,
1233
+ "r0": 172,
1234
+ "r1": 172,
1235
+ "r2": 172,
1236
+ "nnz": 3394764
1237
+ },
1238
+ "model.layers.14.mlp.up_proj": {
1239
+ "o1": 16,
1240
+ "o2": 32,
1241
+ "o3": 37,
1242
+ "i1": 14,
1243
+ "i2": 16,
1244
+ "i3": 16,
1245
+ "r0": 172,
1246
+ "r1": 172,
1247
+ "r2": 172,
1248
+ "nnz": 3394764
1249
+ },
1250
+ "model.layers.14.mlp.down_proj": {
1251
+ "o1": 14,
1252
+ "o2": 16,
1253
+ "o3": 16,
1254
+ "i1": 16,
1255
+ "i2": 32,
1256
+ "i3": 37,
1257
+ "r0": 172,
1258
+ "r1": 172,
1259
+ "r2": 172,
1260
+ "nnz": 3394764
1261
+ },
1262
+ "model.layers.15.self_attn.q_proj": {
1263
+ "o1": 14,
1264
+ "o2": 16,
1265
+ "o3": 16,
1266
+ "i1": 14,
1267
+ "i2": 16,
1268
+ "i3": 16,
1269
+ "r0": 102,
1270
+ "r1": 102,
1271
+ "r2": 102,
1272
+ "nnz": 642252
1273
+ },
1274
+ "model.layers.15.self_attn.k_proj": {
1275
+ "o1": 8,
1276
+ "o2": 8,
1277
+ "o3": 8,
1278
+ "i1": 14,
1279
+ "i2": 16,
1280
+ "i3": 16,
1281
+ "r0": 53,
1282
+ "r1": 53,
1283
+ "r2": 53,
1284
+ "nnz": 91750
1285
+ },
1286
+ "model.layers.15.self_attn.v_proj": {
1287
+ "o1": 8,
1288
+ "o2": 8,
1289
+ "o3": 8,
1290
+ "i1": 14,
1291
+ "i2": 16,
1292
+ "i3": 16,
1293
+ "r0": 53,
1294
+ "r1": 53,
1295
+ "r2": 53,
1296
+ "nnz": 91750
1297
+ },
1298
+ "model.layers.15.self_attn.o_proj": {
1299
+ "o1": 14,
1300
+ "o2": 16,
1301
+ "o3": 16,
1302
+ "i1": 14,
1303
+ "i2": 16,
1304
+ "i3": 16,
1305
+ "r0": 102,
1306
+ "r1": 102,
1307
+ "r2": 102,
1308
+ "nnz": 642252
1309
+ },
1310
+ "model.layers.15.mlp.gate_proj": {
1311
+ "o1": 16,
1312
+ "o2": 32,
1313
+ "o3": 37,
1314
+ "i1": 14,
1315
+ "i2": 16,
1316
+ "i3": 16,
1317
+ "r0": 172,
1318
+ "r1": 172,
1319
+ "r2": 172,
1320
+ "nnz": 3394764
1321
+ },
1322
+ "model.layers.15.mlp.up_proj": {
1323
+ "o1": 16,
1324
+ "o2": 32,
1325
+ "o3": 37,
1326
+ "i1": 14,
1327
+ "i2": 16,
1328
+ "i3": 16,
1329
+ "r0": 172,
1330
+ "r1": 172,
1331
+ "r2": 172,
1332
+ "nnz": 3394764
1333
+ },
1334
+ "model.layers.15.mlp.down_proj": {
1335
+ "o1": 14,
1336
+ "o2": 16,
1337
+ "o3": 16,
1338
+ "i1": 16,
1339
+ "i2": 32,
1340
+ "i3": 37,
1341
+ "r0": 172,
1342
+ "r1": 172,
1343
+ "r2": 172,
1344
+ "nnz": 3394764
1345
+ },
1346
+ "model.layers.16.self_attn.q_proj": {
1347
+ "o1": 14,
1348
+ "o2": 16,
1349
+ "o3": 16,
1350
+ "i1": 14,
1351
+ "i2": 16,
1352
+ "i3": 16,
1353
+ "r0": 102,
1354
+ "r1": 102,
1355
+ "r2": 102,
1356
+ "nnz": 642252
1357
+ },
1358
+ "model.layers.16.self_attn.k_proj": {
1359
+ "o1": 8,
1360
+ "o2": 8,
1361
+ "o3": 8,
1362
+ "i1": 14,
1363
+ "i2": 16,
1364
+ "i3": 16,
1365
+ "r0": 53,
1366
+ "r1": 53,
1367
+ "r2": 53,
1368
+ "nnz": 91750
1369
+ },
1370
+ "model.layers.16.self_attn.v_proj": {
1371
+ "o1": 8,
1372
+ "o2": 8,
1373
+ "o3": 8,
1374
+ "i1": 14,
1375
+ "i2": 16,
1376
+ "i3": 16,
1377
+ "r0": 53,
1378
+ "r1": 53,
1379
+ "r2": 53,
1380
+ "nnz": 91750
1381
+ },
1382
+ "model.layers.16.self_attn.o_proj": {
1383
+ "o1": 14,
1384
+ "o2": 16,
1385
+ "o3": 16,
1386
+ "i1": 14,
1387
+ "i2": 16,
1388
+ "i3": 16,
1389
+ "r0": 102,
1390
+ "r1": 102,
1391
+ "r2": 102,
1392
+ "nnz": 642252
1393
+ },
1394
+ "model.layers.16.mlp.gate_proj": {
1395
+ "o1": 16,
1396
+ "o2": 32,
1397
+ "o3": 37,
1398
+ "i1": 14,
1399
+ "i2": 16,
1400
+ "i3": 16,
1401
+ "r0": 172,
1402
+ "r1": 172,
1403
+ "r2": 172,
1404
+ "nnz": 3394764
1405
+ },
1406
+ "model.layers.16.mlp.up_proj": {
1407
+ "o1": 16,
1408
+ "o2": 32,
1409
+ "o3": 37,
1410
+ "i1": 14,
1411
+ "i2": 16,
1412
+ "i3": 16,
1413
+ "r0": 172,
1414
+ "r1": 172,
1415
+ "r2": 172,
1416
+ "nnz": 3394764
1417
+ },
1418
+ "model.layers.16.mlp.down_proj": {
1419
+ "o1": 14,
1420
+ "o2": 16,
1421
+ "o3": 16,
1422
+ "i1": 16,
1423
+ "i2": 32,
1424
+ "i3": 37,
1425
+ "r0": 172,
1426
+ "r1": 172,
1427
+ "r2": 172,
1428
+ "nnz": 3394764
1429
+ },
1430
+ "model.layers.17.self_attn.q_proj": {
1431
+ "o1": 14,
1432
+ "o2": 16,
1433
+ "o3": 16,
1434
+ "i1": 14,
1435
+ "i2": 16,
1436
+ "i3": 16,
1437
+ "r0": 102,
1438
+ "r1": 102,
1439
+ "r2": 102,
1440
+ "nnz": 642252
1441
+ },
1442
+ "model.layers.17.self_attn.k_proj": {
1443
+ "o1": 8,
1444
+ "o2": 8,
1445
+ "o3": 8,
1446
+ "i1": 14,
1447
+ "i2": 16,
1448
+ "i3": 16,
1449
+ "r0": 53,
1450
+ "r1": 53,
1451
+ "r2": 53,
1452
+ "nnz": 91750
1453
+ },
1454
+ "model.layers.17.self_attn.v_proj": {
1455
+ "o1": 8,
1456
+ "o2": 8,
1457
+ "o3": 8,
1458
+ "i1": 14,
1459
+ "i2": 16,
1460
+ "i3": 16,
1461
+ "r0": 53,
1462
+ "r1": 53,
1463
+ "r2": 53,
1464
+ "nnz": 91750
1465
+ },
1466
+ "model.layers.17.self_attn.o_proj": {
1467
+ "o1": 14,
1468
+ "o2": 16,
1469
+ "o3": 16,
1470
+ "i1": 14,
1471
+ "i2": 16,
1472
+ "i3": 16,
1473
+ "r0": 102,
1474
+ "r1": 102,
1475
+ "r2": 102,
1476
+ "nnz": 642252
1477
+ },
1478
+ "model.layers.17.mlp.gate_proj": {
1479
+ "o1": 16,
1480
+ "o2": 32,
1481
+ "o3": 37,
1482
+ "i1": 14,
1483
+ "i2": 16,
1484
+ "i3": 16,
1485
+ "r0": 172,
1486
+ "r1": 172,
1487
+ "r2": 172,
1488
+ "nnz": 3394764
1489
+ },
1490
+ "model.layers.17.mlp.up_proj": {
1491
+ "o1": 16,
1492
+ "o2": 32,
1493
+ "o3": 37,
1494
+ "i1": 14,
1495
+ "i2": 16,
1496
+ "i3": 16,
1497
+ "r0": 172,
1498
+ "r1": 172,
1499
+ "r2": 172,
1500
+ "nnz": 3394764
1501
+ },
1502
+ "model.layers.17.mlp.down_proj": {
1503
+ "o1": 14,
1504
+ "o2": 16,
1505
+ "o3": 16,
1506
+ "i1": 16,
1507
+ "i2": 32,
1508
+ "i3": 37,
1509
+ "r0": 172,
1510
+ "r1": 172,
1511
+ "r2": 172,
1512
+ "nnz": 3394764
1513
+ },
1514
+ "model.layers.18.self_attn.q_proj": {
1515
+ "o1": 14,
1516
+ "o2": 16,
1517
+ "o3": 16,
1518
+ "i1": 14,
1519
+ "i2": 16,
1520
+ "i3": 16,
1521
+ "r0": 102,
1522
+ "r1": 102,
1523
+ "r2": 102,
1524
+ "nnz": 642252
1525
+ },
1526
+ "model.layers.18.self_attn.k_proj": {
1527
+ "o1": 8,
1528
+ "o2": 8,
1529
+ "o3": 8,
1530
+ "i1": 14,
1531
+ "i2": 16,
1532
+ "i3": 16,
1533
+ "r0": 53,
1534
+ "r1": 53,
1535
+ "r2": 53,
1536
+ "nnz": 91750
1537
+ },
1538
+ "model.layers.18.self_attn.v_proj": {
1539
+ "o1": 8,
1540
+ "o2": 8,
1541
+ "o3": 8,
1542
+ "i1": 14,
1543
+ "i2": 16,
1544
+ "i3": 16,
1545
+ "r0": 53,
1546
+ "r1": 53,
1547
+ "r2": 53,
1548
+ "nnz": 91750
1549
+ },
1550
+ "model.layers.18.self_attn.o_proj": {
1551
+ "o1": 14,
1552
+ "o2": 16,
1553
+ "o3": 16,
1554
+ "i1": 14,
1555
+ "i2": 16,
1556
+ "i3": 16,
1557
+ "r0": 102,
1558
+ "r1": 102,
1559
+ "r2": 102,
1560
+ "nnz": 642252
1561
+ },
1562
+ "model.layers.18.mlp.gate_proj": {
1563
+ "o1": 16,
1564
+ "o2": 32,
1565
+ "o3": 37,
1566
+ "i1": 14,
1567
+ "i2": 16,
1568
+ "i3": 16,
1569
+ "r0": 172,
1570
+ "r1": 172,
1571
+ "r2": 172,
1572
+ "nnz": 3394764
1573
+ },
1574
+ "model.layers.18.mlp.up_proj": {
1575
+ "o1": 16,
1576
+ "o2": 32,
1577
+ "o3": 37,
1578
+ "i1": 14,
1579
+ "i2": 16,
1580
+ "i3": 16,
1581
+ "r0": 172,
1582
+ "r1": 172,
1583
+ "r2": 172,
1584
+ "nnz": 3394764
1585
+ },
1586
+ "model.layers.18.mlp.down_proj": {
1587
+ "o1": 14,
1588
+ "o2": 16,
1589
+ "o3": 16,
1590
+ "i1": 16,
1591
+ "i2": 32,
1592
+ "i3": 37,
1593
+ "r0": 172,
1594
+ "r1": 172,
1595
+ "r2": 172,
1596
+ "nnz": 3394764
1597
+ },
1598
+ "model.layers.19.self_attn.q_proj": {
1599
+ "o1": 14,
1600
+ "o2": 16,
1601
+ "o3": 16,
1602
+ "i1": 14,
1603
+ "i2": 16,
1604
+ "i3": 16,
1605
+ "r0": 102,
1606
+ "r1": 102,
1607
+ "r2": 102,
1608
+ "nnz": 642252
1609
+ },
1610
+ "model.layers.19.self_attn.k_proj": {
1611
+ "o1": 8,
1612
+ "o2": 8,
1613
+ "o3": 8,
1614
+ "i1": 14,
1615
+ "i2": 16,
1616
+ "i3": 16,
1617
+ "r0": 53,
1618
+ "r1": 53,
1619
+ "r2": 53,
1620
+ "nnz": 91750
1621
+ },
1622
+ "model.layers.19.self_attn.v_proj": {
1623
+ "o1": 8,
1624
+ "o2": 8,
1625
+ "o3": 8,
1626
+ "i1": 14,
1627
+ "i2": 16,
1628
+ "i3": 16,
1629
+ "r0": 53,
1630
+ "r1": 53,
1631
+ "r2": 53,
1632
+ "nnz": 91750
1633
+ },
1634
+ "model.layers.19.self_attn.o_proj": {
1635
+ "o1": 14,
1636
+ "o2": 16,
1637
+ "o3": 16,
1638
+ "i1": 14,
1639
+ "i2": 16,
1640
+ "i3": 16,
1641
+ "r0": 102,
1642
+ "r1": 102,
1643
+ "r2": 102,
1644
+ "nnz": 642252
1645
+ },
1646
+ "model.layers.19.mlp.gate_proj": {
1647
+ "o1": 16,
1648
+ "o2": 32,
1649
+ "o3": 37,
1650
+ "i1": 14,
1651
+ "i2": 16,
1652
+ "i3": 16,
1653
+ "r0": 172,
1654
+ "r1": 172,
1655
+ "r2": 172,
1656
+ "nnz": 3394764
1657
+ },
1658
+ "model.layers.19.mlp.up_proj": {
1659
+ "o1": 16,
1660
+ "o2": 32,
1661
+ "o3": 37,
1662
+ "i1": 14,
1663
+ "i2": 16,
1664
+ "i3": 16,
1665
+ "r0": 172,
1666
+ "r1": 172,
1667
+ "r2": 172,
1668
+ "nnz": 3394764
1669
+ },
1670
+ "model.layers.19.mlp.down_proj": {
1671
+ "o1": 14,
1672
+ "o2": 16,
1673
+ "o3": 16,
1674
+ "i1": 16,
1675
+ "i2": 32,
1676
+ "i3": 37,
1677
+ "r0": 172,
1678
+ "r1": 172,
1679
+ "r2": 172,
1680
+ "nnz": 3394764
1681
+ },
1682
+ "model.layers.20.self_attn.q_proj": {
1683
+ "o1": 14,
1684
+ "o2": 16,
1685
+ "o3": 16,
1686
+ "i1": 14,
1687
+ "i2": 16,
1688
+ "i3": 16,
1689
+ "r0": 102,
1690
+ "r1": 102,
1691
+ "r2": 102,
1692
+ "nnz": 642252
1693
+ },
1694
+ "model.layers.20.self_attn.k_proj": {
1695
+ "o1": 8,
1696
+ "o2": 8,
1697
+ "o3": 8,
1698
+ "i1": 14,
1699
+ "i2": 16,
1700
+ "i3": 16,
1701
+ "r0": 53,
1702
+ "r1": 53,
1703
+ "r2": 53,
1704
+ "nnz": 91750
1705
+ },
1706
+ "model.layers.20.self_attn.v_proj": {
1707
+ "o1": 8,
1708
+ "o2": 8,
1709
+ "o3": 8,
1710
+ "i1": 14,
1711
+ "i2": 16,
1712
+ "i3": 16,
1713
+ "r0": 53,
1714
+ "r1": 53,
1715
+ "r2": 53,
1716
+ "nnz": 91750
1717
+ },
1718
+ "model.layers.20.self_attn.o_proj": {
1719
+ "o1": 14,
1720
+ "o2": 16,
1721
+ "o3": 16,
1722
+ "i1": 14,
1723
+ "i2": 16,
1724
+ "i3": 16,
1725
+ "r0": 102,
1726
+ "r1": 102,
1727
+ "r2": 102,
1728
+ "nnz": 642252
1729
+ },
1730
+ "model.layers.20.mlp.gate_proj": {
1731
+ "o1": 16,
1732
+ "o2": 32,
1733
+ "o3": 37,
1734
+ "i1": 14,
1735
+ "i2": 16,
1736
+ "i3": 16,
1737
+ "r0": 172,
1738
+ "r1": 172,
1739
+ "r2": 172,
1740
+ "nnz": 3394764
1741
+ },
1742
+ "model.layers.20.mlp.up_proj": {
1743
+ "o1": 16,
1744
+ "o2": 32,
1745
+ "o3": 37,
1746
+ "i1": 14,
1747
+ "i2": 16,
1748
+ "i3": 16,
1749
+ "r0": 172,
1750
+ "r1": 172,
1751
+ "r2": 172,
1752
+ "nnz": 3394764
1753
+ },
1754
+ "model.layers.20.mlp.down_proj": {
1755
+ "o1": 14,
1756
+ "o2": 16,
1757
+ "o3": 16,
1758
+ "i1": 16,
1759
+ "i2": 32,
1760
+ "i3": 37,
1761
+ "r0": 172,
1762
+ "r1": 172,
1763
+ "r2": 172,
1764
+ "nnz": 3394764
1765
+ },
1766
+ "model.layers.21.self_attn.q_proj": {
1767
+ "o1": 14,
1768
+ "o2": 16,
1769
+ "o3": 16,
1770
+ "i1": 14,
1771
+ "i2": 16,
1772
+ "i3": 16,
1773
+ "r0": 102,
1774
+ "r1": 102,
1775
+ "r2": 102,
1776
+ "nnz": 642252
1777
+ },
1778
+ "model.layers.21.self_attn.k_proj": {
1779
+ "o1": 8,
1780
+ "o2": 8,
1781
+ "o3": 8,
1782
+ "i1": 14,
1783
+ "i2": 16,
1784
+ "i3": 16,
1785
+ "r0": 53,
1786
+ "r1": 53,
1787
+ "r2": 53,
1788
+ "nnz": 91750
1789
+ },
1790
+ "model.layers.21.self_attn.v_proj": {
1791
+ "o1": 8,
1792
+ "o2": 8,
1793
+ "o3": 8,
1794
+ "i1": 14,
1795
+ "i2": 16,
1796
+ "i3": 16,
1797
+ "r0": 53,
1798
+ "r1": 53,
1799
+ "r2": 53,
1800
+ "nnz": 91750
1801
+ },
1802
+ "model.layers.21.self_attn.o_proj": {
1803
+ "o1": 14,
1804
+ "o2": 16,
1805
+ "o3": 16,
1806
+ "i1": 14,
1807
+ "i2": 16,
1808
+ "i3": 16,
1809
+ "r0": 102,
1810
+ "r1": 102,
1811
+ "r2": 102,
1812
+ "nnz": 642252
1813
+ },
1814
+ "model.layers.21.mlp.gate_proj": {
1815
+ "o1": 16,
1816
+ "o2": 32,
1817
+ "o3": 37,
1818
+ "i1": 14,
1819
+ "i2": 16,
1820
+ "i3": 16,
1821
+ "r0": 172,
1822
+ "r1": 172,
1823
+ "r2": 172,
1824
+ "nnz": 3394764
1825
+ },
1826
+ "model.layers.21.mlp.up_proj": {
1827
+ "o1": 16,
1828
+ "o2": 32,
1829
+ "o3": 37,
1830
+ "i1": 14,
1831
+ "i2": 16,
1832
+ "i3": 16,
1833
+ "r0": 172,
1834
+ "r1": 172,
1835
+ "r2": 172,
1836
+ "nnz": 3394764
1837
+ },
1838
+ "model.layers.21.mlp.down_proj": {
1839
+ "o1": 14,
1840
+ "o2": 16,
1841
+ "o3": 16,
1842
+ "i1": 16,
1843
+ "i2": 32,
1844
+ "i3": 37,
1845
+ "r0": 172,
1846
+ "r1": 172,
1847
+ "r2": 172,
1848
+ "nnz": 3394764
1849
+ },
1850
+ "model.layers.22.self_attn.q_proj": {
1851
+ "o1": 14,
1852
+ "o2": 16,
1853
+ "o3": 16,
1854
+ "i1": 14,
1855
+ "i2": 16,
1856
+ "i3": 16,
1857
+ "r0": 102,
1858
+ "r1": 102,
1859
+ "r2": 102,
1860
+ "nnz": 642252
1861
+ },
1862
+ "model.layers.22.self_attn.k_proj": {
1863
+ "o1": 8,
1864
+ "o2": 8,
1865
+ "o3": 8,
1866
+ "i1": 14,
1867
+ "i2": 16,
1868
+ "i3": 16,
1869
+ "r0": 53,
1870
+ "r1": 53,
1871
+ "r2": 53,
1872
+ "nnz": 91750
1873
+ },
1874
+ "model.layers.22.self_attn.v_proj": {
1875
+ "o1": 8,
1876
+ "o2": 8,
1877
+ "o3": 8,
1878
+ "i1": 14,
1879
+ "i2": 16,
1880
+ "i3": 16,
1881
+ "r0": 53,
1882
+ "r1": 53,
1883
+ "r2": 53,
1884
+ "nnz": 91750
1885
+ },
1886
+ "model.layers.22.self_attn.o_proj": {
1887
+ "o1": 14,
1888
+ "o2": 16,
1889
+ "o3": 16,
1890
+ "i1": 14,
1891
+ "i2": 16,
1892
+ "i3": 16,
1893
+ "r0": 102,
1894
+ "r1": 102,
1895
+ "r2": 102,
1896
+ "nnz": 642252
1897
+ },
1898
+ "model.layers.22.mlp.gate_proj": {
1899
+ "o1": 16,
1900
+ "o2": 32,
1901
+ "o3": 37,
1902
+ "i1": 14,
1903
+ "i2": 16,
1904
+ "i3": 16,
1905
+ "r0": 172,
1906
+ "r1": 172,
1907
+ "r2": 172,
1908
+ "nnz": 3394764
1909
+ },
1910
+ "model.layers.22.mlp.up_proj": {
1911
+ "o1": 16,
1912
+ "o2": 32,
1913
+ "o3": 37,
1914
+ "i1": 14,
1915
+ "i2": 16,
1916
+ "i3": 16,
1917
+ "r0": 172,
1918
+ "r1": 172,
1919
+ "r2": 172,
1920
+ "nnz": 3394764
1921
+ },
1922
+ "model.layers.22.mlp.down_proj": {
1923
+ "o1": 14,
1924
+ "o2": 16,
1925
+ "o3": 16,
1926
+ "i1": 16,
1927
+ "i2": 32,
1928
+ "i3": 37,
1929
+ "r0": 172,
1930
+ "r1": 172,
1931
+ "r2": 172,
1932
+ "nnz": 3394764
1933
+ },
1934
+ "model.layers.23.self_attn.q_proj": {
1935
+ "o1": 14,
1936
+ "o2": 16,
1937
+ "o3": 16,
1938
+ "i1": 14,
1939
+ "i2": 16,
1940
+ "i3": 16,
1941
+ "r0": 102,
1942
+ "r1": 102,
1943
+ "r2": 102,
1944
+ "nnz": 642252
1945
+ },
1946
+ "model.layers.23.self_attn.k_proj": {
1947
+ "o1": 8,
1948
+ "o2": 8,
1949
+ "o3": 8,
1950
+ "i1": 14,
1951
+ "i2": 16,
1952
+ "i3": 16,
1953
+ "r0": 53,
1954
+ "r1": 53,
1955
+ "r2": 53,
1956
+ "nnz": 91750
1957
+ },
1958
+ "model.layers.23.self_attn.v_proj": {
1959
+ "o1": 8,
1960
+ "o2": 8,
1961
+ "o3": 8,
1962
+ "i1": 14,
1963
+ "i2": 16,
1964
+ "i3": 16,
1965
+ "r0": 53,
1966
+ "r1": 53,
1967
+ "r2": 53,
1968
+ "nnz": 91750
1969
+ },
1970
+ "model.layers.23.self_attn.o_proj": {
1971
+ "o1": 14,
1972
+ "o2": 16,
1973
+ "o3": 16,
1974
+ "i1": 14,
1975
+ "i2": 16,
1976
+ "i3": 16,
1977
+ "r0": 102,
1978
+ "r1": 102,
1979
+ "r2": 102,
1980
+ "nnz": 642252
1981
+ },
1982
+ "model.layers.23.mlp.gate_proj": {
1983
+ "o1": 16,
1984
+ "o2": 32,
1985
+ "o3": 37,
1986
+ "i1": 14,
1987
+ "i2": 16,
1988
+ "i3": 16,
1989
+ "r0": 172,
1990
+ "r1": 172,
1991
+ "r2": 172,
1992
+ "nnz": 3394764
1993
+ },
1994
+ "model.layers.23.mlp.up_proj": {
1995
+ "o1": 16,
1996
+ "o2": 32,
1997
+ "o3": 37,
1998
+ "i1": 14,
1999
+ "i2": 16,
2000
+ "i3": 16,
2001
+ "r0": 172,
2002
+ "r1": 172,
2003
+ "r2": 172,
2004
+ "nnz": 3394764
2005
+ },
2006
+ "model.layers.23.mlp.down_proj": {
2007
+ "o1": 14,
2008
+ "o2": 16,
2009
+ "o3": 16,
2010
+ "i1": 16,
2011
+ "i2": 32,
2012
+ "i3": 37,
2013
+ "r0": 172,
2014
+ "r1": 172,
2015
+ "r2": 172,
2016
+ "nnz": 3394764
2017
+ },
2018
+ "model.layers.24.self_attn.q_proj": {
2019
+ "o1": 14,
2020
+ "o2": 16,
2021
+ "o3": 16,
2022
+ "i1": 14,
2023
+ "i2": 16,
2024
+ "i3": 16,
2025
+ "r0": 102,
2026
+ "r1": 102,
2027
+ "r2": 102,
2028
+ "nnz": 642252
2029
+ },
2030
+ "model.layers.24.self_attn.k_proj": {
2031
+ "o1": 8,
2032
+ "o2": 8,
2033
+ "o3": 8,
2034
+ "i1": 14,
2035
+ "i2": 16,
2036
+ "i3": 16,
2037
+ "r0": 53,
2038
+ "r1": 53,
2039
+ "r2": 53,
2040
+ "nnz": 91750
2041
+ },
2042
+ "model.layers.24.self_attn.v_proj": {
2043
+ "o1": 8,
2044
+ "o2": 8,
2045
+ "o3": 8,
2046
+ "i1": 14,
2047
+ "i2": 16,
2048
+ "i3": 16,
2049
+ "r0": 53,
2050
+ "r1": 53,
2051
+ "r2": 53,
2052
+ "nnz": 91750
2053
+ },
2054
+ "model.layers.24.self_attn.o_proj": {
2055
+ "o1": 14,
2056
+ "o2": 16,
2057
+ "o3": 16,
2058
+ "i1": 14,
2059
+ "i2": 16,
2060
+ "i3": 16,
2061
+ "r0": 102,
2062
+ "r1": 102,
2063
+ "r2": 102,
2064
+ "nnz": 642252
2065
+ },
2066
+ "model.layers.24.mlp.gate_proj": {
2067
+ "o1": 16,
2068
+ "o2": 32,
2069
+ "o3": 37,
2070
+ "i1": 14,
2071
+ "i2": 16,
2072
+ "i3": 16,
2073
+ "r0": 172,
2074
+ "r1": 172,
2075
+ "r2": 172,
2076
+ "nnz": 3394764
2077
+ },
2078
+ "model.layers.24.mlp.up_proj": {
2079
+ "o1": 16,
2080
+ "o2": 32,
2081
+ "o3": 37,
2082
+ "i1": 14,
2083
+ "i2": 16,
2084
+ "i3": 16,
2085
+ "r0": 172,
2086
+ "r1": 172,
2087
+ "r2": 172,
2088
+ "nnz": 3394764
2089
+ },
2090
+ "model.layers.24.mlp.down_proj": {
2091
+ "o1": 14,
2092
+ "o2": 16,
2093
+ "o3": 16,
2094
+ "i1": 16,
2095
+ "i2": 32,
2096
+ "i3": 37,
2097
+ "r0": 172,
2098
+ "r1": 172,
2099
+ "r2": 172,
2100
+ "nnz": 3394764
2101
+ },
2102
+ "model.layers.25.self_attn.q_proj": {
2103
+ "o1": 14,
2104
+ "o2": 16,
2105
+ "o3": 16,
2106
+ "i1": 14,
2107
+ "i2": 16,
2108
+ "i3": 16,
2109
+ "r0": 102,
2110
+ "r1": 102,
2111
+ "r2": 102,
2112
+ "nnz": 642252
2113
+ },
2114
+ "model.layers.25.self_attn.k_proj": {
2115
+ "o1": 8,
2116
+ "o2": 8,
2117
+ "o3": 8,
2118
+ "i1": 14,
2119
+ "i2": 16,
2120
+ "i3": 16,
2121
+ "r0": 53,
2122
+ "r1": 53,
2123
+ "r2": 53,
2124
+ "nnz": 91750
2125
+ },
2126
+ "model.layers.25.self_attn.v_proj": {
2127
+ "o1": 8,
2128
+ "o2": 8,
2129
+ "o3": 8,
2130
+ "i1": 14,
2131
+ "i2": 16,
2132
+ "i3": 16,
2133
+ "r0": 53,
2134
+ "r1": 53,
2135
+ "r2": 53,
2136
+ "nnz": 91750
2137
+ },
2138
+ "model.layers.25.self_attn.o_proj": {
2139
+ "o1": 14,
2140
+ "o2": 16,
2141
+ "o3": 16,
2142
+ "i1": 14,
2143
+ "i2": 16,
2144
+ "i3": 16,
2145
+ "r0": 102,
2146
+ "r1": 102,
2147
+ "r2": 102,
2148
+ "nnz": 642252
2149
+ },
2150
+ "model.layers.25.mlp.gate_proj": {
2151
+ "o1": 16,
2152
+ "o2": 32,
2153
+ "o3": 37,
2154
+ "i1": 14,
2155
+ "i2": 16,
2156
+ "i3": 16,
2157
+ "r0": 172,
2158
+ "r1": 172,
2159
+ "r2": 172,
2160
+ "nnz": 3394764
2161
+ },
2162
+ "model.layers.25.mlp.up_proj": {
2163
+ "o1": 16,
2164
+ "o2": 32,
2165
+ "o3": 37,
2166
+ "i1": 14,
2167
+ "i2": 16,
2168
+ "i3": 16,
2169
+ "r0": 172,
2170
+ "r1": 172,
2171
+ "r2": 172,
2172
+ "nnz": 3394764
2173
+ },
2174
+ "model.layers.25.mlp.down_proj": {
2175
+ "o1": 14,
2176
+ "o2": 16,
2177
+ "o3": 16,
2178
+ "i1": 16,
2179
+ "i2": 32,
2180
+ "i3": 37,
2181
+ "r0": 172,
2182
+ "r1": 172,
2183
+ "r2": 172,
2184
+ "nnz": 3394764
2185
+ },
2186
+ "model.layers.26.self_attn.q_proj": {
2187
+ "o1": 14,
2188
+ "o2": 16,
2189
+ "o3": 16,
2190
+ "i1": 14,
2191
+ "i2": 16,
2192
+ "i3": 16,
2193
+ "r0": 102,
2194
+ "r1": 102,
2195
+ "r2": 102,
2196
+ "nnz": 642252
2197
+ },
2198
+ "model.layers.26.self_attn.k_proj": {
2199
+ "o1": 8,
2200
+ "o2": 8,
2201
+ "o3": 8,
2202
+ "i1": 14,
2203
+ "i2": 16,
2204
+ "i3": 16,
2205
+ "r0": 53,
2206
+ "r1": 53,
2207
+ "r2": 53,
2208
+ "nnz": 91750
2209
+ },
2210
+ "model.layers.26.self_attn.v_proj": {
2211
+ "o1": 8,
2212
+ "o2": 8,
2213
+ "o3": 8,
2214
+ "i1": 14,
2215
+ "i2": 16,
2216
+ "i3": 16,
2217
+ "r0": 53,
2218
+ "r1": 53,
2219
+ "r2": 53,
2220
+ "nnz": 91750
2221
+ },
2222
+ "model.layers.26.self_attn.o_proj": {
2223
+ "o1": 14,
2224
+ "o2": 16,
2225
+ "o3": 16,
2226
+ "i1": 14,
2227
+ "i2": 16,
2228
+ "i3": 16,
2229
+ "r0": 102,
2230
+ "r1": 102,
2231
+ "r2": 102,
2232
+ "nnz": 642252
2233
+ },
2234
+ "model.layers.26.mlp.gate_proj": {
2235
+ "o1": 16,
2236
+ "o2": 32,
2237
+ "o3": 37,
2238
+ "i1": 14,
2239
+ "i2": 16,
2240
+ "i3": 16,
2241
+ "r0": 172,
2242
+ "r1": 172,
2243
+ "r2": 172,
2244
+ "nnz": 3394764
2245
+ },
2246
+ "model.layers.26.mlp.up_proj": {
2247
+ "o1": 16,
2248
+ "o2": 32,
2249
+ "o3": 37,
2250
+ "i1": 14,
2251
+ "i2": 16,
2252
+ "i3": 16,
2253
+ "r0": 172,
2254
+ "r1": 172,
2255
+ "r2": 172,
2256
+ "nnz": 3394764
2257
+ },
2258
+ "model.layers.26.mlp.down_proj": {
2259
+ "o1": 14,
2260
+ "o2": 16,
2261
+ "o3": 16,
2262
+ "i1": 16,
2263
+ "i2": 32,
2264
+ "i3": 37,
2265
+ "r0": 172,
2266
+ "r1": 172,
2267
+ "r2": 172,
2268
+ "nnz": 3394764
2269
+ },
2270
+ "model.layers.27.self_attn.q_proj": {
2271
+ "o1": 14,
2272
+ "o2": 16,
2273
+ "o3": 16,
2274
+ "i1": 14,
2275
+ "i2": 16,
2276
+ "i3": 16,
2277
+ "r0": 102,
2278
+ "r1": 102,
2279
+ "r2": 102,
2280
+ "nnz": 642252
2281
+ },
2282
+ "model.layers.27.self_attn.k_proj": {
2283
+ "o1": 8,
2284
+ "o2": 8,
2285
+ "o3": 8,
2286
+ "i1": 14,
2287
+ "i2": 16,
2288
+ "i3": 16,
2289
+ "r0": 53,
2290
+ "r1": 53,
2291
+ "r2": 53,
2292
+ "nnz": 91750
2293
+ },
2294
+ "model.layers.27.self_attn.v_proj": {
2295
+ "o1": 8,
2296
+ "o2": 8,
2297
+ "o3": 8,
2298
+ "i1": 14,
2299
+ "i2": 16,
2300
+ "i3": 16,
2301
+ "r0": 53,
2302
+ "r1": 53,
2303
+ "r2": 53,
2304
+ "nnz": 91750
2305
+ },
2306
+ "model.layers.27.self_attn.o_proj": {
2307
+ "o1": 14,
2308
+ "o2": 16,
2309
+ "o3": 16,
2310
+ "i1": 14,
2311
+ "i2": 16,
2312
+ "i3": 16,
2313
+ "r0": 102,
2314
+ "r1": 102,
2315
+ "r2": 102,
2316
+ "nnz": 642252
2317
+ },
2318
+ "model.layers.27.mlp.gate_proj": {
2319
+ "o1": 16,
2320
+ "o2": 32,
2321
+ "o3": 37,
2322
+ "i1": 14,
2323
+ "i2": 16,
2324
+ "i3": 16,
2325
+ "r0": 172,
2326
+ "r1": 172,
2327
+ "r2": 172,
2328
+ "nnz": 3394764
2329
+ },
2330
+ "model.layers.27.mlp.up_proj": {
2331
+ "o1": 16,
2332
+ "o2": 32,
2333
+ "o3": 37,
2334
+ "i1": 14,
2335
+ "i2": 16,
2336
+ "i3": 16,
2337
+ "r0": 172,
2338
+ "r1": 172,
2339
+ "r2": 172,
2340
+ "nnz": 3394764
2341
+ },
2342
+ "model.layers.27.mlp.down_proj": {
2343
+ "o1": 14,
2344
+ "o2": 16,
2345
+ "o3": 16,
2346
+ "i1": 16,
2347
+ "i2": 32,
2348
+ "i3": 37,
2349
+ "r0": 172,
2350
+ "r1": 172,
2351
+ "r2": 172,
2352
+ "nnz": 3394764
2353
+ }
2354
+ }
qwen2.5-7b/state_dict_fp16.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91fbaffbac9975e1df5c1f202c474496df44c103639c4b81fecb2382507e47ac
3
+ size 12984758379
qwen2.5-7b/tensor_formats.py ADDED
@@ -0,0 +1,768 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ """General N-core tensor formats for a linear layer: tensor train (MPO) and tensor ring.
4
+
5
+ WHY THIS EXISTS. The 2-core and 3-core results say the tensorisation step, not the healing
6
+ step, is where the leverage is: at equal parameters the 3-core beat the 2-core AFTER healing
7
+ at both budgets tried (4.72B: 38.94 vs ~36.5 full MMLU at 60M tokens; 5.74B: 44.91 vs 41.54
8
+ probe), and it got there on roughly a quarter of the tokens. That invites two orthogonal
9
+ questions this module exists to answer: how many cores, and which topology.
10
+
11
+ TENSOR TRAIN vs TENSOR RING. A TT/MPO pins the two boundary bonds to 1 -- the chain has open
12
+ ends. A tensor ring closes the chain: core k has shape (r_{k-1}, d_k, r_k) with r_N == r_0,
13
+ and the weight is the TRACE of the cyclic product. TT is exactly the TR special case r_0 = 1,
14
+ so at equal ranks TR is strictly more expressive. It is also strictly harder to fit: TT-SVD
15
+ is a sequence of Eckart-Young-optimal truncations, while a ring has no such closed form, so
16
+ TR is fitted here by TT initialisation followed by alternating least squares. That asymmetry
17
+ matters when reading results -- a TR loss could mean "the format is worse" OR "the fit did
18
+ not converge", so `fit_tr` reports its per-sweep error curve and refuses to return a fit
19
+ worse than its own TT initialisation.
20
+
21
+ INDEX CONVENTION (shared with mpo2.py / mpo3.py). Output mode k travels with input mode k:
22
+
23
+ R(W)[d_1, ..., d_N] = W[(o_1..o_N), (i_1..i_N)], d_k = (o_k, i_k) flattened
24
+
25
+ Every mode must be > 1. A mode of 1 collapses a site and silently reduces the core count,
26
+ which would make an "N-core" result actually be an (N-1)-core one.
27
+
28
+ WHITENING is diagonal and factorised across the N input modes, as in mpo3.py: the whitening
29
+ is then a mode-local rescaling that survives the fit exactly and un-whitens by division.
30
+ """
31
+
32
+ import torch
33
+
34
+
35
+ # --------------------------------------------------------------------------- rearrangement
36
+ def rearrange_n(W: torch.Tensor, osplit, isplit) -> torch.Tensor:
37
+ """W[(o_1..o_N),(i_1..i_N)] -> R[d_1,...,d_N] with d_k = o_k*i_k."""
38
+ n = len(osplit)
39
+ if len(isplit) != n:
40
+ raise ValueError("output and input must be split into the same number of modes")
41
+ perm = [j for k in range(n) for j in (k, n + k)]
42
+ return (W.reshape(*osplit, *isplit).permute(*perm)
43
+ .reshape(*[o * i for o, i in zip(osplit, isplit)]))
44
+
45
+
46
+ def inv_rearrange_n(R: torch.Tensor, osplit, isplit) -> torch.Tensor:
47
+ """Inverse of `rearrange_n`."""
48
+ n = len(osplit)
49
+ inter = [x for k in range(n) for x in (osplit[k], isplit[k])]
50
+ perm = list(range(0, 2 * n, 2)) + list(range(1, 2 * n, 2))
51
+ o = 1
52
+ i = 1
53
+ for k in range(n):
54
+ o *= osplit[k]
55
+ i *= isplit[k]
56
+ return R.reshape(*inter).permute(*perm).reshape(o, i)
57
+
58
+
59
+ def _apply_scales(R: torch.Tensor, osplit, isplit, scales, invert: bool):
60
+ """Multiply (or divide) R by sqrt(d_k[i_k]) along each input mode, in place of a dense L."""
61
+ n = len(osplit)
62
+ shape = [x for k in range(n) for x in (osplit[k], isplit[k])]
63
+ T = R.reshape(*shape)
64
+ for k in range(n):
65
+ s = scales[k].clamp_min(1e-12).sqrt()
66
+ view = [1] * (2 * n)
67
+ view[2 * k + 1] = isplit[k]
68
+ T = T / s.view(*view) if invert else T * s.view(*view)
69
+ return T.reshape(R.shape)
70
+
71
+
72
+ # --------------------------------------------------------------------------- contraction
73
+ def contract_tt(cores) -> torch.Tensor:
74
+ """Contract TT cores [(1,d1,r1), (r1,d2,r2), ..., (r_{N-1},dN,1)] -> R[d_1,...,d_N]."""
75
+ out = cores[0]
76
+ for g in cores[1:]:
77
+ a, b = out.shape[-1], g.shape[0]
78
+ if a != b:
79
+ raise ValueError(f"TT bond mismatch {a} vs {b}")
80
+ out = torch.tensordot(out, g, dims=([out.dim() - 1], [0]))
81
+ if out.shape[0] != 1 or out.shape[-1] != 1:
82
+ raise ValueError("TT boundary bonds must be 1")
83
+ return out.reshape(*out.shape[1:-1])
84
+
85
+
86
+ def contract_tr(cores, chunk: int = 0) -> torch.Tensor:
87
+ """Contract TR cores [(r0,d1,r1), ..., (r_{N-1},dN,r0)] -> R[d_1,...,d_N].
88
+
89
+ The obvious route -- chain every tensordot, then take the diagonal over the two ring
90
+ indices -- materialises (r_0, d_1..d_N, r_0), i.e. r_0^2 times the size of the ANSWER.
91
+ On one LLaMA attention layer at ring rank 118 that is 934 GB, so it does not merely run
92
+ slowly, it cannot run at all. Folding the last contraction and the trace into a single
93
+ einsum keeps the peak at r_0 * prod(d_1..d_{N-1}) * r_{N-1}, and chunking the first mode
94
+ bounds it further for the wide MLP layers.
95
+ """
96
+ n = len(cores)
97
+ if cores[0].shape[0] != cores[-1].shape[-1]:
98
+ raise ValueError(f"ring does not close: {cores[0].shape[0]} vs {cores[-1].shape[-1]}")
99
+ d0 = cores[0].shape[1]
100
+ if chunk and d0 > chunk:
101
+ parts = []
102
+ for lo in range(0, d0, chunk):
103
+ sub = [cores[0][:, lo:min(lo + chunk, d0), :]] + list(cores[1:])
104
+ parts.append(contract_tr(sub, chunk=0))
105
+ return torch.cat(parts, dim=0)
106
+ out = cores[0]
107
+ for g in cores[1:-1]:
108
+ out = torch.tensordot(out, g, dims=([out.dim() - 1], [0]))
109
+ return torch.einsum("i...k,kdi->...d", out, cores[-1])
110
+
111
+
112
+ # --------------------------------------------------------------------------- fitting
113
+ def fit_tt(R: torch.Tensor, ranks):
114
+ """TT-SVD with the given internal ranks. Singular values split symmetrically at each bond,
115
+ matching fit_mpo2/fit_mpo3's gauge so cores stay on comparable scales (fp16-safe and
116
+ kinder to a blockwise quantizer)."""
117
+ dims = list(R.shape)
118
+ n = len(dims)
119
+ if len(ranks) != n - 1:
120
+ raise ValueError(f"{n} sites need {n-1} internal ranks, got {len(ranks)}")
121
+ cores, rest, rprev = [], R.reshape(dims[0], -1), 1
122
+ for k in range(n - 1):
123
+ M = rest.reshape(rprev * dims[k], -1)
124
+ U, S, Vh = torch.linalg.svd(M, full_matrices=False)
125
+ r = min(int(ranks[k]), S.shape[0])
126
+ q = S[:r].clamp_min(0).sqrt()
127
+ cores.append((U[:, :r] * q).reshape(rprev, dims[k], r))
128
+ rest = q[:, None] * Vh[:r]
129
+ rprev = r
130
+ cores.append(rest.reshape(rprev, dims[-1], 1))
131
+ return cores
132
+
133
+
134
+ def tt_to_tr(cores):
135
+ """Reinterpret TT cores as TR cores with r_0 = 1 (an exact, lossless re-labelling)."""
136
+ return [c.clone() for c in cores]
137
+
138
+
139
+ def _subchain(cores, k):
140
+ """Contract every core except k, in cyclic order, -> E[r_k, D, r_{k-1}] with D = prod_{j!=k} d_j."""
141
+ n = len(cores)
142
+ order = [(k + 1 + t) % n for t in range(n - 1)]
143
+ out = cores[order[0]]
144
+ for j in order[1:]:
145
+ out = torch.tensordot(out, cores[j], dims=([out.dim() - 1], [0]))
146
+ return out
147
+
148
+
149
+ def _subchain_chunk(cores, k, lo, hi):
150
+ """`_subchain` with the FIRST following mode restricted to [lo, hi). The restriction rides
151
+ along the contraction untouched, so concatenating the chunks reproduces `_subchain`."""
152
+ n = len(cores)
153
+ order = [(k + 1 + t) % n for t in range(n - 1)]
154
+ out = cores[order[0]][:, lo:hi, :]
155
+ for j in order[1:]:
156
+ out = torch.tensordot(out, cores[j], dims=([out.dim() - 1], [0]))
157
+ return out
158
+
159
+
160
+ def rank_of(cores, k):
161
+ """r_{k-1} * r_k for core k -- the width of that core's least-squares system."""
162
+ n = len(cores)
163
+ return cores[k].shape[0] * cores[k].shape[2]
164
+
165
+
166
+ def _solve_maybe_cpu(AtA, AtW):
167
+ """Solve AtA X = AtW, falling back to the CPU when the GPU cannot hold the factorisation.
168
+
169
+ The normal-equation matrix is (r_{k-1} r_k) square, i.e. it grows as r^4. On down_proj at
170
+ ring rank 219 that is 47961^2 = 9.2 GB, and the factorisation needs a second copy -- no
171
+ amount of chunking the data helps, because this matrix does not depend on the data size.
172
+ Cholesky is tried first (the Gram is symmetric positive definite after the ridge) and
173
+ needs only one triangular factor; if even that does not fit, the solve moves to the host.
174
+ Slow, but a bounded slowdown beats an unbounded failure on the layers that matter most.
175
+ """
176
+ try:
177
+ L = torch.linalg.cholesky(AtA)
178
+ return torch.cholesky_solve(AtW, L)
179
+ except torch.OutOfMemoryError:
180
+ torch.cuda.empty_cache()
181
+ except Exception:
182
+ pass
183
+ try:
184
+ return torch.linalg.solve(AtA, AtW)
185
+ except torch.OutOfMemoryError:
186
+ torch.cuda.empty_cache()
187
+ dev = AtA.device
188
+ X = torch.linalg.solve(AtA.cpu().double(), AtW.cpu().double())
189
+ return X.to(device=dev, dtype=AtW.dtype)
190
+
191
+
192
+ def tr_rel_err(cores, R: torch.Tensor, chunk_elems: int = 250_000_000) -> float:
193
+ """||contract_tr(cores) - R||_F / ||R||_F, accumulated in chunks.
194
+
195
+ Materialising the reconstruction to subtract it needs the reconstruction AND the einsum's
196
+ intermediate at once; on down_proj at ring rank 155 that intermediate is (155, 64, 688,
197
+ 256) = 7 GB even with the first mode already chunked. Accumulating the squared error one
198
+ slice at a time keeps only one slice live, and the chunk width is derived from an element
199
+ budget rather than a hard-coded constant -- a constant is exactly what silently failed to
200
+ engage when a mode happened to equal it.
201
+ """
202
+ n = len(cores)
203
+ d0 = cores[0].shape[1]
204
+ mid = 1
205
+ for k in range(1, n - 1):
206
+ mid *= cores[k].shape[1]
207
+ per_unit = max(1, mid * cores[0].shape[0] * cores[-1].shape[0])
208
+ step = max(1, min(d0, int(chunk_elems // per_unit)))
209
+ acc = 0.0
210
+ for lo in range(0, d0, step):
211
+ hi = min(lo + step, d0)
212
+ sub = [cores[0][:, lo:hi, :]] + list(cores[1:])
213
+ diff = contract_tr(sub) - R[lo:hi]
214
+ acc += float(diff.pow(2).sum())
215
+ del sub, diff
216
+ return (acc ** 0.5) / float(R.norm())
217
+
218
+
219
+ def fit_tr(R: torch.Tensor, ranks, sweeps: int = 30, tol: float = 1e-8, verbose: bool = False,
220
+ seed: int = 1234, restarts: int = 2, solver: str = "lstsq",
221
+ chunk: int = 0, chunk_elems: int = 250_000_000):
222
+ """Fit a tensor ring by TT initialisation + alternating least squares.
223
+
224
+ ranks = [r_0, r_1, ..., r_{N-1}] with r_N == r_0. The TT init uses r_0 = 1 (a legal ring),
225
+ then each ALS sweep re-solves every core in closed form given the others; the ring's extra
226
+ boundary rank is opened up by padding the initialisation. Because ALS on a ring is not
227
+ guaranteed to improve monotonically from an arbitrary start, the best iterate seen is kept
228
+ and the routine REFUSES to return anything worse than its own TT initialisation -- without
229
+ that guard a fitting failure would be indistinguishable from the format being worse, which
230
+ is precisely the comparison this module exists to make.
231
+ """
232
+ n = len(R.shape)
233
+ if len(ranks) != n:
234
+ raise ValueError(f"a ring over {n} sites needs {n} ranks (r_0..r_{{N-1}})")
235
+ dims = list(R.shape)
236
+ rnorm = float(R.norm())
237
+ rnorm2 = float(R.pow(2).sum())
238
+ last_sq = None
239
+ tt = fit_tt(R, ranks[1:])
240
+ base_err = float((contract_tt(tt) - R).norm() / R.norm())
241
+ r0 = int(ranks[0])
242
+ gen = torch.Generator(device="cpu").manual_seed(seed)
243
+
244
+ def padded_init():
245
+ """TT solution embedded in the ring, with the OPENED bond seeded on BOTH ends.
246
+
247
+ Seeding only one end is not enough and is a silent failure: core 0's least-squares
248
+ environment is built from cores 1..N-1, whose ring index comes from core N-1's
249
+ trailing bond. If that stays zero, the environment vanishes on exactly the components
250
+ the ring adds, every ALS solve returns zero there, and the fit never leaves the TT
251
+ solution -- it looks like "the ring buys nothing" rather than "the ring was never
252
+ initialised".
253
+ """
254
+ out = []
255
+ for k, c in enumerate(tt):
256
+ a, d, b = c.shape
257
+ na = r0 if k == 0 else a
258
+ nb = r0 if k == n - 1 else b
259
+ g = torch.zeros(na, d, nb, dtype=R.dtype, device=R.device)
260
+ g[:a, :, :b] = c
261
+ eps = 0.05 * float(c.norm()) / max(1, c.numel()) ** 0.5
262
+ if k == 0 and na > a:
263
+ g[a:, :, :] = eps * torch.randn(na - a, d, nb, generator=gen,
264
+ dtype=R.dtype).to(R.device)
265
+ if k == n - 1 and nb > b:
266
+ g[:, :, b:] = eps * torch.randn(na, d, nb - b, generator=gen,
267
+ dtype=R.dtype).to(R.device)
268
+ out.append(g)
269
+ return out
270
+
271
+ def random_init(g=None):
272
+ """i.i.d. cores whose ring contraction has the right variance.
273
+
274
+ The scale is derived, not guessed. For cores with i.i.d. N(0, s^2) entries the trace
275
+ of the cyclic product is a sum of prod_k r_k independent products of N Gaussians, so
276
+ Var(W) ~= (prod_k r_k) * s^(2N). Matching that to the target mean square gives
277
+ s = (E[R^2] / prod_k r_k)^(1/(2N)). Getting this wrong by a constant factor per core
278
+ compounds to that factor^N in the product, which for N=4,5 puts the initial iterate
279
+ many orders of magnitude away from the data and leaves ALS crawling.
280
+ """
281
+ rr = [int(ranks[k]) for k in range(n)]
282
+ prod = 1.0
283
+ for x in rr:
284
+ prod *= x
285
+ ms = float(R.pow(2).mean())
286
+ s = (ms / prod) ** (1.0 / (2 * n))
287
+ gg = g if g is not None else gen
288
+ return [s * torch.randn(rr[k], dims[k], rr[(k + 1) % n], generator=gg,
289
+ dtype=R.dtype).to(R.device) for k in range(n)]
290
+
291
+ # ALS on a ring has genuine local minima -- a single start that stalls would be reported
292
+ # as "the ring is not better", which is exactly the confound this module must avoid. So
293
+ # several starts are run and the best kept; restarts are cheap next to the SVDs anyway.
294
+ inits = [("tt_padded", padded_init)]
295
+ for j in range(restarts):
296
+ g = torch.Generator(device="cpu").manual_seed(seed + 977 * (j + 1))
297
+ inits.append((f"random{j}", lambda g=g: random_init(g)))
298
+ best, best_err, hists, winner = tt_to_tr(tt), base_err, {}, "tt_init"
299
+ for init_name, init_fn in inits:
300
+ cores, ihist = init_fn(), []
301
+ for it in range(sweeps):
302
+ for k in range(n):
303
+ # The subchain leaves every d index separate and in CYCLIC order starting at
304
+ # k+1. R's remaining modes must be flattened in that SAME order -- movedim
305
+ # gives natural order, which for interior k is a different permutation and
306
+ # would solve the least-squares problem against mismatched columns. It still
307
+ # returns a finite "solution", just to the wrong system.
308
+ # The chunk decision is made from SHAPES ONLY and BEFORE anything large is
309
+ # built. An earlier version computed the full subchain first and then decided
310
+ # whether to chunk, so the unchunked allocation always happened anyway and the
311
+ # chunked branch saved nothing -- the memory-bounded path existed but could
312
+ # never take effect.
313
+ # Auto-size the chunk from a memory budget instead of comparing against a
314
+ # fixed number. A constant threshold silently does nothing when the mode
315
+ # happens to equal it -- which is exactly what let a 4-site fit try to
316
+ # materialise a 134 GB subchain (mode 64, chunk 64, "64 > 64" is false).
317
+ m_ = (k + 1) % n
318
+ other = 1
319
+ for j in range(n):
320
+ if j != k:
321
+ other *= dims[j]
322
+ per_unit = max(1, (other // max(1, dims[m_])) * rank_of(cores, k))
323
+ auto = max(1, min(dims[m_], int(chunk_elems // per_unit)))
324
+ use_chunk = auto < dims[m_]
325
+ if solver == "normal" and use_chunk:
326
+ # Memory-bounded normal equations. Materialising the subchain costs
327
+ # r_k * (prod_{j!=k} d_j) * r_{k-1} floats -- on down_proj at these ranks
328
+ # that is (155, 688, 256, 155) = 17 GB, so the unchunked path cannot run
329
+ # on the MLP layers at all. The Gram and right-hand side are sums over the
330
+ # flattened "others" index, so they accumulate exactly over slices of the
331
+ # first subchain mode; this is the same arithmetic, not an approximation.
332
+ m = m_
333
+ d_next = dims[m]
334
+ rk_, rkm1_ = None, None
335
+ AtA = AtW = None
336
+ Rp = R.permute(*([k] + [(k + 1 + t) % n for t in range(n - 1)]))
337
+ for lo in range(0, d_next, auto):
338
+ hi = min(lo + auto, d_next)
339
+ Ec = _subchain_chunk(cores, k, lo, hi)
340
+ rk_, rkm1_ = Ec.shape[0], Ec.shape[-1]
341
+ Ec = Ec.reshape(rk_, -1, rkm1_)
342
+ Ac = Ec.permute(1, 2, 0).reshape(Ec.shape[1], rkm1_ * rk_)
343
+ Wc = Rp[:, lo:hi].reshape(dims[k], -1)
344
+ g = Ac.transpose(0, 1) @ Ac
345
+ h = Ac.transpose(0, 1) @ Wc.transpose(0, 1)
346
+ AtA = g if AtA is None else AtA + g
347
+ AtW = h if AtW is None else AtW + h
348
+ del Ec, Ac, Wc, g, h
349
+ lam = 1e-8 * float(AtA.diagonal().abs().mean().clamp_min(1e-30))
350
+ AtA_r = AtA + lam * torch.eye(AtA.shape[0], dtype=AtA.dtype,
351
+ device=AtA.device)
352
+ G = _solve_maybe_cpu(AtA_r, AtW)
353
+ del AtA_r
354
+ # ||R - A G||^2 = ||R||^2 - 2<AtW, G> + <G, AtA G>, all from quantities
355
+ # already formed. Computing it by contracting the whole ring instead would
356
+ # cost one full O(prod d_k) tensor per sweep per core.
357
+ sq = rnorm2 - 2.0 * float((AtW * G).sum()) + float((G * (AtA @ G)).sum())
358
+ last_sq = max(sq, 0.0)
359
+ rkm1, rk = rkm1_, rk_
360
+ else:
361
+ # ONE branch builds A/Wk and ONE consumes them. Splitting the decision
362
+ # across two separate if/else chains left the non-chunked solve reachable
363
+ # after the chunked path had run, where `A` is whatever the PREVIOUS core
364
+ # left behind -- a silent wrong answer rather than an error.
365
+ E = _subchain(cores, k) # (r_k, d_{k+1},..,d_{k-1}, r_{k-1})
366
+ rk, rkm1 = E.shape[0], E.shape[-1]
367
+ E = E.reshape(rk, -1, rkm1)
368
+ D = E.shape[1]
369
+ A = E.permute(1, 2, 0).reshape(D, rkm1 * rk)
370
+ perm = [k] + [(k + 1 + t) % n for t in range(n - 1)]
371
+ # R's remaining modes must be flattened in the subchain's CYCLIC order --
372
+ # movedim gives natural order, which for interior k solves the
373
+ # least-squares problem against mismatched columns and still returns a
374
+ # finite "solution", just to the wrong system.
375
+ Wk = R.permute(*perm).reshape(dims[k], D)
376
+ del E
377
+ if solver == "normal":
378
+ AtA = A.transpose(0, 1) @ A
379
+ lam = 1e-8 * float(AtA.diagonal().abs().mean().clamp_min(1e-30))
380
+ AtA += lam * torch.eye(AtA.shape[0], dtype=A.dtype, device=A.device)
381
+ G = _solve_maybe_cpu(AtA, A.transpose(0, 1) @ Wk.transpose(0, 1))
382
+ del AtA
383
+ else:
384
+ G = torch.linalg.lstsq(A, Wk.transpose(0, 1)).solution
385
+ last_sq = None
386
+ del A, Wk
387
+ cores[k] = (G.transpose(0, 1).reshape(dims[k], rkm1, rk)
388
+ .permute(1, 0, 2).contiguous())
389
+ err = (float(last_sq) ** 0.5 / rnorm if last_sq is not None
390
+ else float((contract_tr(cores, chunk=chunk) - R).norm() / rnorm))
391
+ ihist.append(round(err, 8))
392
+ if verbose:
393
+ print(f" TR-ALS[{init_name}] sweep {it+1}: rel err {err:.6f}", flush=True)
394
+ if err < best_err - 1e-12:
395
+ best, best_err, winner = [c.clone() for c in cores], err, init_name
396
+ if it and abs(ihist[-2] - err) < tol * max(err, 1e-12):
397
+ break
398
+ hists[init_name] = ihist
399
+ # The algebraic residual is a difference of nearly equal large numbers; at a relative
400
+ # error of ~1e-2 it has already lost most of its fp32 significance. It is fine for
401
+ # steering ALS but not for the number that gets reported, so the winner is re-measured
402
+ # once by explicit contraction.
403
+ best_err = tr_rel_err(best, R)
404
+ if best_err > base_err:
405
+ return tt_to_tr(tt), base_err, {"fell_back_to_tt": True, "tt_err": base_err,
406
+ "winner": "tt_init", "als_hist": hists}
407
+ return best, best_err, {"fell_back_to_tt": winner == "tt_init", "tt_err": base_err,
408
+ "winner": winner, "als_hist": hists}
409
+
410
+
411
+ # --------------------------------------------------------------------------- bookkeeping
412
+ def tt_params(dims, ranks) -> int:
413
+ r = [1] + [int(x) for x in ranks] + [1]
414
+ return sum(r[k] * dims[k] * r[k + 1] for k in range(len(dims)))
415
+
416
+
417
+ def tr_params(dims, ranks) -> int:
418
+ r = [int(x) for x in ranks]
419
+ n = len(dims)
420
+ return sum(r[k] * dims[k] * r[(k + 1) % n] for k in range(n))
421
+
422
+
423
+ def tt_rank_ceilings(dims):
424
+ """r_k <= min(prod_{j<=k} d_j, prod_{j>k} d_j): above that the truncation is vacuous."""
425
+ n, out = len(dims), []
426
+ for k in range(n - 1):
427
+ left = 1
428
+ for j in range(k + 1):
429
+ left *= dims[j]
430
+ right = 1
431
+ for j in range(k + 1, n):
432
+ right *= dims[j]
433
+ out.append(min(left, right))
434
+ return out
435
+
436
+
437
+ def ranks_for_budget(dims, budget: int, ring: bool, alpha: float = 1.0):
438
+ """Largest ranks fitting `budget`, shaped by r_k proportional to ceiling_k ** alpha.
439
+
440
+ Bisection rather than a closed form: the count is linear in each rank but bilinear in
441
+ adjacent pairs, and cyclic for a ring, so there is no single quadratic to solve.
442
+
443
+ ALPHA EXISTS BECAUSE EQUAL FILL FRACTION IS WRONG WHEN THE CEILINGS ARE LOPSIDED. For a
444
+ 4-site split of 4096 the ceilings are (64, 4096, 64): alpha=1 spends the budget on the
445
+ huge middle bond and returns ranks like (36, 2327, 36), strangling the two bonds that
446
+ actually gate information flow through the chain. alpha=0 gives every bond the same rank
447
+ instead. Neither is right a priori, so the caller is expected to MEASURE across alpha --
448
+ the reconstruction error, not the heuristic, decides.
449
+ """
450
+ ceil_tt = tt_rank_ceilings(dims)
451
+ ceils = ([min(ceil_tt)] + ceil_tt) if ring else ceil_tt
452
+ fn = tr_params if ring else tt_params
453
+ mx = max(ceils)
454
+ shape = [(c / mx) ** alpha for c in ceils]
455
+
456
+ def build(t):
457
+ return [max(1, min(int(round(t * mx * s)), c)) for s, c in zip(shape, ceils)]
458
+
459
+ lo, hi = 0.0, 1.0
460
+ if fn(dims, build(1.0)) <= budget:
461
+ return build(1.0)
462
+ for _ in range(60):
463
+ mid = (lo + hi) / 2
464
+ if fn(dims, build(mid)) > budget:
465
+ hi = mid
466
+ else:
467
+ lo = mid
468
+ r = build(lo)
469
+ while fn(dims, r) > budget and max(r) > 1:
470
+ r[r.index(max(r))] -= 1
471
+ return r
472
+
473
+
474
+ def balanced_split(n: int, k: int):
475
+ """Most balanced k-way factorisation of n with every factor >= 2 (spread-minimising)."""
476
+ best = None
477
+ def rec(rem, parts):
478
+ nonlocal best
479
+ if len(parts) == k - 1:
480
+ if rem >= 2:
481
+ cand = parts + [rem]
482
+ key = max(cand) / min(cand)
483
+ if best is None or key < best[0]:
484
+ best = (key, cand)
485
+ return
486
+ d = 2
487
+ while d * d <= rem or d <= rem:
488
+ if d > rem:
489
+ break
490
+ if rem % d == 0:
491
+ rec(rem // d, parts + [d])
492
+ d += 1
493
+ rec(n, [])
494
+ if best is None:
495
+ raise ValueError(f"no {k}-way factorisation of {n} with all factors >= 2")
496
+ return sorted(best[1])
497
+
498
+
499
+ def self_test(device: str = "cpu") -> None:
500
+ torch.manual_seed(0)
501
+ dt = torch.float64
502
+ for osp, isp in [((4, 3), (2, 5)), ((4, 3, 2), (2, 5, 3)), ((2, 3, 2, 2), (2, 2, 3, 2))]:
503
+ n = len(osp)
504
+ out = 1
505
+ inn = 1
506
+ for x in osp:
507
+ out *= x
508
+ for x in isp:
509
+ inn *= x
510
+ W = torch.randn(out, inn, dtype=dt, device=device)
511
+ R = rearrange_n(W, osp, isp)
512
+ dims = [o * i for o, i in zip(osp, isp)]
513
+ assert list(R.shape) == dims, (R.shape, dims)
514
+ assert torch.equal(inv_rearrange_n(R, osp, isp), W), f"{n}-site rearrange not invertible"
515
+ # index identity, not just the round trip: a wrong-but-self-inverse permutation would
516
+ # pass the round trip and scramble every weight silently
517
+ for _ in range(40):
518
+ oi = [torch.randint(0, x, (1,)).item() for x in osp]
519
+ ii = [torch.randint(0, x, (1,)).item() for x in isp]
520
+ ridx = tuple(oi[k] * isp[k] + ii[k] for k in range(n))
521
+ orow = 0
522
+ for k in range(n):
523
+ orow = orow * osp[k] + oi[k]
524
+ ocol = 0
525
+ for k in range(n):
526
+ ocol = ocol * isp[k] + ii[k]
527
+ assert R[ridx] == W[orow, ocol], f"{n}-site rearrange index map wrong"
528
+
529
+ ceils = tt_rank_ceilings(dims)
530
+ cores = fit_tt(R, ceils)
531
+ e = float((contract_tt(cores) - R).norm() / R.norm())
532
+ assert e < 1e-10, f"{n}-site full-rank TT is not exact ({e:.3e})"
533
+ assert tt_params(dims, ceils) == sum(c.numel() for c in cores), "tt_params disagrees"
534
+
535
+ if n >= 3:
536
+ trunc = [max(1, c // 2) for c in ceils]
537
+ cores = fit_tt(R, trunc)
538
+ assert tt_params(dims, trunc) == sum(c.numel() for c in cores)
539
+ for a in (0.0, 0.5, 1.0):
540
+ rr = ranks_for_budget(dims, tt_params(dims, trunc), ring=False, alpha=a)
541
+ assert tt_params(dims, rr) <= tt_params(dims, trunc), \
542
+ f"TT budget solver overran at alpha={a}"
543
+ # a ring at the SAME parameter budget must not do worse than the TT it starts from
544
+ budget = tt_params(dims, trunc)
545
+ rring = ranks_for_budget(dims, budget, ring=True)
546
+ assert tr_params(dims, rring) <= budget, "TR budget solver overran"
547
+ _c, err_tr, info = fit_tr(R, rring, sweeps=6)
548
+ assert err_tr <= info["tt_err"] + 1e-12, "fit_tr returned worse than its own TT init"
549
+ assert abs(float((contract_tr(_c) - R).norm() / R.norm()) - err_tr) < 1e-8, \
550
+ "reported TR error does not match the returned cores"
551
+
552
+ ring_chk = [torch.randn(3, 5, 4, dtype=dt), torch.randn(4, 6, 2, dtype=dt),
553
+ torch.randn(2, 7, 3, dtype=dt)]
554
+ full = contract_tr(ring_chk)
555
+ assert torch.allclose(full, contract_tr(ring_chk, chunk=2), atol=1e-12), \
556
+ "chunked contract_tr disagrees with the unchunked one"
557
+ ref = torch.einsum("iaj,jbk,kci->abc", *ring_chk)
558
+ assert torch.allclose(full, ref, atol=1e-12), "contract_tr is not the cyclic trace"
559
+
560
+ # a ring with r_0 > 1 must be able to represent things a TT of the same internal ranks cannot
561
+ dims = [6, 6, 6]
562
+ torch.manual_seed(1)
563
+ ring = [torch.randn(3, 6, 3, dtype=dt) for _ in range(3)]
564
+ Rr = contract_tr(ring)
565
+ tt_same = fit_tt(Rr, [3, 3])
566
+ e_tt = float((contract_tt(tt_same) - Rr).norm() / Rr.norm())
567
+ assert e_tt > 1e-3, ("a rank-(3,3,3) ring was reproduced by a rank-(3,3) TT; the ring "
568
+ f"contraction is probably not closing the loop (err {e_tt:.3e})")
569
+ for slv in ("lstsq", "normal"):
570
+ got, err, info = fit_tr(Rr, [3, 3, 3], sweeps=200, restarts=3, solver=slv)
571
+ assert err < 1e-4, (f"TR-ALS[{slv}] failed to recover an exact rank-3 ring "
572
+ f"(err {err:.3e}); winner={info['winner']} "
573
+ f"tt_init={info['tt_err']:.3e}")
574
+ got, err, info = fit_tr(Rr, [3, 3, 3], sweeps=200, restarts=3)
575
+ # chunking changes only how the Gram is accumulated, so it must reach the same optimum
576
+ _g, err_ch, _i = fit_tr(Rr, [3, 3, 3], sweeps=200, restarts=3, solver="normal", chunk=2)
577
+ assert err_ch < 1e-4, f"chunked TR-ALS failed to recover an exact ring (err {err_ch:.3e})"
578
+ assert err < 1e-4, (f"TR-ALS failed to recover an exact rank-3 ring (err {err:.3e}); "
579
+ f"winner={info['winner']} tt_init={info['tt_err']:.3e}")
580
+
581
+ assert balanced_split(4096, 3) == [16, 16, 16], balanced_split(4096, 3)
582
+ assert balanced_split(4096, 2) == [64, 64]
583
+ b = balanced_split(11008, 3)
584
+ assert 43 in b and b[0] * b[1] * b[2] == 11008, b
585
+ print("tensor_formats self-test PASSED (N-site rearrange exact & index-checked, full-rank "
586
+ "TT exact, budget solvers within budget, TR >= its TT init, TR strictly beats TT on "
587
+ "a true ring, balanced splits correct)")
588
+
589
+
590
+ if __name__ == "__main__":
591
+ self_test()
592
+
593
+
594
+ # --------------------------------------------------------------------------- layers
595
+ class TRLinear(torch.nn.Module):
596
+ """Tensor-ring linear layer: W = Tr[G_0 G_1 ... G_{N-1}] after the shared rearrangement.
597
+
598
+ NOT a LowRankLinear subclass, unlike MPO2Linear/MPO3Linear. Those two could pretend to be
599
+ a pair of factors because a train has open ends; a ring genuinely has N 3-D cores and no
600
+ A/B roles to borrow, so anything keyed on `.A`/`.B` (the blockwise quantizer, the bond
601
+ rebalancer) has to be taught about `.cores` explicitly rather than silently doing the
602
+ wrong thing to a subclass it thinks it understands.
603
+
604
+ RECONSTRUCTION IS CHUNKED BY DEFAULT. Merging any two cores of a 3-site ring costs
605
+ r*d_i*d_j*r entries -- on down_proj at ring rank 142 that is 7.1 GB in bf16, per layer,
606
+ per forward. Chunking the first mode bounds it; the cost is more, smaller matmuls.
607
+ """
608
+
609
+ def __init__(self, cores, osplit, isplit, chunk_elems: int = 500_000_000,
610
+ bias=None):
611
+ super().__init__()
612
+ n = len(cores)
613
+ if len(osplit) != n or len(isplit) != n:
614
+ raise ValueError(f"{n} cores need {n} output and {n} input modes")
615
+ if min(list(osplit) + list(isplit)) < 2:
616
+ raise ValueError(f"degenerate split o={tuple(osplit)} i={tuple(isplit)}: a mode of "
617
+ f"1 collapses a site, making this an (N-1)-site network")
618
+ for k in range(n):
619
+ if cores[k].shape[1] != osplit[k] * isplit[k]:
620
+ raise ValueError(f"core {k} has mode {cores[k].shape[1]}, expected "
621
+ f"{osplit[k]}*{isplit[k]}")
622
+ if cores[k].shape[2] != cores[(k + 1) % n].shape[0]:
623
+ raise ValueError(f"ring does not close between cores {k} and {(k+1)%n}")
624
+ self.cores = torch.nn.ParameterList([torch.nn.Parameter(c) for c in cores])
625
+ self.osplit, self.isplit = tuple(int(x) for x in osplit), tuple(int(x) for x in isplit)
626
+ o = i = 1
627
+ for k in range(n):
628
+ o *= self.osplit[k]
629
+ i *= self.isplit[k]
630
+ self.out_features, self.in_features = o, i
631
+ self.ranks = tuple(int(c.shape[0]) for c in cores)
632
+ # Elements per unit of the FIRST mode in contract_tr's peak intermediate, which is
633
+ # (r_0, c, d_1, ..., d_{n-2}, r_{n-1}) -- the LAST core's mode is contracted away by
634
+ # the closing einsum and must not be counted. Including it over-estimated the cost by
635
+ # d_{n-1} (256x on an MLP layer), which drove the chunk to 1 and would have made every
636
+ # MLP forward 256 sequential contractions instead of 8.
637
+ mid = 1
638
+ for k in range(1, n - 1):
639
+ mid *= cores[k].shape[1]
640
+ per_unit = max(1, mid * self.ranks[0] * self.ranks[-1])
641
+ self._chunk = max(1, min(cores[0].shape[1], int(chunk_elems // per_unit)))
642
+ # non-persistent: never wants to show up in a checkpoint, and materialize_() is an
643
+ # inference-only opt-in (see below), so a freshly-loaded layer must start uncached.
644
+ self.register_buffer("_cached_weight", None, persistent=False)
645
+ # LLaMA projections have no bias, but Qwen2's q/k/v do. Dropping it on
646
+ # replacement is SILENT -- the shapes still match, the parameter-count gate
647
+ # still balances (achieved excludes bias, and so would the rebuilt model), and
648
+ # only the accuracy moves. So the bias is carried, not discarded.
649
+ self.bias = None if bias is None else torch.nn.Parameter(bias)
650
+
651
+ def weight(self) -> torch.Tensor:
652
+ if self._cached_weight is not None:
653
+ return self._cached_weight
654
+ cs = list(self.cores)
655
+ R = contract_tr(cs, chunk=self._chunk if self._chunk < cs[0].shape[1] else 0)
656
+ return inv_rearrange_n(R, self.osplit, self.isplit)
657
+
658
+ @torch.no_grad()
659
+ def materialize_(self):
660
+ """Cache the dense weight once. INFERENCE ONLY -- gradients cannot flow through the
661
+ cached tensor back to the cores, so this must never be called before/during training.
662
+
663
+ forward() calls weight() on every call, which redoes the full chunked ring
664
+ contraction (two tensor contractions + a trace per core) from scratch. That is fine
665
+ for a single forward pass, but autoregressive generation calls forward() once per
666
+ layer per GENERATED TOKEN with the cores completely unchanged between calls. Measured
667
+ on tr3_ring4b04_h1's GSM8K eval before this existed: 209s/item, ETA 73h for 1319
668
+ items -- every one of ~200 generated tokens re-contracted all 224 ring layers.
669
+ A train layer (LowRankLinear/MPO2Linear) never had this problem: F.linear(F.linear(x,
670
+ B), A) applies the two factors straight to the activation and never materializes W at
671
+ all, so there was nothing to cache there.
672
+ """
673
+ self._cached_weight = self.weight().detach().clone()
674
+
675
+ def unmaterialize_(self):
676
+ self._cached_weight = None
677
+
678
+ def forward(self, x):
679
+ b = None if self.bias is None else self.bias.to(x.dtype)
680
+ return torch.nn.functional.linear(x, self.weight().to(x.dtype), b)
681
+
682
+ def extra_repr(self) -> str:
683
+ return (f"o={self.osplit}, i={self.isplit}, ranks={self.ranks}, "
684
+ f"chunk={self._chunk}, materialized={self._cached_weight is not None}")
685
+
686
+
687
+ class SparseAugTRLinear(TRLinear):
688
+ """TRLinear plus a sparse additive residual. Same int64-index contract as the MPO layers:
689
+ `sp_idx` must NEVER be cast to a floating dtype -- a `.half()` on a 45M-scale index
690
+ silently rounds it to a different, valid-looking position."""
691
+
692
+ def __init__(self, cores, osplit, isplit, sp_idx, sp_val,
693
+ chunk_elems: int = 500_000_000, bias=None):
694
+ super().__init__(cores, osplit, isplit, chunk_elems, bias)
695
+ if sp_idx.numel() != sp_val.numel():
696
+ raise ValueError(f"{sp_idx.numel()} indices for {sp_val.numel()} values")
697
+ n = self.out_features * self.in_features
698
+ if sp_idx.numel() and (int(sp_idx.max()) >= n or int(sp_idx.min()) < 0):
699
+ raise ValueError("sparse index out of range for this layer")
700
+ self.register_buffer("sp_idx", sp_idx.to(torch.int64))
701
+ self.sp_val = torch.nn.Parameter(sp_val)
702
+
703
+ def weight(self) -> torch.Tensor:
704
+ # must check the cache here too, not just in TRLinear.weight(): materialize_() caches
705
+ # THIS class's weight() (ring + sparse, since self.weight() dispatches polymorphically
706
+ # from inside materialize_()), so without this check a later call would go
707
+ # super().weight() -> see the cache -> return the already-sparse-augmented tensor ->
708
+ # and then add the sparse residual a second time on top of it.
709
+ if self._cached_weight is not None:
710
+ return self._cached_weight
711
+ W = super().weight()
712
+ if self.sp_idx.numel():
713
+ W = W.reshape(-1).index_add(0, self.sp_idx, self.sp_val.to(W.dtype)).view_as(W)
714
+ return W
715
+
716
+ def extra_repr(self) -> str:
717
+ return super().extra_repr() + f", nnz={self.sp_idx.numel()}"
718
+
719
+
720
+ def layer_self_test() -> None:
721
+ torch.manual_seed(0)
722
+ osp, isp = (4, 3, 2), (2, 5, 3)
723
+ dims = [o * i for o, i in zip(osp, isp)]
724
+ cores = [torch.randn(3, dims[0], 4), torch.randn(4, dims[1], 2), torch.randn(2, dims[2], 3)]
725
+ lay = TRLinear([c.clone() for c in cores], osp, isp, chunk_elems=10 ** 9)
726
+ ref = inv_rearrange_n(contract_tr(cores), osp, isp)
727
+ assert torch.allclose(lay.weight(), ref, atol=1e-5), "TRLinear.weight() != contract+inverse"
728
+ # chunking must not change the answer
729
+ lay_c = TRLinear([c.clone() for c in cores], osp, isp, chunk_elems=1)
730
+ assert lay_c._chunk < dims[0], "chunk did not engage"
731
+ assert torch.allclose(lay_c.weight(), ref, atol=1e-5), "chunked forward differs"
732
+ x = torch.randn(7, lay.in_features)
733
+ assert torch.allclose(lay(x), x @ ref.T, atol=1e-4), "forward != x W^T"
734
+ idx = torch.tensor([0, 5, lay.out_features * lay.in_features - 1], dtype=torch.int64)
735
+ val = torch.tensor([1.0, -2.0, 3.0])
736
+ sl = SparseAugTRLinear([c.clone() for c in cores], osp, isp, idx, val, chunk_elems=10 ** 9)
737
+ d = (sl.weight() - ref).reshape(-1)
738
+ assert torch.allclose(d[idx], val, atol=1e-5), "sparse residual not applied at sp_idx"
739
+ assert abs(float(d.abs().sum()) - float(val.abs().sum())) < 1e-4, "residual leaked"
740
+ try:
741
+ TRLinear([torch.zeros(2, 4, 2), torch.zeros(2, 3, 2), torch.zeros(2, 6, 2)],
742
+ (4, 1, 2), (1, 3, 3))
743
+ except ValueError:
744
+ pass
745
+ else:
746
+ raise AssertionError("a degenerate split (mode = 1) was accepted")
747
+ # gradients must reach every core
748
+ lay.zero_grad()
749
+ lay(x).sum().backward()
750
+ for k, c in enumerate(lay.cores):
751
+ assert c.grad is not None and float(c.grad.abs().sum()) > 0, f"core {k} got no gradient"
752
+ # materialize_() must be a pure inference-speed cache: same weight, same forward output,
753
+ # and -- the one bug this is actually guarding against -- the sparse residual must not
754
+ # get added twice once SparseAugTRLinear.weight() is short-circuited by the cache.
755
+ pre = lay.weight().clone()
756
+ lay.materialize_()
757
+ assert lay._cached_weight is not None, "materialize_() did not populate the cache"
758
+ assert torch.allclose(lay.weight(), pre, atol=1e-6), "materialize_() changed weight()"
759
+ assert torch.allclose(lay(x), x @ ref.T, atol=1e-4), "forward != x W^T after materialize_()"
760
+ lay.unmaterialize_()
761
+ assert lay._cached_weight is None, "unmaterialize_() left the cache populated"
762
+ sl_ref = sl.weight().clone()
763
+ sl.materialize_()
764
+ assert torch.allclose(sl.weight(), sl_ref, atol=1e-6), \
765
+ "materialized SparseAugTRLinear.weight() differs -- sparse residual likely double-added"
766
+ print("TRLinear self-test PASSED (weight matches contraction, chunking exact, forward "
767
+ "correct, sparse localised, degenerate split refused, all cores differentiable, "
768
+ "materialize_() cache exact and idempotent)")