CharlesCNorton commited on
Commit ·
470898e
1
Parent(s): 32215c3
remove the superseded standalone float normalize stages from the core generators and their structure checks; the composed pipelines carry their own normalizers
Browse files- src/build.py +4 -45
- src/eval.py +0 -4
- todo.md +0 -3
src/build.py
CHANGED
|
@@ -1035,7 +1035,7 @@ def add_neg_nbits(tensors: Dict[str, torch.Tensor], bits: int) -> None:
|
|
| 1035 |
|
| 1036 |
|
| 1037 |
def add_float16_core(tensors: Dict[str, torch.Tensor]) -> None:
|
| 1038 |
-
"""Add float16 core circuits (unpack, pack, classify
|
| 1039 |
|
| 1040 |
IEEE 754 half-precision format (16 bits):
|
| 1041 |
- Bit 15: Sign (0=positive, 1=negative)
|
|
@@ -1065,27 +1065,6 @@ def add_float16_core(tensors: Dict[str, torch.Tensor]) -> None:
|
|
| 1065 |
add_gate(tensors, f"{prefix}.classify.is_inf.and", [1.0, 1.0], [-2.0])
|
| 1066 |
add_gate(tensors, f"{prefix}.classify.is_nan.and", [1.0, 1.0], [-2.0])
|
| 1067 |
|
| 1068 |
-
for stage in range(4):
|
| 1069 |
-
shift = 1 << (3 - stage)
|
| 1070 |
-
for bit in range(11):
|
| 1071 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.not_sel", [-1.0], [0.0])
|
| 1072 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.and_a", [1.0, 1.0], [-2.0])
|
| 1073 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.and_b", [1.0, 1.0], [-2.0])
|
| 1074 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.or", [1.0, 1.0], [-1.0])
|
| 1075 |
-
|
| 1076 |
-
for stage in range(4):
|
| 1077 |
-
shift = 1 << (3 - stage)
|
| 1078 |
-
for bit in range(5):
|
| 1079 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer1.or", [1.0, 1.0], [-1.0])
|
| 1080 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer1.nand", [-1.0, -1.0], [1.0])
|
| 1081 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer2", [1.0, 1.0], [-2.0])
|
| 1082 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.carry", [1.0, 1.0], [-2.0])
|
| 1083 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer1.or", [1.0, 1.0], [-1.0])
|
| 1084 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer1.nand", [-1.0, -1.0], [1.0])
|
| 1085 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer2", [1.0, 1.0], [-2.0])
|
| 1086 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.carry", [1.0, 1.0], [-2.0])
|
| 1087 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.carry_or", [1.0, 1.0], [-1.0])
|
| 1088 |
-
|
| 1089 |
for i in range(16):
|
| 1090 |
add_gate(tensors, f"{prefix}.pack.bit{i}", [1.0], [-1.0])
|
| 1091 |
|
|
@@ -1773,7 +1752,7 @@ def add_float16_cmp(tensors: Dict[str, torch.Tensor]) -> None:
|
|
| 1773 |
|
| 1774 |
|
| 1775 |
def add_float32_core(tensors: Dict[str, torch.Tensor]) -> None:
|
| 1776 |
-
"""Add float32 core circuits (unpack, pack, classify
|
| 1777 |
|
| 1778 |
IEEE 754 single-precision format (32 bits):
|
| 1779 |
- Bit 31: Sign
|
|
@@ -1797,26 +1776,6 @@ def add_float32_core(tensors: Dict[str, torch.Tensor]) -> None:
|
|
| 1797 |
add_gate(tensors, f"{prefix}.classify.is_inf.and", [1.0, 1.0], [-2.0])
|
| 1798 |
add_gate(tensors, f"{prefix}.classify.is_nan.and", [1.0, 1.0], [-2.0])
|
| 1799 |
|
| 1800 |
-
for stage in range(5):
|
| 1801 |
-
shift = 1 << (4 - stage)
|
| 1802 |
-
for bit in range(24):
|
| 1803 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.not_sel", [-1.0], [0.0])
|
| 1804 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.and_a", [1.0, 1.0], [-2.0])
|
| 1805 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.and_b", [1.0, 1.0], [-2.0])
|
| 1806 |
-
add_gate(tensors, f"{prefix}.normalize.stage{stage}.bit{bit}.or", [1.0, 1.0], [-1.0])
|
| 1807 |
-
|
| 1808 |
-
for stage in range(5):
|
| 1809 |
-
for bit in range(8):
|
| 1810 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer1.or", [1.0, 1.0], [-1.0])
|
| 1811 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer1.nand", [-1.0, -1.0], [1.0])
|
| 1812 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.sum.layer2", [1.0, 1.0], [-2.0])
|
| 1813 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha1.carry", [1.0, 1.0], [-2.0])
|
| 1814 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer1.or", [1.0, 1.0], [-1.0])
|
| 1815 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer1.nand", [-1.0, -1.0], [1.0])
|
| 1816 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.sum.layer2", [1.0, 1.0], [-2.0])
|
| 1817 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.ha2.carry", [1.0, 1.0], [-2.0])
|
| 1818 |
-
add_gate(tensors, f"{prefix}.normalize.exp_adj.stage{stage}.fa{bit}.carry_or", [1.0, 1.0], [-1.0])
|
| 1819 |
-
|
| 1820 |
for i in range(32):
|
| 1821 |
add_gate(tensors, f"{prefix}.pack.bit{i}", [1.0], [-1.0])
|
| 1822 |
|
|
@@ -5056,7 +5015,7 @@ def cmd_alu(args) -> None:
|
|
| 5056 |
print("\nGenerating float16 core circuits...")
|
| 5057 |
try:
|
| 5058 |
add_float16_core(tensors)
|
| 5059 |
-
print(" Added float16 unpack/pack/classify
|
| 5060 |
except ValueError as e:
|
| 5061 |
print(f" float16 core already exists: {e}")
|
| 5062 |
|
|
@@ -5091,7 +5050,7 @@ def cmd_alu(args) -> None:
|
|
| 5091 |
print("\nGenerating float32 core circuits...")
|
| 5092 |
try:
|
| 5093 |
add_float32_core(tensors)
|
| 5094 |
-
print(" Added float32 unpack/pack/classify
|
| 5095 |
except ValueError as e:
|
| 5096 |
print(f" float32 core already exists: {e}")
|
| 5097 |
|
|
|
|
| 1035 |
|
| 1036 |
|
| 1037 |
def add_float16_core(tensors: Dict[str, torch.Tensor]) -> None:
|
| 1038 |
+
"""Add float16 core circuits (unpack, pack, classify).
|
| 1039 |
|
| 1040 |
IEEE 754 half-precision format (16 bits):
|
| 1041 |
- Bit 15: Sign (0=positive, 1=negative)
|
|
|
|
| 1065 |
add_gate(tensors, f"{prefix}.classify.is_inf.and", [1.0, 1.0], [-2.0])
|
| 1066 |
add_gate(tensors, f"{prefix}.classify.is_nan.and", [1.0, 1.0], [-2.0])
|
| 1067 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1068 |
for i in range(16):
|
| 1069 |
add_gate(tensors, f"{prefix}.pack.bit{i}", [1.0], [-1.0])
|
| 1070 |
|
|
|
|
| 1752 |
|
| 1753 |
|
| 1754 |
def add_float32_core(tensors: Dict[str, torch.Tensor]) -> None:
|
| 1755 |
+
"""Add float32 core circuits (unpack, pack, classify).
|
| 1756 |
|
| 1757 |
IEEE 754 single-precision format (32 bits):
|
| 1758 |
- Bit 31: Sign
|
|
|
|
| 1776 |
add_gate(tensors, f"{prefix}.classify.is_inf.and", [1.0, 1.0], [-2.0])
|
| 1777 |
add_gate(tensors, f"{prefix}.classify.is_nan.and", [1.0, 1.0], [-2.0])
|
| 1778 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1779 |
for i in range(32):
|
| 1780 |
add_gate(tensors, f"{prefix}.pack.bit{i}", [1.0], [-1.0])
|
| 1781 |
|
|
|
|
| 5015 |
print("\nGenerating float16 core circuits...")
|
| 5016 |
try:
|
| 5017 |
add_float16_core(tensors)
|
| 5018 |
+
print(" Added float16 unpack/pack/classify")
|
| 5019 |
except ValueError as e:
|
| 5020 |
print(f" float16 core already exists: {e}")
|
| 5021 |
|
|
|
|
| 5050 |
print("\nGenerating float32 core circuits...")
|
| 5051 |
try:
|
| 5052 |
add_float32_core(tensors)
|
| 5053 |
+
print(" Added float32 unpack/pack/classify")
|
| 5054 |
except ValueError as e:
|
| 5055 |
print(f" float32 core already exists: {e}")
|
| 5056 |
|
src/eval.py
CHANGED
|
@@ -4212,9 +4212,6 @@ class BatchedFitnessEvaluator:
|
|
| 4212 |
('float16.classify.frac_zero.weight', (10,)),
|
| 4213 |
('float16.classify.is_zero.and.weight', (2,)),
|
| 4214 |
('float16.classify.is_nan.and.weight', (2,)),
|
| 4215 |
-
('float16.normalize.stage0.bit0.not_sel.weight', (1,)),
|
| 4216 |
-
('float16.normalize.stage0.bit0.and_a.weight', (2,)),
|
| 4217 |
-
('float16.normalize.stage0.bit0.or.weight', (2,)),
|
| 4218 |
('float16.pack.bit0.weight', (1,)),
|
| 4219 |
]
|
| 4220 |
|
|
@@ -4415,7 +4412,6 @@ class BatchedFitnessEvaluator:
|
|
| 4415 |
('float32.classify.frac_zero.weight', (23,)),
|
| 4416 |
('float32.classify.is_zero.and.weight', (2,)),
|
| 4417 |
('float32.classify.is_nan.and.weight', (2,)),
|
| 4418 |
-
('float32.normalize.stage0.bit0.not_sel.weight', (1,)),
|
| 4419 |
('float32.pack.bit0.weight', (1,)),
|
| 4420 |
]
|
| 4421 |
|
|
|
|
| 4212 |
('float16.classify.frac_zero.weight', (10,)),
|
| 4213 |
('float16.classify.is_zero.and.weight', (2,)),
|
| 4214 |
('float16.classify.is_nan.and.weight', (2,)),
|
|
|
|
|
|
|
|
|
|
| 4215 |
('float16.pack.bit0.weight', (1,)),
|
| 4216 |
]
|
| 4217 |
|
|
|
|
| 4412 |
('float32.classify.frac_zero.weight', (23,)),
|
| 4413 |
('float32.classify.is_zero.and.weight', (2,)),
|
| 4414 |
('float32.classify.is_nan.and.weight', (2,)),
|
|
|
|
| 4415 |
('float32.pack.bit0.weight', (1,)),
|
| 4416 |
]
|
| 4417 |
|
todo.md
CHANGED
|
@@ -2,9 +2,6 @@
|
|
| 2 |
|
| 3 |
Unfinished work.
|
| 4 |
|
| 5 |
-
- The float add, multiply, and divide pipelines handle subnormal operands and produce subnormal results rather than flushing them to zero.
|
| 6 |
- The F extension includes a fused multiply-add instruction that rounds once.
|
| 7 |
- Program-counter sequencing and instruction decode are computed by threshold gates rather than by fixed wiring in the runtimes.
|
| 8 |
-
- The standalone float normalize stages, superseded by the composed pipelines' own normalizers, are removed from the circuit inventory.
|
| 9 |
-
- Every gate in the 32-bit multiply circuit resolves its .inputs to a defined signal.
|
| 10 |
- A machine-checked correctness proof relates the shipped weights to the ISA.
|
|
|
|
| 2 |
|
| 3 |
Unfinished work.
|
| 4 |
|
|
|
|
| 5 |
- The F extension includes a fused multiply-add instruction that rounds once.
|
| 6 |
- Program-counter sequencing and instruction decode are computed by threshold gates rather than by fixed wiring in the runtimes.
|
|
|
|
|
|
|
| 7 |
- A machine-checked correctness proof relates the shipped weights to the ISA.
|