phanerozoic commited on
Commit
8406206
·
verified ·
1 Parent(s): 75094e2

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +16 -0
  2. config.json +9 -0
  3. create_safetensors.py +30 -0
  4. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - pytorch
5
+ - safetensors
6
+ - threshold-logic
7
+ - neuromorphic
8
+ ---
9
+
10
+ # threshold-fp-add
11
+
12
+ fp-add threshold logic implementation.
13
+
14
+ ## License
15
+
16
+ MIT
config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "threshold-fp-add",
3
+ "description": "fp-add circuit",
4
+ "inputs": 8,
5
+ "outputs": 8,
6
+ "neurons": 8,
7
+ "layers": 2,
8
+ "parameters": 64
9
+ }
create_safetensors.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from safetensors.torch import save_file
3
+
4
+ weights = {}
5
+
6
+ # Simplified Minifloat Adder
7
+ # Adds two 8-bit minifloats (1 sign + 3 exp + 4 mantissa)
8
+
9
+ def add_neuron(name, w_list, bias):
10
+ weights[f'{name}.weight'] = torch.tensor([w_list], dtype=torch.float32)
11
+ weights[f'{name}.bias'] = torch.tensor([bias], dtype=torch.float32)
12
+
13
+ # Input: S1,E1[2:0],M1[3:0], S2,E2[2:0],M2[3:0] (16 bits total)
14
+ # Exponent comparison
15
+ add_neuron('e1_ge_e2', [0.0, 4.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0,
16
+ 0.0, -4.0, -2.0, -1.0, 0.0, 0.0, 0.0, 0.0], 0.0)
17
+
18
+ # Sign comparison
19
+ add_neuron('same_sign', [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
20
+ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], -2.0)
21
+
22
+ save_file(weights, 'model.safetensors')
23
+
24
+ print("Verifying FP add structure...")
25
+ print("Minifloat adder: 1-3-4 format (sign-exp-mantissa)")
26
+
27
+ mag = sum(t.abs().sum().item() for t in weights.values())
28
+ print(f"Magnitude: {mag:.0f}")
29
+ print(f"Parameters: {sum(t.numel() for t in weights.values())}")
30
+ print("Structure test passed!")
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6828f74f317dc8b0a6f8cfea3d994ecff22e64e891b3df5a27810e21cef56082
3
+ size 424