warden-interp 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.
Files changed (65) hide show
  1. warden_interp-0.1.0/.github/workflows/ci.yml +41 -0
  2. warden_interp-0.1.0/.github/workflows/release.yml +125 -0
  3. warden_interp-0.1.0/.gitignore +34 -0
  4. warden_interp-0.1.0/Cargo.lock +400 -0
  5. warden_interp-0.1.0/Cargo.toml +28 -0
  6. warden_interp-0.1.0/LICENSE +21 -0
  7. warden_interp-0.1.0/PKG-INFO +242 -0
  8. warden_interp-0.1.0/README.md +193 -0
  9. warden_interp-0.1.0/action.yml +66 -0
  10. warden_interp-0.1.0/docs/README.md +33 -0
  11. warden_interp-0.1.0/docs/architecture.md +84 -0
  12. warden_interp-0.1.0/docs/contracts.md +118 -0
  13. warden_interp-0.1.0/docs/drift.md +77 -0
  14. warden_interp-0.1.0/docs/production.md +124 -0
  15. warden_interp-0.1.0/docs/results.md +186 -0
  16. warden_interp-0.1.0/docs/sae-training.md +147 -0
  17. warden_interp-0.1.0/examples/demo.py +26 -0
  18. warden_interp-0.1.0/examples/demo_drift.py +52 -0
  19. warden_interp-0.1.0/examples/ioi_circuit.warden.yaml +22 -0
  20. warden_interp-0.1.0/examples/ioi_drift_regression.warden.yaml +20 -0
  21. warden_interp-0.1.0/examples/ioi_eval.jsonl +32 -0
  22. warden_interp-0.1.0/examples/make_drifted_checkpoint.py +82 -0
  23. warden_interp-0.1.0/examples/make_ioi_eval.py +62 -0
  24. warden_interp-0.1.0/examples/train_layer9_sae.py +63 -0
  25. warden_interp-0.1.0/pyproject.toml +84 -0
  26. warden_interp-0.1.0/python/warden/__init__.py +20 -0
  27. warden_interp-0.1.0/python/warden/adapters/__init__.py +5 -0
  28. warden_interp-0.1.0/python/warden/adapters/base.py +48 -0
  29. warden_interp-0.1.0/python/warden/adapters/huggingface.py +37 -0
  30. warden_interp-0.1.0/python/warden/adapters/pytorch.py +176 -0
  31. warden_interp-0.1.0/python/warden/circuit.py +131 -0
  32. warden_interp-0.1.0/python/warden/cli.py +196 -0
  33. warden_interp-0.1.0/python/warden/contract.py +98 -0
  34. warden_interp-0.1.0/python/warden/dsl.py +86 -0
  35. warden_interp-0.1.0/python/warden/html_report.py +99 -0
  36. warden_interp-0.1.0/python/warden/metrics.py +42 -0
  37. warden_interp-0.1.0/python/warden/plugins.py +59 -0
  38. warden_interp-0.1.0/python/warden/production/__init__.py +4 -0
  39. warden_interp-0.1.0/python/warden/production/otel.py +68 -0
  40. warden_interp-0.1.0/python/warden/production/sampler.py +42 -0
  41. warden_interp-0.1.0/python/warden/pytest_plugin.py +71 -0
  42. warden_interp-0.1.0/python/warden/sae_io.py +118 -0
  43. warden_interp-0.1.0/python/warden/sae_train.py +86 -0
  44. warden_interp-0.1.0/src/activation_cache.rs +47 -0
  45. warden_interp-0.1.0/src/circuit.rs +162 -0
  46. warden_interp-0.1.0/src/lib.rs +24 -0
  47. warden_interp-0.1.0/src/patch.rs +89 -0
  48. warden_interp-0.1.0/src/sae.rs +177 -0
  49. warden_interp-0.1.0/src/sae_train.rs +330 -0
  50. warden_interp-0.1.0/src/scoring.rs +105 -0
  51. warden_interp-0.1.0/tests/conftest.py +103 -0
  52. warden_interp-0.1.0/tests/test_activation_cache.py +34 -0
  53. warden_interp-0.1.0/tests/test_circuit_discovery.py +42 -0
  54. warden_interp-0.1.0/tests/test_circuit_distance.py +26 -0
  55. warden_interp-0.1.0/tests/test_cli.py +113 -0
  56. warden_interp-0.1.0/tests/test_contract_dsl.py +42 -0
  57. warden_interp-0.1.0/tests/test_drift.py +38 -0
  58. warden_interp-0.1.0/tests/test_html_report.py +71 -0
  59. warden_interp-0.1.0/tests/test_necessity_sufficiency.py +67 -0
  60. warden_interp-0.1.0/tests/test_patch_engine.py +42 -0
  61. warden_interp-0.1.0/tests/test_plugins.py +87 -0
  62. warden_interp-0.1.0/tests/test_production_sampler.py +53 -0
  63. warden_interp-0.1.0/tests/test_pytest_plugin.py +44 -0
  64. warden_interp-0.1.0/tests/test_sae.py +79 -0
  65. warden_interp-0.1.0/tests/test_sae_train.py +91 -0
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install Rust
15
+ uses: dtolnay/rust-toolchain@stable
16
+
17
+ - name: Cache cargo registry/build artifacts
18
+ uses: Swatinem/rust-cache@v2
19
+
20
+ - name: Run Rust unit tests
21
+ run: cargo test
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: "3.12"
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v3
30
+
31
+ - name: Install maturin + project (editable, with dev extras)
32
+ run: |
33
+ uv venv
34
+ echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
35
+ source .venv/bin/activate
36
+ uv pip install maturin
37
+ maturin develop --release
38
+ uv pip install -e ".[dev]"
39
+
40
+ - name: Run offline Python test suite
41
+ run: pytest -m "not integration" -v
@@ -0,0 +1,125 @@
1
+ name: Release
2
+
3
+ # Builds wheels for Linux/macOS/Windows + an sdist, then publishes to PyPI via
4
+ # Trusted Publishing (OIDC — no long-lived token stored in this repo).
5
+ #
6
+ # One-time setup required on pypi.org before the first tag push:
7
+ # 1. Create the "warden-interp" project on PyPI (or let the first Trusted
8
+ # Publishing run create it, if using PyPI's "pending publisher" flow).
9
+ # 2. Under the project's "Publishing" settings, add a trusted publisher:
10
+ # owner: ghassenov, repo: warden, workflow: release.yml, environment: pypi
11
+ # 3. Create a GitHub Actions environment named "pypi" in this repo's
12
+ # Settings -> Environments (optionally with required reviewers).
13
+ #
14
+ # The extension uses pyo3's abi3 feature (see Cargo.toml), so one wheel per
15
+ # (OS, arch) covers every supported Python version — no per-version matrix.
16
+
17
+ on:
18
+ push:
19
+ tags:
20
+ - "v*"
21
+
22
+ permissions:
23
+ contents: read
24
+
25
+ jobs:
26
+ linux:
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+ - name: Build wheels (manylinux)
34
+ uses: PyO3/maturin-action@v1
35
+ with:
36
+ target: x86_64
37
+ manylinux: auto
38
+ args: --release --out dist
39
+ - uses: actions/upload-artifact@v4
40
+ with:
41
+ name: wheels-linux-x86_64
42
+ path: dist
43
+
44
+ linux-arm:
45
+ runs-on: ubuntu-24.04-arm
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: actions/setup-python@v5
49
+ with:
50
+ python-version: "3.12"
51
+ - name: Build wheels (manylinux)
52
+ uses: PyO3/maturin-action@v1
53
+ with:
54
+ target: aarch64
55
+ manylinux: auto
56
+ args: --release --out dist
57
+ - uses: actions/upload-artifact@v4
58
+ with:
59
+ name: wheels-linux-aarch64
60
+ path: dist
61
+
62
+ macos:
63
+ runs-on: macos-latest
64
+ steps:
65
+ - uses: actions/checkout@v4
66
+ - uses: actions/setup-python@v5
67
+ with:
68
+ python-version: "3.12"
69
+ - name: "Build wheels (universal2: x86_64 + arm64)"
70
+ uses: PyO3/maturin-action@v1
71
+ with:
72
+ args: --release --target universal2-apple-darwin --out dist
73
+ - uses: actions/upload-artifact@v4
74
+ with:
75
+ name: wheels-macos
76
+ path: dist
77
+
78
+ windows:
79
+ runs-on: windows-latest
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ - uses: actions/setup-python@v5
83
+ with:
84
+ python-version: "3.12"
85
+ - name: Build wheels
86
+ uses: PyO3/maturin-action@v1
87
+ with:
88
+ target: x64
89
+ args: --release --out dist
90
+ - uses: actions/upload-artifact@v4
91
+ with:
92
+ name: wheels-windows
93
+ path: dist
94
+
95
+ sdist:
96
+ runs-on: ubuntu-latest
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+ - name: Build sdist
100
+ uses: PyO3/maturin-action@v1
101
+ with:
102
+ command: sdist
103
+ args: --out dist
104
+ - uses: actions/upload-artifact@v4
105
+ with:
106
+ name: wheels-sdist
107
+ path: dist
108
+
109
+ publish:
110
+ name: Publish to PyPI
111
+ needs: [linux, linux-arm, macos, windows, sdist]
112
+ runs-on: ubuntu-latest
113
+ environment: pypi
114
+ permissions:
115
+ id-token: write # required for Trusted Publishing
116
+ steps:
117
+ - uses: actions/download-artifact@v4
118
+ with:
119
+ pattern: wheels-*
120
+ merge-multiple: true
121
+ path: dist
122
+ - name: Publish to PyPI
123
+ uses: pypa/gh-action-pypi-publish@release/v1
124
+ with:
125
+ packages-dir: dist
@@ -0,0 +1,34 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ debug
4
+ target
5
+
6
+ # These are backup files generated by rustfmt
7
+ **/*.rs.bk
8
+
9
+ # MSVC Windows builds of rustc generate these, which store debugging information
10
+ *.pdb
11
+
12
+ # Generated by cargo mutants
13
+ # Contains mutation testing data
14
+ **/mutants.out*/
15
+
16
+ # RustRover
17
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
18
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
19
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
20
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
21
+ #.idea/
22
+
23
+ # Python
24
+ __pycache__/
25
+ *.pyc
26
+ *.egg-info/
27
+ .pytest_cache/
28
+ .venv/
29
+ python/warden/_core*.so
30
+ python/warden/_core*.pyd
31
+
32
+ # Regeneratable fine-tuned checkpoint used by the drift example (~500MB)
33
+ examples/drifted_gpt2/
34
+
@@ -0,0 +1,400 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "cfg-if"
13
+ version = "1.0.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
16
+
17
+ [[package]]
18
+ name = "crossbeam-deque"
19
+ version = "0.8.6"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
22
+ dependencies = [
23
+ "crossbeam-epoch",
24
+ "crossbeam-utils",
25
+ ]
26
+
27
+ [[package]]
28
+ name = "crossbeam-epoch"
29
+ version = "0.9.18"
30
+ source = "registry+https://github.com/rust-lang/crates.io-index"
31
+ checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
32
+ dependencies = [
33
+ "crossbeam-utils",
34
+ ]
35
+
36
+ [[package]]
37
+ name = "crossbeam-utils"
38
+ version = "0.8.21"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
41
+
42
+ [[package]]
43
+ name = "either"
44
+ version = "1.16.0"
45
+ source = "registry+https://github.com/rust-lang/crates.io-index"
46
+ checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
47
+
48
+ [[package]]
49
+ name = "getrandom"
50
+ version = "0.2.17"
51
+ source = "registry+https://github.com/rust-lang/crates.io-index"
52
+ checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
53
+ dependencies = [
54
+ "cfg-if",
55
+ "libc",
56
+ "wasi",
57
+ ]
58
+
59
+ [[package]]
60
+ name = "heck"
61
+ version = "0.5.0"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
64
+
65
+ [[package]]
66
+ name = "indoc"
67
+ version = "2.0.7"
68
+ source = "registry+https://github.com/rust-lang/crates.io-index"
69
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
70
+ dependencies = [
71
+ "rustversion",
72
+ ]
73
+
74
+ [[package]]
75
+ name = "libc"
76
+ version = "0.2.186"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
79
+
80
+ [[package]]
81
+ name = "matrixmultiply"
82
+ version = "0.3.10"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08"
85
+ dependencies = [
86
+ "autocfg",
87
+ "rawpointer",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "memoffset"
92
+ version = "0.9.1"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
95
+ dependencies = [
96
+ "autocfg",
97
+ ]
98
+
99
+ [[package]]
100
+ name = "ndarray"
101
+ version = "0.16.1"
102
+ source = "registry+https://github.com/rust-lang/crates.io-index"
103
+ checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841"
104
+ dependencies = [
105
+ "matrixmultiply",
106
+ "num-complex",
107
+ "num-integer",
108
+ "num-traits",
109
+ "portable-atomic",
110
+ "portable-atomic-util",
111
+ "rawpointer",
112
+ "rayon",
113
+ ]
114
+
115
+ [[package]]
116
+ name = "num-complex"
117
+ version = "0.4.6"
118
+ source = "registry+https://github.com/rust-lang/crates.io-index"
119
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
120
+ dependencies = [
121
+ "num-traits",
122
+ ]
123
+
124
+ [[package]]
125
+ name = "num-integer"
126
+ version = "0.1.46"
127
+ source = "registry+https://github.com/rust-lang/crates.io-index"
128
+ checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
129
+ dependencies = [
130
+ "num-traits",
131
+ ]
132
+
133
+ [[package]]
134
+ name = "num-traits"
135
+ version = "0.2.19"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
138
+ dependencies = [
139
+ "autocfg",
140
+ ]
141
+
142
+ [[package]]
143
+ name = "numpy"
144
+ version = "0.22.1"
145
+ source = "registry+https://github.com/rust-lang/crates.io-index"
146
+ checksum = "edb929bc0da91a4d85ed6c0a84deaa53d411abfb387fc271124f91bf6b89f14e"
147
+ dependencies = [
148
+ "libc",
149
+ "ndarray",
150
+ "num-complex",
151
+ "num-integer",
152
+ "num-traits",
153
+ "pyo3",
154
+ "rustc-hash",
155
+ ]
156
+
157
+ [[package]]
158
+ name = "once_cell"
159
+ version = "1.21.4"
160
+ source = "registry+https://github.com/rust-lang/crates.io-index"
161
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
162
+
163
+ [[package]]
164
+ name = "portable-atomic"
165
+ version = "1.13.1"
166
+ source = "registry+https://github.com/rust-lang/crates.io-index"
167
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
168
+
169
+ [[package]]
170
+ name = "portable-atomic-util"
171
+ version = "0.2.7"
172
+ source = "registry+https://github.com/rust-lang/crates.io-index"
173
+ checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618"
174
+ dependencies = [
175
+ "portable-atomic",
176
+ ]
177
+
178
+ [[package]]
179
+ name = "ppv-lite86"
180
+ version = "0.2.21"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
183
+ dependencies = [
184
+ "zerocopy",
185
+ ]
186
+
187
+ [[package]]
188
+ name = "proc-macro2"
189
+ version = "1.0.106"
190
+ source = "registry+https://github.com/rust-lang/crates.io-index"
191
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
192
+ dependencies = [
193
+ "unicode-ident",
194
+ ]
195
+
196
+ [[package]]
197
+ name = "pyo3"
198
+ version = "0.22.6"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
201
+ dependencies = [
202
+ "cfg-if",
203
+ "indoc",
204
+ "libc",
205
+ "memoffset",
206
+ "once_cell",
207
+ "portable-atomic",
208
+ "pyo3-build-config",
209
+ "pyo3-ffi",
210
+ "pyo3-macros",
211
+ "unindent",
212
+ ]
213
+
214
+ [[package]]
215
+ name = "pyo3-build-config"
216
+ version = "0.22.6"
217
+ source = "registry+https://github.com/rust-lang/crates.io-index"
218
+ checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
219
+ dependencies = [
220
+ "once_cell",
221
+ "target-lexicon",
222
+ ]
223
+
224
+ [[package]]
225
+ name = "pyo3-ffi"
226
+ version = "0.22.6"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
229
+ dependencies = [
230
+ "libc",
231
+ "pyo3-build-config",
232
+ ]
233
+
234
+ [[package]]
235
+ name = "pyo3-macros"
236
+ version = "0.22.6"
237
+ source = "registry+https://github.com/rust-lang/crates.io-index"
238
+ checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
239
+ dependencies = [
240
+ "proc-macro2",
241
+ "pyo3-macros-backend",
242
+ "quote",
243
+ "syn",
244
+ ]
245
+
246
+ [[package]]
247
+ name = "pyo3-macros-backend"
248
+ version = "0.22.6"
249
+ source = "registry+https://github.com/rust-lang/crates.io-index"
250
+ checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
251
+ dependencies = [
252
+ "heck",
253
+ "proc-macro2",
254
+ "pyo3-build-config",
255
+ "quote",
256
+ "syn",
257
+ ]
258
+
259
+ [[package]]
260
+ name = "quote"
261
+ version = "1.0.46"
262
+ source = "registry+https://github.com/rust-lang/crates.io-index"
263
+ checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
264
+ dependencies = [
265
+ "proc-macro2",
266
+ ]
267
+
268
+ [[package]]
269
+ name = "rand"
270
+ version = "0.8.6"
271
+ source = "registry+https://github.com/rust-lang/crates.io-index"
272
+ checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
273
+ dependencies = [
274
+ "libc",
275
+ "rand_chacha",
276
+ "rand_core",
277
+ ]
278
+
279
+ [[package]]
280
+ name = "rand_chacha"
281
+ version = "0.3.1"
282
+ source = "registry+https://github.com/rust-lang/crates.io-index"
283
+ checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
284
+ dependencies = [
285
+ "ppv-lite86",
286
+ "rand_core",
287
+ ]
288
+
289
+ [[package]]
290
+ name = "rand_core"
291
+ version = "0.6.4"
292
+ source = "registry+https://github.com/rust-lang/crates.io-index"
293
+ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
294
+ dependencies = [
295
+ "getrandom",
296
+ ]
297
+
298
+ [[package]]
299
+ name = "rawpointer"
300
+ version = "0.2.1"
301
+ source = "registry+https://github.com/rust-lang/crates.io-index"
302
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
303
+
304
+ [[package]]
305
+ name = "rayon"
306
+ version = "1.12.0"
307
+ source = "registry+https://github.com/rust-lang/crates.io-index"
308
+ checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
309
+ dependencies = [
310
+ "either",
311
+ "rayon-core",
312
+ ]
313
+
314
+ [[package]]
315
+ name = "rayon-core"
316
+ version = "1.13.0"
317
+ source = "registry+https://github.com/rust-lang/crates.io-index"
318
+ checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
319
+ dependencies = [
320
+ "crossbeam-deque",
321
+ "crossbeam-utils",
322
+ ]
323
+
324
+ [[package]]
325
+ name = "rustc-hash"
326
+ version = "1.1.0"
327
+ source = "registry+https://github.com/rust-lang/crates.io-index"
328
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
329
+
330
+ [[package]]
331
+ name = "rustversion"
332
+ version = "1.0.22"
333
+ source = "registry+https://github.com/rust-lang/crates.io-index"
334
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
335
+
336
+ [[package]]
337
+ name = "syn"
338
+ version = "2.0.118"
339
+ source = "registry+https://github.com/rust-lang/crates.io-index"
340
+ checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
341
+ dependencies = [
342
+ "proc-macro2",
343
+ "quote",
344
+ "unicode-ident",
345
+ ]
346
+
347
+ [[package]]
348
+ name = "target-lexicon"
349
+ version = "0.12.16"
350
+ source = "registry+https://github.com/rust-lang/crates.io-index"
351
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
352
+
353
+ [[package]]
354
+ name = "unicode-ident"
355
+ version = "1.0.24"
356
+ source = "registry+https://github.com/rust-lang/crates.io-index"
357
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
358
+
359
+ [[package]]
360
+ name = "unindent"
361
+ version = "0.2.4"
362
+ source = "registry+https://github.com/rust-lang/crates.io-index"
363
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
364
+
365
+ [[package]]
366
+ name = "warden_core"
367
+ version = "0.1.0"
368
+ dependencies = [
369
+ "ndarray",
370
+ "numpy",
371
+ "pyo3",
372
+ "rand",
373
+ "rayon",
374
+ ]
375
+
376
+ [[package]]
377
+ name = "wasi"
378
+ version = "0.11.1+wasi-snapshot-preview1"
379
+ source = "registry+https://github.com/rust-lang/crates.io-index"
380
+ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
381
+
382
+ [[package]]
383
+ name = "zerocopy"
384
+ version = "0.8.52"
385
+ source = "registry+https://github.com/rust-lang/crates.io-index"
386
+ checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f"
387
+ dependencies = [
388
+ "zerocopy-derive",
389
+ ]
390
+
391
+ [[package]]
392
+ name = "zerocopy-derive"
393
+ version = "0.8.52"
394
+ source = "registry+https://github.com/rust-lang/crates.io-index"
395
+ checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930"
396
+ dependencies = [
397
+ "proc-macro2",
398
+ "quote",
399
+ "syn",
400
+ ]
@@ -0,0 +1,28 @@
1
+ [package]
2
+ name = "warden_core"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ description = "Rust core (numerics + gradient-checked SAE training) for warden-interp"
6
+ license = "MIT"
7
+ repository = "https://github.com/ghassenov/warden"
8
+ publish = false
9
+ readme = "README.md"
10
+
11
+ [lib]
12
+ name = "_core"
13
+ crate-type = ["cdylib", "rlib"]
14
+
15
+ [dependencies]
16
+ pyo3 = { version = "0.22", features = ["abi3-py38"] }
17
+ numpy = "0.22"
18
+ ndarray = { version = "0.16", features = ["rayon"] }
19
+ rayon = "1.10"
20
+
21
+ [dev-dependencies]
22
+ # test-only: gradient-check fixtures need deterministic random arrays.
23
+ # Never shipped in the built extension (production weight-init happens in
24
+ # Python via numpy, see sae_train.py) — see the Phase 5 plan for why.
25
+ rand = "0.8"
26
+
27
+ [profile.release]
28
+ lto = true
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ghassen Naouar
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.