weightlang 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WeightLang contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,286 @@
1
+ Metadata-Version: 2.4
2
+ Name: weightlang
3
+ Version: 0.1.0
4
+ Summary: WeightLang prototype: compile .wgt network descriptions into runnable PyTorch artifacts
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/WeightLang/WeightLang
7
+ Project-URL: Documentation, https://github.com/WeightLang/WeightLang/tree/main/docs
8
+ Project-URL: Releases, https://github.com/WeightLang/WeightLang/releases
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: torch>=2.2
13
+ Requires-Dist: safetensors>=0.4
14
+ Requires-Dist: numpy
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest>=8; extra == "test"
17
+ Dynamic: license-file
18
+
19
+ <p align="center">
20
+ <img src="https://raw.githubusercontent.com/WeightLang/WeightLang/main/assets/logo.png" alt="WeightLang" width="148">
21
+ </p>
22
+
23
+ <h1 align="center">WeightLang</h1>
24
+
25
+ <p align="center">
26
+ <b>A programming language for building neural networks — and shipping their weights.</b>
27
+ </p>
28
+
29
+ <p align="center">
30
+ <a href="https://github.com/WeightLang/WeightLang/releases/latest"><img alt="release" src="https://img.shields.io/github/v/release/WeightLang/WeightLang?label=weightc"></a>
31
+ <img alt="python" src="https://img.shields.io/badge/python-3.10%2B-blue">
32
+ <img alt="backend" src="https://img.shields.io/badge/backend-PyTorch-ee4c2c">
33
+ <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-green"></a>
34
+ <img alt="status" src="https://img.shields.io/badge/status-0.1%20prototype-orange">
35
+ </p>
36
+
37
+ <p align="center">
38
+ <a href="#install">Install</a> ·
39
+ <a href="#quick-start">Quick start</a> ·
40
+ <a href="#the-language">Language</a> ·
41
+ <a href="#reusing-weights">Reuse</a> ·
42
+ <a href="#packages">Packages</a> ·
43
+ <a href="#documentation">Docs</a> ·
44
+ <a href="#limitations">Limitations</a>
45
+ </p>
46
+
47
+ ---
48
+
49
+ You write a network in a `.wgt` file. `weightc` uses PyTorch to build it,
50
+ initialise it, train it or import weights into it, and writes an **artifact**: a
51
+ directory holding the weights plus everything needed to load and run them —
52
+ architecture, input/output contract, versions, hashes, and where every tensor
53
+ came from. Artifacts can be published as packages addressed by GitHub path,
54
+ Go-style, and their weights reused by other programs.
55
+
56
+ WeightLang is meant to be written mostly by AI coding models, so the syntax is
57
+ small, line-oriented and strict. It should still be easy for a person to review.
58
+
59
+ ```text
60
+ xor.wgt ──weightc build──▶ build/xor_mlp/ ──weightc run──▶ {"prob": [[0.00003], [0.9999], ...]}
61
+ ├─ manifest.json structure · I/O · provenance · hashes
62
+ ├─ weights.safetensors float32 tensors, no pickle
63
+ └─ source.wgt the exact source
64
+ ```
65
+
66
+ ## Install
67
+
68
+ **Linux / macOS**
69
+
70
+ ```sh
71
+ curl -fsSL https://github.com/WeightLang/WeightLang/releases/latest/download/install.sh | sh
72
+ ```
73
+
74
+ **Windows (PowerShell)**
75
+
76
+ ```powershell
77
+ irm https://github.com/WeightLang/WeightLang/releases/latest/download/install.ps1 | iex
78
+ ```
79
+
80
+ Both scripts download the `weightlang` wheel from the GitHub release, check its
81
+ sha256 against the release's `SHA256SUMS`, and install it with
82
+ [`uv tool`](https://docs.astral.sh/uv/) if uv is available, otherwise into a
83
+ private virtual environment (no sudo / admin needed). On Linux they install the
84
+ CPU build of PyTorch by default (`WEIGHTLANG_TORCH=default` for PyPI's CUDA
85
+ build). Pin a version with `WEIGHTLANG_VERSION=v0.1.0`. Read the scripts before
86
+ piping them to a shell: [install.sh](install.sh), [install.ps1](install.ps1).
87
+
88
+ <details>
89
+ <summary><b>Other ways to install</b></summary>
90
+
91
+ ```sh
92
+ # With uv, straight from the release wheel
93
+ uv tool install https://github.com/WeightLang/WeightLang/releases/download/v0.1.0/weightlang-0.1.0-py3-none-any.whl
94
+
95
+ # From PyPI (once published there; see "Release status" below)
96
+ uv tool install weightlang # or: pipx install weightlang
97
+
98
+ # From source, for development
99
+ git clone https://github.com/WeightLang/WeightLang && cd WeightLang
100
+ python -m venv .venv && .venv/bin/pip install -e '.[test]'
101
+ ```
102
+
103
+ If PyTorch is already installed system-wide, reuse it:
104
+ `python -m venv --system-site-packages .venv && .venv/bin/pip install --no-build-isolation --no-deps -e .`
105
+
106
+ </details>
107
+
108
+ Requirements: Python ≥ 3.10, PyTorch ≥ 2.2, safetensors ≥ 0.4.
109
+
110
+ ## Quick start
111
+
112
+ ```sh
113
+ weightc check examples/xor.wgt # parse and type-check, no build
114
+ weightc build examples/xor.wgt -o build # init → train → build/xor_mlp/
115
+ weightc run build/xor_mlp --input '[[0,0],[0,1],[1,0],[1,1]]'
116
+ weightc inspect build/xor_mlp # I/O contract + where each tensor came from
117
+ weightc verify build/xor_mlp # re-check hashes, shapes, loadability
118
+ ```
119
+
120
+ ```text
121
+ built build/xor_mlp
122
+ weights sha256 7969227a9c0e3528317e1cd22b8da766e5b1a7a705e0ba96078a86cde8296ba2
123
+ tensors trained=4
124
+ training loss 0.7066 -> 0.0001 on 4 rows (xor), train accuracy 1.00
125
+ ```
126
+
127
+ From Python:
128
+
129
+ ```python
130
+ from weightlang import load_artifact
131
+
132
+ model = load_artifact("build/xor_mlp") # verifies hashes and shapes
133
+ model.predict([[0, 1], [1, 1]]) # tensor([[0.9999], [0.0001]])
134
+ model.module # a plain torch.nn.Sequential
135
+ ```
136
+
137
+ Artifacts can also be loaded with only `torch` + `safetensors` — see
138
+ [docs/artifact.md](docs/artifact.md).
139
+
140
+ | Command | What it does |
141
+ |---|---|
142
+ | `weightc check FILE` | Parse and type-check a `.wgt` file |
143
+ | `weightc build FILE -o DIR` | Build an artifact into `DIR/<model>/` |
144
+ | `weightc run ARTIFACT --input JSON` | Run inference; JSON in, JSON out |
145
+ | `weightc inspect ARTIFACT [--json]` | Show interface, layers and tensor provenance |
146
+ | `weightc verify ARTIFACT` | Check hashes, tensor shapes and loadability |
147
+ | `weightc get [DIR]` | Download, verify and lock the packages in `wgt.mod` |
148
+ | `weightc publish PKG --version vX.Y.Z` | Build a package's release assets |
149
+
150
+ ## The language
151
+
152
+ ```wgt
153
+ wgt 0.1
154
+ model xor_mlp
155
+
156
+ input bits: f32[2]
157
+ output prob: f32[1]
158
+
159
+ layer hidden: linear(in=2, out=8)
160
+ layer act: tanh
161
+ layer head: linear(in=8, out=1)
162
+ layer out: sigmoid
163
+
164
+ data xor:
165
+ [0, 0] -> [0]
166
+ [0, 1] -> [1]
167
+ [1, 0] -> [1]
168
+ [1, 1] -> [0]
169
+
170
+ init seed=42
171
+ train data=xor loss=bce optimizer=adam lr=0.05 epochs=1000
172
+ ```
173
+
174
+ - One statement per line, keyword first, `key=value` options. No expression language.
175
+ - Shapes are checked before anything runs; errors read `xor.wgt:9: shape mismatch: ...`.
176
+ - **Every tensor has an honest origin**, recorded in the manifest:
177
+
178
+ | origin | meaning |
179
+ |---|---|
180
+ | `random-init` | seeded random values, never trained — outputs are **not meaningful** |
181
+ | `trained` | initialised, then trained by this program |
182
+ | `imported` | copied unchanged from another artifact (`upstream_origin` says what it was there) |
183
+ | `imported+trained` | copied, then fine-tuned |
184
+
185
+ A program without `train` still builds, but `build`, `run`, `inspect` and the
186
+ Python loader all flag it, and importing an untrained tensor does not make it
187
+ trained. Training metrics are reported on the training rows only.
188
+
189
+ Full reference: [docs/language.md](docs/language.md).
190
+
191
+ ## Reusing weights
192
+
193
+ Import a layer from another artifact, optionally pin its hash and freeze it:
194
+
195
+ ```wgt
196
+ init seed=7
197
+ import hidden from "../build/xor_mlp" layer=hidden freeze
198
+ train data=xnor loss=bce optimizer=adam lr=0.05 epochs=300
199
+ ```
200
+
201
+ [`examples/xnor_reuse.wgt`](examples/xnor_reuse.wgt) takes the trained hidden
202
+ layer of `xor_mlp`, freezes it and trains only a new head for XNOR. The tests
203
+ check that the imported tensors are bit-identical to the source and stayed
204
+ frozen, that the source hash is recorded (and enforced with `sha256=`), and that
205
+ mismatched layer sizes are rejected. This shows the reuse *mechanism*; with four
206
+ training rows it does not show that reuse helps learning — a fresh network fits
207
+ XNOR too.
208
+
209
+ ## Packages
210
+
211
+ Packages are identified by GitHub path, versions are Git tags, and weights are
212
+ GitHub release assets — not files in Git history.
213
+
214
+ ```text
215
+ wgt.mod require github.com/WeightLang/WeightLang/packages/gates v0.1.0
216
+ xnor.wgt import hidden from "github.com/WeightLang/WeightLang/packages/gates/xor_mlp" layer=hidden freeze
217
+ wgt.sum commit + sha256 of the index, manifest, weights and source — commit this file
218
+ ```
219
+
220
+ ```sh
221
+ weightc get examples/remote_reuse # network: fetch, verify, write wgt.sum
222
+ weightc build examples/remote_reuse/xnor.wgt -o build # offline: cache checked against wgt.sum
223
+ ```
224
+
225
+ `weightc get` resolves the tag to a commit, checks every asset's size and sha256
226
+ against the release's `wgt.index.json`, requires the shipped `source.wgt` to equal
227
+ the file in the repository **at that commit**, and verifies the artifact. A later
228
+ moved tag or replaced asset no longer matches `wgt.sum` and is an error.
229
+
230
+ The first published package is
231
+ [`packages/gates`](packages/gates) → release
232
+ [`packages/gates/v0.1.0`](https://github.com/WeightLang/WeightLang/releases/tag/packages/gates/v0.1.0).
233
+ Publishing your own:
234
+
235
+ ```sh
236
+ weightc publish path/to/pkg --version v0.1.0 -o dist # prints the git tag + gh release commands
237
+ ```
238
+
239
+ Design, lock-file format and known gaps: [docs/packages.md](docs/packages.md).
240
+
241
+ ## Documentation
242
+
243
+ | | |
244
+ |---|---|
245
+ | [docs/language.md](docs/language.md) | Syntax, checks, weight sources and origins |
246
+ | [docs/artifact.md](docs/artifact.md) | Artifact files, manifest fields, verification, loading without WeightLang |
247
+ | [docs/packages.md](docs/packages.md) | Module paths, `wgt.mod`, `wgt.sum`, publishing, fetching, open design |
248
+
249
+ ## Development
250
+
251
+ ```sh
252
+ .venv/bin/python -m pytest # no network
253
+ WEIGHTLANG_NETWORK_TESTS=1 .venv/bin/python -m pytest # + fetch the real gates release
254
+ ruff check src tests && ruff format --check src tests
255
+ ```
256
+
257
+ The suite covers parsing and line-numbered errors, a full XOR build, bit-exact
258
+ outputs after save/reload, byte-stable rebuilds, tamper detection, loading with
259
+ plain PyTorch, untrained labelling, weight reuse, and the package flow (publish,
260
+ get, offline build, tampered assets, moved tags, mismatched source) against an
261
+ in-memory fake of GitHub.
262
+
263
+ ### Release status
264
+
265
+ | Channel | Status |
266
+ |---|---|
267
+ | GitHub release `v0.1.0` (wheel, sdist, `SHA256SUMS`, install scripts) | published |
268
+ | PyPI `weightlang` | not yet — needs a PyPI trusted publisher, then the manual [`publish-pypi`](.github/workflows/publish-pypi.yml) workflow uploads the same files as the GitHub release |
269
+
270
+ ## Limitations
271
+
272
+ - **Small language:** sequential networks only (`linear`, `relu`, `tanh`,
273
+ `sigmoid`), one 1-D `f32` input and output, inline training data, full-batch
274
+ training, `mse`/`bce`, `sgd`/`adam`.
275
+ - **Imports** copy whole `linear` layers. Packages support direct requirements
276
+ only, GitHub releases only, and trust-on-first-use hashes without signatures;
277
+ consumers use the publisher's prebuilt weights.
278
+ - **Reproducibility:** rebuilds are byte-identical on the same PyTorch version and
279
+ CPU; across versions or hardware weights may differ, and the hashes will show it.
280
+ - **Runtime:** PyTorch only; no ONNX or other exports.
281
+ - **Stability:** 0.x — syntax and formats may change. The Windows installer has
282
+ not been run on Windows yet.
283
+
284
+ ## License
285
+
286
+ [MIT](LICENSE)
@@ -0,0 +1,268 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/WeightLang/WeightLang/main/assets/logo.png" alt="WeightLang" width="148">
3
+ </p>
4
+
5
+ <h1 align="center">WeightLang</h1>
6
+
7
+ <p align="center">
8
+ <b>A programming language for building neural networks — and shipping their weights.</b>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/WeightLang/WeightLang/releases/latest"><img alt="release" src="https://img.shields.io/github/v/release/WeightLang/WeightLang?label=weightc"></a>
13
+ <img alt="python" src="https://img.shields.io/badge/python-3.10%2B-blue">
14
+ <img alt="backend" src="https://img.shields.io/badge/backend-PyTorch-ee4c2c">
15
+ <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-green"></a>
16
+ <img alt="status" src="https://img.shields.io/badge/status-0.1%20prototype-orange">
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#install">Install</a> ·
21
+ <a href="#quick-start">Quick start</a> ·
22
+ <a href="#the-language">Language</a> ·
23
+ <a href="#reusing-weights">Reuse</a> ·
24
+ <a href="#packages">Packages</a> ·
25
+ <a href="#documentation">Docs</a> ·
26
+ <a href="#limitations">Limitations</a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ You write a network in a `.wgt` file. `weightc` uses PyTorch to build it,
32
+ initialise it, train it or import weights into it, and writes an **artifact**: a
33
+ directory holding the weights plus everything needed to load and run them —
34
+ architecture, input/output contract, versions, hashes, and where every tensor
35
+ came from. Artifacts can be published as packages addressed by GitHub path,
36
+ Go-style, and their weights reused by other programs.
37
+
38
+ WeightLang is meant to be written mostly by AI coding models, so the syntax is
39
+ small, line-oriented and strict. It should still be easy for a person to review.
40
+
41
+ ```text
42
+ xor.wgt ──weightc build──▶ build/xor_mlp/ ──weightc run──▶ {"prob": [[0.00003], [0.9999], ...]}
43
+ ├─ manifest.json structure · I/O · provenance · hashes
44
+ ├─ weights.safetensors float32 tensors, no pickle
45
+ └─ source.wgt the exact source
46
+ ```
47
+
48
+ ## Install
49
+
50
+ **Linux / macOS**
51
+
52
+ ```sh
53
+ curl -fsSL https://github.com/WeightLang/WeightLang/releases/latest/download/install.sh | sh
54
+ ```
55
+
56
+ **Windows (PowerShell)**
57
+
58
+ ```powershell
59
+ irm https://github.com/WeightLang/WeightLang/releases/latest/download/install.ps1 | iex
60
+ ```
61
+
62
+ Both scripts download the `weightlang` wheel from the GitHub release, check its
63
+ sha256 against the release's `SHA256SUMS`, and install it with
64
+ [`uv tool`](https://docs.astral.sh/uv/) if uv is available, otherwise into a
65
+ private virtual environment (no sudo / admin needed). On Linux they install the
66
+ CPU build of PyTorch by default (`WEIGHTLANG_TORCH=default` for PyPI's CUDA
67
+ build). Pin a version with `WEIGHTLANG_VERSION=v0.1.0`. Read the scripts before
68
+ piping them to a shell: [install.sh](install.sh), [install.ps1](install.ps1).
69
+
70
+ <details>
71
+ <summary><b>Other ways to install</b></summary>
72
+
73
+ ```sh
74
+ # With uv, straight from the release wheel
75
+ uv tool install https://github.com/WeightLang/WeightLang/releases/download/v0.1.0/weightlang-0.1.0-py3-none-any.whl
76
+
77
+ # From PyPI (once published there; see "Release status" below)
78
+ uv tool install weightlang # or: pipx install weightlang
79
+
80
+ # From source, for development
81
+ git clone https://github.com/WeightLang/WeightLang && cd WeightLang
82
+ python -m venv .venv && .venv/bin/pip install -e '.[test]'
83
+ ```
84
+
85
+ If PyTorch is already installed system-wide, reuse it:
86
+ `python -m venv --system-site-packages .venv && .venv/bin/pip install --no-build-isolation --no-deps -e .`
87
+
88
+ </details>
89
+
90
+ Requirements: Python ≥ 3.10, PyTorch ≥ 2.2, safetensors ≥ 0.4.
91
+
92
+ ## Quick start
93
+
94
+ ```sh
95
+ weightc check examples/xor.wgt # parse and type-check, no build
96
+ weightc build examples/xor.wgt -o build # init → train → build/xor_mlp/
97
+ weightc run build/xor_mlp --input '[[0,0],[0,1],[1,0],[1,1]]'
98
+ weightc inspect build/xor_mlp # I/O contract + where each tensor came from
99
+ weightc verify build/xor_mlp # re-check hashes, shapes, loadability
100
+ ```
101
+
102
+ ```text
103
+ built build/xor_mlp
104
+ weights sha256 7969227a9c0e3528317e1cd22b8da766e5b1a7a705e0ba96078a86cde8296ba2
105
+ tensors trained=4
106
+ training loss 0.7066 -> 0.0001 on 4 rows (xor), train accuracy 1.00
107
+ ```
108
+
109
+ From Python:
110
+
111
+ ```python
112
+ from weightlang import load_artifact
113
+
114
+ model = load_artifact("build/xor_mlp") # verifies hashes and shapes
115
+ model.predict([[0, 1], [1, 1]]) # tensor([[0.9999], [0.0001]])
116
+ model.module # a plain torch.nn.Sequential
117
+ ```
118
+
119
+ Artifacts can also be loaded with only `torch` + `safetensors` — see
120
+ [docs/artifact.md](docs/artifact.md).
121
+
122
+ | Command | What it does |
123
+ |---|---|
124
+ | `weightc check FILE` | Parse and type-check a `.wgt` file |
125
+ | `weightc build FILE -o DIR` | Build an artifact into `DIR/<model>/` |
126
+ | `weightc run ARTIFACT --input JSON` | Run inference; JSON in, JSON out |
127
+ | `weightc inspect ARTIFACT [--json]` | Show interface, layers and tensor provenance |
128
+ | `weightc verify ARTIFACT` | Check hashes, tensor shapes and loadability |
129
+ | `weightc get [DIR]` | Download, verify and lock the packages in `wgt.mod` |
130
+ | `weightc publish PKG --version vX.Y.Z` | Build a package's release assets |
131
+
132
+ ## The language
133
+
134
+ ```wgt
135
+ wgt 0.1
136
+ model xor_mlp
137
+
138
+ input bits: f32[2]
139
+ output prob: f32[1]
140
+
141
+ layer hidden: linear(in=2, out=8)
142
+ layer act: tanh
143
+ layer head: linear(in=8, out=1)
144
+ layer out: sigmoid
145
+
146
+ data xor:
147
+ [0, 0] -> [0]
148
+ [0, 1] -> [1]
149
+ [1, 0] -> [1]
150
+ [1, 1] -> [0]
151
+
152
+ init seed=42
153
+ train data=xor loss=bce optimizer=adam lr=0.05 epochs=1000
154
+ ```
155
+
156
+ - One statement per line, keyword first, `key=value` options. No expression language.
157
+ - Shapes are checked before anything runs; errors read `xor.wgt:9: shape mismatch: ...`.
158
+ - **Every tensor has an honest origin**, recorded in the manifest:
159
+
160
+ | origin | meaning |
161
+ |---|---|
162
+ | `random-init` | seeded random values, never trained — outputs are **not meaningful** |
163
+ | `trained` | initialised, then trained by this program |
164
+ | `imported` | copied unchanged from another artifact (`upstream_origin` says what it was there) |
165
+ | `imported+trained` | copied, then fine-tuned |
166
+
167
+ A program without `train` still builds, but `build`, `run`, `inspect` and the
168
+ Python loader all flag it, and importing an untrained tensor does not make it
169
+ trained. Training metrics are reported on the training rows only.
170
+
171
+ Full reference: [docs/language.md](docs/language.md).
172
+
173
+ ## Reusing weights
174
+
175
+ Import a layer from another artifact, optionally pin its hash and freeze it:
176
+
177
+ ```wgt
178
+ init seed=7
179
+ import hidden from "../build/xor_mlp" layer=hidden freeze
180
+ train data=xnor loss=bce optimizer=adam lr=0.05 epochs=300
181
+ ```
182
+
183
+ [`examples/xnor_reuse.wgt`](examples/xnor_reuse.wgt) takes the trained hidden
184
+ layer of `xor_mlp`, freezes it and trains only a new head for XNOR. The tests
185
+ check that the imported tensors are bit-identical to the source and stayed
186
+ frozen, that the source hash is recorded (and enforced with `sha256=`), and that
187
+ mismatched layer sizes are rejected. This shows the reuse *mechanism*; with four
188
+ training rows it does not show that reuse helps learning — a fresh network fits
189
+ XNOR too.
190
+
191
+ ## Packages
192
+
193
+ Packages are identified by GitHub path, versions are Git tags, and weights are
194
+ GitHub release assets — not files in Git history.
195
+
196
+ ```text
197
+ wgt.mod require github.com/WeightLang/WeightLang/packages/gates v0.1.0
198
+ xnor.wgt import hidden from "github.com/WeightLang/WeightLang/packages/gates/xor_mlp" layer=hidden freeze
199
+ wgt.sum commit + sha256 of the index, manifest, weights and source — commit this file
200
+ ```
201
+
202
+ ```sh
203
+ weightc get examples/remote_reuse # network: fetch, verify, write wgt.sum
204
+ weightc build examples/remote_reuse/xnor.wgt -o build # offline: cache checked against wgt.sum
205
+ ```
206
+
207
+ `weightc get` resolves the tag to a commit, checks every asset's size and sha256
208
+ against the release's `wgt.index.json`, requires the shipped `source.wgt` to equal
209
+ the file in the repository **at that commit**, and verifies the artifact. A later
210
+ moved tag or replaced asset no longer matches `wgt.sum` and is an error.
211
+
212
+ The first published package is
213
+ [`packages/gates`](packages/gates) → release
214
+ [`packages/gates/v0.1.0`](https://github.com/WeightLang/WeightLang/releases/tag/packages/gates/v0.1.0).
215
+ Publishing your own:
216
+
217
+ ```sh
218
+ weightc publish path/to/pkg --version v0.1.0 -o dist # prints the git tag + gh release commands
219
+ ```
220
+
221
+ Design, lock-file format and known gaps: [docs/packages.md](docs/packages.md).
222
+
223
+ ## Documentation
224
+
225
+ | | |
226
+ |---|---|
227
+ | [docs/language.md](docs/language.md) | Syntax, checks, weight sources and origins |
228
+ | [docs/artifact.md](docs/artifact.md) | Artifact files, manifest fields, verification, loading without WeightLang |
229
+ | [docs/packages.md](docs/packages.md) | Module paths, `wgt.mod`, `wgt.sum`, publishing, fetching, open design |
230
+
231
+ ## Development
232
+
233
+ ```sh
234
+ .venv/bin/python -m pytest # no network
235
+ WEIGHTLANG_NETWORK_TESTS=1 .venv/bin/python -m pytest # + fetch the real gates release
236
+ ruff check src tests && ruff format --check src tests
237
+ ```
238
+
239
+ The suite covers parsing and line-numbered errors, a full XOR build, bit-exact
240
+ outputs after save/reload, byte-stable rebuilds, tamper detection, loading with
241
+ plain PyTorch, untrained labelling, weight reuse, and the package flow (publish,
242
+ get, offline build, tampered assets, moved tags, mismatched source) against an
243
+ in-memory fake of GitHub.
244
+
245
+ ### Release status
246
+
247
+ | Channel | Status |
248
+ |---|---|
249
+ | GitHub release `v0.1.0` (wheel, sdist, `SHA256SUMS`, install scripts) | published |
250
+ | PyPI `weightlang` | not yet — needs a PyPI trusted publisher, then the manual [`publish-pypi`](.github/workflows/publish-pypi.yml) workflow uploads the same files as the GitHub release |
251
+
252
+ ## Limitations
253
+
254
+ - **Small language:** sequential networks only (`linear`, `relu`, `tanh`,
255
+ `sigmoid`), one 1-D `f32` input and output, inline training data, full-batch
256
+ training, `mse`/`bce`, `sgd`/`adam`.
257
+ - **Imports** copy whole `linear` layers. Packages support direct requirements
258
+ only, GitHub releases only, and trust-on-first-use hashes without signatures;
259
+ consumers use the publisher's prebuilt weights.
260
+ - **Reproducibility:** rebuilds are byte-identical on the same PyTorch version and
261
+ CPU; across versions or hardware weights may differ, and the hashes will show it.
262
+ - **Runtime:** PyTorch only; no ONNX or other exports.
263
+ - **Stability:** 0.x — syntax and formats may change. The Windows installer has
264
+ not been run on Windows yet.
265
+
266
+ ## License
267
+
268
+ [MIT](LICENSE)
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "weightlang"
3
+ version = "0.1.0"
4
+ description = "WeightLang prototype: compile .wgt network descriptions into runnable PyTorch artifacts"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = [
10
+ "torch>=2.2",
11
+ "safetensors>=0.4",
12
+ "numpy", # not used directly; avoids torch warning "Failed to initialize NumPy" on every run
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/WeightLang/WeightLang"
17
+ Documentation = "https://github.com/WeightLang/WeightLang/tree/main/docs"
18
+ Releases = "https://github.com/WeightLang/WeightLang/releases"
19
+
20
+ [project.optional-dependencies]
21
+ test = ["pytest>=8"]
22
+
23
+ [project.scripts]
24
+ weightc = "weightlang.cli:main"
25
+
26
+ [build-system]
27
+ requires = ["setuptools>=77"]
28
+ build-backend = "setuptools.build_meta"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+ pythonpath = ["src"]
36
+
37
+ [tool.ruff]
38
+ line-length = 120
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,17 @@
1
+ """WeightLang prototype: compile .wgt network descriptions into runnable PyTorch artifacts."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from .artifact import Artifact, UntrainedWeightsWarning, load_artifact # noqa: E402
6
+ from .syntax import Program, WgtError, parse, parse_file # noqa: E402
7
+
8
+ __all__ = [
9
+ "Artifact",
10
+ "Program",
11
+ "UntrainedWeightsWarning",
12
+ "WgtError",
13
+ "__version__",
14
+ "load_artifact",
15
+ "parse",
16
+ "parse_file",
17
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())