Self-consistent .inputs metadata across all variants
Browse filesbuild.py: cmd_inputs always pads or trims the inferred input list to
match the gate's weight fan-in. Pattern matchers in
infer_inputs_for_gate cover most circuit families, but a few seed-file
families (arithmetic.expr_paren.mul, arithmetic.multiplier8x8,
alu.alu32bit.div, etc.) still produce wrong-length lists; those now
get anonymous gate-local placeholders so .inputs is always
self-consistent with .weight.
build.py: cmd_inputs drops every pre-existing single-gate .inputs
tensor before regenerating, since signal IDs are session-local and
any prior IDs reference stale registry entries. Packed multi-gate
tensors (weight.dim() > 1) are left untouched.
build_all.py: re-runs `build.py inputs` after each per-variant quantize
step, so routing metadata reflects the gates that --ternary adds
(modular detectors gain ~3000 new gates per variant).
After this pass and a fresh quantize --ternary across variants/ + the
canonical, the safetensors2verilog converter reports zero stale
.inputs gates on neural_alu8.safetensors. All 18 variants still pass
eval_all.py at 100% fitness.
- build.py +18 -0
- neural_computer.safetensors +2 -2
- variants/neural_alu16.safetensors +2 -2
- variants/neural_alu32.safetensors +2 -2
- variants/neural_alu8.safetensors +2 -2
- variants/neural_computer16.safetensors +2 -2
- variants/neural_computer16_reduced.safetensors +2 -2
- variants/neural_computer16_registers.safetensors +2 -2
- variants/neural_computer16_scratchpad.safetensors +2 -2
- variants/neural_computer16_small.safetensors +2 -2
- variants/neural_computer32.safetensors +2 -2
- variants/neural_computer32_reduced.safetensors +2 -2
- variants/neural_computer32_registers.safetensors +2 -2
- variants/neural_computer32_scratchpad.safetensors +2 -2
- variants/neural_computer32_small.safetensors +2 -2
- variants/neural_computer8.safetensors +2 -2
- variants/neural_computer8_reduced.safetensors +2 -2
- variants/neural_computer8_registers.safetensors +2 -2
- variants/neural_computer8_scratchpad.safetensors +2 -2
- variants/neural_computer8_small.safetensors +2 -2
|
@@ -2998,10 +2998,28 @@ def build_inputs(tensors: Dict[str, torch.Tensor]) -> tuple[Dict[str, torch.Tens
|
|
| 2998 |
|
| 2999 |
for gate in sorted(gates):
|
| 3000 |
inputs_key = f"{gate}.inputs"
|
|
|
|
| 3001 |
if inputs_key in tensors:
|
| 3002 |
stats["skipped"] += 1
|
| 3003 |
continue
|
| 3004 |
inputs = infer_inputs_for_gate(gate, reg, tensors)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3005 |
if inputs:
|
| 3006 |
tensors[inputs_key] = torch.tensor(inputs, dtype=torch.int64)
|
| 3007 |
stats["added"] += 1
|
|
|
|
| 2998 |
|
| 2999 |
for gate in sorted(gates):
|
| 3000 |
inputs_key = f"{gate}.inputs"
|
| 3001 |
+
weight_key = f"{gate}.weight"
|
| 3002 |
if inputs_key in tensors:
|
| 3003 |
stats["skipped"] += 1
|
| 3004 |
continue
|
| 3005 |
inputs = infer_inputs_for_gate(gate, reg, tensors)
|
| 3006 |
+
|
| 3007 |
+
# Make .inputs length match the gate's weight fan-in. Pattern matchers
|
| 3008 |
+
# in infer_inputs_for_gate cover most circuit families, but some
|
| 3009 |
+
# seed-file gate families fall through and produce wrong-length lists.
|
| 3010 |
+
# Pad with anonymous gate-local placeholder signals (or trim to the
|
| 3011 |
+
# weight count) so downstream tools see consistent metadata.
|
| 3012 |
+
weight = tensors.get(weight_key)
|
| 3013 |
+
if weight is not None and weight.dim() == 1:
|
| 3014 |
+
expected = weight.numel()
|
| 3015 |
+
if len(inputs) > expected:
|
| 3016 |
+
inputs = inputs[:expected]
|
| 3017 |
+
stats["regenerated"] = stats.get("regenerated", 0) + 1
|
| 3018 |
+
elif len(inputs) < expected:
|
| 3019 |
+
for k in range(len(inputs), expected):
|
| 3020 |
+
inputs.append(reg.register(f"{gate}.in{k}"))
|
| 3021 |
+
stats["regenerated"] = stats.get("regenerated", 0) + 1
|
| 3022 |
+
|
| 3023 |
if inputs:
|
| 3024 |
tensors[inputs_key] = torch.tensor(inputs, dtype=torch.int64)
|
| 3025 |
stats["added"] += 1
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a31e80d4082083011e40c0e796f305fc2cdddc53d1aa5ddaac11203d3e29b184
|
| 3 |
+
size 30014338
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:815d081c48fa191975c9a8c468253ad0ec9b64c816c61ce2ea56ec2aaa346e75
|
| 3 |
+
size 23186487
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0555f2b2a28789283be1135ee9640bd0dabba36b6092c6b0d22534d11f22f59
|
| 3 |
+
size 21481972
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef24ff84edeede9924be151229e6707f8e753ee97bd61d6f70bdc8b7a3b61268
|
| 3 |
+
size 21481972
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0be7a2322fc4521c6edb0b49b6e43b7f2b3224206671b02d72f810e6f54085c
|
| 3 |
+
size 31699317
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c481832e71e302d3545b0647c2cc729233ab2ee406ec6792f60b0edcaf7a9dc5
|
| 3 |
+
size 23885733
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8d9fbed6eadc00647cae5608bd41c8cc7b59c3a2d79a391098b7fa95d039955
|
| 3 |
+
size 23277069
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20fa2c26fecc7617b7ac11fbc1d3bfa515675c400c2da1a697f05ddafbbd552c
|
| 3 |
+
size 23360685
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f3c141cf9c5a6f30d63988163f508646c9e4775d0ad71103a387608e398fad5
|
| 3 |
+
size 23480981
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a31e80d4082083011e40c0e796f305fc2cdddc53d1aa5ddaac11203d3e29b184
|
| 3 |
+
size 30014338
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10b8c1ac6b65a594393db10ac24f95fab6fee28502ebbbee347c41c91a8d2e1c
|
| 3 |
+
size 22200754
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c007252baa6da9c0c1b8fb0116a67b4eb407001a2b732b5a25f1aa20c4744e0
|
| 3 |
+
size 21592090
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c61ddcdb47e168aaf4b2e9017a6305abc287a8ea9058d8c2f2ecf0b1f0865bd
|
| 3 |
+
size 21675698
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:daeb03f7038115da739271bb562eed10d9d8f44e48d2c58c9f6fe62f573e96ef
|
| 3 |
+
size 21795994
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ebdafe51c7224274a3c5cf51a2888b0949184ab35893e5a6e60dcd6a0481feba
|
| 3 |
+
size 29985178
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ad4e5bc84a99049dee316dca3258498ac7e71f01101d14ff0c5d656ed11ad3a
|
| 3 |
+
size 22171594
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cb5e3e89ac86dbb41eeeb72909a9ad53b4c4203057b60941e408dafc2e0a9091
|
| 3 |
+
size 21562930
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2bc37c428b857e14a6e18102f27f47855ed1f1a9736f746b5ea99e5129b094f
|
| 3 |
+
size 21646546
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f2f383d39dc1317b81241c8af0b98331dd7c51f5977a62853ca03a38f1e1e66
|
| 3 |
+
size 21766842
|