|
| 1 | +# ntops.lab |
| 2 | + |
| 3 | +`ntops.lab` is an experimental operator lab for |
| 4 | +[NineToothed](https://github.com/InfiniTensor/ninetoothed). It collects |
| 5 | +generated and hand-shaped NineToothed kernels, keeps a runnable operator |
| 6 | +catalog, and records the current gaps that need compiler/runtime support. |
| 7 | + |
| 8 | +The project is intentionally a lab: many kernels are produced with LLM-assisted |
| 9 | +operator development, then smoke-tested against PyTorch on CUDA. |
| 10 | + |
| 11 | +## Current Coverage |
| 12 | + |
| 13 | +The canonical catalog contains: |
| 14 | + |
| 15 | +- 250 runnable NineToothed implementations |
| 16 | +- 0 unsupported/scaffold source files included in the commit-ready tree |
| 17 | +- gap analysis retained in documentation only |
| 18 | + |
| 19 | +Primary categories: |
| 20 | + |
| 21 | +- `pointwise` |
| 22 | +- `reduction` |
| 23 | +- `linear` |
| 24 | +- `layout` |
| 25 | +- `creation` |
| 26 | +- `normalization` |
| 27 | +- `fused/general` |
| 28 | +- `fused/fla` |
| 29 | +- `fused/dsa` |
| 30 | +- `fused/mhc` |
| 31 | + |
| 32 | +See [docs/operator-coverage.md](docs/operator-coverage.md) for the full list. |
| 33 | + |
| 34 | +## Repository Layout |
| 35 | + |
| 36 | +```text |
| 37 | +src/ntops_lab/ |
| 38 | + catalog.py # manifest loading and query helpers |
| 39 | + cli.py # ntops-lab CLI |
| 40 | + operator_manifest.json # canonical runnable operator catalog |
| 41 | + operators/ # generated NineToothed kernels |
| 42 | +docs/ |
| 43 | + operator-coverage.md # runnable coverage |
| 44 | + runnable-operators.md # runnable operator list |
| 45 | + unrunnable-operators.md # excluded unsupported operator notes |
| 46 | + support-analysis.md # missing capability analysis |
| 47 | +tests/ |
| 48 | + test_catalog.py # CPU-only metadata tests |
| 49 | +scripts/ |
| 50 | + run_operator.py # run one operator's check() |
| 51 | + check_manifest.py # validate manifest/file consistency |
| 52 | +``` |
| 53 | + |
| 54 | +## Install |
| 55 | + |
| 56 | +For metadata inspection and CPU-only tests: |
| 57 | + |
| 58 | +```bash |
| 59 | +python -m venv .venv |
| 60 | +source .venv/bin/activate |
| 61 | +pip install -e ".[dev]" |
| 62 | +``` |
| 63 | + |
| 64 | +For running kernels, use an environment that already has CUDA, PyTorch, and |
| 65 | +NineToothed installed: |
| 66 | + |
| 67 | +```bash |
| 68 | +pip install -e ".[dev]" |
| 69 | +``` |
| 70 | + |
| 71 | +NineToothed and PyTorch are kept as optional GPU dependencies because this |
| 72 | +repository is often inspected on machines without a GPU. |
| 73 | + |
| 74 | +## Use The Catalog |
| 75 | + |
| 76 | +```bash |
| 77 | +ntops-lab summary |
| 78 | +ntops-lab list --status done |
| 79 | +ntops-lab list --category reduction |
| 80 | +``` |
| 81 | + |
| 82 | +From Python: |
| 83 | + |
| 84 | +```python |
| 85 | +from ntops_lab import list_operators, runnable_operators |
| 86 | + |
| 87 | +print(len(runnable_operators())) |
| 88 | +print(list_operators(category="linear")) |
| 89 | +``` |
| 90 | + |
| 91 | +## Run A Kernel Smoke Test |
| 92 | + |
| 93 | +On a CUDA machine with NineToothed available: |
| 94 | + |
| 95 | +```bash |
| 96 | +ntops-lab check add |
| 97 | +python scripts/run_operator.py softmax |
| 98 | +``` |
| 99 | + |
| 100 | +Most runnable operator modules expose: |
| 101 | + |
| 102 | +```python |
| 103 | +make_inputs() |
| 104 | +run_ninetoothed(...) |
| 105 | +run_pytorch(...) |
| 106 | +check() |
| 107 | +``` |
| 108 | + |
| 109 | +`check()` generates representative inputs, runs the NineToothed kernel, runs |
| 110 | +the PyTorch reference, and compares results. |
| 111 | + |
| 112 | +## Run Repository Tests |
| 113 | + |
| 114 | +CPU-only catalog checks: |
| 115 | + |
| 116 | +```bash |
| 117 | +python -m pytest |
| 118 | +python scripts/check_manifest.py |
| 119 | +python -m compileall -q src scripts tests |
| 120 | +``` |
| 121 | + |
| 122 | +GPU smoke checks should be run selectively: |
| 123 | + |
| 124 | +```bash |
| 125 | +ntops-lab check add |
| 126 | +ntops-lab check mm |
| 127 | +ntops-lab check moe_sum |
| 128 | +``` |
| 129 | + |
| 130 | +Running every GPU check can take a while because many operators compile kernels |
| 131 | +on first use. |
| 132 | + |
| 133 | +## What Is Not Included Yet? |
| 134 | + |
| 135 | +Unsupported scaffold source files are intentionally excluded from this commit-ready tree. Remaining gaps mostly need one of these capabilities: |
| 136 | + |
| 137 | +- complex manual layout/indexing |
| 138 | +- dynamic gather/scatter, cache writes, or masked updates |
| 139 | +- top-k/sort/histogram/atomic primitives |
| 140 | +- cross-tile scan, recurrent state, or triangular solve |
| 141 | +- RNG/stateful random distribution support |
| 142 | +- normalization backward or running-stat APIs |
| 143 | + |
| 144 | +See [docs/support-analysis.md](docs/support-analysis.md). |
| 145 | + |
| 146 | +## Project Philosophy |
| 147 | + |
| 148 | +This is a practical operator workshop: |
| 149 | + |
| 150 | +- keep each operator in its own file |
| 151 | +- keep PyTorch references close to implementations |
| 152 | +- make every runnable operator independently smoke-testable |
| 153 | +- record why excluded operators are blocked |
| 154 | +- prefer clear templates over pretending incomplete kernels are done |
| 155 | + |
| 156 | +## License |
| 157 | + |
| 158 | +Standard MIT License. The MIT license is not versioned, so the repository uses |
| 159 | +the canonical MIT text and SPDX-compatible `MIT` package metadata. |
0 commit comments