gras-engine 0.1.0__tar.gz → 0.2.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.
- {gras_engine-0.1.0 → gras_engine-0.2.0}/Cargo.lock +2 -2
- {gras_engine-0.1.0 → gras_engine-0.2.0}/Cargo.toml +1 -1
- {gras_engine-0.1.0 → gras_engine-0.2.0}/PKG-INFO +49 -14
- {gras_engine-0.1.0 → gras_engine-0.2.0}/README.md +19 -6
- {gras_engine-0.1.0 → gras_engine-0.2.0}/examples/mnist.rs +18 -1
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/Cargo.toml +2 -2
- {gras_engine-0.1.0 → gras_engine-0.2.0}/python/README.md +48 -13
- {gras_engine-0.1.0 → gras_engine-0.2.0}/python/gras/__init__.py +6 -3
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/breed/child.rs +19 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/clock/lottery.rs +9 -5
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/tests.rs +9 -3
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/diversity/mod.rs +29 -3
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/founding/seed.rs +1 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/reporting/mod.rs +18 -12
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/reporting/reports.rs +48 -3
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/graph/network.rs +226 -6
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/graph/node.rs +1 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/graph/topology.rs +16 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/state/persistence.rs +1 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/ascii.rs +28 -2
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/graph_utils.rs +20 -1
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/markdown.rs +262 -8
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/mermaid.rs +43 -11
- {gras_engine-0.1.0 → gras_engine-0.2.0}/LICENSE +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/benches/flamegraph.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/benches/memgraph.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/benches/ref_trainer.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/benches/stream.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/benches/support/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/examples/cartpole/tests.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/examples/cartpole.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/examples/python/load_gras_net.py +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/examples/python/test_load_gras_net.py +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/arrays.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/config.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/defaults.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/engine.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/gym.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/lib.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/logging.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/menu.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/gras-py/src/topology.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/pyproject.toml +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/breed/cull.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/breed/evolve.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/breed/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/clock/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/clock/smoothing.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/clock/step.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/clock/stop.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/evolution.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/lottery.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/population.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/ranking.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/run.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder/topology.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config/builder.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/config.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/durability.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/evolution.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/exam.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/ranking.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/resume.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/core/roles.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/diversity/novelty.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/founding/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/founding/pool.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/founding/population.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/reporting/format.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/reporting/lineage.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/reporting/logging.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/start/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/start/rl_engine.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/start/run_spec.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/engine/start/tabular_engine.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/evolution/crossover.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/evolution/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/evolution/mutation.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/evolution/pools.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/evolution/selection.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/graph/inventory.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/graph/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/lib.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/spec/blueprint.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/spec/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/spec/network_facts.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/state/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/challenge.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/core.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/decision_lag.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/env.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/menu.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/optimizer.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/reinforce.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/schedule.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/stream.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/trainer/supervised.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/cfy.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/display.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/error.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/fitness.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/mod.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/race_steps.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/safetensors.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/score.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/seed.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/tabular_data.rs +0 -0
- {gras_engine-0.1.0 → gras_engine-0.2.0}/src/utils/training.rs +0 -0
|
@@ -407,7 +407,7 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
|
|
407
407
|
|
|
408
408
|
[[package]]
|
|
409
409
|
name = "gras"
|
|
410
|
-
version = "2.
|
|
410
|
+
version = "2.2.0"
|
|
411
411
|
dependencies = [
|
|
412
412
|
"clap",
|
|
413
413
|
"comfy-table",
|
|
@@ -426,7 +426,7 @@ dependencies = [
|
|
|
426
426
|
|
|
427
427
|
[[package]]
|
|
428
428
|
name = "gras-py"
|
|
429
|
-
version = "0.
|
|
429
|
+
version = "0.2.0"
|
|
430
430
|
dependencies = [
|
|
431
431
|
"gras",
|
|
432
432
|
"pyo3",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gras-engine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -42,6 +42,29 @@ Python binding.
|
|
|
42
42
|
pip install gras-engine
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
### CPU or CUDA — chosen at build time
|
|
46
|
+
|
|
47
|
+
PyPI publishes only the sdist (the wheel is a plain `linux` tag, not
|
|
48
|
+
manylinux, and carries no libtorch), so `pip install` compiles the extension on
|
|
49
|
+
your machine and the backend is baked into that binary. There is no runtime
|
|
50
|
+
switch: the default is CPU, and CUDA is one extra build argument.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# CUDA build — needs the CUDA libtorch at build AND import time
|
|
54
|
+
export LIBTORCH_PATH=~/.flodl/libtorch/precompiled/cu128
|
|
55
|
+
pip install gras-engine --config-settings="build-args=--features cuda"
|
|
56
|
+
# or, on older tooling: MATURIN_PEP517_ARGS="--features cuda" pip install gras-engine
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Environment variables never select the backend — `LIBTORCH_PATH` only says
|
|
60
|
+
*where* libtorch is, while the feature says *which device the compiled code
|
|
61
|
+
uses*. `gras.built_with_cuda` reports which one you got, so a notebook or a test
|
|
62
|
+
can refuse to assume a GPU it was not built for. A CPU build still works against
|
|
63
|
+
a CUDA libtorch — it simply stays on CPU. The reverse (a CUDA build with a
|
|
64
|
+
CPU-only libtorch) imports fine, because `libtorch_cuda.so` is loaded at run
|
|
65
|
+
time rather than linked, and fails on the first clock when the engine creates
|
|
66
|
+
its CUDA device.
|
|
67
|
+
|
|
45
68
|
```python
|
|
46
69
|
import gras
|
|
47
70
|
|
|
@@ -53,11 +76,15 @@ print(engine.run_dir) # results/<timestamp>/ — history.csv, nets/, champ
|
|
|
53
76
|
|
|
54
77
|
## Requirements
|
|
55
78
|
|
|
56
|
-
- **CPython ≥ 3.12.** 0.
|
|
57
|
-
|
|
58
|
-
- **
|
|
59
|
-
|
|
60
|
-
and
|
|
79
|
+
- **CPython ≥ 3.12.** 0.2 builds one `abi3` extension (`cp312-abi3`), so the
|
|
80
|
+
same compiled module works on 3.12, 3.13 and 3.14.
|
|
81
|
+
- **A build toolchain, because PyPI has only the sdist.** `pip install` runs
|
|
82
|
+
cargo on your machine, so the Rust toolchain is needed to build the binding
|
|
83
|
+
and a C++ toolchain (linker + libstdc++, e.g. `build-essential`) to link
|
|
84
|
+
libtorch. Rust and C++ are install-time requirements only — a wheel built
|
|
85
|
+
elsewhere needs neither at run time.
|
|
86
|
+
- **Linux x86_64.** The wheel the CI builds carries a plain `linux` tag, which
|
|
87
|
+
PyPI refuses, so nothing prebuilt is ever installed.
|
|
61
88
|
- **libtorch, which is not bundled.** The extension links `libtorch_cpu.so` and
|
|
62
89
|
`libc10.so` at run time, so the machine needs a libtorch distribution whose
|
|
63
90
|
ABI matches the build (libtorch 2.x).
|
|
@@ -68,8 +95,16 @@ Point the package at libtorch with one environment variable:
|
|
|
68
95
|
export LIBTORCH_PATH=/path/to/libtorch # the directory that contains lib/
|
|
69
96
|
```
|
|
70
97
|
|
|
71
|
-
|
|
72
|
-
|
|
98
|
+
**Where to put it:** `fdl libtorch download` writes `./libtorch` in the project
|
|
99
|
+
it runs from — the import (below) finds it there, and `fdl setup` points the
|
|
100
|
+
build at it. Otherwise any directory containing `lib/` works with
|
|
101
|
+
`LIBTORCH_PATH` pointing at it while the extension is built; the shared
|
|
102
|
+
convention is `~/.flodl/libtorch/precompiled/{cpu,cu128}` side by side, so one
|
|
103
|
+
machine holds both backends.
|
|
104
|
+
|
|
105
|
+
On import, `gras` looks for `libtorch_cpu.so` in `LIBTORCH_PATH`, then
|
|
106
|
+
`./libtorch`, then `$FLODL_VARIANT` and `{cpu, cuda, cu128}` under
|
|
107
|
+
`~/.flodl/libtorch/precompiled`, and
|
|
73
108
|
loads it with `ctypes` before the extension imports — so `LD_LIBRARY_PATH` is
|
|
74
109
|
not required. If nothing is found you get an ImportError naming libtorch, not
|
|
75
110
|
the loader's message. A CUDA build also loads `libtorch_cuda.so` from the same
|
|
@@ -158,19 +193,19 @@ language, and the parity guard says so.
|
|
|
158
193
|
- A Python loss or fitness closure is not accepted: the loss *is* the autograd
|
|
159
194
|
graph, and rankings must be re-derivable. The compiled name menus are the
|
|
160
195
|
contract; Rust is the door for anything custom.
|
|
161
|
-
- The
|
|
196
|
+
- The wheel is Linux x86_64. It is `linux_x86_64`, not `manylinux`: the
|
|
162
197
|
wheel needs the system's libtorch, so it cannot claim to be self-contained.
|
|
163
198
|
|
|
164
199
|
## Versions
|
|
165
200
|
|
|
166
|
-
`gras.__version__` is the **binding's** version (0.
|
|
167
|
-
of the Rust crate (`gras` on crates.io,
|
|
168
|
-
|
|
201
|
+
`gras.__version__` is the **binding's** version (0.2.x) and moves independently
|
|
202
|
+
of the Rust crate (`gras` on crates.io, 2.2.0). A binding release that needs a
|
|
203
|
+
newer crate says so in its release notes.
|
|
169
204
|
|
|
170
205
|
## More
|
|
171
206
|
|
|
172
|
-
- Tour notebook: `python/notebooks/python_bindings_tour.ipynb` —
|
|
173
|
-
|
|
207
|
+
- Tour notebook: `python/notebooks/python_bindings_tour.ipynb` — self-contained
|
|
208
|
+
cells, from a directory run to gym, arrays and the CPU/CUDA check.
|
|
174
209
|
- Rust crate: https://crates.io/crates/gras · docs: https://docs.rs/gras
|
|
175
210
|
- Source, issues and the publishing notes:
|
|
176
211
|
https://github.com/maulberto3/gras
|
|
@@ -205,12 +205,25 @@ cargo add gras
|
|
|
205
205
|
cargo add gras --features cuda
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
`gras` links libtorch dynamically and does not vendor it
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
`gras` links libtorch dynamically and does not vendor it: headers and libraries
|
|
209
|
+
at compile time, shared objects at run time. `flodl-sys` reads `LIBTORCH_PATH`
|
|
210
|
+
(falling back to `/usr/local/libtorch`), so any arrangement that exports that
|
|
211
|
+
variable works, and CUDA builds need a CUDA-enabled libtorch.
|
|
212
|
+
|
|
213
|
+
`fdl setup` — from `cargo install flodl-cli` — detects the hardware, downloads
|
|
214
|
+
the matching libtorch and points the variable at it. This repository's
|
|
215
|
+
`env_setup.sh` does the same for local development, searching in order:
|
|
216
|
+
|
|
217
|
+
1. `./libtorch`, or `./libtorch/{cpu,cuda,cu128}` — where `fdl libtorch download`
|
|
218
|
+
puts a build by default;
|
|
219
|
+
2. `~/.flodl/libtorch/precompiled/{cpu,cu128,cuda}` — fdl's shared copy, so
|
|
220
|
+
every project on a machine reuses one download per backend;
|
|
221
|
+
3. `/usr/local/libtorch`.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
source env_setup.sh # CPU
|
|
225
|
+
source env_setup.sh cuda # CUDA: skips directories without libtorch_cuda.so
|
|
226
|
+
```
|
|
214
227
|
|
|
215
228
|
## Get started
|
|
216
229
|
|
|
@@ -338,6 +338,20 @@ struct Cli {
|
|
|
338
338
|
#[arg(long, value_name = "P", default_value_t = 0.20)]
|
|
339
339
|
dropout: f32,
|
|
340
340
|
|
|
341
|
+
/// Recurrence: every hidden node whose input width equals its output width (64 → 64 is
|
|
342
|
+
/// common) feeds its pre-activation back through its OWN layer once — the same weights,
|
|
343
|
+
/// twice. A net whose input width also equals its output width sweeps its whole graph
|
|
344
|
+
/// twice; 784 → 10 MNIST nets only get the hidden-node loops. A crossover child can
|
|
345
|
+
/// drift the gene either way.
|
|
346
|
+
#[arg(
|
|
347
|
+
long,
|
|
348
|
+
value_name = "BOOL",
|
|
349
|
+
num_args = 0..=1,
|
|
350
|
+
default_missing_value = "true",
|
|
351
|
+
default_value_t = true
|
|
352
|
+
)]
|
|
353
|
+
recur: bool,
|
|
354
|
+
|
|
341
355
|
/// Name recorded in `engine.json` (informational only).
|
|
342
356
|
#[arg(long, value_name = "NAME", default_value = RUN_NAME)]
|
|
343
357
|
run_name: String,
|
|
@@ -420,7 +434,7 @@ fn main() {
|
|
|
420
434
|
},
|
|
421
435
|
)];
|
|
422
436
|
|
|
423
|
-
let config = common::engine_config(TabularRaceConfig::builder(), &cli.engine, log_level)
|
|
437
|
+
let mut config = common::engine_config(TabularRaceConfig::builder(), &cli.engine, log_level)
|
|
424
438
|
// This example's own half: the flags whose default is its identity.
|
|
425
439
|
.set_run_name(cli.run_name.clone())
|
|
426
440
|
.set_topology_drift(cli.drift)
|
|
@@ -440,6 +454,9 @@ fn main() {
|
|
|
440
454
|
.set_topology_activation_pool(cli.activation_pool.clone())
|
|
441
455
|
.set_topology_standardize_op_pool(cli.standardize_pool.clone())
|
|
442
456
|
.build();
|
|
457
|
+
// Recurrence is a per-net gene carried in the blueprint, not a run measured from the
|
|
458
|
+
// header: stamp the flag on the search space so founders and immigrants are born with it.
|
|
459
|
+
config.topology.options.recur = cli.recur;
|
|
443
460
|
|
|
444
461
|
// `--resume` continues a recorded run (its record wins); `--run-dir` names where a fresh one writes.
|
|
445
462
|
let engine = match &cli.resume {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "gras-py"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
description = "Python bindings for gras (PyO3 extension module `gras._core`)"
|
|
6
6
|
license = "MIT"
|
|
@@ -19,7 +19,7 @@ crate-type = ["cdylib"]
|
|
|
19
19
|
cuda = ["gras/cuda"]
|
|
20
20
|
|
|
21
21
|
[dependencies]
|
|
22
|
-
gras = { path = "..", version = "=2.
|
|
22
|
+
gras = { path = "..", version = "=2.2.0" }
|
|
23
23
|
# 0.30 is the first line that accepts Python 3.14 interpreters. `abi3-py312`
|
|
24
24
|
# builds ONE wheel for every CPython >= 3.12 (`_core.abi3.so`) instead of one
|
|
25
25
|
# per interpreter version — the stable C ABI, which PyO3 supports here because
|
|
@@ -16,6 +16,29 @@ Python binding.
|
|
|
16
16
|
pip install gras-engine
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
### CPU or CUDA — chosen at build time
|
|
20
|
+
|
|
21
|
+
PyPI publishes only the sdist (the wheel is a plain `linux` tag, not
|
|
22
|
+
manylinux, and carries no libtorch), so `pip install` compiles the extension on
|
|
23
|
+
your machine and the backend is baked into that binary. There is no runtime
|
|
24
|
+
switch: the default is CPU, and CUDA is one extra build argument.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# CUDA build — needs the CUDA libtorch at build AND import time
|
|
28
|
+
export LIBTORCH_PATH=~/.flodl/libtorch/precompiled/cu128
|
|
29
|
+
pip install gras-engine --config-settings="build-args=--features cuda"
|
|
30
|
+
# or, on older tooling: MATURIN_PEP517_ARGS="--features cuda" pip install gras-engine
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Environment variables never select the backend — `LIBTORCH_PATH` only says
|
|
34
|
+
*where* libtorch is, while the feature says *which device the compiled code
|
|
35
|
+
uses*. `gras.built_with_cuda` reports which one you got, so a notebook or a test
|
|
36
|
+
can refuse to assume a GPU it was not built for. A CPU build still works against
|
|
37
|
+
a CUDA libtorch — it simply stays on CPU. The reverse (a CUDA build with a
|
|
38
|
+
CPU-only libtorch) imports fine, because `libtorch_cuda.so` is loaded at run
|
|
39
|
+
time rather than linked, and fails on the first clock when the engine creates
|
|
40
|
+
its CUDA device.
|
|
41
|
+
|
|
19
42
|
```python
|
|
20
43
|
import gras
|
|
21
44
|
|
|
@@ -27,11 +50,15 @@ print(engine.run_dir) # results/<timestamp>/ — history.csv, nets/, champ
|
|
|
27
50
|
|
|
28
51
|
## Requirements
|
|
29
52
|
|
|
30
|
-
- **CPython ≥ 3.12.** 0.
|
|
31
|
-
|
|
32
|
-
- **
|
|
33
|
-
|
|
34
|
-
and
|
|
53
|
+
- **CPython ≥ 3.12.** 0.2 builds one `abi3` extension (`cp312-abi3`), so the
|
|
54
|
+
same compiled module works on 3.12, 3.13 and 3.14.
|
|
55
|
+
- **A build toolchain, because PyPI has only the sdist.** `pip install` runs
|
|
56
|
+
cargo on your machine, so the Rust toolchain is needed to build the binding
|
|
57
|
+
and a C++ toolchain (linker + libstdc++, e.g. `build-essential`) to link
|
|
58
|
+
libtorch. Rust and C++ are install-time requirements only — a wheel built
|
|
59
|
+
elsewhere needs neither at run time.
|
|
60
|
+
- **Linux x86_64.** The wheel the CI builds carries a plain `linux` tag, which
|
|
61
|
+
PyPI refuses, so nothing prebuilt is ever installed.
|
|
35
62
|
- **libtorch, which is not bundled.** The extension links `libtorch_cpu.so` and
|
|
36
63
|
`libc10.so` at run time, so the machine needs a libtorch distribution whose
|
|
37
64
|
ABI matches the build (libtorch 2.x).
|
|
@@ -42,8 +69,16 @@ Point the package at libtorch with one environment variable:
|
|
|
42
69
|
export LIBTORCH_PATH=/path/to/libtorch # the directory that contains lib/
|
|
43
70
|
```
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
**Where to put it:** `fdl libtorch download` writes `./libtorch` in the project
|
|
73
|
+
it runs from — the import (below) finds it there, and `fdl setup` points the
|
|
74
|
+
build at it. Otherwise any directory containing `lib/` works with
|
|
75
|
+
`LIBTORCH_PATH` pointing at it while the extension is built; the shared
|
|
76
|
+
convention is `~/.flodl/libtorch/precompiled/{cpu,cu128}` side by side, so one
|
|
77
|
+
machine holds both backends.
|
|
78
|
+
|
|
79
|
+
On import, `gras` looks for `libtorch_cpu.so` in `LIBTORCH_PATH`, then
|
|
80
|
+
`./libtorch`, then `$FLODL_VARIANT` and `{cpu, cuda, cu128}` under
|
|
81
|
+
`~/.flodl/libtorch/precompiled`, and
|
|
47
82
|
loads it with `ctypes` before the extension imports — so `LD_LIBRARY_PATH` is
|
|
48
83
|
not required. If nothing is found you get an ImportError naming libtorch, not
|
|
49
84
|
the loader's message. A CUDA build also loads `libtorch_cuda.so` from the same
|
|
@@ -132,19 +167,19 @@ language, and the parity guard says so.
|
|
|
132
167
|
- A Python loss or fitness closure is not accepted: the loss *is* the autograd
|
|
133
168
|
graph, and rankings must be re-derivable. The compiled name menus are the
|
|
134
169
|
contract; Rust is the door for anything custom.
|
|
135
|
-
- The
|
|
170
|
+
- The wheel is Linux x86_64. It is `linux_x86_64`, not `manylinux`: the
|
|
136
171
|
wheel needs the system's libtorch, so it cannot claim to be self-contained.
|
|
137
172
|
|
|
138
173
|
## Versions
|
|
139
174
|
|
|
140
|
-
`gras.__version__` is the **binding's** version (0.
|
|
141
|
-
of the Rust crate (`gras` on crates.io,
|
|
142
|
-
|
|
175
|
+
`gras.__version__` is the **binding's** version (0.2.x) and moves independently
|
|
176
|
+
of the Rust crate (`gras` on crates.io, 2.2.0). A binding release that needs a
|
|
177
|
+
newer crate says so in its release notes.
|
|
143
178
|
|
|
144
179
|
## More
|
|
145
180
|
|
|
146
|
-
- Tour notebook: `python/notebooks/python_bindings_tour.ipynb` —
|
|
147
|
-
|
|
181
|
+
- Tour notebook: `python/notebooks/python_bindings_tour.ipynb` — self-contained
|
|
182
|
+
cells, from a directory run to gym, arrays and the CPU/CUDA check.
|
|
148
183
|
- Rust crate: https://crates.io/crates/gras · docs: https://docs.rs/gras
|
|
149
184
|
- Source, issues and the publishing notes:
|
|
150
185
|
https://github.com/maulberto3/gras
|
|
@@ -39,16 +39,19 @@ _LIBTORCH_CUDA_NAME = "libtorch_cuda.so"
|
|
|
39
39
|
def _libtorch_roots() -> list[Path]:
|
|
40
40
|
"""Where libtorch may live, in the order the crate's tooling points at it.
|
|
41
41
|
|
|
42
|
-
``env_setup.sh`` exports ``LIBTORCH_PATH`` and ``FLODL_VARIANT``;
|
|
43
|
-
|
|
42
|
+
``env_setup.sh`` exports ``LIBTORCH_PATH`` and ``FLODL_VARIANT``; before
|
|
43
|
+
those come the project-local ``./libtorch`` that ``fdl libtorch download``
|
|
44
|
+
writes, then fdl's shared precompiled dir for kernels started without env.
|
|
44
45
|
"""
|
|
45
46
|
roots: list[Path] = []
|
|
46
47
|
if configured := os.environ.get("LIBTORCH_PATH"):
|
|
47
48
|
roots.append(Path(configured))
|
|
49
|
+
roots.append(Path.cwd() / "libtorch")
|
|
48
50
|
base = Path.home() / ".flodl" / "libtorch" / "precompiled"
|
|
49
51
|
if variant := os.environ.get("FLODL_VARIANT"):
|
|
50
52
|
roots.append(base / variant)
|
|
51
|
-
|
|
53
|
+
# `cu128` is the directory env_setup.sh exports; `cuda` is the generic name.
|
|
54
|
+
roots.extend(base / name for name in ("cpu", "cuda", "cu128"))
|
|
52
55
|
return roots
|
|
53
56
|
|
|
54
57
|
|
|
@@ -116,6 +116,7 @@ const GENE_SALT_COMBINE: u64 = 0x0AC7_0000_0000_0002;
|
|
|
116
116
|
const GENE_SALT_STANDARDIZE: u64 = 0x0AC7_0000_0000_0003;
|
|
117
117
|
const GENE_SALT_PORT: u64 = 0x0AC7_0000_0000_0004;
|
|
118
118
|
const GENE_SALT_DROPOUT: u64 = 0x0AC7_0000_0000_0005;
|
|
119
|
+
const GENE_SALT_RECUR: u64 = 0x0AC7_0000_0000_0008;
|
|
119
120
|
const GENE_SALT_REACH: u64 = 0x0AC7_0000_0000_0006;
|
|
120
121
|
const GENE_SALT_WIDTH: u64 = 0x0AC7_0000_0000_0007;
|
|
121
122
|
|
|
@@ -234,6 +235,14 @@ pub(crate) fn drift_child_genes(
|
|
|
234
235
|
topo.options.dropout_prob = drop.f32() * limits.dropout_cap;
|
|
235
236
|
}
|
|
236
237
|
}
|
|
238
|
+
|
|
239
|
+
// PER-NET GENE: recurrence (one extra sweep of the same graph). Crossover can only
|
|
240
|
+
// DONATE it, so the coin flips the inherited allele: a child may acquire the loop from a
|
|
241
|
+
// parent that did not have it, and lose one it did. The build still gates it on the dims.
|
|
242
|
+
let mut recur = stream(GENE_SALT_RECUR);
|
|
243
|
+
if recur.f32() < p {
|
|
244
|
+
topo.options.recur = !topo.options.recur;
|
|
245
|
+
}
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
#[cfg(test)]
|
|
@@ -393,6 +402,16 @@ mod gene_drift_tests {
|
|
|
393
402
|
);
|
|
394
403
|
}
|
|
395
404
|
|
|
405
|
+
#[test]
|
|
406
|
+
fn the_recurrence_gene_is_a_coin_drift_flips() {
|
|
407
|
+
let mut t = topo(7);
|
|
408
|
+
t.options.recur = true;
|
|
409
|
+
drift_child_genes(&mut t, 0.0, &acts(), &combs(), &stds(), limits(), 7, 3, 1);
|
|
410
|
+
assert!(t.options.recur, "p=0 inherits the gene exactly");
|
|
411
|
+
drift_child_genes(&mut t, 1.0, &acts(), &combs(), &stds(), limits(), 7, 3, 1);
|
|
412
|
+
assert!(!t.options.recur, "p=1 must flip the inherited allele");
|
|
413
|
+
}
|
|
414
|
+
|
|
396
415
|
#[test]
|
|
397
416
|
fn dropout_stays_inside_the_cap_for_every_child_ordinal() {
|
|
398
417
|
for idx in 0..32 {
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
pub enum TrainTicket {
|
|
5
5
|
/// The fittest net earns the most tickets; the updates leg is OFF (`Fm⁺`).
|
|
6
6
|
MostFit,
|
|
7
|
-
/// The fittest net that has trained the LEAST earns the most tickets (`Fm⁺ × Um⁻`)
|
|
8
|
-
|
|
7
|
+
/// The fittest net that has trained the LEAST earns the most tickets (`Fm⁺ × Um⁻`): pay the
|
|
8
|
+
/// net that grades best and has had the fewest updates.
|
|
9
9
|
MostFitFewestUpdates,
|
|
10
10
|
/// The fittest net that has trained the MOST earns the most tickets (`Fm⁺ × Um⁺`).
|
|
11
11
|
MostFitMostUpdates,
|
|
12
12
|
/// The LEAST fit net that has trained the LEAST earns the most tickets (`Fm⁻ × Um⁻`) — the
|
|
13
|
-
///
|
|
13
|
+
/// engine default ([`DEFAULT_TRAIN_TICKET`]): pay the bottom of the field that has had the
|
|
14
|
+
/// fewest updates, so the ladder back up is funded from below.
|
|
15
|
+
#[default]
|
|
14
16
|
LeastFitFewestUpdates,
|
|
15
17
|
/// The LEAST fit net that has trained the MOST earns the most tickets (`Fm⁻ × Um⁺`).
|
|
16
18
|
LeastFitMostUpdates,
|
|
@@ -148,8 +150,10 @@ impl std::str::FromStr for TrainTicket {
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
/// Default ticket LEGS (`set_train_ticket`): the
|
|
152
|
-
|
|
153
|
+
/// Default ticket LEGS (`set_train_ticket`): the LEAST fit net that has trained the FEWEST earns
|
|
154
|
+
/// the most tickets (`Fm⁻ × Um⁻`) — the lottery pays the bottom of the field that has had the
|
|
155
|
+
/// fewest updates, so the net with the most room to improve is funded first.
|
|
156
|
+
pub const DEFAULT_TRAIN_TICKET: TrainTicket = TrainTicket::LeastFitFewestUpdates;
|
|
153
157
|
|
|
154
158
|
/// Default for the lottery's LEARN-ONLY switch (`set_ticket_learn_only`): `false` = a lost ticket idles the net (no train, no eval, nothing measured). `true` = every net…
|
|
155
159
|
pub const DEFAULT_TRAIN_MERIT_LEARN_ONLY: bool = false;
|
|
@@ -65,6 +65,7 @@ fn tiny_topology(seed: usize) -> Topology {
|
|
|
65
65
|
input_dim: Some(2),
|
|
66
66
|
output_dim: Some(2),
|
|
67
67
|
dropout_prob: 0.0,
|
|
68
|
+
recur: false,
|
|
68
69
|
feature_split: None,
|
|
69
70
|
weight_seed: None,
|
|
70
71
|
}),
|
|
@@ -1191,6 +1192,7 @@ fn flat_topology(seed: usize) -> Topology {
|
|
|
1191
1192
|
input_dim: Some(2),
|
|
1192
1193
|
output_dim: Some(2),
|
|
1193
1194
|
dropout_prob: 0.0,
|
|
1195
|
+
recur: false,
|
|
1194
1196
|
feature_split: None,
|
|
1195
1197
|
weight_seed: None,
|
|
1196
1198
|
}),
|
|
@@ -2722,7 +2724,7 @@ fn ticket_leg_spellings_round_trip() {
|
|
|
2722
2724
|
);
|
|
2723
2725
|
assert_eq!(TrainTicket::from_bools(false, false), TrainTicket::MostFit);
|
|
2724
2726
|
assert_eq!(TrainTicket::from_bools(true, false), TrainTicket::LeastFit);
|
|
2725
|
-
assert_eq!(DEFAULT_TRAIN_TICKET, TrainTicket::
|
|
2727
|
+
assert_eq!(DEFAULT_TRAIN_TICKET, TrainTicket::LeastFitFewestUpdates);
|
|
2726
2728
|
// ONE list backs the help text and the error messages: the names are the spellings, in order,
|
|
2727
2729
|
// and every one of them parses back to its own leg.
|
|
2728
2730
|
assert_eq!(TrainTicket::ALL.len(), TrainTicket::ALL_NAMES.len());
|
|
@@ -2822,8 +2824,8 @@ fn unfed_cull_evicts_the_highest_ticket_chance() {
|
|
|
2822
2824
|
eng.state.net_mut(h).unwrap().entered_at_step = born;
|
|
2823
2825
|
}
|
|
2824
2826
|
eng.config.lottery.train_merit_p_min = 0.0;
|
|
2825
|
-
// This test grades one ORDERING, so it pins it: worst-first × fewest-updates
|
|
2826
|
-
// default
|
|
2827
|
+
// This test grades one ORDERING, so it pins it: worst-first × fewest-updates — the engine's
|
|
2828
|
+
// default (`least_fit_fewest_updates`) — so the victim below is the highest-ticket net.
|
|
2827
2829
|
eng.config.lottery.train_ticket = crate::engine::config::TrainTicket::LeastFitFewestUpdates;
|
|
2828
2830
|
eng.config.evolution.crossover_cull_policy =
|
|
2829
2831
|
crate::engine::breed::cull::CrossCullPolicy::HighestTicketChance;
|
|
@@ -3419,6 +3421,10 @@ fn the_whole_run_trend_is_recorded_and_reported() {
|
|
|
3419
3421
|
let _ = std::fs::remove_dir_all(&dir);
|
|
3420
3422
|
let mut eng = engine(&dir, 23).unwrap();
|
|
3421
3423
|
eng.config.population.champion_count = 1;
|
|
3424
|
+
// Pin the lottery to pay EVERY net: this test grades the trend buffer, not the ticket, and
|
|
3425
|
+
// the default leg (`least_fit_fewest_updates`) can leave a net idle for a whole clock.
|
|
3426
|
+
eng.config.lottery.train_merit_p_min = 1.0;
|
|
3427
|
+
eng.config.lottery.train_merit_p_max = 1.0;
|
|
3422
3428
|
eng.seed_population_internal(vec![tiny_topology(7), tiny_topology(8)], Some(0.5))
|
|
3423
3429
|
.unwrap();
|
|
3424
3430
|
let h = eng.state.live_hashes()[0].clone();
|
|
@@ -106,6 +106,11 @@ pub(crate) struct NetShape {
|
|
|
106
106
|
pub nodes: usize,
|
|
107
107
|
/// Wires in the blueprint.
|
|
108
108
|
pub wires: usize,
|
|
109
|
+
/// The Input node's fan-out: the wires leaving it. A wire is one edge and an Input output
|
|
110
|
+
/// port is used at most once, so this is exactly the number of Input ports the feature split
|
|
111
|
+
/// laid down — the number the `%` share alone cannot name outside a partition. `0` when the
|
|
112
|
+
/// net has no readable Input node.
|
|
113
|
+
pub input_wires: usize,
|
|
109
114
|
/// Mean hidden-node width; `0.0` for a net with no hidden node.
|
|
110
115
|
pub dim: f32,
|
|
111
116
|
/// Share of the input each Input port reads on average: `1.0` = no split, `1/ports` = a
|
|
@@ -136,10 +141,19 @@ impl NetShape {
|
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
|
|
139
|
-
/// `Exclusive · 50.0` — policy
|
|
144
|
+
/// `Exclusive · 4 · 50.0` — policy, the Input node's fan-out (wires leaving it) and the mean
|
|
145
|
+
/// kept share in one cell, in percent. The share alone names a partition's port count (`1/P`),
|
|
146
|
+
/// but not a `Random`/`Crossover` one's: the middle number is how many wires the split laid
|
|
147
|
+
/// into the next layer.
|
|
140
148
|
pub fn split_cell(&self) -> Option<String> {
|
|
141
|
-
self.mask
|
|
142
|
-
|
|
149
|
+
self.mask.map(|share| {
|
|
150
|
+
format!(
|
|
151
|
+
"{} · {} · {:.1}",
|
|
152
|
+
self.split_label(),
|
|
153
|
+
self.input_wires,
|
|
154
|
+
share * 100.0
|
|
155
|
+
)
|
|
156
|
+
})
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
159
|
|
|
@@ -151,6 +165,16 @@ pub(crate) fn shape_of(topo: &Topology) -> NetShape {
|
|
|
151
165
|
.filter(|n| n.kind == NodeKind::Hidden)
|
|
152
166
|
.filter_map(|n| n.hidden_dim.map(|d| d as f32))
|
|
153
167
|
.collect();
|
|
168
|
+
let input_wires = topo
|
|
169
|
+
.nodes
|
|
170
|
+
.iter()
|
|
171
|
+
.find(|n| n.kind == NodeKind::Input)
|
|
172
|
+
.map_or(0, |input| {
|
|
173
|
+
topo.connections
|
|
174
|
+
.iter()
|
|
175
|
+
.filter(|c| c.from.node == input.id)
|
|
176
|
+
.count()
|
|
177
|
+
});
|
|
154
178
|
let mask = match topo.nodes.iter().find(|n| n.kind == NodeKind::Input) {
|
|
155
179
|
None => None,
|
|
156
180
|
Some(input) => match input.feature_masks.as_ref() {
|
|
@@ -173,6 +197,7 @@ pub(crate) fn shape_of(topo: &Topology) -> NetShape {
|
|
|
173
197
|
genome: genes(topo),
|
|
174
198
|
nodes: topo.nodes.len(),
|
|
175
199
|
wires: topo.connections.len(),
|
|
200
|
+
input_wires,
|
|
176
201
|
dim: trait_of(&hidden).mean,
|
|
177
202
|
mask,
|
|
178
203
|
}
|
|
@@ -474,6 +499,7 @@ mod tests {
|
|
|
474
499
|
genome: genome(tokens),
|
|
475
500
|
nodes: 1,
|
|
476
501
|
wires: 1,
|
|
502
|
+
input_wires: 1,
|
|
477
503
|
dim: 4.0,
|
|
478
504
|
mask: None,
|
|
479
505
|
};
|
|
@@ -1347,7 +1347,8 @@ fn ticket_column(legs: crate::engine::config::TrainTicket) -> &'static str {
|
|
|
1347
1347
|
/// `split`/`keep`/`%`. A column is as wide as its longest LINE, not as wide as the label was on
|
|
1348
1348
|
/// one line, so the header's height is what buys every ROW its width.
|
|
1349
1349
|
fn wrap_header(cell: &str) -> String {
|
|
1350
|
-
cell.replace("
|
|
1350
|
+
cell.replace("split (wires) · keep", "split\n(wires)\nkeep")
|
|
1351
|
+
.replace(" = ", " =\n")
|
|
1351
1352
|
.replace(" minmax", "\nminmax")
|
|
1352
1353
|
.replace(" + (", " +\n(")
|
|
1353
1354
|
.replace(" × ", "\n× ")
|
|
@@ -1380,10 +1381,12 @@ const COL_DEPTH: &str = "depth (D)";
|
|
|
1380
1381
|
/// two adjacent columns both called "eval" read as the same quantity.
|
|
1381
1382
|
const COL_EVAL: &str = "eval time (µs)";
|
|
1382
1383
|
const COL_EXAM: &str = "exam (X)";
|
|
1383
|
-
/// `split · keep %`: the policy
|
|
1384
|
-
/// carries no masks (`100.0`), `Exclusive`/`Chunks` are
|
|
1385
|
-
/// repaired coin flip, and `Crossover` is a blended split.
|
|
1386
|
-
|
|
1384
|
+
/// `split (wires) · keep %`: the policy, how many wires leave the Input node, then the mean share
|
|
1385
|
+
/// of the input each Input port reads. `Full` carries no masks (`100.0`), `Exclusive`/`Chunks` are
|
|
1386
|
+
/// partitions (`1/P × 100`), `Random` is a repaired coin flip, and `Crossover` is a blended split.
|
|
1387
|
+
/// The `%` is stated once, in the header; the parenthetical names the middle value, because the
|
|
1388
|
+
/// share alone only names a partition's wire count.
|
|
1389
|
+
const COL_MASK: &str = "split (wires) · keep %";
|
|
1387
1390
|
|
|
1388
1391
|
/// The columns the card actually PRINTS, in reading order — `STOP_HEADER_FIXED` minus the cells
|
|
1389
1392
|
/// this run cannot fill.
|
|
@@ -1558,7 +1561,7 @@ fn stop_legend_rows(ctx: &LegendCtx<'_>) -> Vec<(String, String)> {
|
|
|
1558
1561
|
),
|
|
1559
1562
|
(
|
|
1560
1563
|
COL_MASK.to_string(),
|
|
1561
|
-
"the split policy
|
|
1564
|
+
"the split policy, the wires leaving the Input node and the mean share of the input each Input port reads, in percent: `Full · 1 · 100.0` = no masks, `Exclusive · P · 1/P×100` = a partition (the middle number is the wire count), `Chunks · 100/P` = an ordered partition, `Random`/`Crossover` = a coin-flipped or blended split, where the share alone would not name the wire count"
|
|
1562
1565
|
.to_string(),
|
|
1563
1566
|
),
|
|
1564
1567
|
(
|
|
@@ -1922,7 +1925,7 @@ mod stop_legend_tests {
|
|
|
1922
1925
|
"params".to_string(),
|
|
1923
1926
|
"thickness (H)".to_string(),
|
|
1924
1927
|
"depth (D)".to_string(),
|
|
1925
|
-
"split · keep %".to_string(),
|
|
1928
|
+
"split (wires) · keep %".to_string(),
|
|
1926
1929
|
"fit (F = mean)".to_string(),
|
|
1927
1930
|
"slope (S)".to_string(),
|
|
1928
1931
|
];
|
|
@@ -1934,7 +1937,7 @@ mod stop_legend_tests {
|
|
|
1934
1937
|
"1.0K",
|
|
1935
1938
|
"1.0",
|
|
1936
1939
|
"2",
|
|
1937
|
-
"Exclusive · 50.0",
|
|
1940
|
+
"Exclusive · 4 · 50.0",
|
|
1938
1941
|
"0.50",
|
|
1939
1942
|
"0.01",
|
|
1940
1943
|
],
|
|
@@ -1945,7 +1948,7 @@ mod stop_legend_tests {
|
|
|
1945
1948
|
"2.0K",
|
|
1946
1949
|
"1.5",
|
|
1947
1950
|
"3",
|
|
1948
|
-
"Random · 75.0",
|
|
1951
|
+
"Random · 2 · 75.0",
|
|
1949
1952
|
"0.70",
|
|
1950
1953
|
"na",
|
|
1951
1954
|
],
|
|
@@ -2884,6 +2887,7 @@ mod tests {
|
|
|
2884
2887
|
genome: [(token.to_string(), 1usize)].into_iter().collect(),
|
|
2885
2888
|
nodes: 1,
|
|
2886
2889
|
wires: 1,
|
|
2890
|
+
input_wires: 1,
|
|
2887
2891
|
dim: 4.0,
|
|
2888
2892
|
mask: Some(1.0),
|
|
2889
2893
|
}
|
|
@@ -2893,14 +2897,15 @@ mod tests {
|
|
|
2893
2897
|
fn split_cell_carries_both_the_policy_and_the_share() {
|
|
2894
2898
|
use crate::graph::topology::FeatureSplitPolicy;
|
|
2895
2899
|
let mut shape = shape("W:Tanh");
|
|
2900
|
+
shape.input_wires = 4;
|
|
2896
2901
|
shape.split = Some(FeatureSplitPolicy::Random);
|
|
2897
2902
|
shape.mask = Some(0.75);
|
|
2898
|
-
assert_eq!(shape.split_cell().as_deref(), Some("Random · 75.0"));
|
|
2903
|
+
assert_eq!(shape.split_cell().as_deref(), Some("Random · 4 · 75.0"));
|
|
2899
2904
|
shape.split = Some(FeatureSplitPolicy::Crossover);
|
|
2900
|
-
assert_eq!(shape.split_cell().as_deref(), Some("Crossover · 75.0"));
|
|
2905
|
+
assert_eq!(shape.split_cell().as_deref(), Some("Crossover · 4 · 75.0"));
|
|
2901
2906
|
shape.split = None;
|
|
2902
2907
|
shape.mask = Some(1.0);
|
|
2903
|
-
assert_eq!(shape.split_cell().as_deref(), Some("Full · 100.0"));
|
|
2908
|
+
assert_eq!(shape.split_cell().as_deref(), Some("Full · 4 · 100.0"));
|
|
2904
2909
|
}
|
|
2905
2910
|
|
|
2906
2911
|
/// A shape with two gene tokens, ONE of them `W:Tanh` — so its Δ to [`shape`]
|
|
@@ -2916,6 +2921,7 @@ mod tests {
|
|
|
2916
2921
|
.collect(),
|
|
2917
2922
|
nodes: 1,
|
|
2918
2923
|
wires: 2,
|
|
2924
|
+
input_wires: 2,
|
|
2919
2925
|
dim: 8.0,
|
|
2920
2926
|
mask: Some(0.5),
|
|
2921
2927
|
}
|