deltaw 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
deltaw-0.1.0/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.
deltaw-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: deltaw
3
+ Version: 0.1.0
4
+ Summary: Version control for model weights: lossless tensor deltas, git-style history, tensor diffs and merges, sparse hot patches.
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/tcmartin/deltaw
7
+ Project-URL: Issues, https://github.com/tcmartin/deltaw/issues
8
+ Keywords: git,version-control,checkpoints,safetensors,pytorch,model-editing,weight-space
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy>=1.22
16
+ Requires-Dist: zstandard>=0.19
17
+ Provides-Extra: torch
18
+ Requires-Dist: torch>=2.0; extra == "torch"
19
+ Provides-Extra: hf
20
+ Requires-Dist: huggingface_hub>=0.20; extra == "hf"
21
+ Provides-Extra: test
22
+ Requires-Dist: pytest; extra == "test"
23
+ Requires-Dist: torch>=2.0; extra == "test"
24
+ Requires-Dist: safetensors; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # deltaw (ΔW)
28
+
29
+ **Version control for model weights.** Git-style commits, branches, diffs, merges and
30
+ bisect for checkpoints, with lossless tensor deltas, so a hundred edited copies of a
31
+ model cost about as much disk as one. Sparse hot patches let you apply an edit to a
32
+ live model and take it back out without reloading.
33
+
34
+ It's built for weight-space editing: you change a few columns, a rank-one direction
35
+ or a gate vector, evaluate, keep or discard, and repeat. Saving every candidate as a
36
+ full checkpoint fills a disk fast. deltaw stores what actually changed.
37
+
38
+ ```
39
+ $ deltaw import runs/box-dropout-001 --branch box-dropout --verify # output trimmed
40
+ importing runs/box-dropout-001 as series onto branch box-dropout
41
+ ...
42
+ checkpoint-000073728-0000.pt: 279.9 MB -> 256.6 MB
43
+ checkpoint-000074752-0001.pt: 279.9 MB -> 43.4 MB
44
+ ...
45
+ checkpoint-000077824-0004.pt: 279.9 MB -> 42.8 MB
46
+ checkpoint-000077824-0005.pt: 279.9 MB -> 212.5 KB
47
+ ...
48
+ done: 23 commits on box-dropout; 6.2 GB read, 942.6 MB stored (6.6x) in 14s
49
+ verifying against source files ...
50
+ 55 source files match; 53 stored files rebuild to their hashes; 0 problems
51
+ ```
52
+
53
+ ## What it does
54
+
55
+ | | |
56
+ |---|---|
57
+ | **Lossless, byte-exact** | Every file comes back exactly as it went in, bit for bit, including PyTorch `.pt` zips. Nothing is quantized, pruned or approximated. |
58
+ | **Tensor-aware storage** | Files are split into tensors, and tensors into chunks. Each chunk is content-addressed (BLAKE2b), so identical tensors are stored once across all checkpoints. Changed chunks are stored as the smallest of: plain, XOR against the previous version, or sparse (changed indices + new values). Bytes are regrouped by significance before zstd, so float exponents compress together. |
59
+ | **Git workflow** | `init`, `add`, `commit`, `status`, `log`, `show`, `diff`, `checkout`, `branch`, `tag`, `merge`, `bisect`, `gc`, `verify`. Commits carry free-form metadata (`--meta score=0.91`) for eval results and edit rationale. |
60
+ | **Tensor diffs** | `deltaw diff A B` lists which tensors changed, how many elements, ‖ΔW‖, ‖ΔW‖/‖W‖ and max change. `--svd` adds leading singular values of each 2-D delta, so a rank-one edit shows as rank one. |
61
+ | **Element-wise merge** | A three-way merge per element: edits to different elements of the same tensor merge cleanly. Real conflicts stop the merge, unless you choose `--strategy ours`, `theirs` or `sum` (task arithmetic: base + Δours + Δtheirs). |
62
+ | **Hot patches** | `deltaw patch create A B` writes a sparse patch (indices + new values) as a `.safetensors` file. `Patch.apply(model)` writes it into a live PyTorch model in place, and the returned `Undo` restores the exact previous bits. `Patch.apply_to_vllm(llm)` patches a running vLLM engine through vLLM's own checkpoint-patch loader, and `Patch.to_vllm()` builds `SparseWeightPatch` objects for its `sparse_nccl` weight transfer. |
63
+ | **Remotes** | `push`, `fetch`, `pull` and `clone` to a directory (local disk, NAS, anything rsync-able) or a Hugging Face Hub repo (`hf://user/name`). Only missing objects move. Pushes must be fast-forwards unless forced, and `clone --depth 1` fetches just the latest version. |
64
+ | **Import existing piles** | `deltaw import DIR` turns a directory of checkpoints into history without copying anything into a working tree. Each file becomes one commit (or each subdirectory one commit, for HF Trainer layouts), each delta-encoded against the previous one. |
65
+ | **Works with git** | `deltaw git-setup` makes plain `git diff` show per-tensor changes for `.safetensors` / `.pt` files. |
66
+
67
+ Text files (configs, notes, eval JSON) are tracked like any other file, with normal
68
+ unified text diffs.
69
+
70
+ ## Measured on real checkpoints
71
+
72
+ Hardware: 4-core desktop CPU, NVMe, nothing on the GPU. All results lossless and verified by rebuilding
73
+ every file.
74
+
75
+ **Weight-space edit loop, Qwen3.5-2B (4.55 GB bf16 safetensors).** 24 candidate edits:
76
+ scaling 128 or 512 writer columns of an MLP `down_proj` at three strengths, dense
77
+ rank-one updates, and 1-D `A_log` gate edits, each on its own branch.
78
+ ([benchmarks/wsp_edit_loop.py](https://github.com/tcmartin/deltaw/blob/main/benchmarks/wsp_edit_loop.py))
79
+
80
+ | edit | elements changed | stored | time to commit |
81
+ |---|---:|---:|---:|
82
+ | scale 128 columns | 262,144 | 0.27–0.36 MB | 0.1–0.3 s |
83
+ | scale 512 columns | 1,048,576 | 0.92–1.44 MB | 0.2 s |
84
+ | rank-one ΔW = αuvᵀ on a whole 2048×6144 matrix | ~11.9 M | ~13.9 MB | 0.5 s |
85
+ | 4 entries of `A_log` | 4 | < 1 KB | < 0.1 s |
86
+ | base model itself | – | 3.12 GB (from 4.55 GB) | 10 s |
87
+
88
+ Base plus 24 candidates: 113.7 GB of model files stored in 3.2 GB (35.8x). `deltaw
89
+ verify` checked all 25 versions in 22 s.
90
+
91
+ **Training run with LoRA adapters, frozen heads and optimizer state.** 22 checkpoints
92
+ of 280 MB plus sidecar files: 6.2 GB → 943 MB (6.6x) in 14 s. Frozen tensors are
93
+ stored once; a few "different" checkpoints turn out to be identical in content and
94
+ cost about 200 KB each.
95
+
96
+ **Worst case: every element changes.** 43 checkpoints of a LoRA run where adapters and
97
+ optimizer moments all move each step: 11.3 GB → 6.4 GB (1.8x) at 346 MB/s.
98
+
99
+ **Live hot patch, Qwen3.5-0.8B in transformers.** Patching 262,144 elements of one
100
+ `down_proj` took 20 ms in place on CPU; reverting took 0.7 ms. After the revert, every
101
+ parameter and the output logits were bit-identical to the original.
102
+ ([benchmarks/live_hotpatch.py](https://github.com/tcmartin/deltaw/blob/main/benchmarks/live_hotpatch.py))
103
+
104
+ **Hot patch inside vLLM, Qwen3.5-0.8B on an RTX 3090.** A deltaw patch (327,680
105
+ elements in one `down_proj` and in `gate_proj`, which vLLM fuses into `gate_up_proj`)
106
+ applied to a running vLLM 0.34 engine in 80 ms. Greedy outputs and top-5 logprobs on
107
+ four prompts then matched a fresh vLLM load of the edited checkpoint exactly. The
108
+ reverse patch (7 ms) brought them back to exactly the original.
109
+ ([benchmarks/vllm_live.py](https://github.com/tcmartin/deltaw/blob/main/benchmarks/vllm_live.py))
110
+
111
+ **A real 408 GB pile.** 100 training-run directories from Qwen3.5 adapter and head
112
+ experiments (LoRA adapters, trained heads, optimizer state, feature caches, configs),
113
+ imported into one store with one branch per run: 408.5 GB → 199.2 GB (2.05x) in
114
+ just under two hours. Every run was checked byte for byte against its source, with 0
115
+ problems. Most of these runs update adapters and optimizer moments on every step,
116
+ so this is close to the dense worst case below. The best runs reached 3–4x; runs
117
+ that are mostly a single checkpoint got 1.2–1.5x.
118
+
119
+ What it can't do: when every element changes (full fine-tuning, optimizer moments),
120
+ lossless storage only gets about 1.8x. There's no free lunch for dense, noisy
121
+ updates, and deltaw doesn't pretend otherwise. The big wins come from tensors that
122
+ don't change, checkpoints that repeat, and edits that are sparse or low-precision.
123
+
124
+ ## Install
125
+
126
+ ```bash
127
+ pip install deltaw # numpy + zstandard
128
+ pip install "deltaw[torch]" # for hot patches and --svd
129
+ ```
130
+
131
+ or from source: `pip install -e .`
132
+
133
+ ## Quick start
134
+
135
+ ```bash
136
+ deltaw init
137
+ deltaw add model.safetensors config.json notes.md
138
+ deltaw commit -m "base model"
139
+
140
+ # ... edit weights in place (any tool), then
141
+ deltaw diff # which tensors changed, by how much
142
+ deltaw commit -a -m "L9: scale 128 writer columns x1.5" --meta mmlu=0.612
143
+
144
+ deltaw checkout -b try-rank1 HEAD~1 # branch from the base
145
+ deltaw log --oneline
146
+ deltaw show --svd # what the last commit changed, with singular values
147
+ deltaw checkout main -- model.safetensors # restore one file from a branch
148
+ ```
149
+
150
+ Turning an existing pile into history:
151
+
152
+ ```bash
153
+ deltaw import /data/runs/my-run --verify # one commit per checkpoint file
154
+ deltaw import /data/sweeps/edits --mode subdirs # one commit per subdirectory
155
+ deltaw stats
156
+ deltaw export my-run~3 checkpoint-0042.pt -o /tmp/ckpt.pt # rebuild any version
157
+ ```
158
+
159
+ `import` never deletes or modifies your files. Once `--verify` reports 0 problems,
160
+ deleting the originals is your call.
161
+
162
+ ## Editing loops in Python
163
+
164
+ ```python
165
+ from deltaw import Repo, Patch, commit_patch
166
+
167
+ repo = Repo.open("my-model-repo") # HEAD has model.safetensors
168
+
169
+ before = {name: W.clone()} # the tensors you are about to edit
170
+ edit(model) # your weight-space edit
171
+ after = {name: model.get_parameter(name).detach()}
172
+
173
+ patch = Patch.from_state_dicts(before, after) # exact, sparse
174
+ cid = commit_patch(repo, patch, "model.safetensors",
175
+ "L9: scale 128 columns", meta={"score": 0.61})
176
+ # only the touched chunks are written; the full model is never re-serialized
177
+ ```
178
+
179
+ Trying a candidate on a live model and always rolling back:
180
+
181
+ ```python
182
+ patch = Patch.load("candidate.safetensors") # from `deltaw patch create A B -o ...`
183
+ with patch.applied(model): # in place, no reload
184
+ score = evaluate(model)
185
+ # weights are bit-identical to before here, even if evaluate() raised
186
+ ```
187
+
188
+ Switching a loaded model between commits without reloading it:
189
+
190
+ ```python
191
+ from deltaw import LiveCheckout
192
+
193
+ live = LiveCheckout(repo, model, "main", path="model.safetensors")
194
+ live.switch("try-rank1") # writes only the elements that differ between the commits
195
+ live.switch("main") # back to the exact original bits
196
+ ```
197
+
198
+ Patches *set* values rather than adding deltas, so switching back and forth never
199
+ accumulates bf16 rounding error.
200
+
201
+ ### vLLM
202
+
203
+ Patching an offline `vllm.LLM` engine in place (start Python with
204
+ `VLLM_ALLOW_INSECURE_SERIALIZATION=1`, which lets the loader be sent to vLLM's worker
205
+ process):
206
+
207
+ ```python
208
+ llm = LLM(model="my-model-dir")
209
+ patch = Patch.between(repo, "main", "try-rank1", path="model.safetensors")
210
+ patch.apply_to_vllm(llm) # vLLM's own load_checkpoint_weight_patches: handles fused/packed params
211
+ ...
212
+ Patch.between(repo, "try-rank1", "main", path="model.safetensors").apply_to_vllm(llm) # revert
213
+ ```
214
+
215
+ For a trainer driving a separate vLLM server with the `sparse_nccl` weight-transfer
216
+ backend:
217
+
218
+ ```python
219
+ engine.send_weights(patch.to_vllm()) # SparseWeightPatch: int32 flat indices, new values, full_shape
220
+ ```
221
+
222
+ Names are Hugging Face checkpoint names, which they are for safetensors commits. vLLM
223
+ patches support floating-point tensors, and parameters whose loaders transform the
224
+ values (rather than copying them) are rejected by vLLM itself. The in-engine path is
225
+ tested on a GPU (above). The `sparse_nccl` objects pass vLLM's own validator, but the
226
+ NCCL broadcast between processes needs two GPUs and hasn't been run here.
227
+
228
+ ## Sharing: remotes
229
+
230
+ ```bash
231
+ deltaw remote add origin /mnt/nas/models/qwen-edits # or hf://you/qwen-edits
232
+ deltaw push # current branch; --tags, --force
233
+ deltaw clone /mnt/nas/models/qwen-edits work # or: deltaw clone hf://you/qwen-edits
234
+ deltaw clone hf://you/qwen-edits --depth 1 # latest version only
235
+ deltaw pull # fetch + fast-forward or element-wise merge
236
+ ```
237
+
238
+ Hugging Face remotes need `pip install huggingface_hub` and a token with write
239
+ access for pushing. A new Hub repo is created private unless you pass `--public`.
240
+
241
+ ## Finding the edit that broke something
242
+
243
+ ```bash
244
+ deltaw bisect start main base
245
+ deltaw bisect run "python eval.py --threshold 0.6" # exit 0 = good, 1 = bad, 125 = skip
246
+ deltaw bisect reset
247
+ ```
248
+
249
+ ## How it works
250
+
251
+ ```
252
+ commit ──> tree ──> file manifest ──> segments ──> chunks (content-addressed)
253
+ (format, size, tensor: name, dtype, shape
254
+ Merkle root) glue: headers, pickles, zip records
255
+ ```
256
+
257
+ * **Parsing without loading.** safetensors headers give names, dtypes and offsets.
258
+ PyTorch `.pt` files are uncompressed zips: each storage record becomes a tensor
259
+ segment, and tensor names are recovered by walking `data.pkl` with a stub unpickler
260
+ that never runs code from the file. Everything else (headers, pickles, zip
261
+ directories) is kept verbatim as glue, so concatenating segments rebuilds the
262
+ original bytes exactly.
263
+ * **Chunks** are at most 32 MB, cut at element boundaries. A one-row edit to a
264
+ 1 GB embedding rewrites one chunk, not the tensor.
265
+ * **Deltas** are taken against the chunk at the same position of the same tensor in
266
+ the previous version. XOR keeps the sign and exponent bits that didn't change as
267
+ zero runs, and sparse coding stores only changed elements. Delta chains are capped
268
+ at depth 24, like git's pack depth.
269
+ * **Integrity.** Every decoded chunk is checked against its BLAKE2b id. A file is
270
+ identified by the Merkle root of its chunk ids, so committing a patch is O(edit)
271
+ rather than O(model). `deltaw verify` rebuilds everything.
272
+
273
+ Repository layout: `.deltaw/objects/ab/cdef…` (one file per object), `refs/heads`,
274
+ `refs/tags`, `HEAD`, `index.json`, much like `.git`.
275
+
276
+ ## Why not git-lfs / git-theta / Xet / DVC?
277
+
278
+ * **git-lfs, DVC** store whole files: every checkpoint is a new full copy.
279
+ * **Hugging Face Xet** deduplicates byte chunks across uploads. That's great for
280
+ unchanged files, but a fine-tune or an edit that touches every 64 KB region of a
281
+ tensor defeats it, and it doesn't know what a tensor is (no tensor diffs, merges
282
+ or patches).
283
+ * **[git-theta](https://github.com/r-three/git-theta)** (ICML 2023) is the closest
284
+ prior work and inspired parts of this design: per-parameter-group tracking, sparse
285
+ and low-rank updates, merges. It works through git clean/smudge filters and LFS;
286
+ it hasn't been updated since 2024.
287
+ * **Upstreaming into git itself** isn't realistic: git's object model and delta
288
+ compression are byte-oriented by design. Its extension points (diff drivers,
289
+ filters) are the right place to plug in, which `deltaw git-setup` does.
290
+
291
+ deltaw keeps its own object store to get element-aware deltas, byte-exact rebuilds of
292
+ `.pt` files, O(edit) patch commits, and an import path that doesn't push 500 GB
293
+ through a git filter.
294
+
295
+ ## Status
296
+
297
+ v0.1, alpha. The on-disk format may still change before 1.0. Tested: 26 unit tests,
298
+ plus the real-checkpoint benchmarks above. The Hugging Face transport is implemented
299
+ but not yet tested end to end against the Hub. Not done yet:
300
+
301
+ - packfiles (many tiny objects become many tiny files)
302
+ - converting dense 2-D deltas to LoRA adapters via truncated SVD (lossy, opt-in)
303
+ - best-parent search when importing unordered checkpoints
304
+ - GGUF-aware parsing (GGUF files are stored as generic chunked blobs today)
305
+
306
+ ## License
307
+
308
+ Apache-2.0