XuhanH commited on
Commit
43bcf0c
·
verified ·
1 Parent(s): b80a6a1

Publish SWD factor checkpoints

Browse files
Files changed (48) hide show
  1. .gitattributes +0 -34
  2. .pytest_cache/.gitignore +2 -0
  3. .pytest_cache/CACHEDIR.TAG +4 -0
  4. .pytest_cache/README.md +8 -0
  5. .pytest_cache/v/cache/nodeids +3 -0
  6. .pytest_cache/v/cache/stepwise +1 -0
  7. LICENSE +202 -0
  8. NOTICE +14 -0
  9. README.md +128 -0
  10. RELEASE_MANIFEST.csv +12 -0
  11. THIRD_PARTY_LICENSES/GPT2-MODIFIED-MIT.txt +24 -0
  12. __pycache__/swd_loader.cpython-312.pyc +0 -0
  13. checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/config.json +832 -0
  14. checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/model.safetensors +3 -0
  15. checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/provenance.json +224 -0
  16. checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/config.json +30 -0
  17. checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/model.safetensors +3 -0
  18. checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/provenance.json +33 -0
  19. checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/config.json +30 -0
  20. checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/model.safetensors +3 -0
  21. checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/provenance.json +33 -0
  22. checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/config.json +48 -0
  23. checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/model.safetensors +3 -0
  24. checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/provenance.json +45 -0
  25. checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/config.json +48 -0
  26. checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/model.safetensors +3 -0
  27. checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/provenance.json +45 -0
  28. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/config.json +30 -0
  29. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/model.safetensors +3 -0
  30. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/provenance.json +33 -0
  31. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/config.json +30 -0
  32. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/model.safetensors +3 -0
  33. checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/provenance.json +33 -0
  34. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/config.json +30 -0
  35. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/model.safetensors +3 -0
  36. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/provenance.json +33 -0
  37. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/config.json +30 -0
  38. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/model.safetensors +3 -0
  39. checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/provenance.json +33 -0
  40. checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/config.json +31 -0
  41. checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/model.safetensors +3 -0
  42. checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/provenance.json +35 -0
  43. checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/config.json +31 -0
  44. checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/model.safetensors +3 -0
  45. checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/provenance.json +35 -0
  46. examples/load_checkpoint.py +17 -0
  47. requirements.txt +4 -0
  48. swd_loader.py +228 -0
.gitattributes CHANGED
@@ -1,35 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.safetensors filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
.pytest_cache/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Created by pytest automatically.
2
+ *
.pytest_cache/CACHEDIR.TAG ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
2
+ # This file is a cache directory tag created by pytest.
3
+ # For information about cache directory tags, see:
4
+ # https://bford.info/cachedir/spec.html
.pytest_cache/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
.pytest_cache/v/cache/nodeids ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [
2
+ "tests/test_loader.py::test_factorized_and_folded"
3
+ ]
.pytest_cache/v/cache/stepwise ADDED
@@ -0,0 +1 @@
 
 
1
+ []
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 [yyyy] [name of copyright owner]
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.
NOTICE ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Sparse Weight Decomposition Checkpoints
2
+ Copyright 2026 SWD authors
3
+
4
+ This distribution contains factor checkpoints derived from the following
5
+ pretrained models:
6
+
7
+ - GPT-2, Copyright 2019 OpenAI, distributed under the Modified MIT License.
8
+ See THIRD_PARTY_LICENSES/GPT2-MODIFIED-MIT.txt.
9
+ - Qwen2.5-0.5B and Qwen2.5-1.5B, Copyright 2024 Alibaba Cloud, distributed
10
+ under the Apache License 2.0.
11
+ - Qwen3.5-27B, Copyright 2026 Alibaba Cloud, distributed under the Apache
12
+ License 2.0.
13
+
14
+ No base-model weights are redistributed in this repository.
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: apache-2.0
4
+ tags:
5
+ - mechanistic-interpretability
6
+ - sparse-models
7
+ - model-decomposition
8
+ - circuit-analysis
9
+ base_model:
10
+ - gpt2
11
+ - Qwen/Qwen2.5-0.5B
12
+ - Qwen/Qwen2.5-1.5B
13
+ - Qwen/Qwen3.5-27B
14
+ datasets:
15
+ - HuggingFaceFW/fineweb-edu
16
+ ---
17
+
18
+ # Sparse Weight Decomposition Checkpoints
19
+
20
+ This repository contains factor-only Sparse Weight Decomposition (SWD)
21
+ checkpoints used in our replacement-fidelity and circuit-extraction
22
+ experiments. It does **not** redistribute any base model. Load the corresponding
23
+ base model first, then apply one checkpoint with `swd_loader.py`.
24
+
25
+ Each replaced matrix is represented as
26
+
27
+ ```text
28
+ output = input @ read @ write + bias
29
+ ```
30
+
31
+ The intermediate coordinates are the SWD bottleneck units used for circuit
32
+ scoring and ablation. `s=0.5` and `s=0.75` mean that 50% and 75% of all entries
33
+ across the two factors are zero, respectively.
34
+
35
+ ## Included Checkpoints
36
+
37
+ | Base model | Replacement | Setting | Data used | CE delta vs dense |
38
+ |---|---|---:|---:|---:|
39
+ | GPT-2 Small | Layer 8 `mlp.c_proj` | `s=0.5` | 16,384 tokens | 0.000889 |
40
+ | GPT-2 Small | Layer 8 `mlp.c_proj` | `s=0.75` | 16,384 tokens | 0.008292 |
41
+ | Qwen2.5-0.5B | Layer 12 `mlp.down_proj` | `s=0.5` | 1,024 tokens | 0.001222 |
42
+ | Qwen2.5-0.5B | Layer 12 `mlp.down_proj` | `s=0.75` | 1,048,576 tokens | 0.005010 |
43
+ | Qwen2.5-1.5B | Layer 14 `mlp.down_proj` | `s=0.5` | 1,024 tokens | 0.000733 |
44
+ | Qwen2.5-1.5B | Layer 14 `mlp.down_proj` | `s=0.75` | 1,048,576 tokens | 0.001222 |
45
+ | Qwen3.5-27B | Layer 31 `mlp.down_proj` | `s=0.5` | 2,048 tokens | -0.000427 |
46
+ | Qwen3.5-27B | Layer 31 `mlp.down_proj` | `s=0.75` | 1,048,576 tokens | -0.000448 |
47
+ | GPT-2 Small | Layer 8 complete MLP | `s=0.5` | 16,384 tokens | 0.004003 |
48
+ | GPT-2 Small | Layer 8 complete MLP | `s=0.75` | 1,048,576 tokens | 0.015521 |
49
+ | GPT-2 Small | All 48 transformer-block linear projections | fixed-support SWD-FT | 20,578,304 tokens | 0.151263* |
50
+
51
+ `*` The full-model value uses its full-model stress evaluation and should not
52
+ be numerically compared with the single-matrix unified CE rows.
53
+
54
+ The Qwen2.5-3B checkpoints are distributed separately at
55
+ [`veri-safe/SWD-Qwen2.5-3B`](https://huggingface.co/veri-safe/SWD-Qwen2.5-3B)
56
+ because the upstream model uses the Qwen Research License.
57
+
58
+ ## Usage
59
+
60
+ Install the lightweight loader dependencies:
61
+
62
+ ```bash
63
+ pip install torch safetensors transformers huggingface_hub
64
+ ```
65
+
66
+ After downloading this repository, load a base model and apply a checkpoint:
67
+
68
+ ```python
69
+ from transformers import AutoModelForCausalLM
70
+ from swd_loader import apply_swd_checkpoint
71
+
72
+ model = AutoModelForCausalLM.from_pretrained("gpt2")
73
+ apply_swd_checkpoint(
74
+ model,
75
+ "checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384",
76
+ mode="factorized",
77
+ )
78
+ ```
79
+
80
+ `mode="factorized"` installs `SWDLinear`, exposing
81
+ `component_activations(inputs)`. Use `mode="folded"` to write `read @ write`
82
+ back into the original dense module for conventional inference.
83
+
84
+ The base model must be fully materialized before applying a checkpoint. For
85
+ large models loaded with a device map, each replacement is moved to the device
86
+ and dtype of its target module.
87
+
88
+ ## Format
89
+
90
+ Every checkpoint directory contains:
91
+
92
+ ```text
93
+ model.safetensors # factor tensors only; no pickle
94
+ config.json # base model, module paths, shapes, sparsity, and token exposure
95
+ provenance.json # source hashes, conversion rule, and validation result
96
+ ```
97
+
98
+ All public factors follow `[input, rank] @ [rank, output]`, independent of the
99
+ source framework's dense-weight layout. Qwen2.5 source factors are transposed
100
+ into this convention; Qwen3.5 feature shards are concatenated along the rank
101
+ dimension without changing dtype or values. Full-model GPT-2 checkpoint biases
102
+ are included because they belong to the fixed-support fine-tuned checkpoint.
103
+
104
+ `RELEASE_MANIFEST.csv` is the machine-readable checkpoint index. Each
105
+ checkpoint's `provenance.json` records its source hashes and conversion
106
+ validation.
107
+
108
+ ## Validation
109
+
110
+ Before release, every checkpoint was checked for source identity, finite
111
+ tensors, shape compatibility, factor nonzero counts, and exact tensor equality
112
+ after the safetensors round-trip.
113
+
114
+ The release intentionally excludes base-model weights, activation Grams, dense
115
+ target/reconstructed matrices, optimizer state, data caches, remote-transfer
116
+ archives, credentials, and cluster-local paths.
117
+
118
+ ## Links
119
+
120
+ - Code: https://github.com/Veri-Safe/SWD
121
+ - Models: https://huggingface.co/veri-safe/SWD
122
+
123
+ ## License
124
+
125
+ The SWD release code and the checkpoints in this repository are distributed
126
+ under the Apache License 2.0. The GPT-2-derived checkpoints also retain the
127
+ upstream Modified MIT notice in
128
+ `THIRD_PARTY_LICENSES/GPT2-MODIFIED-MIT.txt`. See `NOTICE` for attribution.
RELEASE_MANIFEST.csv ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ variant_id,base_model,replacement_scope,sparsity,token_exposure,ce_delta_vs_dense,module_count,bottleneck_units,active_factor_scalars,relative_path,weights_bytes,weights_sha256
2
+ gpt2_small_l8_cproj_s0p5,gpt2,single_matrix,0.5,16384,0.0008888365819190724,1,768,1179646,checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384,11796752,e4dc8d3fbe3f9b491a3ccadf928de65d0ad98f6826844b3143d04e1bd06a6942
3
+ gpt2_small_l8_cproj_s0p75,gpt2,single_matrix,0.75,16384,0.0082921466752812,1,768,589822,checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384,11796752,f6db8a41cfacc8cb6ce54429c6c39be7b74ba36a7d9a1aa9b3e55b1f0e0b097e
4
+ qwen25_0p5b_l12_downproj_s0p5,Qwen/Qwen2.5-0.5B,single_matrix,0.5,1024,0.0012218963831869267,1,896,2179070,checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024,20644120,400f49a25d6862f584c8057d138b83802d47e13c31b4b58acb1b4a740805ca6e
5
+ qwen25_0p5b_l12_downproj_s0p75,Qwen/Qwen2.5-0.5B,single_matrix,0.75,1048576,0.005009775171065822,1,896,1089534,checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576,20644120,530b19e4f58da33e6f3b6a7bad749cd3e8bafa8b67ee41939075d3dcb1fb4078
6
+ qwen25_1p5b_l14_downproj_s0p5,Qwen/Qwen2.5-1.5B,single_matrix,0.5,1024,0.0007331378299122449,1,1536,6881278,checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024,64487712,ad3be13722726a1a447c2ea7f41c1ee55a21099ac231ae1ea2089950d1a204dc
7
+ qwen25_1p5b_l14_downproj_s0p75,Qwen/Qwen2.5-1.5B,single_matrix,0.75,1048576,0.0012218963831869267,1,1536,3440638,checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576,64487712,aa3fa378549da027bb4bf2778fa80b158c01840aa0306025c5f828baa5bcf7dd
8
+ qwen35_27b_l31_downproj_s0p5,Qwen/Qwen3.5-27B,single_matrix,0.5,2048,-0.00042653013883819924,1,5120,44564478,checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048,230687008,84c6673c889c229853de6cea4556f4ee1b7e054b03e191353fb96563c7d31877
9
+ qwen35_27b_l31_downproj_s0p75,Qwen/Qwen3.5-27B,single_matrix,0.75,1048576,-0.00044806658464224824,1,5120,22282238,checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576,230687008,92eeb9672d70cbc16c4483bfa9673593781bf73069e145aad75bf6350df86066
10
+ gpt2_small_l8_mlp_s0p5,gpt2,mlp_replacement,0.5,16384,0.004003,2,1536,2359292,checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384,23593408,a56f5ae70bf0b3c3fa0750e53d226928a7de3e27b84458d9fcef4b159e16ea57
11
+ gpt2_small_l8_mlp_s0p75,gpt2,mlp_replacement,0.75,1048576,0.01552128791809082,2,1536,1179644,checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576,23593408,8852687de6d0d890e55c2df5a4e097224e6125d6bd4987391e50625b222953b3
12
+ gpt2_small_full_model_swdft,gpt2,full_model_linear_replacement,matched_active_budget,20578304,0.151263,48,36864,26770800,checkpoints/gpt2-small/full-model/swd-ft-tokens20578304,453329504,b18359f09dcd61ccd3197ad2c5e66e47a55ab0cc3979870dc67ce667edf2f51e
THIRD_PARTY_LICENSES/GPT2-MODIFIED-MIT.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Modified MIT License
2
+
3
+ Software Copyright (c) 2019 OpenAI
4
+
5
+ We don’t claim ownership of the content you create with GPT-2, so it is yours to do with as you please.
6
+ We only ask that you use GPT-2 responsibly and clearly indicate your content was created using GPT-2.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
9
+ associated documentation files (the "Software"), to deal in the Software without restriction,
10
+ including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
12
+ subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included
15
+ in all copies or substantial portions of the Software.
16
+ The above copyright notice and this permission notice need not be included
17
+ with content created by the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
20
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
24
+ OR OTHER DEALINGS IN THE SOFTWARE.
__pycache__/swd_loader.cpython-312.pyc ADDED
Binary file (12.3 kB). View file
 
checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/config.json ADDED
@@ -0,0 +1,832 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "gpt2",
3
+ "ce_delta_vs_dense": 0.151263,
4
+ "factorization_tokens": 4194304,
5
+ "fixed_support_finetuning_tokens": 16384000,
6
+ "method": "SWD",
7
+ "module_count": 48,
8
+ "module_replacements": [
9
+ {
10
+ "base_weight_layout": "in_out",
11
+ "bias_key": "modules.000.bias",
12
+ "bias_policy": "checkpoint",
13
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
14
+ "forward_equation": "output = input @ read @ write + bias",
15
+ "input_dim": 768,
16
+ "module_path": "transformer.h.0.attn.c_attn",
17
+ "output_dim": 2304,
18
+ "rank": 768,
19
+ "read_dtype": "float32",
20
+ "read_key": "modules.000.read",
21
+ "read_nnz": 147455,
22
+ "write_dtype": "float32",
23
+ "write_key": "modules.000.write",
24
+ "write_nnz": 410270
25
+ },
26
+ {
27
+ "base_weight_layout": "in_out",
28
+ "bias_key": "modules.001.bias",
29
+ "bias_policy": "checkpoint",
30
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
31
+ "forward_equation": "output = input @ read @ write + bias",
32
+ "input_dim": 768,
33
+ "module_path": "transformer.h.0.attn.c_proj",
34
+ "output_dim": 768,
35
+ "rank": 768,
36
+ "read_dtype": "float32",
37
+ "read_key": "modules.001.read",
38
+ "read_nnz": 94370,
39
+ "write_dtype": "float32",
40
+ "write_key": "modules.001.write",
41
+ "write_nnz": 91537
42
+ },
43
+ {
44
+ "base_weight_layout": "in_out",
45
+ "bias_key": "modules.002.bias",
46
+ "bias_policy": "checkpoint",
47
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
48
+ "forward_equation": "output = input @ read @ write + bias",
49
+ "input_dim": 768,
50
+ "module_path": "transformer.h.0.mlp.c_fc",
51
+ "output_dim": 3072,
52
+ "rank": 768,
53
+ "read_dtype": "float32",
54
+ "read_key": "modules.002.read",
55
+ "read_nnz": 147455,
56
+ "write_dtype": "float32",
57
+ "write_key": "modules.002.write",
58
+ "write_nnz": 596179
59
+ },
60
+ {
61
+ "base_weight_layout": "in_out",
62
+ "bias_key": "modules.003.bias",
63
+ "bias_policy": "checkpoint",
64
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
65
+ "forward_equation": "output = input @ read @ write + bias",
66
+ "input_dim": 3072,
67
+ "module_path": "transformer.h.0.mlp.c_proj",
68
+ "output_dim": 768,
69
+ "rank": 768,
70
+ "read_dtype": "float32",
71
+ "read_key": "modules.003.read",
72
+ "read_nnz": 596179,
73
+ "write_dtype": "float32",
74
+ "write_key": "modules.003.write",
75
+ "write_nnz": 147455
76
+ },
77
+ {
78
+ "base_weight_layout": "in_out",
79
+ "bias_key": "modules.004.bias",
80
+ "bias_policy": "checkpoint",
81
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
82
+ "forward_equation": "output = input @ read @ write + bias",
83
+ "input_dim": 768,
84
+ "module_path": "transformer.h.1.attn.c_attn",
85
+ "output_dim": 2304,
86
+ "rank": 768,
87
+ "read_dtype": "float32",
88
+ "read_key": "modules.004.read",
89
+ "read_nnz": 147455,
90
+ "write_dtype": "float32",
91
+ "write_key": "modules.004.write",
92
+ "write_nnz": 410270
93
+ },
94
+ {
95
+ "base_weight_layout": "in_out",
96
+ "bias_key": "modules.005.bias",
97
+ "bias_policy": "checkpoint",
98
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
99
+ "forward_equation": "output = input @ read @ write + bias",
100
+ "input_dim": 768,
101
+ "module_path": "transformer.h.1.attn.c_proj",
102
+ "output_dim": 768,
103
+ "rank": 768,
104
+ "read_dtype": "float32",
105
+ "read_key": "modules.005.read",
106
+ "read_nnz": 94370,
107
+ "write_dtype": "float32",
108
+ "write_key": "modules.005.write",
109
+ "write_nnz": 91537
110
+ },
111
+ {
112
+ "base_weight_layout": "in_out",
113
+ "bias_key": "modules.006.bias",
114
+ "bias_policy": "checkpoint",
115
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
116
+ "forward_equation": "output = input @ read @ write + bias",
117
+ "input_dim": 768,
118
+ "module_path": "transformer.h.1.mlp.c_fc",
119
+ "output_dim": 3072,
120
+ "rank": 768,
121
+ "read_dtype": "float32",
122
+ "read_key": "modules.006.read",
123
+ "read_nnz": 147455,
124
+ "write_dtype": "float32",
125
+ "write_key": "modules.006.write",
126
+ "write_nnz": 596179
127
+ },
128
+ {
129
+ "base_weight_layout": "in_out",
130
+ "bias_key": "modules.007.bias",
131
+ "bias_policy": "checkpoint",
132
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
133
+ "forward_equation": "output = input @ read @ write + bias",
134
+ "input_dim": 3072,
135
+ "module_path": "transformer.h.1.mlp.c_proj",
136
+ "output_dim": 768,
137
+ "rank": 768,
138
+ "read_dtype": "float32",
139
+ "read_key": "modules.007.read",
140
+ "read_nnz": 596179,
141
+ "write_dtype": "float32",
142
+ "write_key": "modules.007.write",
143
+ "write_nnz": 147455
144
+ },
145
+ {
146
+ "base_weight_layout": "in_out",
147
+ "bias_key": "modules.008.bias",
148
+ "bias_policy": "checkpoint",
149
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
150
+ "forward_equation": "output = input @ read @ write + bias",
151
+ "input_dim": 768,
152
+ "module_path": "transformer.h.2.attn.c_attn",
153
+ "output_dim": 2304,
154
+ "rank": 768,
155
+ "read_dtype": "float32",
156
+ "read_key": "modules.008.read",
157
+ "read_nnz": 147455,
158
+ "write_dtype": "float32",
159
+ "write_key": "modules.008.write",
160
+ "write_nnz": 410270
161
+ },
162
+ {
163
+ "base_weight_layout": "in_out",
164
+ "bias_key": "modules.009.bias",
165
+ "bias_policy": "checkpoint",
166
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
167
+ "forward_equation": "output = input @ read @ write + bias",
168
+ "input_dim": 768,
169
+ "module_path": "transformer.h.2.attn.c_proj",
170
+ "output_dim": 768,
171
+ "rank": 768,
172
+ "read_dtype": "float32",
173
+ "read_key": "modules.009.read",
174
+ "read_nnz": 94370,
175
+ "write_dtype": "float32",
176
+ "write_key": "modules.009.write",
177
+ "write_nnz": 91537
178
+ },
179
+ {
180
+ "base_weight_layout": "in_out",
181
+ "bias_key": "modules.010.bias",
182
+ "bias_policy": "checkpoint",
183
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
184
+ "forward_equation": "output = input @ read @ write + bias",
185
+ "input_dim": 768,
186
+ "module_path": "transformer.h.2.mlp.c_fc",
187
+ "output_dim": 3072,
188
+ "rank": 768,
189
+ "read_dtype": "float32",
190
+ "read_key": "modules.010.read",
191
+ "read_nnz": 147455,
192
+ "write_dtype": "float32",
193
+ "write_key": "modules.010.write",
194
+ "write_nnz": 596179
195
+ },
196
+ {
197
+ "base_weight_layout": "in_out",
198
+ "bias_key": "modules.011.bias",
199
+ "bias_policy": "checkpoint",
200
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
201
+ "forward_equation": "output = input @ read @ write + bias",
202
+ "input_dim": 3072,
203
+ "module_path": "transformer.h.2.mlp.c_proj",
204
+ "output_dim": 768,
205
+ "rank": 768,
206
+ "read_dtype": "float32",
207
+ "read_key": "modules.011.read",
208
+ "read_nnz": 596179,
209
+ "write_dtype": "float32",
210
+ "write_key": "modules.011.write",
211
+ "write_nnz": 147455
212
+ },
213
+ {
214
+ "base_weight_layout": "in_out",
215
+ "bias_key": "modules.012.bias",
216
+ "bias_policy": "checkpoint",
217
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
218
+ "forward_equation": "output = input @ read @ write + bias",
219
+ "input_dim": 768,
220
+ "module_path": "transformer.h.3.attn.c_attn",
221
+ "output_dim": 2304,
222
+ "rank": 768,
223
+ "read_dtype": "float32",
224
+ "read_key": "modules.012.read",
225
+ "read_nnz": 147455,
226
+ "write_dtype": "float32",
227
+ "write_key": "modules.012.write",
228
+ "write_nnz": 410270
229
+ },
230
+ {
231
+ "base_weight_layout": "in_out",
232
+ "bias_key": "modules.013.bias",
233
+ "bias_policy": "checkpoint",
234
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
235
+ "forward_equation": "output = input @ read @ write + bias",
236
+ "input_dim": 768,
237
+ "module_path": "transformer.h.3.attn.c_proj",
238
+ "output_dim": 768,
239
+ "rank": 768,
240
+ "read_dtype": "float32",
241
+ "read_key": "modules.013.read",
242
+ "read_nnz": 94370,
243
+ "write_dtype": "float32",
244
+ "write_key": "modules.013.write",
245
+ "write_nnz": 91537
246
+ },
247
+ {
248
+ "base_weight_layout": "in_out",
249
+ "bias_key": "modules.014.bias",
250
+ "bias_policy": "checkpoint",
251
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
252
+ "forward_equation": "output = input @ read @ write + bias",
253
+ "input_dim": 768,
254
+ "module_path": "transformer.h.3.mlp.c_fc",
255
+ "output_dim": 3072,
256
+ "rank": 768,
257
+ "read_dtype": "float32",
258
+ "read_key": "modules.014.read",
259
+ "read_nnz": 147455,
260
+ "write_dtype": "float32",
261
+ "write_key": "modules.014.write",
262
+ "write_nnz": 596179
263
+ },
264
+ {
265
+ "base_weight_layout": "in_out",
266
+ "bias_key": "modules.015.bias",
267
+ "bias_policy": "checkpoint",
268
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
269
+ "forward_equation": "output = input @ read @ write + bias",
270
+ "input_dim": 3072,
271
+ "module_path": "transformer.h.3.mlp.c_proj",
272
+ "output_dim": 768,
273
+ "rank": 768,
274
+ "read_dtype": "float32",
275
+ "read_key": "modules.015.read",
276
+ "read_nnz": 596179,
277
+ "write_dtype": "float32",
278
+ "write_key": "modules.015.write",
279
+ "write_nnz": 147455
280
+ },
281
+ {
282
+ "base_weight_layout": "in_out",
283
+ "bias_key": "modules.016.bias",
284
+ "bias_policy": "checkpoint",
285
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
286
+ "forward_equation": "output = input @ read @ write + bias",
287
+ "input_dim": 768,
288
+ "module_path": "transformer.h.4.attn.c_attn",
289
+ "output_dim": 2304,
290
+ "rank": 768,
291
+ "read_dtype": "float32",
292
+ "read_key": "modules.016.read",
293
+ "read_nnz": 147455,
294
+ "write_dtype": "float32",
295
+ "write_key": "modules.016.write",
296
+ "write_nnz": 410270
297
+ },
298
+ {
299
+ "base_weight_layout": "in_out",
300
+ "bias_key": "modules.017.bias",
301
+ "bias_policy": "checkpoint",
302
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
303
+ "forward_equation": "output = input @ read @ write + bias",
304
+ "input_dim": 768,
305
+ "module_path": "transformer.h.4.attn.c_proj",
306
+ "output_dim": 768,
307
+ "rank": 768,
308
+ "read_dtype": "float32",
309
+ "read_key": "modules.017.read",
310
+ "read_nnz": 94370,
311
+ "write_dtype": "float32",
312
+ "write_key": "modules.017.write",
313
+ "write_nnz": 91537
314
+ },
315
+ {
316
+ "base_weight_layout": "in_out",
317
+ "bias_key": "modules.018.bias",
318
+ "bias_policy": "checkpoint",
319
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
320
+ "forward_equation": "output = input @ read @ write + bias",
321
+ "input_dim": 768,
322
+ "module_path": "transformer.h.4.mlp.c_fc",
323
+ "output_dim": 3072,
324
+ "rank": 768,
325
+ "read_dtype": "float32",
326
+ "read_key": "modules.018.read",
327
+ "read_nnz": 147455,
328
+ "write_dtype": "float32",
329
+ "write_key": "modules.018.write",
330
+ "write_nnz": 596179
331
+ },
332
+ {
333
+ "base_weight_layout": "in_out",
334
+ "bias_key": "modules.019.bias",
335
+ "bias_policy": "checkpoint",
336
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
337
+ "forward_equation": "output = input @ read @ write + bias",
338
+ "input_dim": 3072,
339
+ "module_path": "transformer.h.4.mlp.c_proj",
340
+ "output_dim": 768,
341
+ "rank": 768,
342
+ "read_dtype": "float32",
343
+ "read_key": "modules.019.read",
344
+ "read_nnz": 596179,
345
+ "write_dtype": "float32",
346
+ "write_key": "modules.019.write",
347
+ "write_nnz": 147455
348
+ },
349
+ {
350
+ "base_weight_layout": "in_out",
351
+ "bias_key": "modules.020.bias",
352
+ "bias_policy": "checkpoint",
353
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
354
+ "forward_equation": "output = input @ read @ write + bias",
355
+ "input_dim": 768,
356
+ "module_path": "transformer.h.5.attn.c_attn",
357
+ "output_dim": 2304,
358
+ "rank": 768,
359
+ "read_dtype": "float32",
360
+ "read_key": "modules.020.read",
361
+ "read_nnz": 147455,
362
+ "write_dtype": "float32",
363
+ "write_key": "modules.020.write",
364
+ "write_nnz": 410270
365
+ },
366
+ {
367
+ "base_weight_layout": "in_out",
368
+ "bias_key": "modules.021.bias",
369
+ "bias_policy": "checkpoint",
370
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
371
+ "forward_equation": "output = input @ read @ write + bias",
372
+ "input_dim": 768,
373
+ "module_path": "transformer.h.5.attn.c_proj",
374
+ "output_dim": 768,
375
+ "rank": 768,
376
+ "read_dtype": "float32",
377
+ "read_key": "modules.021.read",
378
+ "read_nnz": 94370,
379
+ "write_dtype": "float32",
380
+ "write_key": "modules.021.write",
381
+ "write_nnz": 91537
382
+ },
383
+ {
384
+ "base_weight_layout": "in_out",
385
+ "bias_key": "modules.022.bias",
386
+ "bias_policy": "checkpoint",
387
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
388
+ "forward_equation": "output = input @ read @ write + bias",
389
+ "input_dim": 768,
390
+ "module_path": "transformer.h.5.mlp.c_fc",
391
+ "output_dim": 3072,
392
+ "rank": 768,
393
+ "read_dtype": "float32",
394
+ "read_key": "modules.022.read",
395
+ "read_nnz": 147455,
396
+ "write_dtype": "float32",
397
+ "write_key": "modules.022.write",
398
+ "write_nnz": 596179
399
+ },
400
+ {
401
+ "base_weight_layout": "in_out",
402
+ "bias_key": "modules.023.bias",
403
+ "bias_policy": "checkpoint",
404
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
405
+ "forward_equation": "output = input @ read @ write + bias",
406
+ "input_dim": 3072,
407
+ "module_path": "transformer.h.5.mlp.c_proj",
408
+ "output_dim": 768,
409
+ "rank": 768,
410
+ "read_dtype": "float32",
411
+ "read_key": "modules.023.read",
412
+ "read_nnz": 596179,
413
+ "write_dtype": "float32",
414
+ "write_key": "modules.023.write",
415
+ "write_nnz": 147455
416
+ },
417
+ {
418
+ "base_weight_layout": "in_out",
419
+ "bias_key": "modules.024.bias",
420
+ "bias_policy": "checkpoint",
421
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
422
+ "forward_equation": "output = input @ read @ write + bias",
423
+ "input_dim": 768,
424
+ "module_path": "transformer.h.6.attn.c_attn",
425
+ "output_dim": 2304,
426
+ "rank": 768,
427
+ "read_dtype": "float32",
428
+ "read_key": "modules.024.read",
429
+ "read_nnz": 147455,
430
+ "write_dtype": "float32",
431
+ "write_key": "modules.024.write",
432
+ "write_nnz": 410270
433
+ },
434
+ {
435
+ "base_weight_layout": "in_out",
436
+ "bias_key": "modules.025.bias",
437
+ "bias_policy": "checkpoint",
438
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
439
+ "forward_equation": "output = input @ read @ write + bias",
440
+ "input_dim": 768,
441
+ "module_path": "transformer.h.6.attn.c_proj",
442
+ "output_dim": 768,
443
+ "rank": 768,
444
+ "read_dtype": "float32",
445
+ "read_key": "modules.025.read",
446
+ "read_nnz": 94370,
447
+ "write_dtype": "float32",
448
+ "write_key": "modules.025.write",
449
+ "write_nnz": 91537
450
+ },
451
+ {
452
+ "base_weight_layout": "in_out",
453
+ "bias_key": "modules.026.bias",
454
+ "bias_policy": "checkpoint",
455
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
456
+ "forward_equation": "output = input @ read @ write + bias",
457
+ "input_dim": 768,
458
+ "module_path": "transformer.h.6.mlp.c_fc",
459
+ "output_dim": 3072,
460
+ "rank": 768,
461
+ "read_dtype": "float32",
462
+ "read_key": "modules.026.read",
463
+ "read_nnz": 147455,
464
+ "write_dtype": "float32",
465
+ "write_key": "modules.026.write",
466
+ "write_nnz": 596179
467
+ },
468
+ {
469
+ "base_weight_layout": "in_out",
470
+ "bias_key": "modules.027.bias",
471
+ "bias_policy": "checkpoint",
472
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
473
+ "forward_equation": "output = input @ read @ write + bias",
474
+ "input_dim": 3072,
475
+ "module_path": "transformer.h.6.mlp.c_proj",
476
+ "output_dim": 768,
477
+ "rank": 768,
478
+ "read_dtype": "float32",
479
+ "read_key": "modules.027.read",
480
+ "read_nnz": 596179,
481
+ "write_dtype": "float32",
482
+ "write_key": "modules.027.write",
483
+ "write_nnz": 147455
484
+ },
485
+ {
486
+ "base_weight_layout": "in_out",
487
+ "bias_key": "modules.028.bias",
488
+ "bias_policy": "checkpoint",
489
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
490
+ "forward_equation": "output = input @ read @ write + bias",
491
+ "input_dim": 768,
492
+ "module_path": "transformer.h.7.attn.c_attn",
493
+ "output_dim": 2304,
494
+ "rank": 768,
495
+ "read_dtype": "float32",
496
+ "read_key": "modules.028.read",
497
+ "read_nnz": 147455,
498
+ "write_dtype": "float32",
499
+ "write_key": "modules.028.write",
500
+ "write_nnz": 410270
501
+ },
502
+ {
503
+ "base_weight_layout": "in_out",
504
+ "bias_key": "modules.029.bias",
505
+ "bias_policy": "checkpoint",
506
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
507
+ "forward_equation": "output = input @ read @ write + bias",
508
+ "input_dim": 768,
509
+ "module_path": "transformer.h.7.attn.c_proj",
510
+ "output_dim": 768,
511
+ "rank": 768,
512
+ "read_dtype": "float32",
513
+ "read_key": "modules.029.read",
514
+ "read_nnz": 94370,
515
+ "write_dtype": "float32",
516
+ "write_key": "modules.029.write",
517
+ "write_nnz": 91537
518
+ },
519
+ {
520
+ "base_weight_layout": "in_out",
521
+ "bias_key": "modules.030.bias",
522
+ "bias_policy": "checkpoint",
523
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
524
+ "forward_equation": "output = input @ read @ write + bias",
525
+ "input_dim": 768,
526
+ "module_path": "transformer.h.7.mlp.c_fc",
527
+ "output_dim": 3072,
528
+ "rank": 768,
529
+ "read_dtype": "float32",
530
+ "read_key": "modules.030.read",
531
+ "read_nnz": 147455,
532
+ "write_dtype": "float32",
533
+ "write_key": "modules.030.write",
534
+ "write_nnz": 596179
535
+ },
536
+ {
537
+ "base_weight_layout": "in_out",
538
+ "bias_key": "modules.031.bias",
539
+ "bias_policy": "checkpoint",
540
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
541
+ "forward_equation": "output = input @ read @ write + bias",
542
+ "input_dim": 3072,
543
+ "module_path": "transformer.h.7.mlp.c_proj",
544
+ "output_dim": 768,
545
+ "rank": 768,
546
+ "read_dtype": "float32",
547
+ "read_key": "modules.031.read",
548
+ "read_nnz": 596179,
549
+ "write_dtype": "float32",
550
+ "write_key": "modules.031.write",
551
+ "write_nnz": 147455
552
+ },
553
+ {
554
+ "base_weight_layout": "in_out",
555
+ "bias_key": "modules.032.bias",
556
+ "bias_policy": "checkpoint",
557
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
558
+ "forward_equation": "output = input @ read @ write + bias",
559
+ "input_dim": 768,
560
+ "module_path": "transformer.h.8.attn.c_attn",
561
+ "output_dim": 2304,
562
+ "rank": 768,
563
+ "read_dtype": "float32",
564
+ "read_key": "modules.032.read",
565
+ "read_nnz": 147455,
566
+ "write_dtype": "float32",
567
+ "write_key": "modules.032.write",
568
+ "write_nnz": 410270
569
+ },
570
+ {
571
+ "base_weight_layout": "in_out",
572
+ "bias_key": "modules.033.bias",
573
+ "bias_policy": "checkpoint",
574
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
575
+ "forward_equation": "output = input @ read @ write + bias",
576
+ "input_dim": 768,
577
+ "module_path": "transformer.h.8.attn.c_proj",
578
+ "output_dim": 768,
579
+ "rank": 768,
580
+ "read_dtype": "float32",
581
+ "read_key": "modules.033.read",
582
+ "read_nnz": 94370,
583
+ "write_dtype": "float32",
584
+ "write_key": "modules.033.write",
585
+ "write_nnz": 91537
586
+ },
587
+ {
588
+ "base_weight_layout": "in_out",
589
+ "bias_key": "modules.034.bias",
590
+ "bias_policy": "checkpoint",
591
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
592
+ "forward_equation": "output = input @ read @ write + bias",
593
+ "input_dim": 768,
594
+ "module_path": "transformer.h.8.mlp.c_fc",
595
+ "output_dim": 3072,
596
+ "rank": 768,
597
+ "read_dtype": "float32",
598
+ "read_key": "modules.034.read",
599
+ "read_nnz": 147455,
600
+ "write_dtype": "float32",
601
+ "write_key": "modules.034.write",
602
+ "write_nnz": 596179
603
+ },
604
+ {
605
+ "base_weight_layout": "in_out",
606
+ "bias_key": "modules.035.bias",
607
+ "bias_policy": "checkpoint",
608
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
609
+ "forward_equation": "output = input @ read @ write + bias",
610
+ "input_dim": 3072,
611
+ "module_path": "transformer.h.8.mlp.c_proj",
612
+ "output_dim": 768,
613
+ "rank": 768,
614
+ "read_dtype": "float32",
615
+ "read_key": "modules.035.read",
616
+ "read_nnz": 596179,
617
+ "write_dtype": "float32",
618
+ "write_key": "modules.035.write",
619
+ "write_nnz": 147455
620
+ },
621
+ {
622
+ "base_weight_layout": "in_out",
623
+ "bias_key": "modules.036.bias",
624
+ "bias_policy": "checkpoint",
625
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
626
+ "forward_equation": "output = input @ read @ write + bias",
627
+ "input_dim": 768,
628
+ "module_path": "transformer.h.9.attn.c_attn",
629
+ "output_dim": 2304,
630
+ "rank": 768,
631
+ "read_dtype": "float32",
632
+ "read_key": "modules.036.read",
633
+ "read_nnz": 147455,
634
+ "write_dtype": "float32",
635
+ "write_key": "modules.036.write",
636
+ "write_nnz": 410270
637
+ },
638
+ {
639
+ "base_weight_layout": "in_out",
640
+ "bias_key": "modules.037.bias",
641
+ "bias_policy": "checkpoint",
642
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
643
+ "forward_equation": "output = input @ read @ write + bias",
644
+ "input_dim": 768,
645
+ "module_path": "transformer.h.9.attn.c_proj",
646
+ "output_dim": 768,
647
+ "rank": 768,
648
+ "read_dtype": "float32",
649
+ "read_key": "modules.037.read",
650
+ "read_nnz": 94370,
651
+ "write_dtype": "float32",
652
+ "write_key": "modules.037.write",
653
+ "write_nnz": 91537
654
+ },
655
+ {
656
+ "base_weight_layout": "in_out",
657
+ "bias_key": "modules.038.bias",
658
+ "bias_policy": "checkpoint",
659
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
660
+ "forward_equation": "output = input @ read @ write + bias",
661
+ "input_dim": 768,
662
+ "module_path": "transformer.h.9.mlp.c_fc",
663
+ "output_dim": 3072,
664
+ "rank": 768,
665
+ "read_dtype": "float32",
666
+ "read_key": "modules.038.read",
667
+ "read_nnz": 147455,
668
+ "write_dtype": "float32",
669
+ "write_key": "modules.038.write",
670
+ "write_nnz": 596179
671
+ },
672
+ {
673
+ "base_weight_layout": "in_out",
674
+ "bias_key": "modules.039.bias",
675
+ "bias_policy": "checkpoint",
676
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
677
+ "forward_equation": "output = input @ read @ write + bias",
678
+ "input_dim": 3072,
679
+ "module_path": "transformer.h.9.mlp.c_proj",
680
+ "output_dim": 768,
681
+ "rank": 768,
682
+ "read_dtype": "float32",
683
+ "read_key": "modules.039.read",
684
+ "read_nnz": 596179,
685
+ "write_dtype": "float32",
686
+ "write_key": "modules.039.write",
687
+ "write_nnz": 147455
688
+ },
689
+ {
690
+ "base_weight_layout": "in_out",
691
+ "bias_key": "modules.040.bias",
692
+ "bias_policy": "checkpoint",
693
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
694
+ "forward_equation": "output = input @ read @ write + bias",
695
+ "input_dim": 768,
696
+ "module_path": "transformer.h.10.attn.c_attn",
697
+ "output_dim": 2304,
698
+ "rank": 768,
699
+ "read_dtype": "float32",
700
+ "read_key": "modules.040.read",
701
+ "read_nnz": 147455,
702
+ "write_dtype": "float32",
703
+ "write_key": "modules.040.write",
704
+ "write_nnz": 410270
705
+ },
706
+ {
707
+ "base_weight_layout": "in_out",
708
+ "bias_key": "modules.041.bias",
709
+ "bias_policy": "checkpoint",
710
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
711
+ "forward_equation": "output = input @ read @ write + bias",
712
+ "input_dim": 768,
713
+ "module_path": "transformer.h.10.attn.c_proj",
714
+ "output_dim": 768,
715
+ "rank": 768,
716
+ "read_dtype": "float32",
717
+ "read_key": "modules.041.read",
718
+ "read_nnz": 94370,
719
+ "write_dtype": "float32",
720
+ "write_key": "modules.041.write",
721
+ "write_nnz": 91537
722
+ },
723
+ {
724
+ "base_weight_layout": "in_out",
725
+ "bias_key": "modules.042.bias",
726
+ "bias_policy": "checkpoint",
727
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
728
+ "forward_equation": "output = input @ read @ write + bias",
729
+ "input_dim": 768,
730
+ "module_path": "transformer.h.10.mlp.c_fc",
731
+ "output_dim": 3072,
732
+ "rank": 768,
733
+ "read_dtype": "float32",
734
+ "read_key": "modules.042.read",
735
+ "read_nnz": 147455,
736
+ "write_dtype": "float32",
737
+ "write_key": "modules.042.write",
738
+ "write_nnz": 596179
739
+ },
740
+ {
741
+ "base_weight_layout": "in_out",
742
+ "bias_key": "modules.043.bias",
743
+ "bias_policy": "checkpoint",
744
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
745
+ "forward_equation": "output = input @ read @ write + bias",
746
+ "input_dim": 3072,
747
+ "module_path": "transformer.h.10.mlp.c_proj",
748
+ "output_dim": 768,
749
+ "rank": 768,
750
+ "read_dtype": "float32",
751
+ "read_key": "modules.043.read",
752
+ "read_nnz": 596179,
753
+ "write_dtype": "float32",
754
+ "write_key": "modules.043.write",
755
+ "write_nnz": 147455
756
+ },
757
+ {
758
+ "base_weight_layout": "in_out",
759
+ "bias_key": "modules.044.bias",
760
+ "bias_policy": "checkpoint",
761
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
762
+ "forward_equation": "output = input @ read @ write + bias",
763
+ "input_dim": 768,
764
+ "module_path": "transformer.h.11.attn.c_attn",
765
+ "output_dim": 2304,
766
+ "rank": 768,
767
+ "read_dtype": "float32",
768
+ "read_key": "modules.044.read",
769
+ "read_nnz": 147455,
770
+ "write_dtype": "float32",
771
+ "write_key": "modules.044.write",
772
+ "write_nnz": 410270
773
+ },
774
+ {
775
+ "base_weight_layout": "in_out",
776
+ "bias_key": "modules.045.bias",
777
+ "bias_policy": "checkpoint",
778
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
779
+ "forward_equation": "output = input @ read @ write + bias",
780
+ "input_dim": 768,
781
+ "module_path": "transformer.h.11.attn.c_proj",
782
+ "output_dim": 768,
783
+ "rank": 768,
784
+ "read_dtype": "float32",
785
+ "read_key": "modules.045.read",
786
+ "read_nnz": 94370,
787
+ "write_dtype": "float32",
788
+ "write_key": "modules.045.write",
789
+ "write_nnz": 91537
790
+ },
791
+ {
792
+ "base_weight_layout": "in_out",
793
+ "bias_key": "modules.046.bias",
794
+ "bias_policy": "checkpoint",
795
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
796
+ "forward_equation": "output = input @ read @ write + bias",
797
+ "input_dim": 768,
798
+ "module_path": "transformer.h.11.mlp.c_fc",
799
+ "output_dim": 3072,
800
+ "rank": 768,
801
+ "read_dtype": "float32",
802
+ "read_key": "modules.046.read",
803
+ "read_nnz": 147455,
804
+ "write_dtype": "float32",
805
+ "write_key": "modules.046.write",
806
+ "write_nnz": 596179
807
+ },
808
+ {
809
+ "base_weight_layout": "in_out",
810
+ "bias_key": "modules.047.bias",
811
+ "bias_policy": "checkpoint",
812
+ "conversion_rule": "read=A; write=B; bias=checkpoint bias",
813
+ "forward_equation": "output = input @ read @ write + bias",
814
+ "input_dim": 3072,
815
+ "module_path": "transformer.h.11.mlp.c_proj",
816
+ "output_dim": 768,
817
+ "rank": 768,
818
+ "read_dtype": "float32",
819
+ "read_key": "modules.047.read",
820
+ "read_nnz": 596179,
821
+ "write_dtype": "float32",
822
+ "write_key": "modules.047.write",
823
+ "write_nnz": 147455
824
+ }
825
+ ],
826
+ "replacement_scope": "full_model_linear_replacement",
827
+ "schema_version": "swd_factor_checkpoint_v1",
828
+ "sparsity": "matched_active_budget",
829
+ "token_exposure": 20578304,
830
+ "variant_id": "gpt2_small_full_model_swdft",
831
+ "weights_file": "model.safetensors"
832
+ }
checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b18359f09dcd61ccd3197ad2c5e66e47a55ab0cc3979870dc67ce667edf2f51e
3
+ size 453329504
checkpoints/gpt2-small/full-model/swd-ft-tokens20578304/provenance.json ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "transformer.h.0.attn.c_attn",
5
+ "rule": "read=A; write=B; bias=checkpoint bias"
6
+ },
7
+ {
8
+ "module_path": "transformer.h.0.attn.c_proj",
9
+ "rule": "read=A; write=B; bias=checkpoint bias"
10
+ },
11
+ {
12
+ "module_path": "transformer.h.0.mlp.c_fc",
13
+ "rule": "read=A; write=B; bias=checkpoint bias"
14
+ },
15
+ {
16
+ "module_path": "transformer.h.0.mlp.c_proj",
17
+ "rule": "read=A; write=B; bias=checkpoint bias"
18
+ },
19
+ {
20
+ "module_path": "transformer.h.1.attn.c_attn",
21
+ "rule": "read=A; write=B; bias=checkpoint bias"
22
+ },
23
+ {
24
+ "module_path": "transformer.h.1.attn.c_proj",
25
+ "rule": "read=A; write=B; bias=checkpoint bias"
26
+ },
27
+ {
28
+ "module_path": "transformer.h.1.mlp.c_fc",
29
+ "rule": "read=A; write=B; bias=checkpoint bias"
30
+ },
31
+ {
32
+ "module_path": "transformer.h.1.mlp.c_proj",
33
+ "rule": "read=A; write=B; bias=checkpoint bias"
34
+ },
35
+ {
36
+ "module_path": "transformer.h.2.attn.c_attn",
37
+ "rule": "read=A; write=B; bias=checkpoint bias"
38
+ },
39
+ {
40
+ "module_path": "transformer.h.2.attn.c_proj",
41
+ "rule": "read=A; write=B; bias=checkpoint bias"
42
+ },
43
+ {
44
+ "module_path": "transformer.h.2.mlp.c_fc",
45
+ "rule": "read=A; write=B; bias=checkpoint bias"
46
+ },
47
+ {
48
+ "module_path": "transformer.h.2.mlp.c_proj",
49
+ "rule": "read=A; write=B; bias=checkpoint bias"
50
+ },
51
+ {
52
+ "module_path": "transformer.h.3.attn.c_attn",
53
+ "rule": "read=A; write=B; bias=checkpoint bias"
54
+ },
55
+ {
56
+ "module_path": "transformer.h.3.attn.c_proj",
57
+ "rule": "read=A; write=B; bias=checkpoint bias"
58
+ },
59
+ {
60
+ "module_path": "transformer.h.3.mlp.c_fc",
61
+ "rule": "read=A; write=B; bias=checkpoint bias"
62
+ },
63
+ {
64
+ "module_path": "transformer.h.3.mlp.c_proj",
65
+ "rule": "read=A; write=B; bias=checkpoint bias"
66
+ },
67
+ {
68
+ "module_path": "transformer.h.4.attn.c_attn",
69
+ "rule": "read=A; write=B; bias=checkpoint bias"
70
+ },
71
+ {
72
+ "module_path": "transformer.h.4.attn.c_proj",
73
+ "rule": "read=A; write=B; bias=checkpoint bias"
74
+ },
75
+ {
76
+ "module_path": "transformer.h.4.mlp.c_fc",
77
+ "rule": "read=A; write=B; bias=checkpoint bias"
78
+ },
79
+ {
80
+ "module_path": "transformer.h.4.mlp.c_proj",
81
+ "rule": "read=A; write=B; bias=checkpoint bias"
82
+ },
83
+ {
84
+ "module_path": "transformer.h.5.attn.c_attn",
85
+ "rule": "read=A; write=B; bias=checkpoint bias"
86
+ },
87
+ {
88
+ "module_path": "transformer.h.5.attn.c_proj",
89
+ "rule": "read=A; write=B; bias=checkpoint bias"
90
+ },
91
+ {
92
+ "module_path": "transformer.h.5.mlp.c_fc",
93
+ "rule": "read=A; write=B; bias=checkpoint bias"
94
+ },
95
+ {
96
+ "module_path": "transformer.h.5.mlp.c_proj",
97
+ "rule": "read=A; write=B; bias=checkpoint bias"
98
+ },
99
+ {
100
+ "module_path": "transformer.h.6.attn.c_attn",
101
+ "rule": "read=A; write=B; bias=checkpoint bias"
102
+ },
103
+ {
104
+ "module_path": "transformer.h.6.attn.c_proj",
105
+ "rule": "read=A; write=B; bias=checkpoint bias"
106
+ },
107
+ {
108
+ "module_path": "transformer.h.6.mlp.c_fc",
109
+ "rule": "read=A; write=B; bias=checkpoint bias"
110
+ },
111
+ {
112
+ "module_path": "transformer.h.6.mlp.c_proj",
113
+ "rule": "read=A; write=B; bias=checkpoint bias"
114
+ },
115
+ {
116
+ "module_path": "transformer.h.7.attn.c_attn",
117
+ "rule": "read=A; write=B; bias=checkpoint bias"
118
+ },
119
+ {
120
+ "module_path": "transformer.h.7.attn.c_proj",
121
+ "rule": "read=A; write=B; bias=checkpoint bias"
122
+ },
123
+ {
124
+ "module_path": "transformer.h.7.mlp.c_fc",
125
+ "rule": "read=A; write=B; bias=checkpoint bias"
126
+ },
127
+ {
128
+ "module_path": "transformer.h.7.mlp.c_proj",
129
+ "rule": "read=A; write=B; bias=checkpoint bias"
130
+ },
131
+ {
132
+ "module_path": "transformer.h.8.attn.c_attn",
133
+ "rule": "read=A; write=B; bias=checkpoint bias"
134
+ },
135
+ {
136
+ "module_path": "transformer.h.8.attn.c_proj",
137
+ "rule": "read=A; write=B; bias=checkpoint bias"
138
+ },
139
+ {
140
+ "module_path": "transformer.h.8.mlp.c_fc",
141
+ "rule": "read=A; write=B; bias=checkpoint bias"
142
+ },
143
+ {
144
+ "module_path": "transformer.h.8.mlp.c_proj",
145
+ "rule": "read=A; write=B; bias=checkpoint bias"
146
+ },
147
+ {
148
+ "module_path": "transformer.h.9.attn.c_attn",
149
+ "rule": "read=A; write=B; bias=checkpoint bias"
150
+ },
151
+ {
152
+ "module_path": "transformer.h.9.attn.c_proj",
153
+ "rule": "read=A; write=B; bias=checkpoint bias"
154
+ },
155
+ {
156
+ "module_path": "transformer.h.9.mlp.c_fc",
157
+ "rule": "read=A; write=B; bias=checkpoint bias"
158
+ },
159
+ {
160
+ "module_path": "transformer.h.9.mlp.c_proj",
161
+ "rule": "read=A; write=B; bias=checkpoint bias"
162
+ },
163
+ {
164
+ "module_path": "transformer.h.10.attn.c_attn",
165
+ "rule": "read=A; write=B; bias=checkpoint bias"
166
+ },
167
+ {
168
+ "module_path": "transformer.h.10.attn.c_proj",
169
+ "rule": "read=A; write=B; bias=checkpoint bias"
170
+ },
171
+ {
172
+ "module_path": "transformer.h.10.mlp.c_fc",
173
+ "rule": "read=A; write=B; bias=checkpoint bias"
174
+ },
175
+ {
176
+ "module_path": "transformer.h.10.mlp.c_proj",
177
+ "rule": "read=A; write=B; bias=checkpoint bias"
178
+ },
179
+ {
180
+ "module_path": "transformer.h.11.attn.c_attn",
181
+ "rule": "read=A; write=B; bias=checkpoint bias"
182
+ },
183
+ {
184
+ "module_path": "transformer.h.11.attn.c_proj",
185
+ "rule": "read=A; write=B; bias=checkpoint bias"
186
+ },
187
+ {
188
+ "module_path": "transformer.h.11.mlp.c_fc",
189
+ "rule": "read=A; write=B; bias=checkpoint bias"
190
+ },
191
+ {
192
+ "module_path": "transformer.h.11.mlp.c_proj",
193
+ "rule": "read=A; write=B; bias=checkpoint bias"
194
+ }
195
+ ],
196
+ "excluded": [
197
+ "base model weights",
198
+ "activation Gram matrices",
199
+ "dense target and reconstructed weights",
200
+ "optimizer state and data caches",
201
+ "cluster-local absolute paths"
202
+ ],
203
+ "notes": [
204
+ "Contains all 48 transformer-block linear projections.",
205
+ "The reported CE delta uses the full-model stress evaluation rather than the single-matrix unified CE surface."
206
+ ],
207
+ "source_artifact_hashes": [
208
+ {
209
+ "bundle_id": "gpt2_small_full_model_swdft",
210
+ "hash_semantics": "source_file",
211
+ "sha256": "a21298cc05d95aff90b55119248c22756e9136002f3717df5dff1a380e47538d"
212
+ }
213
+ ],
214
+ "source_bundle_ids": [
215
+ "gpt2_small_full_model_swdft"
216
+ ],
217
+ "source_format": "gpt2_full_model_fixed_support_swdft",
218
+ "validation": {
219
+ "all_tensors_finite": true,
220
+ "orientation_random_input_max_abs_error": 0.0,
221
+ "safetensors_exact_round_trip": true
222
+ },
223
+ "variant_id": "gpt2_small_full_model_swdft"
224
+ }
checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "gpt2",
3
+ "ce_delta_vs_dense": 0.0008888365819190724,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "in_out",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=A_prop; write=B_prop",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 3072,
13
+ "module_path": "transformer.h.8.mlp.c_proj",
14
+ "output_dim": 768,
15
+ "rank": 768,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 1032191,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 147455
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.5,
27
+ "token_exposure": 16384,
28
+ "variant_id": "gpt2_small_l8_cproj_s0p5",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4dc8d3fbe3f9b491a3ccadf928de65d0ad98f6826844b3143d04e1bd06a6942
3
+ size 11796752
checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "transformer.h.8.mlp.c_proj",
5
+ "rule": "read=A_prop; write=B_prop"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "gpt2_small_l8_cproj_s0p5",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "ecafa0a74c7e06824e223520abb99c47292ba7e19071e2f15066dffce6101ebe"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "gpt2_small_l8_cproj_s0p5"
25
+ ],
26
+ "source_format": "gpt2_factor_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 0.0,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "gpt2_small_l8_cproj_s0p5"
33
+ }
checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "gpt2",
3
+ "ce_delta_vs_dense": 0.0082921466752812,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "in_out",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=A_prop; write=B_prop",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 3072,
13
+ "module_path": "transformer.h.8.mlp.c_proj",
14
+ "output_dim": 768,
15
+ "rank": 768,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 442367,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 147455
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.75,
27
+ "token_exposure": 16384,
28
+ "variant_id": "gpt2_small_l8_cproj_s0p75",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f6db8a41cfacc8cb6ce54429c6c39be7b74ba36a7d9a1aa9b3e55b1f0e0b097e
3
+ size 11796752
checkpoints/gpt2-small/layer8-cproj/s0p75-tokens16384/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "transformer.h.8.mlp.c_proj",
5
+ "rule": "read=A_prop; write=B_prop"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "gpt2_small_l8_cproj_s0p75",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "a9f9798ce6c6d2ff06409b663285605f37ca51d84386549b66b9cd75016aa70d"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "gpt2_small_l8_cproj_s0p75"
25
+ ],
26
+ "source_format": "gpt2_factor_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 0.0,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "gpt2_small_l8_cproj_s0p75"
33
+ }
checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "gpt2",
3
+ "ce_delta_vs_dense": 0.004003,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "in_out",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=A_prop; write=B_prop",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 768,
13
+ "module_path": "transformer.h.8.mlp.c_fc",
14
+ "output_dim": 3072,
15
+ "rank": 768,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 147455,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 1032191
22
+ },
23
+ {
24
+ "base_weight_layout": "in_out",
25
+ "bias_key": null,
26
+ "bias_policy": "preserve_base",
27
+ "conversion_rule": "read=A_prop; write=B_prop",
28
+ "forward_equation": "output = input @ read @ write + bias",
29
+ "input_dim": 3072,
30
+ "module_path": "transformer.h.8.mlp.c_proj",
31
+ "output_dim": 768,
32
+ "rank": 768,
33
+ "read_dtype": "float32",
34
+ "read_key": "modules.001.read",
35
+ "read_nnz": 1032191,
36
+ "write_dtype": "float32",
37
+ "write_key": "modules.001.write",
38
+ "write_nnz": 147455
39
+ }
40
+ ],
41
+ "preserves_base_mlp_nonlinearity": true,
42
+ "replacement_scope": "mlp_replacement",
43
+ "schema_version": "swd_factor_checkpoint_v1",
44
+ "sparsity": 0.5,
45
+ "token_exposure": 16384,
46
+ "variant_id": "gpt2_small_l8_mlp_s0p5",
47
+ "weights_file": "model.safetensors"
48
+ }
checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a56f5ae70bf0b3c3fa0750e53d226928a7de3e27b84458d9fcef4b159e16ea57
3
+ size 23593408
checkpoints/gpt2-small/layer8-mlp-sequential/s0p5-tokens16384/provenance.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "transformer.h.8.mlp.c_fc",
5
+ "rule": "read=A_prop; write=B_prop"
6
+ },
7
+ {
8
+ "module_path": "transformer.h.8.mlp.c_proj",
9
+ "rule": "read=A_prop; write=B_prop"
10
+ }
11
+ ],
12
+ "excluded": [
13
+ "base model weights",
14
+ "activation Gram matrices",
15
+ "dense target and reconstructed weights",
16
+ "optimizer state and data caches",
17
+ "cluster-local absolute paths"
18
+ ],
19
+ "notes": [
20
+ "The base model GELU between c_fc and c_proj is retained."
21
+ ],
22
+ "source_artifact_hashes": [
23
+ {
24
+ "bundle_id": "gpt2_small_l8_mlp_s0p5_cfc",
25
+ "hash_semantics": "source_file",
26
+ "sha256": "a1b4486e628f3a7a5010f851c70244a2a7f05391a91d63bf12d9f7bf64ba1431"
27
+ },
28
+ {
29
+ "bundle_id": "gpt2_small_l8_mlp_s0p5_cproj",
30
+ "hash_semantics": "source_file",
31
+ "sha256": "4a3fbe7294d367fc4820fc0014d9a6ef67511cf9c312fce94c3cacb03cb2e240"
32
+ }
33
+ ],
34
+ "source_bundle_ids": [
35
+ "gpt2_small_l8_mlp_s0p5_cfc",
36
+ "gpt2_small_l8_mlp_s0p5_cproj"
37
+ ],
38
+ "source_format": "gpt2_sequential_mlp_factor_artifacts",
39
+ "validation": {
40
+ "all_tensors_finite": true,
41
+ "orientation_random_input_max_abs_error": 0.0,
42
+ "safetensors_exact_round_trip": true
43
+ },
44
+ "variant_id": "gpt2_small_l8_mlp_s0p5"
45
+ }
checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "gpt2",
3
+ "ce_delta_vs_dense": 0.01552128791809082,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "in_out",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=A_prop; write=B_prop",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 768,
13
+ "module_path": "transformer.h.8.mlp.c_fc",
14
+ "output_dim": 3072,
15
+ "rank": 768,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 147455,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 442367
22
+ },
23
+ {
24
+ "base_weight_layout": "in_out",
25
+ "bias_key": null,
26
+ "bias_policy": "preserve_base",
27
+ "conversion_rule": "read=A_prop; write=B_prop",
28
+ "forward_equation": "output = input @ read @ write + bias",
29
+ "input_dim": 3072,
30
+ "module_path": "transformer.h.8.mlp.c_proj",
31
+ "output_dim": 768,
32
+ "rank": 768,
33
+ "read_dtype": "float32",
34
+ "read_key": "modules.001.read",
35
+ "read_nnz": 442367,
36
+ "write_dtype": "float32",
37
+ "write_key": "modules.001.write",
38
+ "write_nnz": 147455
39
+ }
40
+ ],
41
+ "preserves_base_mlp_nonlinearity": true,
42
+ "replacement_scope": "mlp_replacement",
43
+ "schema_version": "swd_factor_checkpoint_v1",
44
+ "sparsity": 0.75,
45
+ "token_exposure": 1048576,
46
+ "variant_id": "gpt2_small_l8_mlp_s0p75",
47
+ "weights_file": "model.safetensors"
48
+ }
checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8852687de6d0d890e55c2df5a4e097224e6125d6bd4987391e50625b222953b3
3
+ size 23593408
checkpoints/gpt2-small/layer8-mlp-sequential/s0p75-tokens1048576/provenance.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "transformer.h.8.mlp.c_fc",
5
+ "rule": "read=A_prop; write=B_prop"
6
+ },
7
+ {
8
+ "module_path": "transformer.h.8.mlp.c_proj",
9
+ "rule": "read=A_prop; write=B_prop"
10
+ }
11
+ ],
12
+ "excluded": [
13
+ "base model weights",
14
+ "activation Gram matrices",
15
+ "dense target and reconstructed weights",
16
+ "optimizer state and data caches",
17
+ "cluster-local absolute paths"
18
+ ],
19
+ "notes": [
20
+ "The base model GELU between c_fc and c_proj is retained."
21
+ ],
22
+ "source_artifact_hashes": [
23
+ {
24
+ "bundle_id": "gpt2_small_l8_mlp_s0p75_cfc",
25
+ "hash_semantics": "source_file",
26
+ "sha256": "8bc0ae08ecc7a56d762ae642af9641b25bf12f5e461ab97dc4a38945863df700"
27
+ },
28
+ {
29
+ "bundle_id": "gpt2_small_l8_mlp_s0p75_cproj",
30
+ "hash_semantics": "source_file",
31
+ "sha256": "4414abe8b83d4244b6b11c6af3e59aa234f4904400df4a038e7d77185c0d7a6f"
32
+ }
33
+ ],
34
+ "source_bundle_ids": [
35
+ "gpt2_small_l8_mlp_s0p75_cfc",
36
+ "gpt2_small_l8_mlp_s0p75_cproj"
37
+ ],
38
+ "source_format": "gpt2_sequential_mlp_factor_artifacts",
39
+ "validation": {
40
+ "all_tensors_finite": true,
41
+ "orientation_random_input_max_abs_error": 0.0,
42
+ "safetensors_exact_round_trip": true
43
+ },
44
+ "variant_id": "gpt2_small_l8_mlp_s0p75"
45
+ }
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen2.5-0.5B",
3
+ "ce_delta_vs_dense": 0.0012218963831869267,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "source stores Linear weight as A@B; read=B.T; write=A.T",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 4864,
13
+ "module_path": "model.layers.12.mlp.down_proj",
14
+ "output_dim": 896,
15
+ "rank": 896,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 1978367,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 200703
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.5,
27
+ "token_exposure": 1024,
28
+ "variant_id": "qwen25_0p5b_l12_downproj_s0p5",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:400f49a25d6862f584c8057d138b83802d47e13c31b4b58acb1b4a740805ca6e
3
+ size 20644120
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p5-tokens1024/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.12.mlp.down_proj",
5
+ "rule": "source stores Linear weight as A@B; read=B.T; write=A.T"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "qwen25_0p5b_l12_downproj_s0p5",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "3202ce0270f0f75bfb14d6bb253fbda1b4dbfee077d892a295a30fbf449e1059"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "qwen25_0p5b_l12_downproj_s0p5"
25
+ ],
26
+ "source_format": "qwen25_factor_and_baseline_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 1.7881393432617188e-06,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "qwen25_0p5b_l12_downproj_s0p5"
33
+ }
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen2.5-0.5B",
3
+ "ce_delta_vs_dense": 0.005009775171065822,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "source stores Linear weight as A@B; read=B.T; write=A.T",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 4864,
13
+ "module_path": "model.layers.12.mlp.down_proj",
14
+ "output_dim": 896,
15
+ "rank": 896,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 888831,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 200703
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.75,
27
+ "token_exposure": 1048576,
28
+ "variant_id": "qwen25_0p5b_l12_downproj_s0p75",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:530b19e4f58da33e6f3b6a7bad749cd3e8bafa8b67ee41939075d3dcb1fb4078
3
+ size 20644120
checkpoints/qwen2.5-0.5b/layer12-down-proj/s0p75-tokens1048576/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.12.mlp.down_proj",
5
+ "rule": "source stores Linear weight as A@B; read=B.T; write=A.T"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "qwen25_0p5b_l12_downproj_s0p75",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "55862fab1505f2def48246d94cc1aa23e384511deb4906b8ce1de43f0ac130ca"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "qwen25_0p5b_l12_downproj_s0p75"
25
+ ],
26
+ "source_format": "qwen25_factor_and_baseline_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 1.430511474609375e-06,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "qwen25_0p5b_l12_downproj_s0p75"
33
+ }
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen2.5-1.5B",
3
+ "ce_delta_vs_dense": 0.0007331378299122449,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "source stores Linear weight as A@B; read=B.T; write=A.T",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 8960,
13
+ "module_path": "model.layers.14.mlp.down_proj",
14
+ "output_dim": 1536,
15
+ "rank": 1536,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 6291455,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 589823
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.5,
27
+ "token_exposure": 1024,
28
+ "variant_id": "qwen25_1p5b_l14_downproj_s0p5",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad3be13722726a1a447c2ea7f41c1ee55a21099ac231ae1ea2089950d1a204dc
3
+ size 64487712
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p5-tokens1024/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.14.mlp.down_proj",
5
+ "rule": "source stores Linear weight as A@B; read=B.T; write=A.T"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "qwen25_1p5b_l14_downproj_s0p5",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "7f7eae2b0b8c0e309adc7f1d09667f3bc8a894abac2a99f0038729527960e0fd"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "qwen25_1p5b_l14_downproj_s0p5"
25
+ ],
26
+ "source_format": "qwen25_factor_and_baseline_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 4.5299530029296875e-06,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "qwen25_1p5b_l14_downproj_s0p5"
33
+ }
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen2.5-1.5B",
3
+ "ce_delta_vs_dense": 0.0012218963831869267,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "source stores Linear weight as A@B; read=B.T; write=A.T",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 8960,
13
+ "module_path": "model.layers.14.mlp.down_proj",
14
+ "output_dim": 1536,
15
+ "rank": 1536,
16
+ "read_dtype": "float32",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 2850815,
19
+ "write_dtype": "float32",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 589823
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "sparsity": 0.75,
27
+ "token_exposure": 1048576,
28
+ "variant_id": "qwen25_1p5b_l14_downproj_s0p75",
29
+ "weights_file": "model.safetensors"
30
+ }
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa3fa378549da027bb4bf2778fa80b158c01840aa0306025c5f828baa5bcf7dd
3
+ size 64487712
checkpoints/qwen2.5-1.5b/layer14-down-proj/s0p75-tokens1048576/provenance.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.14.mlp.down_proj",
5
+ "rule": "source stores Linear weight as A@B; read=B.T; write=A.T"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [],
16
+ "source_artifact_hashes": [
17
+ {
18
+ "bundle_id": "qwen25_1p5b_l14_downproj_s0p75",
19
+ "hash_semantics": "source_file",
20
+ "sha256": "993fab945123bd20ff08a5c6dc2a7c1de58b4764e3531b86b207ab0c8e887c09"
21
+ }
22
+ ],
23
+ "source_bundle_ids": [
24
+ "qwen25_1p5b_l14_downproj_s0p75"
25
+ ],
26
+ "source_format": "qwen25_factor_and_baseline_artifact",
27
+ "validation": {
28
+ "all_tensors_finite": true,
29
+ "orientation_random_input_max_abs_error": 3.814697265625e-06,
30
+ "safetensors_exact_round_trip": true
31
+ },
32
+ "variant_id": "qwen25_1p5b_l14_downproj_s0p75"
33
+ }
checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen3.5-27B",
3
+ "ce_delta_vs_dense": -0.00042653013883819924,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=cat(shard.A, dim=1); write=cat(shard.B, dim=0)",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 17408,
13
+ "module_path": "model.layers.31.mlp.down_proj",
14
+ "output_dim": 5120,
15
+ "rank": 5120,
16
+ "read_dtype": "bfloat16",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 38010879,
19
+ "write_dtype": "bfloat16",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 6553599
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "source_shard_count": 4,
27
+ "sparsity": 0.5,
28
+ "token_exposure": 2048,
29
+ "variant_id": "qwen35_27b_l31_downproj_s0p5",
30
+ "weights_file": "model.safetensors"
31
+ }
checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84c6673c889c229853de6cea4556f4ee1b7e054b03e191353fb96563c7d31877
3
+ size 230687008
checkpoints/qwen3.5-27b/layer31-down-proj/s0p5-tokens2048/provenance.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.31.mlp.down_proj",
5
+ "rule": "read=cat(shard.A, dim=1); write=cat(shard.B, dim=0)"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [
16
+ "Source BF16 precision is preserved."
17
+ ],
18
+ "source_artifact_hashes": [
19
+ {
20
+ "bundle_id": "qwen35_27b_l31_downproj_s0p5",
21
+ "hash_semantics": "source_checkpoint_aggregate",
22
+ "sha256": "ab3528492d78d7935cb8422b687672eb11dcad7bda77a20dc3ff0d8cfb09c18f"
23
+ }
24
+ ],
25
+ "source_bundle_ids": [
26
+ "qwen35_27b_l31_downproj_s0p5"
27
+ ],
28
+ "source_format": "qwen35_four_shard_factor_checkpoint",
29
+ "validation": {
30
+ "all_tensors_finite": true,
31
+ "orientation_random_input_max_abs_error": 3.814697265625e-06,
32
+ "safetensors_exact_round_trip": true
33
+ },
34
+ "variant_id": "qwen35_27b_l31_downproj_s0p5"
35
+ }
checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "Qwen/Qwen3.5-27B",
3
+ "ce_delta_vs_dense": -0.00044806658464224824,
4
+ "method": "SWD",
5
+ "module_replacements": [
6
+ {
7
+ "base_weight_layout": "out_in",
8
+ "bias_key": null,
9
+ "bias_policy": "preserve_base",
10
+ "conversion_rule": "read=cat(shard.A, dim=1); write=cat(shard.B, dim=0)",
11
+ "forward_equation": "output = input @ read @ write + bias",
12
+ "input_dim": 17408,
13
+ "module_path": "model.layers.31.mlp.down_proj",
14
+ "output_dim": 5120,
15
+ "rank": 5120,
16
+ "read_dtype": "bfloat16",
17
+ "read_key": "modules.000.read",
18
+ "read_nnz": 15728639,
19
+ "write_dtype": "bfloat16",
20
+ "write_key": "modules.000.write",
21
+ "write_nnz": 6553599
22
+ }
23
+ ],
24
+ "replacement_scope": "single_matrix",
25
+ "schema_version": "swd_factor_checkpoint_v1",
26
+ "source_shard_count": 4,
27
+ "sparsity": 0.75,
28
+ "token_exposure": 1048576,
29
+ "variant_id": "qwen35_27b_l31_downproj_s0p75",
30
+ "weights_file": "model.safetensors"
31
+ }
checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92eeb9672d70cbc16c4483bfa9673593781bf73069e145aad75bf6350df86066
3
+ size 230687008
checkpoints/qwen3.5-27b/layer31-down-proj/s0p75-tokens1048576/provenance.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "conversion": [
3
+ {
4
+ "module_path": "model.layers.31.mlp.down_proj",
5
+ "rule": "read=cat(shard.A, dim=1); write=cat(shard.B, dim=0)"
6
+ }
7
+ ],
8
+ "excluded": [
9
+ "base model weights",
10
+ "activation Gram matrices",
11
+ "dense target and reconstructed weights",
12
+ "optimizer state and data caches",
13
+ "cluster-local absolute paths"
14
+ ],
15
+ "notes": [
16
+ "Source BF16 precision is preserved."
17
+ ],
18
+ "source_artifact_hashes": [
19
+ {
20
+ "bundle_id": "qwen35_27b_l31_downproj_s0p75",
21
+ "hash_semantics": "source_checkpoint_aggregate",
22
+ "sha256": "3b94e88ab0e48e4c1a3d7977aa05a5c579d461a013dde2a4a3671a020ff3e124"
23
+ }
24
+ ],
25
+ "source_bundle_ids": [
26
+ "qwen35_27b_l31_downproj_s0p75"
27
+ ],
28
+ "source_format": "qwen35_four_shard_factor_checkpoint",
29
+ "validation": {
30
+ "all_tensors_finite": true,
31
+ "orientation_random_input_max_abs_error": 2.384185791015625e-06,
32
+ "safetensors_exact_round_trip": true
33
+ },
34
+ "variant_id": "qwen35_27b_l31_downproj_s0p75"
35
+ }
examples/load_checkpoint.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal example for applying an SWD checkpoint to a base model."""
2
+
3
+ from pathlib import Path
4
+
5
+ from transformers import AutoModelForCausalLM
6
+
7
+ from swd_loader import apply_swd_checkpoint
8
+
9
+
10
+ repo_root = Path(__file__).resolve().parents[1]
11
+ checkpoint = repo_root / "checkpoints/gpt2-small/layer8-cproj/s0p5-tokens16384"
12
+ model = AutoModelForCausalLM.from_pretrained("gpt2")
13
+
14
+ # Use mode="folded" for a conventional dense module after loading.
15
+ applied = apply_swd_checkpoint(model, checkpoint, mode="factorized")
16
+ print(applied)
17
+ print(model.transformer.h[8].mlp.c_proj)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch>=2.1
2
+ safetensors>=0.4
3
+ huggingface_hub>=1.0
4
+ transformers
swd_loader.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Load SWD factor checkpoints into an already constructed PyTorch model."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Any, Literal
9
+
10
+ import torch
11
+ from safetensors.torch import load_file
12
+ from torch import nn
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class AppliedReplacement:
17
+ module_path: str
18
+ input_dim: int
19
+ rank: int
20
+ output_dim: int
21
+ mode: str
22
+
23
+
24
+ class SWDLinear(nn.Module):
25
+ """Two-factor linear map with explicit scalar bottleneck activations."""
26
+
27
+ def __init__(
28
+ self,
29
+ read: torch.Tensor,
30
+ write: torch.Tensor,
31
+ bias: torch.Tensor | None = None,
32
+ ) -> None:
33
+ super().__init__()
34
+ if read.ndim != 2 or write.ndim != 2 or read.shape[1] != write.shape[0]:
35
+ raise ValueError(
36
+ f"Invalid SWD shapes: read={tuple(read.shape)}, write={tuple(write.shape)}"
37
+ )
38
+ self.read = nn.Parameter(read.detach().contiguous(), requires_grad=False)
39
+ self.write = nn.Parameter(write.detach().contiguous(), requires_grad=False)
40
+ self.bias = (
41
+ None
42
+ if bias is None
43
+ else nn.Parameter(bias.detach().contiguous(), requires_grad=False)
44
+ )
45
+
46
+ @property
47
+ def in_features(self) -> int:
48
+ return int(self.read.shape[0])
49
+
50
+ @property
51
+ def rank(self) -> int:
52
+ return int(self.read.shape[1])
53
+
54
+ @property
55
+ def out_features(self) -> int:
56
+ return int(self.write.shape[1])
57
+
58
+ def component_activations(self, inputs: torch.Tensor) -> torch.Tensor:
59
+ return inputs.matmul(self.read)
60
+
61
+ def forward(self, inputs: torch.Tensor) -> torch.Tensor:
62
+ outputs = self.component_activations(inputs).matmul(self.write)
63
+ if self.bias is not None:
64
+ outputs = outputs + self.bias
65
+ return outputs
66
+
67
+
68
+ def _get_child(module: Any, name: str) -> Any:
69
+ if name.isdigit() and isinstance(module, (nn.ModuleList, nn.Sequential)):
70
+ return module[int(name)]
71
+ return getattr(module, name)
72
+
73
+
74
+ def _set_child(module: Any, name: str, value: nn.Module) -> None:
75
+ if name.isdigit() and isinstance(module, (nn.ModuleList, nn.Sequential)):
76
+ module[int(name)] = value
77
+ return
78
+ setattr(module, name, value)
79
+
80
+
81
+ def _resolve_parent(model: nn.Module, module_path: str) -> tuple[Any, str, nn.Module]:
82
+ parts = module_path.split(".")
83
+ if not parts or any(not part for part in parts):
84
+ raise ValueError(f"Invalid module path: {module_path!r}")
85
+ parent: Any = model
86
+ for part in parts[:-1]:
87
+ parent = _get_child(parent, part)
88
+ leaf = parts[-1]
89
+ target = _get_child(parent, leaf)
90
+ if not isinstance(target, nn.Module):
91
+ raise TypeError(f"Target at {module_path!r} is not an nn.Module")
92
+ return parent, leaf, target
93
+
94
+
95
+ def _module_device_dtype(module: nn.Module) -> tuple[torch.device, torch.dtype]:
96
+ weight = getattr(module, "weight", None)
97
+ if not torch.is_tensor(weight):
98
+ raise TypeError("Target module must expose a materialized weight tensor")
99
+ if weight.device.type == "meta":
100
+ raise ValueError("Load/materialize the base model before applying SWD factors")
101
+ if not weight.dtype.is_floating_point:
102
+ raise TypeError(f"Unsupported target weight dtype: {weight.dtype}")
103
+ return weight.device, weight.dtype
104
+
105
+
106
+ def _validate_base_weight(
107
+ module: nn.Module,
108
+ *,
109
+ module_path: str,
110
+ input_dim: int,
111
+ output_dim: int,
112
+ layout: str,
113
+ ) -> None:
114
+ weight = getattr(module, "weight", None)
115
+ if not torch.is_tensor(weight):
116
+ raise TypeError(f"{module_path} does not expose a weight tensor")
117
+ expected = (
118
+ (input_dim, output_dim) if layout == "in_out" else (output_dim, input_dim)
119
+ )
120
+ if tuple(weight.shape) != expected:
121
+ raise ValueError(
122
+ f"Base weight mismatch at {module_path}: got {tuple(weight.shape)}, expected {expected}"
123
+ )
124
+
125
+
126
+ def _select_bias(
127
+ module: nn.Module,
128
+ tensors: dict[str, torch.Tensor],
129
+ spec: dict[str, Any],
130
+ *,
131
+ device: torch.device,
132
+ dtype: torch.dtype,
133
+ ) -> torch.Tensor | None:
134
+ policy = spec["bias_policy"]
135
+ if policy == "checkpoint":
136
+ bias = tensors[spec["bias_key"]]
137
+ elif policy == "preserve_base":
138
+ bias = getattr(module, "bias", None)
139
+ elif policy == "none":
140
+ bias = None
141
+ else:
142
+ raise ValueError(f"Unknown bias policy: {policy}")
143
+ return None if bias is None else bias.detach().to(device=device, dtype=dtype)
144
+
145
+
146
+ def _fold_into_module(
147
+ module: nn.Module,
148
+ read: torch.Tensor,
149
+ write: torch.Tensor,
150
+ bias: torch.Tensor | None,
151
+ *,
152
+ layout: str,
153
+ ) -> None:
154
+ dense_in_out = read.matmul(write)
155
+ dense = dense_in_out if layout == "in_out" else dense_in_out.transpose(0, 1)
156
+ weight = getattr(module, "weight")
157
+ with torch.no_grad():
158
+ weight.copy_(dense.to(device=weight.device, dtype=weight.dtype))
159
+ existing_bias = getattr(module, "bias", None)
160
+ if bias is not None:
161
+ if existing_bias is None:
162
+ raise ValueError("Checkpoint provides bias but base module has no bias parameter")
163
+ existing_bias.copy_(bias.to(existing_bias.device, existing_bias.dtype))
164
+
165
+
166
+ def load_swd_config(checkpoint_dir: str | Path) -> dict[str, Any]:
167
+ path = Path(checkpoint_dir) / "config.json"
168
+ with path.open(encoding="utf-8") as handle:
169
+ config = json.load(handle)
170
+ if config.get("schema_version") != "swd_factor_checkpoint_v1":
171
+ raise ValueError(f"Unsupported SWD schema: {config.get('schema_version')!r}")
172
+ return config
173
+
174
+
175
+ def apply_swd_checkpoint(
176
+ model: nn.Module,
177
+ checkpoint_dir: str | Path,
178
+ *,
179
+ mode: Literal["factorized", "folded"] = "factorized",
180
+ ) -> list[AppliedReplacement]:
181
+ """Apply one release checkpoint to a loaded base model.
182
+
183
+ ``factorized`` installs :class:`SWDLinear` modules and preserves explicit
184
+ bottleneck activations. ``folded`` writes ``read @ write`` into the existing
185
+ dense modules for conventional inference.
186
+ """
187
+
188
+ if mode not in {"factorized", "folded"}:
189
+ raise ValueError(f"Unknown mode: {mode}")
190
+ root = Path(checkpoint_dir)
191
+ config = load_swd_config(root)
192
+ tensors = load_file(root / config["weights_file"], device="cpu")
193
+ applied: list[AppliedReplacement] = []
194
+
195
+ for spec in config["module_replacements"]:
196
+ path = spec["module_path"]
197
+ parent, leaf, module = _resolve_parent(model, path)
198
+ input_dim = int(spec["input_dim"])
199
+ rank = int(spec["rank"])
200
+ output_dim = int(spec["output_dim"])
201
+ layout = spec["base_weight_layout"]
202
+ _validate_base_weight(
203
+ module,
204
+ module_path=path,
205
+ input_dim=input_dim,
206
+ output_dim=output_dim,
207
+ layout=layout,
208
+ )
209
+ device, dtype = _module_device_dtype(module)
210
+ read = tensors[spec["read_key"]]
211
+ write = tensors[spec["write_key"]]
212
+ if tuple(read.shape) != (input_dim, rank):
213
+ raise ValueError(f"Read tensor mismatch for {path}: {tuple(read.shape)}")
214
+ if tuple(write.shape) != (rank, output_dim):
215
+ raise ValueError(f"Write tensor mismatch for {path}: {tuple(write.shape)}")
216
+ read = read.to(device=device, dtype=dtype)
217
+ write = write.to(device=device, dtype=dtype)
218
+ bias = _select_bias(module, tensors, spec, device=device, dtype=dtype)
219
+
220
+ if mode == "factorized":
221
+ _set_child(parent, leaf, SWDLinear(read, write, bias))
222
+ else:
223
+ _fold_into_module(module, read, write, bias, layout=layout)
224
+
225
+ applied.append(
226
+ AppliedReplacement(path, input_dim, rank, output_dim, mode)
227
+ )
228
+ return applied