Skip to content

Commit a95bde3

Browse files
committed
Roadmap update
1 parent 517377f commit a95bde3

18 files changed

Lines changed: 1202 additions & 48 deletions

.github/workflows/ci.yml

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,47 +31,67 @@ jobs:
3131
build-and-test:
3232
name: Matrix build & tests
3333
needs: format-and-lint
34-
runs-on: ubuntu-latest
34+
runs-on: ${{ matrix.compiler.os }}
3535
strategy:
3636
fail-fast: false
3737
matrix:
3838
compiler:
3939
- name: gcc
4040
c: gcc
4141
cxx: g++
42+
os: ubuntu-latest
4243
- name: clang
4344
c: clang
4445
cxx: clang++
46+
os: ubuntu-latest
47+
- name: appleclang
48+
c: clang
49+
cxx: clang++
50+
os: macos-14
4551
configuration:
4652
- name: minimal
4753
python_bindings: OFF
4854
- name: python
4955
python_bindings: ON
50-
avx:
51-
- name: avx
52-
flags: "-mavx512f"
56+
python_version: "3.11"
57+
simd:
5358
- name: scalar
5459
flags: "-mno-avx"
60+
- name: avx2
61+
flags: "-mavx2"
62+
build_type:
63+
- Release
64+
- Debug
65+
exclude:
66+
- compiler:
67+
name: appleclang
68+
simd:
69+
name: avx2
5570
env:
56-
BUILD_DIR: build-${{ matrix.compiler.name }}-${{ matrix.configuration.name }}-${{ matrix.avx.name }}
57-
ARTIFACT_LABEL: ci-${{ matrix.compiler.name }}-${{ matrix.configuration.name }}-${{ matrix.avx.name }}
71+
BUILD_DIR: build-${{ matrix.compiler.os }}-${{ matrix.compiler.name }}-${{ matrix.configuration.name }}-${{ matrix.simd.name }}-${{ matrix.build_type }}
72+
ARTIFACT_LABEL: ci-${{ matrix.compiler.os }}-${{ matrix.compiler.name }}-${{ matrix.configuration.name }}-${{ matrix.simd.name }}-${{ matrix.build_type }}
5873
steps:
5974
- uses: actions/checkout@v4
75+
- name: Setup Python
76+
if: matrix.configuration.name == 'python'
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: ${{ matrix.configuration.python_version }}
6080
- name: Configure
6181
run: |
6282
cmake -S . -B "$BUILD_DIR" \
6383
-DT81LIB_BUILD_TESTS=ON \
6484
-DT81LIB_BUILD_PYTHON_BINDINGS=${{ matrix.configuration.python_bindings }} \
85+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
6586
-DCMAKE_C_COMPILER=${{ matrix.compiler.c }} \
6687
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \
67-
-DCMAKE_C_FLAGS="${{ matrix.avx.flags }}" \
68-
-DCMAKE_CXX_FLAGS="${{ matrix.avx.flags }}"
88+
${{ runner.os == 'Linux' && format('-DCMAKE_C_FLAGS={0} -DCMAKE_CXX_FLAGS={0}', matrix.simd.flags) || '' }}
6989
- name: Build
7090
run: cmake --build "$BUILD_DIR" --parallel
7191
- name: Test
7292
run: ctest --test-dir "$BUILD_DIR" --output-on-failure
7393
- name: Python binding + GGUF regression tests
74-
if: matrix.configuration.name == 'python'
94+
if: matrix.configuration.name == 'python' && runner.os == 'Linux'
7595
run: |
7696
set -euo pipefail
7797
mkdir -p artifacts
@@ -91,6 +111,47 @@ jobs:
91111
name: ${{ env.ARTIFACT_LABEL }}
92112
path: artifacts
93113

114+
coverage:
115+
name: Coverage report
116+
runs-on: ubuntu-latest
117+
needs: build-and-test
118+
env:
119+
BUILD_DIR: build-coverage
120+
steps:
121+
- uses: actions/checkout@v4
122+
- name: Setup Python
123+
uses: actions/setup-python@v5
124+
with:
125+
python-version: "3.11"
126+
- name: Install coverage tooling
127+
run: |
128+
python3 -m pip install --upgrade pip
129+
python3 -m pip install gcovr
130+
- name: Configure
131+
run: |
132+
cmake -S . -B "$BUILD_DIR" \
133+
-DT81LIB_BUILD_TESTS=ON \
134+
-DT81LIB_BUILD_PYTHON_BINDINGS=OFF \
135+
-DCMAKE_BUILD_TYPE=Debug \
136+
-DCMAKE_C_FLAGS="--coverage -O0 -g" \
137+
-DCMAKE_CXX_FLAGS="--coverage -O0 -g"
138+
- name: Build
139+
run: cmake --build "$BUILD_DIR" --parallel
140+
- name: Test
141+
run: ctest --test-dir "$BUILD_DIR" --output-on-failure
142+
- name: Generate coverage report
143+
run: |
144+
mkdir -p artifacts
145+
gcovr --root . \
146+
--exclude "$BUILD_DIR/.*" \
147+
--xml --output artifacts/coverage.xml \
148+
--html --html-details --output artifacts/coverage.html
149+
- name: Upload coverage artifacts
150+
uses: actions/upload-artifact@v4
151+
with:
152+
name: coverage-report
153+
path: artifacts
154+
94155
gpu-cuda:
95156
name: CUDA GPU smoke
96157
runs-on: ubuntu-latest

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ This file helps AI agents discover and understand how to work with this reposito
6262
- Enhanced `tests/python/test_gguf.py` with quant-parameterized round-trip checks, metadata assertions, and a regression case for invalid quant identifiers to spotlight the GGUF helpers before future agents touch them.
6363
- Hardened the SIMD detection helpers in `include/t81/core/detail/simd.hpp` with CPUID/xgetbv fallbacks, documented the `add_trytes_*` overflow semantics, and made NEON runtime checks opt-out via `T81_DISABLE_NEON`.
6464
- Added the `compression-first` GGUF export profile (metadata + CLI flags), plus `scripts/gguf_benchmark.py` and CLI docs that walk FP16 to ternary GGUF before/after measurements.
65+
- Added `examples/ternary_phi3_ptq_qat_demo.ipynb` to showcase Phi-3-mini PTQ/QAT size, latency, and perplexity comparisons in one compact notebook.

DEVELOPMENT.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Developer Onboarding Guide
1+
# Developer Onboarding Guide
22

33
This project already boasts extensive documentation (`README.md`, `docs/index.md`, `AGENTS.md`, `docs/ROADMAP.md`), but this guide focuses on the concrete steps a new contributor needs to take so they can build, test, and iterate quickly.
44

@@ -11,15 +11,43 @@ cd t81lib
1111

1212
The repository uses CMake for every build target, so keep a spare build directory for each configuration (e.g., `build`, `build-python`).
1313

14-
## 2. Native C++ build & tests
14+
## 2. Quickstart matrix
15+
16+
Pick the smallest path that matches your task:
17+
18+
**C++ core only** (no Python bindings)
19+
20+
```bash
21+
cmake -S . -B build -DT81LIB_BUILD_TESTS=ON
22+
cmake --build build
23+
ctest --test-dir build
24+
```
25+
26+
**C++ + Python bindings (pybind11)**
27+
28+
```bash
29+
cmake -S . -B build-python -DT81LIB_BUILD_PYTHON_BINDINGS=ON -DT81LIB_BUILD_TESTS=ON
30+
cmake --build build-python
31+
PYTHONPATH=build-python python tests/python/test_bindings.py
32+
```
33+
34+
**CLI helpers (torch/transformers extras)**
35+
36+
```bash
37+
pipx install .[torch]
38+
pipx ensurepath
39+
t81 --help
40+
```
41+
42+
## 3. Native C++ build & tests
1543

1644
```bash
1745
./run-tests.sh
1846
```
1947

2048
`run-tests.sh` (located in the repo root) configures CMake with `-DT81LIB_BUILD_TESTS=ON`, builds the default targets, and runs `ctest`. The script respects the `BUILD_DIR` environment variable, so you can run `BUILD_DIR=build-debug ./run-tests.sh` if you want a custom path.
2149

22-
## 3. Python bindings
50+
## 4. Python bindings
2351

2452
```bash
2553
./build-python.sh
@@ -37,19 +65,39 @@ pipx ensurepath
3765

3866
The console scripts `t81-convert`, `t81-gguf`, and `t81-qat` become available after the pipx installation.
3967

40-
## 4. CLI helpers
68+
## 5. Common workflows
69+
70+
Use the scripts in the repo root for the most common tasks:
71+
72+
```bash
73+
# clean configure + build + ctest
74+
./run-tests.sh
75+
76+
# configure + build the pybind11 module
77+
./build-python.sh
78+
79+
# custom build dir
80+
BUILD_DIR=build-debug ./run-tests.sh
81+
```
82+
83+
Expected outputs:
84+
85+
- `run-tests.sh` prints the CMake configure summary, build steps, and `ctest` results.
86+
- `build-python.sh` emits the binding target and leaves the extension module in the build dir.
87+
88+
## 6. CLI helpers
4189

4290
All CLI workflow documentation lives in `docs/references/cli-usage.md`, and the Mermaid diagrams are in `docs/diagrams/cli-workflows-mermaid.md`. Consult those docs for flag explanations, input requirements, and usage examples before writing CLI-focused contributions.
4391

44-
## 5. Documentation & roadmap
92+
## 7. Documentation & roadmap
4593

4694
If you're updating architecture or proposing a major change, refer to `docs/ROADMAP.md` for the current vision and the recommended initiatives that maintainers are tracking. Document your work in the nearest relevant doc (README, docs/index, AGENTS, etc.).
4795

48-
## 6. Developer container
96+
## 8. Developer container
4997

50-
VS Code users can open this repo in the configured `.devcontainer` to get a reproducible environment with CMake, Ninja, Clang, Python, and pipx pre-installed. After opening the folder, select **Reopen in Container** and let VS Code build the container once.
98+
Preferred setup is a native local toolchain. Use the `.devcontainer` only if you need a fully reproducible VS Code + Docker environment with CMake, Ninja, Clang, Python, and pipx pre-installed. After opening the folder in VS Code, select **Reopen in Container** and let the container build once.
5199

52-
## 7. Additional tips
100+
## 9. Additional tips
53101

54102
* Keep your changes small and test locally before opening a PR.
55103
* Run `clang-format` on files you touch (see `.clang-format` for the style configuration).

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ README.md — Visitor-facing overview, focused onboarding, and first-steps guida
1414
packed ternary GEMMs, Python bindings, and quantization helpers to deterministic numerics and ternary-aware
1515
AI workflows.
1616

17+
**Featured demo**[Ternary Quantization on Phi-3-mini: PTQ + QAT (8-10x compression, <10% PPL degradation)](examples/ternary_phi3_ptq_qat_demo.ipynb)
18+
19+
## Getting started for Torch users
20+
21+
If you are arriving from PyTorch or Hugging Face, start here and treat `t81` as your single entry point:
22+
23+
```bash
24+
python3 -m venv .venv
25+
source .venv/bin/activate
26+
pip install ".[torch]"
27+
```
28+
29+
```python
30+
import t81 as t8
31+
32+
tensor = t8.torch.TernaryTensor.from_float(weight, threshold=0.45)
33+
output = tensor.matmul_input(input_tensor, bias=bias)
34+
```
35+
36+
# -> Runs 2-4x faster on CPU than FP16 with packed ternary kernels
37+
38+
Next steps: `t8.nn.Linear` for drop-in layers, `t8.convert`/`t8.gguf` for programmatic conversion, and `t81 convert`/`t81 gguf` for CLI flows.
39+
1740
## Minimum viable success
1841

1942
```cpp
@@ -121,7 +144,7 @@ Optional CUDA/ROCm backends can be enabled with `-DUSE_CUDA=ON` / `-DUSE_ROCM=ON
121144

122145
## CLI helpers
123146

124-
`t81 convert`, `t81 gguf`, `t81 info`, and `t81-qat` automate quantize→export→train flows with progress reporting and validation hooks (the legacy `t81-convert`/`t81-gguf` names still work). Browse [docs/references/cli-usage.md](docs/references/cli-usage.md), [docs/diagrams/cli-workflows-mermaid.md](docs/diagrams/cli-workflows-mermaid.md), and [examples/cli-examples.md](examples/cli-examples.md) for recipes.
147+
`t81 convert`, `t81 gguf`, `t81 info`, and `t81-qat` automate quantize→export→train flows with progress reporting and validation hooks (the legacy `t81-convert`/`t81-gguf` names still work). Note: both `t81 convert` (new) and `t81-convert` (legacy) are available for backward compatibility. Browse [docs/references/cli-usage.md](docs/references/cli-usage.md), [docs/diagrams/cli-workflows-mermaid.md](docs/diagrams/cli-workflows-mermaid.md), and [examples/cli-examples.md](examples/cli-examples.md) for recipes.
125148

126149
### Large models & GGUF streaming
127150

@@ -153,7 +176,7 @@ For a zero-disk workaround you can also dequantize on the fly (via `t81.dequanti
153176
- Deterministic numerics and research-grade arithmetic built atop the same core.
154177
- Ternary hardware simulation and energy modeling (see [docs/hardware.md](docs/hardware.md)).
155178

156-
See [docs/use-cases.md](docs/use-cases.md) for demos, notebooks, and experiments that spotlight these flows.
179+
See [Use Cases & Demos](docs/use-cases.md) for real-world workflows, including the Phi-3-mini ternary notebook.
157180

158181
## Examples
159182

docs/ROADMAP.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,45 @@ The codebase is thoughtfully commented, consistently formatted by `clang-format`
5656

5757
## 3. Next Steps Recommendations
5858

59+
### Progress update (2024)
60+
61+
Recent work has delivered parts of this roadmap:
62+
63+
* **Recommendation 1** — quickstart matrix + common workflows added to `DEVELOPMENT.md`.
64+
* **Recommendation 2** — CI matrix expanded for OS/build types and SIMD guards; Python tests standardized on Linux.
65+
* **Recommendation 3** — Python entry-points table added to `docs/python-api.md` and `docs/python-cookbook.md`, with links from `docs/index.md`.
66+
67+
Remaining items are listed below with the next steps still required.
68+
5969
### Recommendation 1: Streamline the Developer Onboarding Experience
6070

6171
* **Why**: New contributors struggle with CMake options, Python extras, and building bindings.
6272
* **Benefits**: Faster first-time builds, fewer setup questions, more contributions.
6373
* **Effort**: Medium.
6474
* **Implementation**:
65-
1. Add `DEVELOPMENT.md` with step-by-step instructions (clone, configure with `T81LIB_BUILD_PYTHON_BINDINGS`, `pipx` options, CLI usage).
66-
2. Provide helper scripts or Makefile targets (`run-tests.sh`, `build-python.sh`) that wrap the most common commands.
67-
3. Deliver a `.devcontainer` (VS Code + Docker) to let contributors spin up a configured environment without manual dependency juggling.
75+
1. Expand `DEVELOPMENT.md` with a quickstart matrix (CMake-only vs. bindings vs. torch extras) and explicit `T81LIB_BUILD_PYTHON_BINDINGS` examples. **Done.**
76+
2. Add a short "common workflows" section that references `run-tests.sh` and `build-python.sh`, plus expected outputs/flags. **Done.**
77+
3. Decide whether a `.devcontainer` is still needed or document the current preferred local setup to avoid duplicate paths. **Done.**
6878

6979
### Recommendation 2: Expand CI and Code Quality Automation
7080

7181
* **Why**: The existing CI could do more to prevent regressions and enforce style across languages.
7282
* **Benefits**: Higher confidence in main, earlier detection of regressions, better cross-platform coverage.
7383
* **Effort**: Medium.
7484
* **Implementation**:
75-
1. Extend `.github/workflows/ci.yml` with a build matrix (GCC/Clang, binding vs. minimal configuration, AVX vs. scalar) and run both C++ and Python test suites.
76-
2. Add format/lint steps (`clang-format` check, `ruff`/`black` for Python) to gate style.
77-
3. Publish coverage/artifacts (e.g., via Codecov or GHA artifacts) so maintainers can monitor test completeness.
85+
1. Extend `.github/workflows/ci.yml` with a richer build matrix (GCC/Clang, bindings vs. minimal configuration, AVX vs. scalar) and run both C++ and Python test suites. **Done (matrix + SIMD guard updates).**
86+
2. Add format/lint steps (`clang-format` check, `ruff`/`black` for Python) to gate style. **Done.**
87+
3. Publish coverage/artifacts (e.g., via Codecov or GHA artifacts) so maintainers can monitor test completeness. **Done (coverage artifact upload).**
7888

7989
### Recommendation 3: Unify and Document the Python API Surface
8090

8191
* **Why**: Python users currently discover helpers across `t81lib`, `t81`, and CLI docs.
8292
* **Benefits**: Easier discoverability, faster adoption, clearer path from C++ bindings to Torch wrappers.
8393
* **Effort**: Low-Medium.
8494
* **Implementation**:
85-
1. Integrate Sphinx or MkDocs into `docs/` to auto-generate Python API reference from docstrings and tie it to the existing docs site.
86-
2. Add a “Python Cookbook” doc with recipes showing how to combine `t81lib.pack_dense_matrix`, `t81.torch.TernaryTensor`, and CLI helpers.
87-
3. Consider re-exporting the binding objects via the higher-level `t81` module so users can `import t81` and access the full quantization stack.
95+
1. Expand MkDocs coverage by generating the Python API reference via mkdocstrings and ensuring key modules are linked from `docs/index.md`. **Done (entry-point links + extra directives).**
96+
2. Keep the “Python Cookbook” up to date with end-to-end recipes (bindings + `t81.torch` + CLI), and add a short "choose your entry point" table. **Done (entry points table).**
97+
3. Validate that the `t81` re-exports stay in sync with `t81lib` bindings and add a quick API surface checklist. **Done (checklist added).**
8898

8999
### Recommendation 4: Introduce a Standardized Quantization-Aware Training Benchmark
90100

@@ -93,8 +103,8 @@ The codebase is thoughtfully commented, consistently formatted by `clang-format`
93103
* **Effort**: High.
94104
* **Implementation**:
95105
1. Define a benchmark (e.g., small BERT or ViT on GLUE/CIFAR subsets) with FP32, PTQ, and QAT runs.
96-
2. Create a `scripts/` benchmark script that trains the model, applies `t81` quantization, and logs accuracy, model size, and latency.
97-
3. Document the benchmark/results in a new `BENCHMARKS.md` (link from `README.md`) so the community can reproduce and compare.
106+
2. Extend the existing `scripts/` benchmark tooling to log accuracy, model size, and latency in a standardized JSON schema.
107+
3. Update `BENCHMARKS.md` with reproducible baseline results and link the dataset/model artifacts used for comparisons.
98108

99109
### Recommendation 5: Harden the GPU Tensor Metadata Path
100110

docs/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ docs/index.md — Primary landing page for the documentation set.
77
This landing page highlights the most helpful resources for people discovering `t81lib` or wanting
88
to understand the balanced ternary engine without digging through specs immediately.
99

10+
## Featured example
11+
12+
Try the compact, end-to-end PTQ + QAT notebook that measures size, latency, and perplexity on Phi-3-mini:
13+
[`examples/ternary_phi3_ptq_qat_demo.ipynb`](../examples/ternary_phi3_ptq_qat_demo.ipynb).
14+
15+
**Featured demo**[Try Phi-3-mini PTQ + QAT](../examples/ternary_phi3_ptq_qat_demo.ipynb)
16+
17+
## Getting started for Torch users
18+
19+
If you are arriving from PyTorch or Hugging Face, use `t81` as the single entry point and alias it once:
20+
21+
```bash
22+
python3 -m venv .venv
23+
source .venv/bin/activate
24+
pip install ".[torch]"
25+
```
26+
27+
```python
28+
import t81 as t8
29+
30+
tensor = t8.torch.TernaryTensor.from_float(weight, threshold=0.45)
31+
output = tensor.matmul_input(input_tensor, bias=bias)
32+
```
33+
34+
From here: `t8.nn.Linear` for drop-in layers, `t8.convert`/`t8.gguf` for scripted conversion, and `t81 convert`/`t81 gguf` for CLI workflows.
35+
1036
## Core resources
1137

1238
- **Landing & Quick Start**[`README.md`](../README.md) contains the hero content, badges, and a comprehensive quick
@@ -22,6 +48,7 @@ to understand the balanced ternary engine without digging through specs immediat
2248
[`examples/ternary_sparse_preview.py`](../examples/ternary_sparse_preview.py) for runnable workflows.
2349
- **Python API reference**[`docs/python-api.md`](python-api.md) lays out how MkDocs plus `mkdocstrings` auto-generate the binding reference.
2450
- **Python cookbook**[`docs/python-cookbook.md`](python-cookbook.md) gathers recipes that mix `t81lib.pack_dense_matrix`, `t81.torch.TernaryTensor`, and the CLI helpers.
51+
- **Python entry points**[`docs/python-api.md`](python-api.md) and [`docs/python-cookbook.md`](python-cookbook.md) now include a quick table showing which module to import for each workflow.
2552
- **Python install paths**[`docs/python-install.md`](python-install.md) explains pip/pipx builds, validation tips, and CLI helper installs.
2653
- **PyTorch how-to**[`docs/torch.md`](torch.md) walks through `t81.torch`, `t81.nn`, conversion helpers, and how the CLI scripts mirror the Python flows.
2754
- **CLI reference**[`docs/references/cli-usage.md`](references/cli-usage.md) lists the unified `t81 convert`/`t81 gguf` helpers (with legacy `t81-convert`/`t81-gguf` aliases) plus `t81-qat`

0 commit comments

Comments
 (0)