phanerozoic commited on
Commit
6cb43ee
·
verified ·
1 Parent(s): 7572285

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 +31 -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-multiply
11
+
12
+ fp-multiply threshold logic implementation.
13
+
14
+ ## License
15
+
16
+ MIT
config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "threshold-fp-multiply",
3
+ "description": "fp-multiply circuit",
4
+ "inputs": 8,
5
+ "outputs": 8,
6
+ "neurons": 8,
7
+ "layers": 2,
8
+ "parameters": 64
9
+ }
create_safetensors.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from safetensors.torch import save_file
3
+
4
+ weights = {}
5
+
6
+ # Simplified Minifloat Multiplier
7
+ # Multiplies two 8-bit minifloats
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
+ # Sign of result = XOR of input signs
14
+ add_neuron('sign_or', [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
15
+ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], -1.0)
16
+ add_neuron('sign_nand', [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
17
+ -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 1.0)
18
+
19
+ # Exponent addition (simplified)
20
+ add_neuron('exp_sum', [0.0, 4.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0,
21
+ 0.0, 4.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0)
22
+
23
+ save_file(weights, 'model.safetensors')
24
+
25
+ print("Verifying FP multiply structure...")
26
+ print("Minifloat multiplier: sign XOR, exp add, mantissa multiply")
27
+
28
+ mag = sum(t.abs().sum().item() for t in weights.values())
29
+ print(f"Magnitude: {mag:.0f}")
30
+ print(f"Parameters: {sum(t.numel() for t in weights.values())}")
31
+ print("Structure test passed!")
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b26d04256164b33c89de7c798f642e5b6722ba30d02d8f26701962cac08adf61
3
+ size 636