CharlesCNorton commited on
Commit
e84332b
·
1 Parent(s): 719dc06

Self-consistent .inputs metadata across all variants

Browse files

build.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 CHANGED
@@ -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
neural_computer.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a4333d8f1ea13945e129711733b7f79e96a9d876f40342db1e1634fdd2d85056
3
- size 27674339
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a31e80d4082083011e40c0e796f305fc2cdddc53d1aa5ddaac11203d3e29b184
3
+ size 30014338
variants/neural_alu16.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e4bb673798d1e81b4717907d1b352e72e084c31bc7e29a4a7d57a976234ee5f2
3
- size 20543560
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:815d081c48fa191975c9a8c468253ad0ec9b64c816c61ce2ea56ec2aaa346e75
3
+ size 23186487
variants/neural_alu32.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e00da59527751140f4ab49cb23c08625f42ff2dd58edfc986d8227beb0861ef7
3
- size 19144181
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0555f2b2a28789283be1135ee9640bd0dabba36b6092c6b0d22534d11f22f59
3
+ size 21481972
variants/neural_alu8.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cf695c9047ff59cc0aed1b541f49b22d0820f474d38790496b9118551393c628
3
- size 18974877
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef24ff84edeede9924be151229e6707f8e753ee97bd61d6f70bdc8b7a3b61268
3
+ size 21481972
variants/neural_computer16.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d3aba5acdd2e5c177e3517f75a3e2adbc24873e1152d9e588ae8a542a2b14e2b
3
- size 29055270
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0be7a2322fc4521c6edb0b49b6e43b7f2b3224206671b02d72f810e6f54085c
3
+ size 31699317
variants/neural_computer16_reduced.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f1c8de07c243b19cd997dcedddf6b9e916d1ac316c8e468d5538b0eda7f7d3c9
3
- size 21244574
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c481832e71e302d3545b0647c2cc729233ab2ee406ec6792f60b0edcaf7a9dc5
3
+ size 23885733
variants/neural_computer16_registers.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:97918a5d3239178a7568a96b4e895bbd29feb8e3e41726baff62bacf00a1e5de
3
- size 20630294
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8d9fbed6eadc00647cae5608bd41c8cc7b59c3a2d79a391098b7fa95d039955
3
+ size 23277069
variants/neural_computer16_scratchpad.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:05d26708a1ae548a6e46d73e444022af911dfe8bba43313dddf135be6f2ee618
3
- size 20710790
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20fa2c26fecc7617b7ac11fbc1d3bfa515675c400c2da1a697f05ddafbbd552c
3
+ size 23360685
variants/neural_computer16_small.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7185ef10e5639e7cce6f5a91dc604872c4bb4740be6f1125a71b981225bcf3ad
3
- size 20829606
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f3c141cf9c5a6f30d63988163f508646c9e4775d0ad71103a387608e398fad5
3
+ size 23480981
variants/neural_computer32.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a4333d8f1ea13945e129711733b7f79e96a9d876f40342db1e1634fdd2d85056
3
- size 27674339
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a31e80d4082083011e40c0e796f305fc2cdddc53d1aa5ddaac11203d3e29b184
3
+ size 30014338
variants/neural_computer32_reduced.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3521e0322363c3d55966810bda3efbf11ba0dd338f94ddee3128e15df6f05fa1
3
- size 19863635
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10b8c1ac6b65a594393db10ac24f95fab6fee28502ebbbee347c41c91a8d2e1c
3
+ size 22200754
variants/neural_computer32_registers.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bebf86dc5d383c10f069127d2dd10a045590c401df8d61fd8b160e4cb7dfc0d8
3
- size 19249315
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c007252baa6da9c0c1b8fb0116a67b4eb407001a2b732b5a25f1aa20c4744e0
3
+ size 21592090
variants/neural_computer32_scratchpad.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc140be67469b1eea6080081a3ed413a4a7f995fcf0db98bc16a885561b1b7cf
3
- size 19329827
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c61ddcdb47e168aaf4b2e9017a6305abc287a8ea9058d8c2f2ecf0b1f0865bd
3
+ size 21675698
variants/neural_computer32_small.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1a5f9964c7c6470495a1982ebfe60f8ba76a60f18fd9a84fedbdefc52f619963
3
- size 19448667
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daeb03f7038115da739271bb562eed10d9d8f44e48d2c58c9f6fe62f573e96ef
3
+ size 21795994
variants/neural_computer8.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f6f90ec62fa9b95de0740b4532872cf287986636f0ae53f2d8681ab4bbd4250b
3
- size 27477411
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebdafe51c7224274a3c5cf51a2888b0949184ab35893e5a6e60dcd6a0481feba
3
+ size 29985178
variants/neural_computer8_reduced.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b4d6c5f20b3f292ca725e4b0101b83d351b6018a82884b4283b648acddc0d7aa
3
- size 19666683
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ad4e5bc84a99049dee316dca3258498ac7e71f01101d14ff0c5d656ed11ad3a
3
+ size 22171594
variants/neural_computer8_registers.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7ecced984c18842e8b69e57dfc4e033780f6f1d72af8df33bffa784d648e0168
3
- size 19052491
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb5e3e89ac86dbb41eeeb72909a9ad53b4c4203057b60941e408dafc2e0a9091
3
+ size 21562930
variants/neural_computer8_scratchpad.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:945d2e44f7527dc71342baf80402ae6c538d5ae5ec0a65107ebe9bc560f4794e
3
- size 19133083
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2bc37c428b857e14a6e18102f27f47855ed1f1a9736f746b5ea99e5129b094f
3
+ size 21646546
variants/neural_computer8_small.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6b6f18efce73b5c4df27e8e60928a971a717374905b3036fff7ae5158af53271
3
- size 19251795
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f2f383d39dc1317b81241c8af0b98331dd7c51f5977a62853ca03a38f1e1e66
3
+ size 21766842