torch-type-nn 0.1.0.dev0__tar.gz → 0.1.1.dev0__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 (80) hide show
  1. torch_type_nn-0.1.1.dev0/BOARD.CUDA.md +183 -0
  2. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/BOARD.md +76 -48
  3. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/PKG-INFO +43 -34
  4. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/README.md +42 -33
  5. torch_type_nn-0.1.1.dev0/VERSIONS.md +48 -0
  6. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/bench.py +93 -9
  7. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/board.py +80 -7
  8. torch_type_nn-0.1.1.dev0/benchmarks/results/board-cuda.jsonl +18 -0
  9. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/results/board-per-sample.jsonl +36 -36
  10. torch_type_nn-0.1.1.dev0/benchmarks/results/scale-batch32.jsonl +10 -0
  11. torch_type_nn-0.1.1.dev0/benchmarks/results/scale-cuda.jsonl +8 -0
  12. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/scale.py +64 -34
  13. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/docs/AUDIT.md +10 -0
  14. torch_type_nn-0.1.1.dev0/docs/BACKENDS.md +32 -0
  15. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/docs/DIFFERENCES.md +17 -0
  16. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/flake.lock +3 -3
  17. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/flake.nix +47 -2
  18. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/pyproject.toml +7 -2
  19. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/__init__.py +4 -0
  20. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/adapters/typenn.py +30 -4
  21. torch_type_nn-0.1.1.dev0/src/torch_type_nn/backend.py +26 -0
  22. torch_type_nn-0.1.1.dev0/src/torch_type_nn/cuda/__init__.py +8 -0
  23. torch_type_nn-0.1.1.dev0/src/torch_type_nn/cuda/adapter.py +549 -0
  24. torch_type_nn-0.1.1.dev0/src/torch_type_nn/cuda/model.py +733 -0
  25. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/__init__.py +8 -0
  26. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/_build.py +63 -0
  27. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/_lib.py +52 -0
  28. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/ORIGIN +4 -0
  29. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/common.h +73 -0
  30. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/tnn_py.c +183 -0
  31. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/tnn_py.h +38 -0
  32. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn.c +474 -0
  33. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn.h +124 -0
  34. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_overfit.c +461 -0
  35. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_overfit.h +119 -0
  36. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_overfit_scale.c +554 -0
  37. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_overfit_scale.h +50 -0
  38. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_scale.c +831 -0
  39. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/c/type_nn_scale.h +57 -0
  40. torch_type_nn-0.1.1.dev0/src/torch_type_nn/native/model.py +192 -0
  41. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/scaling.py +4 -0
  42. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/conftest.py +20 -0
  43. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_board.py +38 -0
  44. torch_type_nn-0.1.1.dev0/tests/test_cuda.py +93 -0
  45. torch_type_nn-0.1.1.dev0/tests/test_native.py +77 -0
  46. torch_type_nn-0.1.1.dev0/tests/test_package.py +31 -0
  47. torch_type_nn-0.1.1.dev0/tests/test_scale.py +77 -0
  48. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_threshold.py +44 -0
  49. torch_type_nn-0.1.0.dev0/benchmarks/results/scale-batch32.jsonl +0 -10
  50. torch_type_nn-0.1.0.dev0/tests/test_package.py +0 -11
  51. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/.gitignore +0 -0
  52. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/LICENSE +0 -0
  53. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/data/README.md +0 -0
  54. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/datasets.json +0 -0
  55. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/fetch_data.py +0 -0
  56. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/benchmarks/reference/c-type-nn-7333bf7-30seeds.jsonl +0 -0
  57. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/docs/ADAPTERS.md +0 -0
  58. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/adapters/__init__.py +0 -0
  59. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/adapters/mlp.py +0 -0
  60. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/edits.py +0 -0
  61. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/functional.py +0 -0
  62. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/layer.py +0 -0
  63. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/mlp.py +0 -0
  64. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/network.py +0 -0
  65. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/optim.py +0 -0
  66. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/protocol.py +0 -0
  67. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/py.typed +0 -0
  68. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/src/torch_type_nn/train.py +0 -0
  69. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/c/crosscheck.c +0 -0
  70. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/data/iris_prune_boundary.pt +0 -0
  71. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/helpers.py +0 -0
  72. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_crosscheck_c.py +0 -0
  73. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_datasets.py +0 -0
  74. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_device.py +0 -0
  75. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_edits.py +0 -0
  76. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_functional.py +0 -0
  77. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_layer.py +0 -0
  78. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_mlp.py +0 -0
  79. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_optim.py +0 -0
  80. {torch_type_nn-0.1.0.dev0 → torch_type_nn-0.1.1.dev0}/tests/test_scaling.py +0 -0
@@ -0,0 +1,183 @@
1
+ # CUDA board
2
+
3
+ Numbers on this page come from `benchmarks/board.py --write-cuda`. They are
4
+ **not** bit-identical to C `bench.c`; C stays the number-for-number backend
5
+ on [BOARD.md](BOARD.md). This file is the ragged device store
6
+ (`CudaTypeNN`: packed `W (R, n_in)`, fused `X @ W.T`).
7
+
8
+ `nix flake check --impure` skips `checks.cuda` unless the Nix daemon enables
9
+ the `cuda` system feature. A GPU machine without that feature still runs the
10
+ suite on the host:
11
+
12
+ ```sh
13
+ nix run .#test-cuda # pytest + xor on the device (prints the probe)
14
+ nix run .#board-cuda # 5-seed CUDA board + scale, then this file
15
+ ```
16
+
17
+ or step by step:
18
+
19
+ ```sh
20
+ nix run .#bench-cuda -- all cuda-type-nn,cuda-type-nn-overfit,mlp \
21
+ --seeds 5 --device cuda --jobs 0 \
22
+ > benchmarks/results/board-cuda.jsonl
23
+ nix run .#scale-cuda -- all --models cuda-type-nn,cuda-type-nn-overfit,mlp-16,mlp-64 \
24
+ --seeds 5 --device cuda --jobs 0 \
25
+ > benchmarks/results/scale-cuda.jsonl
26
+ nix run .#board -- \
27
+ --board benchmarks/results/board-cuda.jsonl \
28
+ --scale benchmarks/results/scale-cuda.jsonl \
29
+ --write-cuda BOARD.CUDA.md
30
+ ```
31
+
32
+ Look for `======== torch-type-nn CUDA probe ========` and
33
+ `torch-type-nn device: CUDA …` in the log. A green run with only
34
+ `torch-type-nn device: CPU` did not use a GPU.
35
+
36
+ ## Why C rows disagreed across the two boards
37
+
38
+ Two different gaps, not one:
39
+
40
+ 1. **C type-nn on BOARD.md vs C type-nn on BOARD.CUDA.md.**
41
+ `board.py --write-cuda` used to merge `benchmarks/reference/c-type-nn-7333bf7-30seeds.jsonl`
42
+ (C binary, 30 seeds) into this file. BOARD.md's C rows are
43
+ **5-seed NativeTypeNN**. Those are not the same experiment. The CUDA
44
+ writer no longer reads that 30-seed file. Pass
45
+ `benchmarks/results/board-per-sample.jsonl` next to `board-cuda.jsonl`
46
+ so both markdown files show the same 5-seed C cells.
47
+
48
+ 2. **C type-nn vs cuda-type-nn (and the overfit pair).**
49
+ `CudaTypeNN` is the C *layout* (ragged `W (R, n_in)`, fused GEMM) with
50
+ a *thinner scaler*. It is not `type_nn_scale.c` / `type_nn_overfit_scale.c`.
51
+ Missing or simplified relative to C: pair-cache BIC, width probes
52
+ (new unit + consumer column at 0), the fold when a depth probe is
53
+ inserted, and C's exact identity-layer metric. So CUDA stays closer to
54
+ birth depth, grows fewer params, and can lose on xor-train / Friedman
55
+ while C grows. Forward+Adam on a *fixed* graph match C; the structure
56
+ trajectory does not. C remains the number-for-number backend.
57
+
58
+ ## Per-sample tasks
59
+
60
+ Same tasks, split, epochs and lr as [BOARD.md](BOARD.md). CUDA rows are
61
+ per-sample Adam on the device (C protocol, fused GEMV). MLP rows in the
62
+ same jsonl were trained with `--device cuda`.
63
+
64
+ <!-- board:per-sample -->
65
+ Generated by `benchmarks/board.py --write-cuda` from `benchmarks/results/board-cuda.jsonl`, `benchmarks/results/board-per-sample.jsonl` (5 seeds, batch 1, cpu; 5 seeds, batch 1, cuda; cuda type-nn rows from CudaTypeNN).
66
+
67
+ | task | model | hold MSE | ± sd | hold acc | train MSE | params | ± sd | layers | train s | µs/inf |
68
+ |---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
69
+ | xor | torch ref-type-nn | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 55.15 | 482.6 |
70
+ | xor | torch ref-type-nn-overfit | n/a | n/a | n/a | 4.90e-06 | 56.0 | 17.0 | 1→2.4 | 39.42 | 245.0 |
71
+ | xor | **torch type-nn** | n/a | n/a | n/a | 5.11e-06 | 63.0 | 23.7 | 1→2.4 | 35.06 | 232.7 |
72
+ | xor | torch type-nn-bic | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 41.22 | 238.3 |
73
+ | xor | torch MLP | n/a | n/a | n/a | 9.61e-29 | 33.0 | 0.0 | 2→2.0 | 13.40 | 68.1 |
74
+ | xor | torch MLP, scaled | n/a | n/a | n/a | 8.34e-02 | 39.0 | 37.1 | 2→3.2 | 20.45 | 99.3 |
75
+ | xor | cuda type-nn | n/a | n/a | n/a | 6.74e-06 | 24.8 | 1.8 | 1→2.0 | 411.38 | 7308.3 |
76
+ | xor | cuda type-nn-overfit | n/a | n/a | n/a | 1.04e-06 | 73.6 | 36.0 | 1→2.6 | 288.21 | 10705.1 |
77
+ | iris | torch ref-type-nn | 0.0331 | 0.0142 | 0.947 | 6.29e-03 | 144.6 | 27.0 | 3→4.0 | 201.94 | 614.1 |
78
+ | iris | torch ref-type-nn-overfit | 0.0272 | 0.0034 | 0.956 | 8.28e-04 | 159.6 | 33.6 | 3→4.0 | 191.22 | 1070.9 |
79
+ | iris | **torch type-nn** | 0.0258 | 0.0019 | 0.956 | 6.23e-04 | 180.0 | 15.1 | 3→4.0 | 206.52 | 501.9 |
80
+ | iris | torch type-nn-bic | 0.0250 | 0.0062 | 0.964 | 1.37e-04 | 134.8 | 41.1 | 3→4.0 | 221.54 | 975.8 |
81
+ | iris | torch MLP | 0.0309 | 0.0043 | 0.956 | 1.48e-02 | 67.0 | 0.0 | 2→2.0 | 36.89 | 70.0 |
82
+ | iris | torch MLP, scaled | 0.0262 | 0.0044 | 0.956 | 6.08e-03 | 71.8 | 16.3 | 2→3.0 | 63.95 | 178.1 |
83
+ | iris | cuda type-nn | 0.0234 | 0.0040 | 0.960 | 1.99e-04 | 139.8 | 40.5 | 3→4.0 | 1398.00 | 15537.4 |
84
+ | iris | cuda type-nn-overfit | 0.0404 | 0.0354 | 0.956 | 1.57e-02 | 189.8 | 38.3 | 3→4.0 | 1265.22 | 15649.2 |
85
+ | wine | torch ref-type-nn | 0.0198 | 0.0070 | 0.959 | 3.20e-05 | 214.6 | 34.6 | 4→5.0 | 236.12 | 602.9 |
86
+ | wine | torch ref-type-nn-overfit | 0.0364 | 0.0107 | 0.933 | 2.72e-05 | 357.0 | 14.6 | 4→5.0 | 239.31 | 592.6 |
87
+ | wine | **torch type-nn** | 0.0189 | 0.0066 | 0.967 | 6.97e-05 | 486.2 | 15.5 | 4→5.0 | 240.25 | 1301.7 |
88
+ | wine | torch type-nn-bic | 0.0264 | 0.0072 | 0.952 | 4.31e-05 | 194.2 | 72.0 | 4→4.8 | 220.96 | 359.4 |
89
+ | wine | torch MLP | 0.0259 | 0.0032 | 0.956 | 3.87e-03 | 275.0 | 0.0 | 2→2.0 | 39.39 | 144.4 |
90
+ | wine | torch MLP, scaled | 0.0177 | 0.0078 | 0.967 | 3.23e-04 | 124.6 | 32.7 | 2→3.0 | 71.08 | 107.6 |
91
+ | wine | cuda type-nn | 0.0208 | 0.0043 | 0.959 | 2.67e-05 | 214.6 | 44.8 | 4→5.0 | 1641.16 | 19566.2 |
92
+ | wine | cuda type-nn-overfit | 0.0220 | 0.0094 | 0.963 | 1.21e-05 | 470.2 | 52.3 | 4→5.0 | 1476.59 | 19374.9 |
93
+ | wdbc | torch ref-type-nn | 0.0439 | 0.0056 | 0.952 | 4.88e-04 | 175.8 | 36.3 | 3→4.0 | 221.42 | 501.3 |
94
+ | wdbc | torch ref-type-nn-overfit | 0.0435 | 0.0059 | 0.950 | 5.14e-04 | 184.8 | 55.6 | 3→3.6 | 206.28 | 129.5 |
95
+ | wdbc | **torch type-nn** | 0.0473 | 0.0037 | 0.949 | 4.94e-04 | 220.0 | 40.7 | 3→3.6 | 230.46 | 480.6 |
96
+ | wdbc | torch type-nn-bic | 0.0436 | 0.0052 | 0.950 | 1.64e-03 | 210.0 | 83.4 | 3→4.0 | 238.39 | 479.6 |
97
+ | wdbc | torch MLP | 0.0471 | 0.0040 | 0.944 | 5.70e-03 | 513.0 | 0.0 | 2→2.0 | 35.73 | 23.4 |
98
+ | wdbc | torch MLP, scaled | 0.0539 | 0.0079 | 0.943 | 1.84e-03 | 132.0 | 23.3 | 2→3.0 | 91.83 | 85.3 |
99
+ | wdbc | cuda type-nn | 0.0435 | 0.0028 | 0.952 | 9.64e-05 | 207.8 | 34.3 | 3→4.0 | 1529.38 | 4255.6 |
100
+ | wdbc | cuda type-nn-overfit | 0.0475 | 0.0035 | 0.945 | 4.42e-04 | 211.2 | 41.6 | 3→3.4 | 1115.29 | 1265.5 |
101
+ | diabetes | torch ref-type-nn | 0.0328 | 0.0005 | n/a | 2.73e-02 | 18.6 | 4.9 | 2→2.2 | 273.17 | 501.6 |
102
+ | diabetes | torch ref-type-nn-overfit | 0.0366 | 0.0030 | n/a | 2.43e-02 | 31.8 | 7.8 | 2→2.4 | 261.55 | 261.2 |
103
+ | diabetes | **torch type-nn** | 0.0501 | 0.0145 | n/a | 1.75e-02 | 100.0 | 42.6 | 2→3.0 | 244.53 | 788.5 |
104
+ | diabetes | torch type-nn-bic | 0.0330 | 0.0006 | n/a | 2.78e-02 | 18.0 | 2.1 | 2→2.6 | 251.05 | 161.2 |
105
+ | diabetes | torch MLP | 0.0478 | 0.0038 | n/a | 1.47e-02 | 193.0 | 0.0 | 2→2.0 | 69.91 | 32.2 |
106
+ | diabetes | torch MLP, scaled | 0.0410 | 0.0017 | n/a | 2.05e-02 | 61.6 | 10.3 | 2→3.0 | 134.33 | 82.6 |
107
+ | diabetes | cuda type-nn | 0.0328 | 0.0006 | n/a | 2.78e-02 | 17.4 | 1.3 | 2→2.8 | 1680.93 | 11631.7 |
108
+ | diabetes | cuda type-nn-overfit | 0.0453 | 0.0053 | n/a | 1.74e-02 | 98.4 | 22.1 | 2→3.0 | 1703.39 | 11891.0 |
109
+ | ionosphere | torch ref-type-nn | 0.0919 | 0.0212 | 0.900 | 7.40e-03 | 157.2 | 59.2 | 4→5.0 | 261.99 | 629.1 |
110
+ | ionosphere | torch ref-type-nn-overfit | 0.0899 | 0.0199 | 0.898 | 1.61e-03 | 319.6 | 71.2 | 4→4.6 | 243.87 | 880.4 |
111
+ | ionosphere | **torch type-nn** | 0.0854 | 0.0209 | 0.909 | 7.06e-04 | 389.6 | 66.3 | 4→4.8 | 233.66 | 1876.2 |
112
+ | ionosphere | torch type-nn-bic | 0.0837 | 0.0137 | 0.909 | 5.08e-03 | 212.8 | 26.7 | 4→4.8 | 272.71 | 1002.3 |
113
+ | ionosphere | torch MLP | 0.1356 | 0.0128 | 0.908 | 1.57e-02 | 577.0 | 0.0 | 2→2.0 | 46.17 | 122.2 |
114
+ | ionosphere | torch MLP, scaled | 0.1149 | 0.0224 | 0.887 | 8.43e-03 | 167.8 | 17.1 | 2→3.0 | 81.57 | 108.7 |
115
+ | ionosphere | cuda type-nn | 0.1001 | 0.0113 | 0.877 | 2.13e-02 | 167.2 | 124.5 | 4→4.2 | 1711.80 | 11845.0 |
116
+ | ionosphere | cuda type-nn-overfit | 0.1028 | 0.0333 | 0.887 | 1.24e-02 | 336.2 | 35.9 | 4→4.8 | 1755.88 | 10559.1 |
117
+ <!-- /board:per-sample -->
118
+
119
+ ## Comparisons
120
+
121
+ Hold-out gap is **clear** when it exceeds two standard errors of the
122
+ difference, `2 sqrt(sd_a²/n_a + sd_b²/n_b)`.
123
+
124
+ <!-- board:pairs -->
125
+ | task | comparison | Δ hold MSE | 2se | verdict | params ratio |
126
+ |---|---|---:|---:|---|---:|
127
+ | xor | cuda type-nn vs torch MLP | n/a | n/a | both fit (no hold-out) | 0.75× |
128
+ | xor | cuda type-nn-overfit vs torch MLP | n/a | n/a | both fit (no hold-out) | 2.23× |
129
+ | xor | cuda type-nn vs cuda type-nn-overfit | n/a | n/a | both fit (no hold-out) | 0.34× |
130
+ | iris | cuda type-nn vs torch MLP | -0.0075 | 0.0053 | lower, **clear** | 2.09× |
131
+ | iris | cuda type-nn-overfit vs torch MLP | +0.0095 | 0.0319 | higher, within noise | 2.83× |
132
+ | iris | cuda type-nn vs cuda type-nn-overfit | -0.0171 | 0.0319 | lower, within noise | 0.74× |
133
+ | wine | cuda type-nn vs torch MLP | -0.0050 | 0.0048 | lower, **clear** | 0.78× |
134
+ | wine | cuda type-nn-overfit vs torch MLP | -0.0039 | 0.0089 | lower, within noise | 1.71× |
135
+ | wine | cuda type-nn vs cuda type-nn-overfit | -0.0011 | 0.0092 | lower, within noise | 0.46× |
136
+ | wdbc | cuda type-nn vs torch MLP | -0.0037 | 0.0044 | lower, within noise | 0.41× |
137
+ | wdbc | cuda type-nn-overfit vs torch MLP | +0.0003 | 0.0047 | higher, within noise | 0.41× |
138
+ | wdbc | cuda type-nn vs cuda type-nn-overfit | -0.0040 | 0.0040 | lower, within noise | 0.98× |
139
+ | diabetes | cuda type-nn vs torch MLP | -0.0150 | 0.0034 | lower, **clear** | 0.09× |
140
+ | diabetes | cuda type-nn-overfit vs torch MLP | -0.0024 | 0.0058 | lower, within noise | 0.51× |
141
+ | diabetes | cuda type-nn vs cuda type-nn-overfit | -0.0125 | 0.0047 | lower, **clear** | 0.18× |
142
+ | ionosphere | cuda type-nn vs torch MLP | -0.0355 | 0.0153 | lower, **clear** | 0.29× |
143
+ | ionosphere | cuda type-nn-overfit vs torch MLP | -0.0328 | 0.0319 | lower, **clear** | 0.58× |
144
+ | ionosphere | cuda type-nn vs cuda type-nn-overfit | -0.0027 | 0.0315 | lower, within noise | 0.50× |
145
+ <!-- /board:pairs -->
146
+
147
+ ## Larger data
148
+
149
+ Same `scale.py` tasks as [BOARD.md](BOARD.md) (digits, Friedman #1). CUDA
150
+ rows use `CudaTypeNN.epoch` (per-sample on the device). MLP-16 / MLP-64 in
151
+ this file are the batched baseline on the same `--device`.
152
+
153
+ <!-- board:scale -->
154
+ Generated by `benchmarks/board.py` from `benchmarks/results/scale-cuda.jsonl`, `benchmarks/results/scale-batch32.jsonl` (5 seeds, batch 1, cuda; 5 seeds, batch 32, cpu).
155
+
156
+ | task | model | hold MSE | ± sd | × noise floor | hold acc | train MSE | params | layers | train s |
157
+ |---|---|---:|---:|---:|---:|---:|---:|---:|---:|
158
+ | digits | **type-nn** | 0.00620 | 0.00131 | n/a | 0.963 | 0.00023 | 5509 | 7.0 | 32.1 |
159
+ | digits | type-nn-bic | 0.00696 | 0.00028 | n/a | 0.957 | 0.00014 | 3352 | 7.0 | 221.1 |
160
+ | digits | MLP, scaled | 0.00779 | 0.00053 | n/a | 0.964 | 0.00170 | 1323 | 3.0 | 8.5 |
161
+ | digits | MLP-16 | 0.01110 | 0.00074 | n/a | 0.959 | 0.00490 | 1210 | 2.0 | 4.1 |
162
+ | digits | MLP-64 | 0.01089 | 0.00022 | n/a | 0.974 | 0.00343 | 4810 | 2.0 | 5.4 |
163
+ | digits | cuda type-nn | 0.00754 | 0.00059 | n/a | 0.954 | 0.00013 | 3273 | 7.0 | 6584.2 |
164
+ | digits | cuda type-nn-overfit | 0.00663 | 0.00089 | n/a | 0.958 | 0.00011 | 3678 | 6.0 | 5958.5 |
165
+ | friedman | **type-nn** | 0.00660 | 0.00037 | 6.65 | n/a | 0.00666 | 18 | 2.0 | 217.7 |
166
+ | friedman | type-nn-bic | 0.00195 | 0.00089 | 1.97 | n/a | 0.00194 | 80 | 3.0 | 243.6 |
167
+ | friedman | MLP, scaled | 0.01377 | 0.01039 | 13.88 | n/a | 0.01362 | 17 | 2.6 | 96.7 |
168
+ | friedman | MLP-16 | 0.00121 | 0.00013 | 1.22 | n/a | 0.00118 | 193 | 2.0 | 48.1 |
169
+ | friedman | MLP-64 | 0.00114 | 0.00005 | 1.15 | n/a | 0.00110 | 769 | 2.0 | 34.8 |
170
+ | friedman | cuda type-nn | 0.00152 | 0.00032 | 1.53 | n/a | 0.00151 | 79 | 3.0 | 28158.7 |
171
+ | friedman | cuda type-nn-overfit | 0.00670 | 0.00003 | 6.75 | n/a | 0.00677 | 15 | 2.0 | 23214.0 |
172
+
173
+ friedman: noise floor (best reachable hold-out MSE, `1 / span²`) = 0.00099
174
+
175
+ | task | comparison | Δ hold MSE | 2se | verdict | params ratio |
176
+ |---|---|---:|---:|---|---:|
177
+ | digits | cuda type-nn vs MLP-16 | -0.0036 | 0.0008 | lower, **clear** | 2.71× |
178
+ | digits | cuda type-nn-overfit vs MLP-16 | -0.0045 | 0.0010 | lower, **clear** | 3.04× |
179
+ | digits | cuda type-nn vs cuda type-nn-overfit | +0.0009 | 0.0010 | higher, within noise | 0.89× |
180
+ | friedman | cuda type-nn vs MLP-16 | +0.0003 | 0.0003 | higher, **clear** | 0.41× |
181
+ | friedman | cuda type-nn-overfit vs MLP-16 | +0.0055 | 0.0001 | higher, **clear** | 0.08× |
182
+ | friedman | cuda type-nn vs cuda type-nn-overfit | -0.0052 | 0.0003 | lower, **clear** | 5.27× |
183
+ <!-- /board:scale -->
@@ -31,7 +31,33 @@ over the second's.
31
31
  | torch ref-type-nn-overfit | C's `type-nn-overfit` exactly: threshold rule, `width_through_depth_probe=False` |
32
32
  | torch MLP | the C board's baseline: Linear-ReLU-Linear, 8 hidden units (n ≤ 4) or 16, stock Adam |
33
33
  | torch MLP, scaled | `ScalableMLP` grown and pruned by the default (threshold) rule, stock Adam |
34
- | C type-nn, C type-nn-overfit, C c-mlp | hadilq/type-nn `7333bf7`, run on the same machine as its committed reference (deterministic; reproduces digit for digit) |
34
+ | C type-nn, C type-nn-overfit | `NativeTypeNN` wrapping C `type-nn` / `type-nn-overfit` (`7333bf7`): ragged Ors, C's own scaler; `bench.py` models `c-type-nn` / `c-type-nn-overfit` (`backend=nativetypenn`). One seed matches `bench.c` bit-for-bit. Default board is **5 seeds** (type-nn `BOARD.txt`). `benchmarks/reference/` is a **30-seed** C-binary file and is only the fallback before those cells are run; do not compare 5-seed wrapper means to that 30-seed file. |
35
+ | C c-mlp | hadilq/type-nn `7333bf7` binary board (no Python wrapper) |
36
+
37
+ ### type-nn vs type-nn-overfit (not a wrapper bug)
38
+
39
+ Both C rows are `NativeTypeNN` calling `7333bf7` `bench.c`. The 5-seed means
40
+ match type-nn `BOARD.txt`. Overfit is **not** "BIC plus extra width so hold-out
41
+ always wins."
42
+
43
+ - **C type-nn** (`rule="bic"`): a structure stays only if it pays its
44
+ parameters on the measured training pairs,
45
+ `n ln(MSE_without/MSE_with) > k ln n`.
46
+ - **C type-nn-overfit** (`rule="threshold"`): probes promote on displacement
47
+ past `θ(T)=lr T^{3/4}` and drop only when they fall back inside the identity
48
+ band. That *does* let the graph grow more freely.
49
+
50
+ On the 5-seed C board that is what happens: overfit has **more params** than
51
+ BIC on xor (108 vs 26), iris (175 vs 125), wine (393 vs 170), diabetes
52
+ (33 vs 20), ionosphere (298 vs 154); wdbc is a tie (~163). Train MSE is
53
+ usually tighter. Hold-out vs BIC is **mixed** (overfit better on wine and
54
+ ionosphere; BIC better on iris, wdbc, diabetes). That is the prior doing
55
+ its job, not a failed grow.
56
+
57
+ Overfit vs C c-mlp on hold-out: lower on iris, wine, diabetes, ionosphere
58
+ (clear on the last two); within noise on wdbc — with fewer params than the
59
+ MLP except on iris/wine. The type-nn README claim is "fits train ~10× tighter
60
+ than c-mlp at similar hold-out," not "beats BIC on hold-out."
35
61
 
36
62
  ## Per-sample board
37
63
 
@@ -53,57 +79,57 @@ Generated by `benchmarks/board.py` from `benchmarks/reference/c-type-nn-7333bf7-
53
79
  | xor | C type-nn | n/a | n/a | n/a | 1.67e-02 | 23.6 | 5.8 | 1→1.9 | 0.01 | 0.1 |
54
80
  | xor | C type-nn-overfit | n/a | n/a | n/a | 2.03e-04 | 78.8 | 47.4 | 1→2.7 | 0.01 | 0.2 |
55
81
  | xor | C c-mlp | n/a | n/a | n/a | 8.76e-03 | 33.0 | 0.0 | 2→2.0 | 0.00 | 0.0 |
56
- | xor | torch ref-type-nn | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 67.24 | 319.7 |
57
- | xor | torch ref-type-nn-overfit | n/a | n/a | n/a | 4.90e-06 | 56.0 | 17.0 | 1→2.4 | 46.32 | 497.0 |
58
- | xor | **torch type-nn** | n/a | n/a | n/a | 5.11e-06 | 63.0 | 23.7 | 1→2.4 | 46.60 | 1066.2 |
59
- | xor | torch type-nn-bic | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 58.89 | 149.1 |
60
- | xor | torch MLP | n/a | n/a | n/a | 9.61e-29 | 33.0 | 0.0 | 2→2.0 | 12.39 | 66.9 |
61
- | xor | torch MLP, scaled | n/a | n/a | n/a | 8.34e-02 | 39.0 | 37.1 | 2→3.2 | 23.44 | 97.2 |
82
+ | xor | torch ref-type-nn | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 55.15 | 482.6 |
83
+ | xor | torch ref-type-nn-overfit | n/a | n/a | n/a | 4.90e-06 | 56.0 | 17.0 | 1→2.4 | 39.42 | 245.0 |
84
+ | xor | **torch type-nn** | n/a | n/a | n/a | 5.11e-06 | 63.0 | 23.7 | 1→2.4 | 35.06 | 232.7 |
85
+ | xor | torch type-nn-bic | n/a | n/a | n/a | 8.40e-06 | 24.8 | 1.8 | 1→2.0 | 41.22 | 238.3 |
86
+ | xor | torch MLP | n/a | n/a | n/a | 9.61e-29 | 33.0 | 0.0 | 2→2.0 | 13.40 | 68.1 |
87
+ | xor | torch MLP, scaled | n/a | n/a | n/a | 8.34e-02 | 39.0 | 37.1 | 2→3.2 | 20.45 | 99.3 |
62
88
  | iris | C type-nn | 0.0248 | 0.0055 | 0.961 | 3.17e-03 | 120.0 | 45.6 | 3→4.0 | 0.38 | 0.6 |
63
89
  | iris | C type-nn-overfit | 0.0240 | 0.0053 | 0.961 | 8.43e-04 | 166.2 | 26.7 | 3→4.0 | 0.07 | 0.6 |
64
90
  | iris | C c-mlp | 0.0302 | 0.0052 | 0.956 | 1.24e-02 | 67.0 | 0.0 | 2→2.0 | 0.02 | 0.1 |
65
- | iris | torch ref-type-nn | 0.0331 | 0.0142 | 0.947 | 6.29e-03 | 144.6 | 27.0 | 3→4.0 | 226.46 | 496.2 |
66
- | iris | torch ref-type-nn-overfit | 0.0272 | 0.0034 | 0.956 | 8.28e-04 | 159.6 | 33.6 | 3→4.0 | 223.01 | 965.7 |
67
- | iris | **torch type-nn** | 0.0258 | 0.0019 | 0.956 | 6.23e-04 | 180.0 | 15.1 | 3→4.0 | 225.93 | 1105.1 |
68
- | iris | torch type-nn-bic | 0.0250 | 0.0062 | 0.964 | 1.37e-04 | 134.8 | 41.1 | 3→4.0 | 243.32 | 456.3 |
69
- | iris | torch MLP | 0.0309 | 0.0043 | 0.956 | 1.48e-02 | 67.0 | 0.0 | 2→2.0 | 41.09 | 65.9 |
70
- | iris | torch MLP, scaled | 0.0262 | 0.0044 | 0.956 | 6.08e-03 | 71.8 | 16.3 | 2→3.0 | 83.05 | 193.3 |
91
+ | iris | torch ref-type-nn | 0.0331 | 0.0142 | 0.947 | 6.29e-03 | 144.6 | 27.0 | 3→4.0 | 201.94 | 614.1 |
92
+ | iris | torch ref-type-nn-overfit | 0.0272 | 0.0034 | 0.956 | 8.28e-04 | 159.6 | 33.6 | 3→4.0 | 191.22 | 1070.9 |
93
+ | iris | **torch type-nn** | 0.0258 | 0.0019 | 0.956 | 6.23e-04 | 180.0 | 15.1 | 3→4.0 | 206.52 | 501.9 |
94
+ | iris | torch type-nn-bic | 0.0250 | 0.0062 | 0.964 | 1.37e-04 | 134.8 | 41.1 | 3→4.0 | 221.54 | 975.8 |
95
+ | iris | torch MLP | 0.0309 | 0.0043 | 0.956 | 1.48e-02 | 67.0 | 0.0 | 2→2.0 | 36.89 | 70.0 |
96
+ | iris | torch MLP, scaled | 0.0262 | 0.0044 | 0.956 | 6.08e-03 | 71.8 | 16.3 | 2→3.0 | 63.95 | 178.1 |
71
97
  | wine | C type-nn | 0.0241 | 0.0070 | 0.956 | 4.21e-04 | 183.2 | 62.2 | 4→5.1 | 0.52 | 0.5 |
72
98
  | wine | C type-nn-overfit | 0.0258 | 0.0099 | 0.954 | 2.94e-04 | 378.0 | 47.3 | 4→4.9 | 0.11 | 0.9 |
73
99
  | wine | C c-mlp | 0.0243 | 0.0042 | 0.970 | 2.68e-03 | 275.0 | 0.0 | 2→2.0 | 0.03 | 0.2 |
74
- | wine | torch ref-type-nn | 0.0198 | 0.0070 | 0.959 | 3.20e-05 | 214.6 | 34.6 | 4→5.0 | 249.18 | 589.4 |
75
- | wine | torch ref-type-nn-overfit | 0.0364 | 0.0107 | 0.933 | 2.72e-05 | 357.0 | 14.6 | 4→5.0 | 239.02 | 1400.0 |
76
- | wine | **torch type-nn** | 0.0189 | 0.0066 | 0.967 | 6.97e-05 | 486.2 | 15.5 | 4→5.0 | 241.50 | 579.0 |
77
- | wine | torch type-nn-bic | 0.0264 | 0.0072 | 0.952 | 4.31e-05 | 194.2 | 72.0 | 4→4.8 | 263.42 | 1204.3 |
78
- | wine | torch MLP | 0.0259 | 0.0032 | 0.956 | 3.87e-03 | 275.0 | 0.0 | 2→2.0 | 37.77 | 71.8 |
79
- | wine | torch MLP, scaled | 0.0177 | 0.0078 | 0.967 | 3.23e-04 | 124.6 | 32.7 | 2→3.0 | 70.93 | 176.3 |
100
+ | wine | torch ref-type-nn | 0.0198 | 0.0070 | 0.959 | 3.20e-05 | 214.6 | 34.6 | 4→5.0 | 236.12 | 602.9 |
101
+ | wine | torch ref-type-nn-overfit | 0.0364 | 0.0107 | 0.933 | 2.72e-05 | 357.0 | 14.6 | 4→5.0 | 239.31 | 592.6 |
102
+ | wine | **torch type-nn** | 0.0189 | 0.0066 | 0.967 | 6.97e-05 | 486.2 | 15.5 | 4→5.0 | 240.25 | 1301.7 |
103
+ | wine | torch type-nn-bic | 0.0264 | 0.0072 | 0.952 | 4.31e-05 | 194.2 | 72.0 | 4→4.8 | 220.96 | 359.4 |
104
+ | wine | torch MLP | 0.0259 | 0.0032 | 0.956 | 3.87e-03 | 275.0 | 0.0 | 2→2.0 | 39.39 | 144.4 |
105
+ | wine | torch MLP, scaled | 0.0177 | 0.0078 | 0.967 | 3.23e-04 | 124.6 | 32.7 | 2→3.0 | 71.08 | 107.6 |
80
106
  | wdbc | C type-nn | 0.0488 | 0.0089 | 0.946 | 2.07e-03 | 153.0 | 36.5 | 3→4.0 | 0.17 | 0.3 |
81
107
  | wdbc | C type-nn-overfit | 0.0472 | 0.0077 | 0.948 | 2.85e-03 | 176.6 | 40.5 | 3→3.4 | 0.06 | 0.2 |
82
108
  | wdbc | C c-mlp | 0.0459 | 0.0028 | 0.944 | 4.99e-03 | 513.0 | 0.0 | 2→2.0 | 0.09 | 0.3 |
83
- | wdbc | torch ref-type-nn | 0.0439 | 0.0056 | 0.952 | 4.88e-04 | 175.8 | 36.3 | 3→4.0 | 241.50 | 1055.6 |
84
- | wdbc | torch ref-type-nn-overfit | 0.0435 | 0.0059 | 0.950 | 5.14e-04 | 184.8 | 55.6 | 3→3.6 | 227.80 | 165.4 |
85
- | wdbc | **torch type-nn** | 0.0473 | 0.0037 | 0.949 | 4.94e-04 | 220.0 | 40.7 | 3→3.6 | 235.37 | 1032.9 |
86
- | wdbc | torch type-nn-bic | 0.0436 | 0.0052 | 0.950 | 1.64e-03 | 210.0 | 83.4 | 3→4.0 | 243.94 | 494.9 |
87
- | wdbc | torch MLP | 0.0471 | 0.0040 | 0.944 | 5.70e-03 | 513.0 | 0.0 | 2→2.0 | 31.36 | 25.5 |
88
- | wdbc | torch MLP, scaled | 0.0539 | 0.0079 | 0.943 | 1.84e-03 | 132.0 | 23.3 | 2→3.0 | 85.69 | 80.2 |
109
+ | wdbc | torch ref-type-nn | 0.0439 | 0.0056 | 0.952 | 4.88e-04 | 175.8 | 36.3 | 3→4.0 | 221.42 | 501.3 |
110
+ | wdbc | torch ref-type-nn-overfit | 0.0435 | 0.0059 | 0.950 | 5.14e-04 | 184.8 | 55.6 | 3→3.6 | 206.28 | 129.5 |
111
+ | wdbc | **torch type-nn** | 0.0473 | 0.0037 | 0.949 | 4.94e-04 | 220.0 | 40.7 | 3→3.6 | 230.46 | 480.6 |
112
+ | wdbc | torch type-nn-bic | 0.0436 | 0.0052 | 0.950 | 1.64e-03 | 210.0 | 83.4 | 3→4.0 | 238.39 | 479.6 |
113
+ | wdbc | torch MLP | 0.0471 | 0.0040 | 0.944 | 5.70e-03 | 513.0 | 0.0 | 2→2.0 | 35.73 | 23.4 |
114
+ | wdbc | torch MLP, scaled | 0.0539 | 0.0079 | 0.943 | 1.84e-03 | 132.0 | 23.3 | 2→3.0 | 91.83 | 85.3 |
89
115
  | diabetes | C type-nn | 0.0331 | 0.0014 | n/a | 2.72e-02 | 20.1 | 5.5 | 2→2.5 | 0.06 | 0.1 |
90
116
  | diabetes | C type-nn-overfit | 0.0374 | 0.0027 | n/a | 2.41e-02 | 33.0 | 9.9 | 2→2.5 | 0.03 | 0.1 |
91
117
  | diabetes | C c-mlp | 0.0476 | 0.0038 | n/a | 1.38e-02 | 193.0 | 0.0 | 2→2.0 | 0.04 | 0.2 |
92
- | diabetes | torch ref-type-nn | 0.0328 | 0.0005 | n/a | 2.73e-02 | 18.6 | 4.9 | 2→2.2 | 263.32 | 547.7 |
93
- | diabetes | torch ref-type-nn-overfit | 0.0366 | 0.0030 | n/a | 2.43e-02 | 31.8 | 7.8 | 2→2.4 | 264.63 | 247.2 |
94
- | diabetes | **torch type-nn** | 0.0501 | 0.0145 | n/a | 1.75e-02 | 100.0 | 42.6 | 2→3.0 | 311.33 | 367.8 |
95
- | diabetes | torch type-nn-bic | 0.0330 | 0.0006 | n/a | 2.78e-02 | 18.0 | 2.1 | 2→2.6 | 288.10 | 503.3 |
96
- | diabetes | torch MLP | 0.0478 | 0.0038 | n/a | 1.47e-02 | 193.0 | 0.0 | 2→2.0 | 71.59 | 33.9 |
97
- | diabetes | torch MLP, scaled | 0.0410 | 0.0017 | n/a | 2.05e-02 | 61.6 | 10.3 | 2→3.0 | 137.15 | 142.8 |
118
+ | diabetes | torch ref-type-nn | 0.0328 | 0.0005 | n/a | 2.73e-02 | 18.6 | 4.9 | 2→2.2 | 273.17 | 501.6 |
119
+ | diabetes | torch ref-type-nn-overfit | 0.0366 | 0.0030 | n/a | 2.43e-02 | 31.8 | 7.8 | 2→2.4 | 261.55 | 261.2 |
120
+ | diabetes | **torch type-nn** | 0.0501 | 0.0145 | n/a | 1.75e-02 | 100.0 | 42.6 | 2→3.0 | 244.53 | 788.5 |
121
+ | diabetes | torch type-nn-bic | 0.0330 | 0.0006 | n/a | 2.78e-02 | 18.0 | 2.1 | 2→2.6 | 251.05 | 161.2 |
122
+ | diabetes | torch MLP | 0.0478 | 0.0038 | n/a | 1.47e-02 | 193.0 | 0.0 | 2→2.0 | 69.91 | 32.2 |
123
+ | diabetes | torch MLP, scaled | 0.0410 | 0.0017 | n/a | 2.05e-02 | 61.6 | 10.3 | 2→3.0 | 134.33 | 82.6 |
98
124
  | ionosphere | C type-nn | 0.0932 | 0.0166 | 0.895 | 1.22e-02 | 146.4 | 60.1 | 4→4.8 | 0.23 | 0.5 |
99
125
  | ionosphere | C type-nn-overfit | 0.0811 | 0.0183 | 0.911 | 2.35e-03 | 336.9 | 78.6 | 4→4.4 | 0.10 | 1.0 |
100
126
  | ionosphere | C c-mlp | 0.1412 | 0.0172 | 0.899 | 1.59e-02 | 577.0 | 0.0 | 2→2.0 | 0.07 | 0.4 |
101
- | ionosphere | torch ref-type-nn | 0.0919 | 0.0212 | 0.900 | 7.40e-03 | 157.2 | 59.2 | 4→5.0 | 275.86 | 612.0 |
102
- | ionosphere | torch ref-type-nn-overfit | 0.0899 | 0.0199 | 0.898 | 1.61e-03 | 319.6 | 71.2 | 4→4.6 | 263.69 | 570.3 |
103
- | ionosphere | **torch type-nn** | 0.0854 | 0.0209 | 0.909 | 7.06e-04 | 389.6 | 66.3 | 4→4.8 | 263.67 | 1315.4 |
104
- | ionosphere | torch type-nn-bic | 0.0837 | 0.0137 | 0.909 | 5.08e-03 | 212.8 | 26.7 | 4→4.8 | 280.34 | 474.0 |
105
- | ionosphere | torch MLP | 0.1356 | 0.0128 | 0.908 | 1.57e-02 | 577.0 | 0.0 | 2→2.0 | 46.46 | 66.3 |
106
- | ionosphere | torch MLP, scaled | 0.1149 | 0.0224 | 0.887 | 8.43e-03 | 167.8 | 17.1 | 2→3.0 | 82.35 | 88.1 |
127
+ | ionosphere | torch ref-type-nn | 0.0919 | 0.0212 | 0.900 | 7.40e-03 | 157.2 | 59.2 | 4→5.0 | 261.99 | 629.1 |
128
+ | ionosphere | torch ref-type-nn-overfit | 0.0899 | 0.0199 | 0.898 | 1.61e-03 | 319.6 | 71.2 | 4→4.6 | 243.87 | 880.4 |
129
+ | ionosphere | **torch type-nn** | 0.0854 | 0.0209 | 0.909 | 7.06e-04 | 389.6 | 66.3 | 4→4.8 | 233.66 | 1876.2 |
130
+ | ionosphere | torch type-nn-bic | 0.0837 | 0.0137 | 0.909 | 5.08e-03 | 212.8 | 26.7 | 4→4.8 | 272.71 | 1002.3 |
131
+ | ionosphere | torch MLP | 0.1356 | 0.0128 | 0.908 | 1.57e-02 | 577.0 | 0.0 | 2→2.0 | 46.17 | 122.2 |
132
+ | ionosphere | torch MLP, scaled | 0.1149 | 0.0224 | 0.887 | 8.43e-03 | 167.8 | 17.1 | 2→3.0 | 81.57 | 108.7 |
107
133
  <!-- /board:per-sample -->
108
134
 
109
135
  ### Is the port faithful?
@@ -201,23 +227,25 @@ type-nn, stock Adam otherwise), 5 seeds, the same 70/30 xorshift split.
201
227
 
202
228
  The type-nn and scaled-MLP models are built by the same constructor as the
203
229
  per-sample board (`bench.build`); MLP-16 and MLP-64 are fixed one-hidden-layer
204
- MLPs.
230
+ MLPs. `c-type-nn` and `c-type-nn-overfit` use NativeTypeNN's per-sample C
231
+ epoch on these tasks too (batch size 1, not 32). CUDA rows live on
232
+ [BOARD.CUDA.md](BOARD.CUDA.md).
205
233
 
206
234
  <!-- board:scale -->
207
235
  Generated by `benchmarks/board.py` from `benchmarks/results/scale-batch32.jsonl` (5 seeds, batch 32, cpu).
208
236
 
209
237
  | task | model | hold MSE | ± sd | × noise floor | hold acc | train MSE | params | layers | train s |
210
238
  |---|---|---:|---:|---:|---:|---:|---:|---:|---:|
211
- | digits | **type-nn** | 0.00620 | 0.00131 | n/a | 0.963 | 0.00023 | 5509 | 7.0 | 38.0 |
212
- | digits | type-nn-bic | 0.00696 | 0.00028 | n/a | 0.957 | 0.00014 | 3352 | 7.0 | 202.5 |
213
- | digits | MLP, scaled | 0.00779 | 0.00053 | n/a | 0.964 | 0.00170 | 1323 | 3.0 | 9.0 |
214
- | digits | MLP-16 | 0.01110 | 0.00074 | n/a | 0.959 | 0.00490 | 1210 | 2.0 | 3.7 |
215
- | digits | MLP-64 | 0.01089 | 0.00022 | n/a | 0.974 | 0.00343 | 4810 | 2.0 | 4.7 |
216
- | friedman | **type-nn** | 0.00660 | 0.00037 | 6.65 | n/a | 0.00666 | 18 | 2.0 | 211.7 |
217
- | friedman | type-nn-bic | 0.00195 | 0.00089 | 1.97 | n/a | 0.00194 | 80 | 3.0 | 254.0 |
218
- | friedman | MLP, scaled | 0.01377 | 0.01039 | 13.88 | n/a | 0.01362 | 17 | 2.6 | 93.0 |
219
- | friedman | MLP-16 | 0.00121 | 0.00013 | 1.22 | n/a | 0.00118 | 193 | 2.0 | 56.3 |
220
- | friedman | MLP-64 | 0.00114 | 0.00005 | 1.15 | n/a | 0.00110 | 769 | 2.0 | 43.2 |
239
+ | digits | **type-nn** | 0.00620 | 0.00131 | n/a | 0.963 | 0.00023 | 5509 | 7.0 | 32.1 |
240
+ | digits | type-nn-bic | 0.00696 | 0.00028 | n/a | 0.957 | 0.00014 | 3352 | 7.0 | 221.1 |
241
+ | digits | MLP, scaled | 0.00779 | 0.00053 | n/a | 0.964 | 0.00170 | 1323 | 3.0 | 8.5 |
242
+ | digits | MLP-16 | 0.01110 | 0.00074 | n/a | 0.959 | 0.00490 | 1210 | 2.0 | 4.1 |
243
+ | digits | MLP-64 | 0.01089 | 0.00022 | n/a | 0.974 | 0.00343 | 4810 | 2.0 | 5.4 |
244
+ | friedman | **type-nn** | 0.00660 | 0.00037 | 6.65 | n/a | 0.00666 | 18 | 2.0 | 217.7 |
245
+ | friedman | type-nn-bic | 0.00195 | 0.00089 | 1.97 | n/a | 0.00194 | 80 | 3.0 | 243.6 |
246
+ | friedman | MLP, scaled | 0.01377 | 0.01039 | 13.88 | n/a | 0.01362 | 17 | 2.6 | 96.7 |
247
+ | friedman | MLP-16 | 0.00121 | 0.00013 | 1.22 | n/a | 0.00118 | 193 | 2.0 | 48.1 |
248
+ | friedman | MLP-64 | 0.00114 | 0.00005 | 1.15 | n/a | 0.00110 | 769 | 2.0 | 34.8 |
221
249
 
222
250
  friedman: noise floor (best reachable hold-out MSE, `1 / span²`) = 0.00099
223
251
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: torch-type-nn
3
- Version: 0.1.0.dev0
3
+ Version: 0.1.1.dev0
4
4
  Summary: type-nn for PyTorch: networks of partition functions (And of Ors) that grow and prune their own width, degree and depth
5
5
  Project-URL: Homepage, https://github.com/hadilq/torch-type-nn
6
6
  Project-URL: Repository, https://github.com/hadilq/torch-type-nn
@@ -34,7 +34,7 @@ grows and prunes its own width, degree and depth while it trains. The
34
34
  design is explained in
35
35
  [Train the knowledge](https://hadilq.com/posts/train-the-knowledge/).
36
36
 
37
- > Status: alpha (0.1.0.dev0). Forward, gradients and the per-Or Adam step
37
+ > Status: alpha (0.1.1.dev0). Forward, gradients and the per-Or Adam step
38
38
  > agree with the C reference to 1e-12, and both C scaling rules have exact
39
39
  > ports on the board (see [Validation](#validation)). Deliberate differences
40
40
  > from C are listed in [docs/DIFFERENCES.md](https://github.com/hadilq/torch-type-nn/blob/main/docs/DIFFERENCES.md); the audit
@@ -74,6 +74,34 @@ for epoch in range(E):
74
74
  scaler.end() # last prune; no probe survives
75
75
  ```
76
76
 
77
+ ### C backend (board rows "C type-nn" / "C type-nn-overfit")
78
+
79
+ The torch `AndOr` pads every unit to max degree. C keeps one `w[n_in]` per
80
+ live Or. Those models are `NativeTypeNN`, and they are what the board
81
+ calls **C type-nn** and **C type-nn-overfit**:
82
+
83
+ ```python
84
+ from torch_type_nn import NativeTypeNN
85
+ net = NativeTypeNN(4, 3, rule="threshold") # C type-nn-overfit
86
+ # net = NativeTypeNN(4, 3, rule="bic") # C type-nn
87
+ ```
88
+
89
+ ```sh
90
+ python benchmarks/bench.py iris c-type-nn,c-type-nn-overfit
91
+ ```
92
+
93
+ `CudaTypeNN` is the same ragged layout packed for a fused GEMM on a torch
94
+ device (CUDA when present). Board models `cuda-type-nn` /
95
+ `cuda-type-nn-overfit`:
96
+
97
+ ```sh
98
+ python benchmarks/bench.py xor cuda-type-nn,cuda-type-nn-overfit --device cuda
99
+ ```
100
+
101
+ `nix flake check -L` prints `torch-type-nn device: …` from pytest so a
102
+ GPU run cannot look green without saying which device it used. See
103
+ [docs/BACKENDS.md](docs/BACKENDS.md).
104
+
77
105
  ## Structure learning
78
106
 
79
107
  One dummy rule on three axes. A **probe** is an identity that back-prop is
@@ -184,7 +212,8 @@ Two independent checks against [hadilq/type-nn](https://github.com/hadilq/type-n
184
212
  writes every table of [BOARD.md](https://github.com/hadilq/torch-type-nn/blob/main/BOARD.md) from the result files.
185
213
 
186
214
  ```sh
187
- nix run .#board-all # every result on all cores, then BOARD.md's tables
215
+ nix run .#board-all # CPU board + scale (now includes C type-nn rows)
216
+ nix run .#board-cuda # CUDA board → BOARD.CUDA.md (host GPU; see below)
188
217
  ```
189
218
 
190
219
  ## Development
@@ -201,8 +230,17 @@ nix flake check # build the package, run pytest inside the build (with th
201
230
  nix build # ./result: the installed package
202
231
  nix run .#dist # sdist + wheel in ./dist, checked by twine
203
232
  nix run .#publish -- --repository testpypi # upload (TestPyPI first)
233
+ nix run .#update-deps # VERSIONS.md; bump patch + PR inputs if a pin moved
204
234
  ```
205
235
 
236
+ `nix run .#update-deps -- --pr` pushes `deps/update` and opens the PR (needs
237
+ `gh` and `GH_TOKEN`). The same command is the daily cron in
238
+ [`.github/workflows/update-deps.yml`](.github/workflows/update-deps.yml).
239
+ Pins and the resolved nixpkgs versions are in [VERSIONS.md](VERSIONS.md).
240
+ A type-nn rev change copies the vendored C snapshot only (`tnn_py.c` /
241
+ `tnn_py.h` stay); the Python port is not rewritten.
242
+
243
+
206
244
  The benchmark datasets are pinned (URL + SRI hash) in
207
245
  `benchmarks/datasets.json` and never committed; see
208
246
  [benchmarks/data/README.md](https://github.com/hadilq/torch-type-nn/blob/main/benchmarks/data/README.md).
@@ -224,6 +262,7 @@ nix flake check --impure # adds checks.cuda when /dev/nvidiactl exists
224
262
  TORCH_TYPE_NN_CUDA=1 nix flake check --impure # force it (=0: leave it out)
225
263
  nix develop .#cuda # torch-bin (CUDA 13.0) shell
226
264
  nix run .#bench-cuda -- all all --seeds 5 --device cuda
265
+ nix run .#board-cuda # writes BOARD.CUDA.md from device runs
227
266
  ```
228
267
 
229
268
  A plain `nix flake check` is a pure evaluation, which cannot see the host, so
@@ -265,37 +304,7 @@ path that may be missing). With several GPUs add `/dev/nvidia1`, ... Check with
265
304
 
266
305
  ## Publishing
267
306
 
268
- Releases go to PyPI from GitHub Actions with trusted publishing
269
- (`.github/workflows/publish.yml`): no API token is stored anywhere.
270
-
271
- One-time setup, on PyPI → *Your account* → *Publishing* → *Add a new pending
272
- publisher* → *GitHub*:
273
-
274
- | field | value |
275
- |---|---|
276
- | PyPI Project Name | `torch-type-nn` |
277
- | Owner | `hadilq` |
278
- | Repository name | `torch-type-nn` |
279
- | Workflow name | `publish.yml` |
280
- | Environment name | `pypi` |
281
-
282
- For TestPyPI, the same on test.pypi.org (a separate account) with environment
283
- `testpypi`. GitHub creates both environments on first use; add protection
284
- rules (e.g. required reviewers) under *Settings → Environments* if wanted.
285
-
286
- Release:
287
-
288
- ```sh
289
- # 1. set the version in pyproject.toml (e.g. 0.1.0), commit, push
290
- # 2. rehearse: Actions → publish → Run workflow → testpypi
291
- # 3. release: the tag must equal the version
292
- git tag v0.1.0 && git push origin v0.1.0
293
- ```
294
-
295
- The workflow builds the sdist and wheel, runs the test-suite against the
296
- built wheel (CPU torch), and only then uploads. Locally, `nix run .#dist`
297
- builds and checks the same files; `nix run .#publish` uploads them with
298
- twine and a token.
307
+ It's in development state, but you can use download it from PyPI [here](https://pypi.org/project/torch-type-nn/).
299
308
 
300
309
  ## License
301
310
 
@@ -6,7 +6,7 @@ grows and prunes its own width, degree and depth while it trains. The
6
6
  design is explained in
7
7
  [Train the knowledge](https://hadilq.com/posts/train-the-knowledge/).
8
8
 
9
- > Status: alpha (0.1.0.dev0). Forward, gradients and the per-Or Adam step
9
+ > Status: alpha (0.1.1.dev0). Forward, gradients and the per-Or Adam step
10
10
  > agree with the C reference to 1e-12, and both C scaling rules have exact
11
11
  > ports on the board (see [Validation](#validation)). Deliberate differences
12
12
  > from C are listed in [docs/DIFFERENCES.md](https://github.com/hadilq/torch-type-nn/blob/main/docs/DIFFERENCES.md); the audit
@@ -46,6 +46,34 @@ for epoch in range(E):
46
46
  scaler.end() # last prune; no probe survives
47
47
  ```
48
48
 
49
+ ### C backend (board rows "C type-nn" / "C type-nn-overfit")
50
+
51
+ The torch `AndOr` pads every unit to max degree. C keeps one `w[n_in]` per
52
+ live Or. Those models are `NativeTypeNN`, and they are what the board
53
+ calls **C type-nn** and **C type-nn-overfit**:
54
+
55
+ ```python
56
+ from torch_type_nn import NativeTypeNN
57
+ net = NativeTypeNN(4, 3, rule="threshold") # C type-nn-overfit
58
+ # net = NativeTypeNN(4, 3, rule="bic") # C type-nn
59
+ ```
60
+
61
+ ```sh
62
+ python benchmarks/bench.py iris c-type-nn,c-type-nn-overfit
63
+ ```
64
+
65
+ `CudaTypeNN` is the same ragged layout packed for a fused GEMM on a torch
66
+ device (CUDA when present). Board models `cuda-type-nn` /
67
+ `cuda-type-nn-overfit`:
68
+
69
+ ```sh
70
+ python benchmarks/bench.py xor cuda-type-nn,cuda-type-nn-overfit --device cuda
71
+ ```
72
+
73
+ `nix flake check -L` prints `torch-type-nn device: …` from pytest so a
74
+ GPU run cannot look green without saying which device it used. See
75
+ [docs/BACKENDS.md](docs/BACKENDS.md).
76
+
49
77
  ## Structure learning
50
78
 
51
79
  One dummy rule on three axes. A **probe** is an identity that back-prop is
@@ -156,7 +184,8 @@ Two independent checks against [hadilq/type-nn](https://github.com/hadilq/type-n
156
184
  writes every table of [BOARD.md](https://github.com/hadilq/torch-type-nn/blob/main/BOARD.md) from the result files.
157
185
 
158
186
  ```sh
159
- nix run .#board-all # every result on all cores, then BOARD.md's tables
187
+ nix run .#board-all # CPU board + scale (now includes C type-nn rows)
188
+ nix run .#board-cuda # CUDA board → BOARD.CUDA.md (host GPU; see below)
160
189
  ```
161
190
 
162
191
  ## Development
@@ -173,8 +202,17 @@ nix flake check # build the package, run pytest inside the build (with th
173
202
  nix build # ./result: the installed package
174
203
  nix run .#dist # sdist + wheel in ./dist, checked by twine
175
204
  nix run .#publish -- --repository testpypi # upload (TestPyPI first)
205
+ nix run .#update-deps # VERSIONS.md; bump patch + PR inputs if a pin moved
176
206
  ```
177
207
 
208
+ `nix run .#update-deps -- --pr` pushes `deps/update` and opens the PR (needs
209
+ `gh` and `GH_TOKEN`). The same command is the daily cron in
210
+ [`.github/workflows/update-deps.yml`](.github/workflows/update-deps.yml).
211
+ Pins and the resolved nixpkgs versions are in [VERSIONS.md](VERSIONS.md).
212
+ A type-nn rev change copies the vendored C snapshot only (`tnn_py.c` /
213
+ `tnn_py.h` stay); the Python port is not rewritten.
214
+
215
+
178
216
  The benchmark datasets are pinned (URL + SRI hash) in
179
217
  `benchmarks/datasets.json` and never committed; see
180
218
  [benchmarks/data/README.md](https://github.com/hadilq/torch-type-nn/blob/main/benchmarks/data/README.md).
@@ -196,6 +234,7 @@ nix flake check --impure # adds checks.cuda when /dev/nvidiactl exists
196
234
  TORCH_TYPE_NN_CUDA=1 nix flake check --impure # force it (=0: leave it out)
197
235
  nix develop .#cuda # torch-bin (CUDA 13.0) shell
198
236
  nix run .#bench-cuda -- all all --seeds 5 --device cuda
237
+ nix run .#board-cuda # writes BOARD.CUDA.md from device runs
199
238
  ```
200
239
 
201
240
  A plain `nix flake check` is a pure evaluation, which cannot see the host, so
@@ -237,37 +276,7 @@ path that may be missing). With several GPUs add `/dev/nvidia1`, ... Check with
237
276
 
238
277
  ## Publishing
239
278
 
240
- Releases go to PyPI from GitHub Actions with trusted publishing
241
- (`.github/workflows/publish.yml`): no API token is stored anywhere.
242
-
243
- One-time setup, on PyPI → *Your account* → *Publishing* → *Add a new pending
244
- publisher* → *GitHub*:
245
-
246
- | field | value |
247
- |---|---|
248
- | PyPI Project Name | `torch-type-nn` |
249
- | Owner | `hadilq` |
250
- | Repository name | `torch-type-nn` |
251
- | Workflow name | `publish.yml` |
252
- | Environment name | `pypi` |
253
-
254
- For TestPyPI, the same on test.pypi.org (a separate account) with environment
255
- `testpypi`. GitHub creates both environments on first use; add protection
256
- rules (e.g. required reviewers) under *Settings → Environments* if wanted.
257
-
258
- Release:
259
-
260
- ```sh
261
- # 1. set the version in pyproject.toml (e.g. 0.1.0), commit, push
262
- # 2. rehearse: Actions → publish → Run workflow → testpypi
263
- # 3. release: the tag must equal the version
264
- git tag v0.1.0 && git push origin v0.1.0
265
- ```
266
-
267
- The workflow builds the sdist and wheel, runs the test-suite against the
268
- built wheel (CPU torch), and only then uploads. Locally, `nix run .#dist`
269
- builds and checks the same files; `nix run .#publish` uploads them with
270
- twine and a token.
279
+ It's in development state, but you can use download it from PyPI [here](https://pypi.org/project/torch-type-nn/).
271
280
 
272
281
  ## License
273
282