This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ethos_router.py | |
| # A compact, self-contained PyTorch router with sinusoidal ID codes, | |
| # top-b axis selection, and additive beam search. | |
| # | |
| # Shapes (conventions used below): | |
| # B = batch | |
| # D = model/embedding dim | |
| # H = heads | |
| # A = routing axes per head | |
| # r = axis query dim (must be even for [cos,sin] codes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ethos_gen_mlp.py | |
| # ETHOS (TF32/FP32) for flattened CIFAR-10: | |
| # Router (pure-ID, custom autograd) → W1/W2 → FiLM → vector gate → dictionaries → mean heads → logits | |
| from __future__ import annotations | |
| import math | |
| from typing import Optional, Tuple | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ASYNC_ENGINE_COUNT: 4 | |
| CAN_MAP_HOST_MEMORY: 1 | |
| CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM: 1 | |
| CLOCK_RATE: 1965000 | |
| COMPUTE_CAPABILITY_MAJOR: 10 | |
| COMPUTE_CAPABILITY_MINOR: 0 | |
| COMPUTE_MODE: DEFAULT | |
| COMPUTE_PREEMPTION_SUPPORTED: 1 | |
| CONCURRENT_KERNELS: 1 | |
| CONCURRENT_MANAGED_ACCESS: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| with open(sys.argv[0]) as f: | |
| code = f.read() # read the code of this file ASAP, for logging | |
| import uuid | |
| import time | |
| import copy | |
| from dataclasses import dataclass | |
| from functools import lru_cache | |
| from pathlib import Path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def count_code(l): | |
| x=l.split() | |
| count = 0 | |
| c = False | |
| o = False | |
| r = 0 | |
| for i in range(len(x)): | |
| if str(x[i]) == "c": | |
| c = True | |
| r = i |