tsugi-mend 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.
- tsugi_mend-0.1.0/.github/workflows/ci.yml +43 -0
- tsugi_mend-0.1.0/.gitignore +75 -0
- tsugi_mend-0.1.0/LICENSE +239 -0
- tsugi_mend-0.1.0/NOTICE +63 -0
- tsugi_mend-0.1.0/PKG-INFO +139 -0
- tsugi_mend-0.1.0/README.md +99 -0
- tsugi_mend-0.1.0/docs/architecture.md +82 -0
- tsugi_mend-0.1.0/docs/benchmark_protocol.md +80 -0
- tsugi_mend-0.1.0/docs/convergence_equivalence_sketch.md +129 -0
- tsugi_mend-0.1.0/docs/phase2_week1_async_tp_overlap.md +127 -0
- tsugi_mend-0.1.0/examples/concurrent_orchestrator.py +154 -0
- tsugi_mend-0.1.0/examples/minimal_single_process.py +75 -0
- tsugi_mend-0.1.0/pyproject.toml +67 -0
- tsugi_mend-0.1.0/src/tsugi_mend/__init__.py +31 -0
- tsugi_mend-0.1.0/src/tsugi_mend/async_tp.py +75 -0
- tsugi_mend-0.1.0/src/tsugi_mend/compression.py +276 -0
- tsugi_mend-0.1.0/src/tsugi_mend/concurrent.py +289 -0
- tsugi_mend-0.1.0/src/tsugi_mend/config.py +285 -0
- tsugi_mend-0.1.0/src/tsugi_mend/desync_optimizer.py +157 -0
- tsugi_mend-0.1.0/src/tsugi_mend/diagnostics.py +50 -0
- tsugi_mend-0.1.0/src/tsugi_mend/failslow.py +134 -0
- tsugi_mend-0.1.0/src/tsugi_mend/reducer.py +372 -0
- tsugi_mend-0.1.0/src/tsugi_mend/runtime.py +411 -0
- tsugi_mend-0.1.0/src/tsugi_mend/sideband.py +236 -0
- tsugi_mend-0.1.0/src/tsugi_mend/topology.py +188 -0
- tsugi_mend-0.1.0/tests/__init__.py +0 -0
- tsugi_mend-0.1.0/tests/conftest.py +7 -0
- tsugi_mend-0.1.0/tests/test_compression.py +258 -0
- tsugi_mend-0.1.0/tests/test_concurrent_outer_step.py +303 -0
- tsugi_mend-0.1.0/tests/test_config.py +73 -0
- tsugi_mend-0.1.0/tests/test_desync_optimizer.py +94 -0
- tsugi_mend-0.1.0/tests/test_failslow.py +109 -0
- tsugi_mend-0.1.0/tests/test_reducer.py +322 -0
- tsugi_mend-0.1.0/tests/test_runtime_integration.py +482 -0
- tsugi_mend-0.1.0/tests/test_sideband.py +125 -0
- tsugi_mend-0.1.0/tests/test_topology.py +109 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Cache pip
|
|
25
|
+
uses: actions/cache@v4
|
|
26
|
+
with:
|
|
27
|
+
path: ~/.cache/pip
|
|
28
|
+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
|
|
29
|
+
|
|
30
|
+
- name: Install package + dev extras
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
pip install -e ".[dev]"
|
|
34
|
+
|
|
35
|
+
- name: Lint (ruff)
|
|
36
|
+
run: ruff check src tests
|
|
37
|
+
|
|
38
|
+
- name: Type check (mypy)
|
|
39
|
+
run: mypy src
|
|
40
|
+
continue-on-error: true
|
|
41
|
+
|
|
42
|
+
- name: Run pytest
|
|
43
|
+
run: pytest -q
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
share/python-wheels/
|
|
20
|
+
*.egg-info/
|
|
21
|
+
.installed.cfg
|
|
22
|
+
*.egg
|
|
23
|
+
MANIFEST
|
|
24
|
+
|
|
25
|
+
# Virtual environments
|
|
26
|
+
venv/
|
|
27
|
+
.venv/
|
|
28
|
+
env/
|
|
29
|
+
ENV/
|
|
30
|
+
|
|
31
|
+
# Testing
|
|
32
|
+
.pytest_cache/
|
|
33
|
+
.coverage
|
|
34
|
+
.coverage.*
|
|
35
|
+
.cache
|
|
36
|
+
nosetests.xml
|
|
37
|
+
coverage.xml
|
|
38
|
+
*.cover
|
|
39
|
+
.hypothesis/
|
|
40
|
+
|
|
41
|
+
# Type checking
|
|
42
|
+
.mypy_cache/
|
|
43
|
+
.dmypy.json
|
|
44
|
+
dmypy.json
|
|
45
|
+
.pyre/
|
|
46
|
+
.pytype/
|
|
47
|
+
|
|
48
|
+
# IDE
|
|
49
|
+
.vscode/
|
|
50
|
+
.idea/
|
|
51
|
+
*.swp
|
|
52
|
+
*.swo
|
|
53
|
+
*~
|
|
54
|
+
|
|
55
|
+
# OS
|
|
56
|
+
.DS_Store
|
|
57
|
+
Thumbs.db
|
|
58
|
+
|
|
59
|
+
# Diagnostics / run outputs
|
|
60
|
+
results/
|
|
61
|
+
*.jsonl
|
|
62
|
+
*.log
|
|
63
|
+
checkpoints/
|
|
64
|
+
wandb/
|
|
65
|
+
*.pt
|
|
66
|
+
*.bin
|
|
67
|
+
*.safetensors
|
|
68
|
+
|
|
69
|
+
# HuggingFace cache (if user pins it under repo)
|
|
70
|
+
.cache/
|
|
71
|
+
hf_cache/
|
|
72
|
+
|
|
73
|
+
# Local environment files
|
|
74
|
+
.env
|
|
75
|
+
.env.local
|
tsugi_mend-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
================================================================
|
|
2
|
+
Why Apache-2.0 for tsugiai-mend-sdk (NOTICE PREAMBLE)
|
|
3
|
+
================================================================
|
|
4
|
+
|
|
5
|
+
This SDK (tsugiai-mend-sdk, the "Software") is licensed under the
|
|
6
|
+
Apache License, Version 2.0 ("Apache-2.0"), with its full automatic
|
|
7
|
+
patent grant. The full Apache-2.0 license text follows below.
|
|
8
|
+
|
|
9
|
+
TsugiCinema, Inc. ("Licensor") publishes a separate, patent-aligned
|
|
10
|
+
SDK at github.com/tsugiai/tsugi-kpool ("tsugiai-kpool-sdk"),
|
|
11
|
+
which is also licensed under the Apache License, Version 2.0. That
|
|
12
|
+
SDK is the reduction-to-practice artifact for two TsugiCinema US
|
|
13
|
+
provisional patents (US App. 64/060,315 K-Pool LoRA and US App.
|
|
14
|
+
64/055,093 Infinity) and exercises elements of those patent claims
|
|
15
|
+
at LoRA-adapter granularity. The Apache-2.0 patent grant in Section 3
|
|
16
|
+
on that SDK extends to those patent estates as practiced by the SDK
|
|
17
|
+
code as distributed, bounded by Section 3's "necessarily infringed
|
|
18
|
+
by their Contribution" language.
|
|
19
|
+
|
|
20
|
+
THIS SDK (tsugiai-mend-sdk) IS A DELIBERATELY SEPARATE WORK. It does
|
|
21
|
+
not exercise either of TsugiCinema's two patent estates listed
|
|
22
|
+
above. It is an integration of public-art techniques:
|
|
23
|
+
|
|
24
|
+
- Decoupled DiLoCo (Douillard et al., arXiv:2604.21428, April 2026)
|
|
25
|
+
- DES-LOC / Local Adam (Iacob et al., arXiv:2505.22549, May 2025)
|
|
26
|
+
- Async Tensor Parallelism (PyTorch / TorchTitan, September 2024)
|
|
27
|
+
- FALCON fail-slow mitigation (arXiv:2410.12588, October 2024)
|
|
28
|
+
|
|
29
|
+
Because this SDK does not exercise TsugiCinema's K-Pool LoRA or
|
|
30
|
+
Infinity patent claim elements, the Apache-2.0 automatic patent
|
|
31
|
+
grant on this SDK does not extend a license to either of those
|
|
32
|
+
patent estates. Users who wish to use the patent-aligned mechanisms
|
|
33
|
+
covered by US App. 64/060,315 or US App. 64/055,093 (variance-
|
|
34
|
+
threshold trigger, K-of-N adapter routing with sideband-coordinated
|
|
35
|
+
elastic buffer, etc.) should engage with TsugiCinema separately;
|
|
36
|
+
those mechanisms are NOT present in this SDK and the Apache-2.0
|
|
37
|
+
grant on this SDK does not reach them.
|
|
38
|
+
|
|
39
|
+
The two SDKs share zero code. This SDK was scoped on 2026-05-21 to
|
|
40
|
+
maximize measured throughput uplift on cross-rack distributed
|
|
41
|
+
training using public-art techniques only, so that the Apache-2.0
|
|
42
|
+
patent grant could be granted without scoping and without leaking
|
|
43
|
+
the patent moat carried by tsugiai-kpool-sdk.
|
|
44
|
+
|
|
45
|
+
The full Apache License, Version 2.0 follows.
|
|
46
|
+
|
|
47
|
+
================================================================
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Apache License
|
|
51
|
+
Version 2.0, January 2004
|
|
52
|
+
http://www.apache.org/licenses/
|
|
53
|
+
|
|
54
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
55
|
+
|
|
56
|
+
1. Definitions.
|
|
57
|
+
|
|
58
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
59
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
60
|
+
|
|
61
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
62
|
+
the copyright owner that is granting the License.
|
|
63
|
+
|
|
64
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
65
|
+
other entities that control, are controlled by, or are under common
|
|
66
|
+
control with that entity. For the purposes of this definition,
|
|
67
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
68
|
+
direction or management of such entity, whether by contract or
|
|
69
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
70
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
71
|
+
|
|
72
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
73
|
+
exercising permissions granted by this License.
|
|
74
|
+
|
|
75
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
76
|
+
including but not limited to software source code, documentation
|
|
77
|
+
source, and configuration files.
|
|
78
|
+
|
|
79
|
+
"Object" form shall mean any form resulting from mechanical
|
|
80
|
+
transformation or translation of a Source form, including but
|
|
81
|
+
not limited to compiled object code, generated documentation,
|
|
82
|
+
and conversions to other media types.
|
|
83
|
+
|
|
84
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
85
|
+
Object form, made available under the License, as indicated by a
|
|
86
|
+
copyright notice that is included in or attached to the work
|
|
87
|
+
(an example is provided in the Appendix below).
|
|
88
|
+
|
|
89
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
90
|
+
form, that is based on (or derived from) the Work and for which the
|
|
91
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
92
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
93
|
+
of this License, Derivative Works shall not include works that remain
|
|
94
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
95
|
+
the Work and Derivative Works thereof.
|
|
96
|
+
|
|
97
|
+
"Contribution" shall mean any work of authorship, including
|
|
98
|
+
the original version of the Work and any modifications or additions
|
|
99
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
100
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
101
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
102
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
103
|
+
means any form of electronic, verbal, or written communication sent
|
|
104
|
+
to the Licensor or its representatives, including but not limited to
|
|
105
|
+
communication on electronic mailing lists, source code control systems,
|
|
106
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
107
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
108
|
+
excluding communication that is conspicuously marked or otherwise
|
|
109
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
110
|
+
|
|
111
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
112
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
113
|
+
subsequently incorporated within the Work.
|
|
114
|
+
|
|
115
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
116
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
117
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
118
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
119
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
120
|
+
Work and such Derivative Works in Source or Object form.
|
|
121
|
+
|
|
122
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
123
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
124
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
125
|
+
(except as stated in this section) patent license to make, have made,
|
|
126
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
127
|
+
where such license applies only to those patent claims licensable
|
|
128
|
+
by such Contributor that are necessarily infringed by their
|
|
129
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
130
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
131
|
+
institute patent litigation against any entity (including a
|
|
132
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
133
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
134
|
+
or contributory patent infringement, then any patent licenses
|
|
135
|
+
granted to You under this License for that Work shall terminate
|
|
136
|
+
as of the date such litigation is filed.
|
|
137
|
+
|
|
138
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
139
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
140
|
+
modifications, and in Source or Object form, provided that You
|
|
141
|
+
meet the following conditions:
|
|
142
|
+
|
|
143
|
+
(a) You must give any other recipients of the Work or
|
|
144
|
+
Derivative Works a copy of this License; and
|
|
145
|
+
|
|
146
|
+
(b) You must cause any modified files to carry prominent notices
|
|
147
|
+
stating that You changed the files; and
|
|
148
|
+
|
|
149
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
150
|
+
that You distribute, all copyright, patent, trademark, and
|
|
151
|
+
attribution notices from the Source form of the Work,
|
|
152
|
+
excluding those notices that do not pertain to any part of
|
|
153
|
+
the Derivative Works; and
|
|
154
|
+
|
|
155
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
156
|
+
distribution, then any Derivative Works that You distribute must
|
|
157
|
+
include a readable copy of the attribution notices contained
|
|
158
|
+
within such NOTICE file, excluding those notices that do not
|
|
159
|
+
pertain to any part of the Derivative Works, in at least one
|
|
160
|
+
of the following places: within a NOTICE text file distributed
|
|
161
|
+
as part of the Derivative Works; within the Source form or
|
|
162
|
+
documentation, if provided along with the Derivative Works; or,
|
|
163
|
+
within a display generated by the Derivative Works, if and
|
|
164
|
+
wherever such third-party notices normally appear. The contents
|
|
165
|
+
of the NOTICE file are for informational purposes only and
|
|
166
|
+
do not modify the License. You may add Your own attribution
|
|
167
|
+
notices within Derivative Works that You distribute, alongside
|
|
168
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
169
|
+
that such additional attribution notices cannot be construed
|
|
170
|
+
as modifying the License.
|
|
171
|
+
|
|
172
|
+
You may add Your own copyright statement to Your modifications and
|
|
173
|
+
may provide additional or different license terms and conditions
|
|
174
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
175
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
176
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
177
|
+
the conditions stated in this License.
|
|
178
|
+
|
|
179
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
180
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
181
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
182
|
+
this License, without any additional terms or conditions.
|
|
183
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
184
|
+
the terms of any separate license agreement you may have executed
|
|
185
|
+
with Licensor regarding such Contributions.
|
|
186
|
+
|
|
187
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
188
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
189
|
+
except as required for describing the origin of the Work and
|
|
190
|
+
reproducing the content of the NOTICE file.
|
|
191
|
+
|
|
192
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
193
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
194
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
195
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
196
|
+
implied, including, without limitation, any warranties or conditions
|
|
197
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
198
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
199
|
+
appropriateness of using or redistributing the Work and assume any
|
|
200
|
+
risks associated with Your exercise of permissions under this License.
|
|
201
|
+
|
|
202
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
203
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
204
|
+
unless required by applicable law (such as deliberate and grossly
|
|
205
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
206
|
+
liable to You for damages, including any direct, indirect, special,
|
|
207
|
+
incidental, or consequential damages of any character arising as a
|
|
208
|
+
result of this License or out of the use or inability to use the
|
|
209
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
210
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
211
|
+
other commercial damages or losses), even if such Contributor
|
|
212
|
+
has been advised of the possibility of such damages.
|
|
213
|
+
|
|
214
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
215
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
216
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
217
|
+
or other liability obligations and/or rights consistent with this
|
|
218
|
+
License. However, in accepting such obligations, You may act only
|
|
219
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
220
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
221
|
+
defend, and hold each Contributor harmless for any liability
|
|
222
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
223
|
+
of your accepting any such warranty or additional liability.
|
|
224
|
+
|
|
225
|
+
END OF TERMS AND CONDITIONS
|
|
226
|
+
|
|
227
|
+
Copyright 2026 TsugiCinema, Inc.
|
|
228
|
+
|
|
229
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
230
|
+
you may not use this file except in compliance with the License.
|
|
231
|
+
You may obtain a copy of the License at
|
|
232
|
+
|
|
233
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
234
|
+
|
|
235
|
+
Unless required by applicable law or agreed to in writing, software
|
|
236
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
237
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
238
|
+
See the License for the specific language governing permissions and
|
|
239
|
+
limitations under the License.
|
tsugi_mend-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
tsugiai-mend-sdk
|
|
2
|
+
Copyright 2026 TsugiCinema, Inc.
|
|
3
|
+
|
|
4
|
+
This product includes software developed by TsugiCinema, Inc. and is
|
|
5
|
+
licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
6
|
+
|
|
7
|
+
This software composes public prior art from the following sources.
|
|
8
|
+
Each citation is to the published reference describing the technique
|
|
9
|
+
exercised in this codebase; the implementation here is original
|
|
10
|
+
TsugiCinema, Inc. code that reproduces the published mechanism.
|
|
11
|
+
|
|
12
|
+
1. Cross-rack reducer (GraceWindowSyncer state machine).
|
|
13
|
+
Decoupled DiLoCo: Continual Pre-Training of Language Models
|
|
14
|
+
without Aggregator Synchronization.
|
|
15
|
+
Douillard, A.; Donchev, A.; Rush, A.; Riedel, S. (2026).
|
|
16
|
+
arXiv:2604.21428.
|
|
17
|
+
|
|
18
|
+
2. Desynchronized optimizer momenta (DES-LOC).
|
|
19
|
+
Local Adam: Globally-Sparse Local Updates for Distributed Adam.
|
|
20
|
+
Mishchenko, K. et al. (2025). arXiv:2505.22549.
|
|
21
|
+
|
|
22
|
+
3. Async tensor parallelism (intra-node async-TP overlap hooks).
|
|
23
|
+
TorchTitan: PyTorch Pre-training Native Library.
|
|
24
|
+
Wanchao Liang, Tianyu Liu, Less Wright, Will Constable,
|
|
25
|
+
Andrew Gu, Chien-Chin Huang, Iris Zhang, Wei Feng,
|
|
26
|
+
Howard Huang, Junjie Wang, Sanket Purandare, Gokul Nadathur,
|
|
27
|
+
Stratos Idreos. PyTorch (2024). https://github.com/pytorch/torchtitan
|
|
28
|
+
|
|
29
|
+
4. Fail-slow detection (FALCON sliding-window z-score).
|
|
30
|
+
FALCON: Pinpointing and Mitigating Stragglers for Large-Scale
|
|
31
|
+
Hybrid-Parallel Training.
|
|
32
|
+
Wu, T. et al. (2024). arXiv:2410.12588.
|
|
33
|
+
|
|
34
|
+
5. Optional gradient compression (PowerSGD with error feedback).
|
|
35
|
+
PowerSGD: Practical Low-Rank Gradient Compression for Distributed
|
|
36
|
+
Optimization.
|
|
37
|
+
Vogels, T.; Karimireddy, S. P.; Jaggi, M. (2019).
|
|
38
|
+
NeurIPS 2019. arXiv:1905.13727.
|
|
39
|
+
The PowerSGD primitive in `src/tsugi_mend/compression.py` is a
|
|
40
|
+
from-scratch reproduction of the rank-r power-iteration algorithm
|
|
41
|
+
with persistent error feedback. PyTorch's native
|
|
42
|
+
`torch.distributed.algorithms.ddp_comm_hooks.powerSGD_hook` was
|
|
43
|
+
considered but is DDP-bucket-bound and not directly reusable for
|
|
44
|
+
the GraceWindowSyncer fragment-merge path.
|
|
45
|
+
|
|
46
|
+
6. Concurrent outer-step orchestrator (Phase 2 Week 1 marquee feature).
|
|
47
|
+
Original TsugiCinema, Inc. work. The orchestrator wraps the
|
|
48
|
+
Decoupled DiLoCo control law (item 1) in an asyncio-task-based
|
|
49
|
+
pattern that overlaps the cross-rack grace window with inner-step
|
|
50
|
+
forward/backward compute. Convergence-equivalent to Decoupled
|
|
51
|
+
DiLoCo by Algorithm 2 staggering analysis; see
|
|
52
|
+
`docs/phase2_week1_async_tp_overlap.md` for the proof sketch.
|
|
53
|
+
|
|
54
|
+
Patent posture:
|
|
55
|
+
The Apache-2.0 license grants a full automatic patent grant on the
|
|
56
|
+
techniques exercised in this codebase. The mend SDK is patent-
|
|
57
|
+
independent by deliberate construction; it does NOT exercise the
|
|
58
|
+
K-Pool LoRA (US App. 64/060,315) or Infinity (US App. 64/055,093)
|
|
59
|
+
patent estates owned by TsugiCinema, Inc. Those mechanisms (variance-
|
|
60
|
+
threshold trigger; K-of-N adapter routing; elastic-adapter-buffer
|
|
61
|
+
quorum-based merge) live in the companion patent-aligned SDK at
|
|
62
|
+
github.com/tsugiai/tsugi-kpool and are not present in this
|
|
63
|
+
repository.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tsugi-mend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: tsugiai-mend-sdk. Maximum-uplift cross-rack distributed-training reducer built on Decoupled DiLoCo + DES-LOC + async tensor parallelism + FALCON fail-slow mitigation. Patent-independent by deliberate construction; see LICENSE preamble.
|
|
5
|
+
Project-URL: Homepage, https://tsugilabs.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/tsugiai/tsugi-mend
|
|
7
|
+
Project-URL: Unified-SDK, https://github.com/tsugiai/tsugi
|
|
8
|
+
Project-URL: Companion-SDK-Patent-Aligned, https://github.com/tsugiai/tsugi-kpool
|
|
9
|
+
Author-email: Tong Liu <tong@tsugicinema.com>
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: async-tp,cross-rack,decoupled-diloco,des-loc,distributed-training,failslow,pytorch
|
|
14
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: numpy>=1.26
|
|
22
|
+
Requires-Dist: torch>=2.4
|
|
23
|
+
Provides-Extra: benchmark
|
|
24
|
+
Requires-Dist: accelerate>=0.34; extra == 'benchmark'
|
|
25
|
+
Requires-Dist: datasets>=2.20; extra == 'benchmark'
|
|
26
|
+
Requires-Dist: evaluate>=0.4; extra == 'benchmark'
|
|
27
|
+
Requires-Dist: hf-transfer>=0.1; extra == 'benchmark'
|
|
28
|
+
Requires-Dist: matplotlib>=3.8; extra == 'benchmark'
|
|
29
|
+
Requires-Dist: protobuf>=4.25; extra == 'benchmark'
|
|
30
|
+
Requires-Dist: pyyaml>=6.0; extra == 'benchmark'
|
|
31
|
+
Requires-Dist: scipy>=1.13; extra == 'benchmark'
|
|
32
|
+
Requires-Dist: sentencepiece>=0.2; extra == 'benchmark'
|
|
33
|
+
Requires-Dist: transformers>=4.45; extra == 'benchmark'
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# tsugiai-mend-sdk
|
|
42
|
+
|
|
43
|
+
Maximum-uplift cross-rack distributed-training reducer for PyTorch.
|
|
44
|
+
|
|
45
|
+
A software-only drop-in that replaces the cross-rack data-parallel
|
|
46
|
+
all-reduce with an integration of public-art techniques designed to
|
|
47
|
+
maximize measured tokens-per-second uplift on realistic cross-rack
|
|
48
|
+
topology:
|
|
49
|
+
|
|
50
|
+
- **Decoupled DiLoCo** (Douillard et al., arXiv:2604.21428, April 2026): independent asynchronous learners, minimum quorum, adaptive grace window, token-weighted merge.
|
|
51
|
+
- **DES-LOC / Local Adam** (Iacob et al., arXiv:2505.22549, May 2025; ICLR 2026): desynchronized synchronization periods for adaptive-optimizer momenta.
|
|
52
|
+
- **Async tensor parallelism** (PyTorch / TorchTitan, September 2024): intra-node overlap of all-gather / reduce-scatter with matmul.
|
|
53
|
+
- **FALCON fail-slow mitigation** (arXiv:2410.12588, October 2024): sliding-window z-score detection of slow nodes to exclude them from the current quorum round.
|
|
54
|
+
|
|
55
|
+
The SDK keeps intra-rack TP / CP / PP / FSDP collectives unchanged (vanilla NCCL inside the NVLink domain) and replaces only the off-rack DP boundary with the four-paper stack above.
|
|
56
|
+
|
|
57
|
+
## License and IP posture
|
|
58
|
+
|
|
59
|
+
This SDK is licensed under **Apache-2.0** with its full automatic patent grant. The SDK is patent-independent by deliberate construction: it does not exercise the K-Pool LoRA (US App. 64/060,315) or Infinity (US App. 64/055,093) patent estates that the companion SDK (`tsugiai-kpool-sdk`, also Apache-2.0) does. Read the preamble at the top of the `LICENSE` file for the full posture explanation.
|
|
60
|
+
|
|
61
|
+
The companion patent-aligned SDK at `github.com/tsugiai/tsugi-kpool` is the reduction-to-practice artifact for those two TsugiCinema patent estates. The two SDKs share zero code.
|
|
62
|
+
|
|
63
|
+
## Headline measurement
|
|
64
|
+
|
|
65
|
+
| Workload | Hardware | Measurement | Reference |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| **Statistical-confidence headline (Hopper 3-seed CI)** | Modal H100:1, Qwen-2.5-1.5B, 200 steps × 3 seeds at 2000ms | **+71.49% ± 2.83% (95% CI)** throughput uplift | `docs/phase2_multi_seed_ci_results.md` |
|
|
68
|
+
| **Cross-rack grace-window overlap on Hopper at 7B production scale** | Modal H100:1, Qwen-2.5-7B, 200 steps × 5 delays | **+76.58% at 2000ms; +39.72% at 1000ms; +19.20% at 500ms** | `docs/phase2_delay_sweep_qwen7b_results.md` |
|
|
69
|
+
| **Intermediate model-scale (3B) confirmation (Hopper 3-seed CI)** | Modal H100:1, Qwen-2.5-3B, 200 steps × 4 delays × 3 seeds | **+41.31% ± 0.29% at 2000ms (n=3); +20.40% ± 0.03% at 1000ms; +9.75% ± 0.04% at 500ms** | Continuation doc 2026-05-23 |
|
|
70
|
+
| Cross-rack grace-window overlap on Hopper at 1.5B model scale | Modal H100:1, Qwen-2.5-1.5B, 200 steps × 7 delays | +70.64% at 2000ms; +34.73% at 1000ms; +16.86% at 500ms; concurrent path constant ~30,840 tok/s across all delays | `docs/phase2_delay_sweep_results.md` |
|
|
71
|
+
| Cross-rack grace-window overlap on A10G | Modal A10G, SmolLM-135M, 200 steps × 7 delays | +52.75% at 2000ms (constant); +11.61% at 500ms; -0.06% overhead at 0ms; bit-exact loss preserved across all cells | `docs/phase2_delay_sweep_results.md` |
|
|
72
|
+
| **A10G delay-distribution stress-test sweep** | Modal A10G, SmolLM-135M, 200 steps × 4 delays × 3 distributions | **constant +52.53% / bimodal-stress +8.29% / long-tail-stress +19.44% at delay=2000ms** (parameters NOT FALCON-anchored; see briefs 06/07/08 in MasterVision) | Continuation doc 2026-05-23 |
|
|
73
|
+
| **Production-realistic multi-GPU FSDP + 7B model (3-seed CI)** | Modal 8xH100 FSDP FULL_SHARD, Qwen-2.5-7B + simulated 2-rack, 4 delays × 3 seeds | **+6.37% ± 1.31% at delay=2000ms (n=3; replaces the prior +7.36% single-seed)** | Continuation doc 2026-05-23 |
|
|
74
|
+
| Multi-GPU FSDP smaller model | Modal 8xH100 FSDP, Qwen-2.5-1.5B + simulated 2-rack, 7 delays | +3.08% at 2000ms (synthetic 8xGPU floor) | `docs/stage_c_phase2_delay_sweep_results.md` |
|
|
75
|
+
| Real cross-network 2-node 8xV100 (synchronous reducer; preserved baseline) | Lambda Labs commodity Ethernet, SmolLM-135M, 500 paired steps | +28.58% tokens-per-second uplift vs vanilla FSDP, bit-exact-identical loss | `docs/stage_d_proper_results.md` |
|
|
76
|
+
| H100 Hopper single-instance (synchronous reducer baseline) | Modal 8x H100 SXM5, Llama-3-8B, 2000 paired steps × 3 seeds | -0.97% ± 1.5% (predicted null; Hopper NVLink absorbs the synchronous-path cross-rack tax) | `docs/stage_e_results.md` |
|
|
77
|
+
| **H100 Hopper single-instance + concurrent orchestrator (Track A, 3-seed CI)** | Modal 8x H100 SXM5, Llama-3-8B, 200 paired steps × 3 seeds at delay=2000ms | **+2.88% ± 0.43% (n=3)** throughput uplift; loss equivalence preserved (sync 0.288, conc 0.278) | Continuation doc 2026-05-23 |
|
|
78
|
+
| **Item E DeepSpeed ZeRO-3 head-to-head measured orthogonality** | Modal 8x H100 SXM5, Qwen-2.5-7B + DeepSpeed ZeRO-3 (stage=3, overlap_comm=True), 200 paired steps × 3 seeds at delay=2000ms | **+29.6% concurrent vs sync (n=3 paired; per-seed jitter <1pp)**; concurrent +0.44% vs no-delay baseline. DeepSpeed's intra-iteration overlap cannot recover the outer-step wait; Mend's outer-step concurrent_outer_step recovers essentially all of it | (internal benchmark report) |
|
|
79
|
+
| **Real cross-network 2-pod 8xH100 (Stage E-prime; production-fabric floor; n=1 paired)** | RunPod 2x 8x H100 SXM5 over real InfiniBand or RoCE v2 3.2 Tbps (AP-IN-1), Llama-3-8B, 500 paired steps × 1 seed | **+1.42% tps + 0.18% loss delta (effectively bit-exact)**; production-fabric floor anchor; n=1 caveat is load-bearing (same order of magnitude as +1.40% baseline-only seed variance); n=3 CI pending | `docs/stage_e_prime_results.md` |
|
|
80
|
+
|
|
81
|
+
The **+71.49% ± 2.83% (95% CI; n=3) Hopper headline** is the canonical enterprise cross-rack DD-grade measurement. The orchestrator's uplift is governed by `N * T_step / G` (sync_period_steps × per-step compute time, vs grace_window_ms); apparent "non-monotonicity with model size" at H100:1 (Qwen-3B +41.31% sits below both Qwen-1.5B +71.49% and Qwen-7B +76.58%) is fully explained by the Qwen-7B measurement using 1/8 the tokens-per-step (seq_len=1024 mbs=1 vs seq_len=2048 mbs=4). At fixed tokens-per-step, uplift is monotonically decreasing in model size. The analytical model and the proposed `N* = ceil(G / T_step)` auto-tuner spec are documented in an internal companion brief on uplift-surface characterization. Production-realistic multi-GPU FSDP yields a smaller honest floor (**+6.37% ± 1.31% n=3** paired at delay=2000ms; replaces the prior +7.36% single-seed) because 8-rank NCCL pipelining absorbs some of the synthetic delay; the real Stage D-proper measurement on actual cross-network would lift this number back up.
|
|
82
|
+
|
|
83
|
+
**Delay-distribution stress-test disclosure (Track D 2026-05-23)**: the constant-delay headlines (e.g., +52.53% A10G at delay=2000ms) are ceiling-case stress tests. The bimodal and log-normal variants are alternative stress-test shapes whose parameters are NOT directly FALCON-anchored: FALCON Table 2 reports only inter-node RDMA CoV=0.29 as the quantitative variance number; it does NOT publish per-iteration percentile breakdowns or bimodal characterizations. The current `bimodal` (80/20 at 50ms/base) delivers +8.29% on the same A10G + SmolLM-135M workload; the current `long_tail` (sigma=1.0) delivers +19.44%. A FALCON-CoV-anchored re-tune (95/5 bimodal, sigma~0.285 log-normal) is proposed in an internal FALCON-distribution-verification brief. Until that re-measurement lands, the +28.58% Stage D-proper Lambda V100 cross-network result remains the most defensible production-grounded headline.
|
|
84
|
+
|
|
85
|
+
At every scale, the concurrent path's throughput is rock-solid across all delays (Qwen-7B single-process: 4,300 ± 80 tok/s; Qwen-3B Hopper: 18,153 ± 4 tok/s; Qwen-1.5B Hopper: 30,840 ± 35 tok/s; SmolLM-135M A10G: 23,610 ± 80 tok/s); the synchronous baseline collapses linearly. The FALCON paper (arXiv:2410.12588) documents cross-rack inter-node RDMA variance (CoV=0.29) but does not characterize the per-iteration latency distribution shape that this sweep parameterizes; the delay-sweep is a stress-test, not a literal FALCON-replay.
|
|
86
|
+
|
|
87
|
+
## Status
|
|
88
|
+
|
|
89
|
+
Stage A through Stage E-prime all PASS. Phase 2 Week 1 (concurrent async-TP overlap with cross-rack reducer) shipped with the `ConcurrentOuterStep` orchestrator integrated. **Stage D-proper for Hopper-cross-network real-fabric is point-estimate closed via Stage E-prime (RunPod 2x 8x H100 InfiniBand 3.2 Tbps, n=1 paired, +1.42% production-fabric floor); n=3 CI pending.** Item E head-to-head against DeepSpeed ZeRO-3 confirms orthogonality at +29.6% concurrent vs sync on a Tier-1 hyperscaler stack. See `docs/60_day_plan.md` for the Phase 2 nine-week sprint.
|
|
90
|
+
|
|
91
|
+
## Quickstart
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from tsugi_mend import MendConfig, mend_init, mend_shutdown
|
|
95
|
+
|
|
96
|
+
config = MendConfig(
|
|
97
|
+
quorum_min_learners=4,
|
|
98
|
+
grace_window_ms=2000,
|
|
99
|
+
token_weighted_merge=True,
|
|
100
|
+
sync_period_steps=128,
|
|
101
|
+
momentum_sync_period_steps=512,
|
|
102
|
+
async_tp_enabled=True,
|
|
103
|
+
# Phase 2 Week 1 (2026-05-22): orchestrator overlaps the cross-rack
|
|
104
|
+
# outer-step wait with inner-step async-TP compute. Default True.
|
|
105
|
+
# See docs/phase2_delay_sweep_results.md for the +52.75% measurement.
|
|
106
|
+
concurrent_outer_step=True,
|
|
107
|
+
failslow_zscore_threshold=3.0,
|
|
108
|
+
failslow_window_steps=50,
|
|
109
|
+
rack_aware=True,
|
|
110
|
+
sideband_addr="tcp://0.0.0.0:51900",
|
|
111
|
+
sideband_peers=("tcp://peer1:51900", "tcp://peer2:51900"),
|
|
112
|
+
sideband_heartbeat_ms=100,
|
|
113
|
+
diagnostics_dir="./results/mend_diag",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
mend_init(model, config)
|
|
117
|
+
# ... train normally ...
|
|
118
|
+
mend_shutdown(model)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Layout
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
src/tsugi_mend/ SDK source
|
|
125
|
+
tests/ Stage A unit and integration tests (CPU-only)
|
|
126
|
+
benchmarks/ Stage B/C/D/E launch scripts (cloud-gated)
|
|
127
|
+
docs/ architecture, benchmark protocol, convergence-equivalence sketch
|
|
128
|
+
examples/ minimal training-loop integration examples
|
|
129
|
+
scripts/ utility scripts (env audit, cost estimator)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Companion SDK
|
|
133
|
+
|
|
134
|
+
For LoRA-adapter-granularity productization that exercises the K-Pool LoRA and Infinity patent estates, see `tsugiai-kpool-sdk`. The two SDKs serve different acquirer-due-diligence legs:
|
|
135
|
+
|
|
136
|
+
- **Patent moat leg (kpool):** the IP that goes into the Definitive Agreement's assignment schedule.
|
|
137
|
+
- **Operational uplift leg (max):** the engineering artifact a partner can run Monday morning on their cluster.
|
|
138
|
+
|
|
139
|
+
Both legs are independent. Either can stand on its own.
|