CharlesCNorton commited on
Commit ·
947fcab
1
Parent(s): 88fca93
Remove dead routing code from eval.py
Browse files
README.md
CHANGED
|
@@ -24,8 +24,7 @@ Each gate is a threshold logic unit: `output = step(weights · inputs + bias)`.
|
|
| 24 |
|------|-------------|
|
| 25 |
| `arithmetic.safetensors` | 23,494 tensors encoding 7,828 gates |
|
| 26 |
| `eval.py` | Test harness (206,124 tests) |
|
| 27 |
-
| `
|
| 28 |
-
| `routing.json` | Signal routing for complex circuits |
|
| 29 |
|
| 30 |
## Circuits
|
| 31 |
|
|
|
|
| 24 |
|------|-------------|
|
| 25 |
| `arithmetic.safetensors` | 23,494 tensors encoding 7,828 gates |
|
| 26 |
| `eval.py` | Test harness (206,124 tests) |
|
| 27 |
+
| `build.py` | Builds tensors and infers gate connectivity |
|
|
|
|
| 28 |
|
| 29 |
## Circuits
|
| 30 |
|
eval.py
CHANGED
|
@@ -48,7 +48,6 @@ class TestResult:
|
|
| 48 |
@dataclass
|
| 49 |
class EvalContext:
|
| 50 |
tensors: Dict[str, torch.Tensor]
|
| 51 |
-
routing: Dict[str, List[str]]
|
| 52 |
gates: List[str]
|
| 53 |
signals: Dict[str, int]
|
| 54 |
name_to_id: Dict[str, int] = field(default_factory=dict)
|
|
@@ -82,15 +81,6 @@ def load_model(path: str = "./arithmetic.safetensors") -> Tuple[Dict[str, torch.
|
|
| 82 |
return tensors, gates, signals, name_to_id
|
| 83 |
|
| 84 |
|
| 85 |
-
def load_routing(path: str = "./routing.json") -> Dict[str, List[str]]:
|
| 86 |
-
"""Load routing configuration."""
|
| 87 |
-
try:
|
| 88 |
-
with open(path, 'r') as f:
|
| 89 |
-
return json.load(f)
|
| 90 |
-
except FileNotFoundError:
|
| 91 |
-
return {}
|
| 92 |
-
|
| 93 |
-
|
| 94 |
def evaluate_gate(ctx: EvalContext, gate: str, inputs: torch.Tensor) -> torch.Tensor:
|
| 95 |
"""Evaluate a single threshold gate."""
|
| 96 |
weight_key = f"{gate}.weight"
|
|
@@ -1928,7 +1918,6 @@ def print_summary(results: List[TestResult], ctx: EvalContext,
|
|
| 1928 |
def main():
|
| 1929 |
parser = argparse.ArgumentParser(description="Unified evaluator for threshold-calculus circuits")
|
| 1930 |
parser.add_argument("--model", default="./arithmetic.safetensors", help="Path to model file")
|
| 1931 |
-
parser.add_argument("--routing", default="./routing.json", help="Path to routing file")
|
| 1932 |
parser.add_argument("--category", "-c", action="append", help="Test specific category (can repeat)")
|
| 1933 |
parser.add_argument("--circuit", action="append", help="Test specific circuit (can repeat)")
|
| 1934 |
parser.add_argument("--quick", "-q", action="store_true", help="Quick mode (fewer test cases)")
|
|
@@ -1947,13 +1936,11 @@ def main():
|
|
| 1947 |
|
| 1948 |
print(f"Loading model from {args.model}...")
|
| 1949 |
tensors, gates, signals, name_to_id = load_model(args.model)
|
| 1950 |
-
routing = load_routing(args.routing)
|
| 1951 |
|
| 1952 |
print(f"Loaded {len(tensors)} tensors, {len(gates)} gates, {len(signals)} signals")
|
| 1953 |
|
| 1954 |
ctx = EvalContext(
|
| 1955 |
tensors=tensors,
|
| 1956 |
-
routing=routing,
|
| 1957 |
gates=gates,
|
| 1958 |
signals=signals,
|
| 1959 |
name_to_id=name_to_id,
|
|
|
|
| 48 |
@dataclass
|
| 49 |
class EvalContext:
|
| 50 |
tensors: Dict[str, torch.Tensor]
|
|
|
|
| 51 |
gates: List[str]
|
| 52 |
signals: Dict[str, int]
|
| 53 |
name_to_id: Dict[str, int] = field(default_factory=dict)
|
|
|
|
| 81 |
return tensors, gates, signals, name_to_id
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
def evaluate_gate(ctx: EvalContext, gate: str, inputs: torch.Tensor) -> torch.Tensor:
|
| 85 |
"""Evaluate a single threshold gate."""
|
| 86 |
weight_key = f"{gate}.weight"
|
|
|
|
| 1918 |
def main():
|
| 1919 |
parser = argparse.ArgumentParser(description="Unified evaluator for threshold-calculus circuits")
|
| 1920 |
parser.add_argument("--model", default="./arithmetic.safetensors", help="Path to model file")
|
|
|
|
| 1921 |
parser.add_argument("--category", "-c", action="append", help="Test specific category (can repeat)")
|
| 1922 |
parser.add_argument("--circuit", action="append", help="Test specific circuit (can repeat)")
|
| 1923 |
parser.add_argument("--quick", "-q", action="store_true", help="Quick mode (fewer test cases)")
|
|
|
|
| 1936 |
|
| 1937 |
print(f"Loading model from {args.model}...")
|
| 1938 |
tensors, gates, signals, name_to_id = load_model(args.model)
|
|
|
|
| 1939 |
|
| 1940 |
print(f"Loaded {len(tensors)} tensors, {len(gates)} gates, {len(signals)} signals")
|
| 1941 |
|
| 1942 |
ctx = EvalContext(
|
| 1943 |
tensors=tensors,
|
|
|
|
| 1944 |
gates=gates,
|
| 1945 |
signals=signals,
|
| 1946 |
name_to_id=name_to_id,
|