graft-ml 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- graft_ml-0.1.0/.gitignore +11 -0
- graft_ml-0.1.0/LICENSE +21 -0
- graft_ml-0.1.0/PKG-INFO +235 -0
- graft_ml-0.1.0/README.md +188 -0
- graft_ml-0.1.0/assets/graft-lockup-dark.svg +13 -0
- graft_ml-0.1.0/assets/graft-lockup-light.svg +13 -0
- graft_ml-0.1.0/assets/graft-mark-dark.svg +4 -0
- graft_ml-0.1.0/assets/graft-mark-light.svg +4 -0
- graft_ml-0.1.0/pyproject.toml +83 -0
- graft_ml-0.1.0/src/graft/__init__.py +23 -0
- graft_ml-0.1.0/src/graft/chop.py +331 -0
- graft_ml-0.1.0/src/graft/cli.py +417 -0
- graft_ml-0.1.0/src/graft/compiler.py +337 -0
- graft_ml-0.1.0/src/graft/runtime.py +406 -0
- graft_ml-0.1.0/src/graft/scanner.py +316 -0
- graft_ml-0.1.0/tests/test_graft.py +262 -0
graft_ml-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Exowatt AI Lab / Couplet Physical AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
graft_ml-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: graft-ml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compile any codebase into a 3.5 MB neural specialist in milliseconds. Zero backprop, sub-4ms inference, 91% fewer frontier tokens.
|
|
5
|
+
Project-URL: Homepage, https://github.com/couplet-physical-ai/graft
|
|
6
|
+
Project-URL: Repository, https://github.com/couplet-physical-ai/graft
|
|
7
|
+
Project-URL: Issues, https://github.com/couplet-physical-ai/graft/issues
|
|
8
|
+
Author-email: Exowatt AI Lab <ai-lab@exowatt.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: codebase,flashlora,inference,lora,ml,ridge,safetensors,specialists,weights
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: numpy>=1.24
|
|
24
|
+
Requires-Dist: safetensors>=0.4.3
|
|
25
|
+
Provides-Extra: cuda
|
|
26
|
+
Requires-Dist: accelerate>=0.33; extra == 'cuda'
|
|
27
|
+
Requires-Dist: fastapi>=0.111; extra == 'cuda'
|
|
28
|
+
Requires-Dist: pydantic>=2.7; extra == 'cuda'
|
|
29
|
+
Requires-Dist: torch>=2.3; extra == 'cuda'
|
|
30
|
+
Requires-Dist: transformers>=4.45; extra == 'cuda'
|
|
31
|
+
Requires-Dist: uvicorn>=0.30; extra == 'cuda'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: fastapi>=0.111; extra == 'dev'
|
|
34
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
35
|
+
Requires-Dist: pydantic>=2.7; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=8.2; extra == 'dev'
|
|
37
|
+
Requires-Dist: uvicorn>=0.30; extra == 'dev'
|
|
38
|
+
Provides-Extra: server
|
|
39
|
+
Requires-Dist: fastapi>=0.111; extra == 'server'
|
|
40
|
+
Requires-Dist: pydantic>=2.7; extra == 'server'
|
|
41
|
+
Requires-Dist: uvicorn>=0.30; extra == 'server'
|
|
42
|
+
Provides-Extra: torch
|
|
43
|
+
Requires-Dist: accelerate>=0.33; extra == 'torch'
|
|
44
|
+
Requires-Dist: torch>=2.3; extra == 'torch'
|
|
45
|
+
Requires-Dist: transformers>=4.45; extra == 'torch'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<picture>
|
|
50
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-dark.svg" />
|
|
51
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-light.svg" />
|
|
52
|
+
<img alt="graft" src="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-dark.svg" width="280" />
|
|
53
|
+
</picture>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<h3 align="center">Compile any codebase into a 3.5 MB neural specialist in milliseconds.</h3>
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
Zero backprop · Physically chopped mid-layer decoders · Sub-4 ms GPU inference · 91% fewer frontier prompt tokens
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<p align="center">
|
|
63
|
+
<a href="#quickstart">Quickstart</a> ·
|
|
64
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
65
|
+
<a href="#benchmarks">Benchmarks</a> ·
|
|
66
|
+
<a href="#4-repo-real-code-refactor-case-study">4-Repo Case Study</a> ·
|
|
67
|
+
<a href="#cli-reference">CLI Reference</a> ·
|
|
68
|
+
<a href="LICENSE">MIT License</a>
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
Every AI coding agent wakes up with amnesia — re-reading the same codebases, schemas, and guardrails over and over through massive frontier prompts.
|
|
74
|
+
|
|
75
|
+
**Graft** compiles a repository, API contract, or policy corpus directly into a **3.5 MB `.safetensors` specialist adapter** in **milliseconds** using closed-form **FlashLoRA-Ridge** — with **zero gradient descent** and **zero training epochs**. All specialists share one physically chopped mid-layer trunk (`Qwen3-0.6B L14/28`, `Qwen3-4B L18/36`, or `Qwen3.5-9B L20/32`, `lm_head` deleted) and hot-swap in **0.30 ms** over PCIe, letting a single GPU serve thousands of specialists at **883 queries/sec**.
|
|
76
|
+
|
|
77
|
+
Keep frontier models for the hard 20%. Let 3.5 MB compiled repo brains handle the rest.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Quickstart
|
|
82
|
+
|
|
83
|
+
Install locally (runs out-of-the-box on any CPU laptop via pure-NumPy mode, or add `[cuda]` for full PyTorch + CUDA Graph mid-layer execution):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install graft-ml # CPU + CLI (lightweight core: numpy + safetensors)
|
|
87
|
+
pip install "graft-ml[server]" # + FastAPI multi-adapter hot-swap server
|
|
88
|
+
pip install "graft-ml[cuda]" # + PyTorch / Transformers / CUDA mid-layer trunk
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Compile any repository into a 3.5 MB specialist and query it in 3 commands:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1. Inspect files, SLOC, and estimated prompt tokens
|
|
95
|
+
graft scan .
|
|
96
|
+
|
|
97
|
+
# 2. Compile your codebase into a 3.5 MB .safetensors specialist (0 gradient steps)
|
|
98
|
+
graft compile . --out ./repo.graft.safetensors
|
|
99
|
+
|
|
100
|
+
# Or compile one or more labeled task specialists (e.g. PR guardrails, routers, auditors) on CUDA:
|
|
101
|
+
graft compile ./services --examples ./specialists.json --out ./adapters/ --device cuda
|
|
102
|
+
|
|
103
|
+
# 3. Query the compiled specialist with zero codebase context in the prompt
|
|
104
|
+
graft query ./repo.graft.safetensors "Where is the FlashLoRA-Ridge compiler implemented?"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Serve a whole directory of specialists on one shared trunk with sub-millisecond hot-swapping:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
graft serve ./adapters/ --port 8787
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Reproduce the compile speed, latency, memory footprint, and wrong-adapter causal-swap proof locally:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
graft bench
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## How It Works
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
Codebase / Policy Corpus ──▶ Mid-Layer Chopped Trunk (L14/28, lm_head deleted)
|
|
125
|
+
│
|
|
126
|
+
▼
|
|
127
|
+
Thin SVD + Closed-Form Dual Ridge
|
|
128
|
+
(0 backprop · ~145 ms · 3.54 MB)
|
|
129
|
+
│
|
|
130
|
+
▼
|
|
131
|
+
repo.graft.safetensors (3.54 MB)
|
|
132
|
+
│
|
|
133
|
+
┌──────────────────────────────┼──────────────────────────────┐
|
|
134
|
+
▼ ▼ ▼
|
|
135
|
+
graft query graft serve Frontier Agent
|
|
136
|
+
3.77 ms p50 (L4) 883 QPS · 0.30 ms hot-swap -91% prompt tokens
|
|
137
|
+
0 context tokens 1M models = 3.38 TB NVMe 4.7× lower API spend
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
1. **Physical Mid-Layer Chop (`graft.chop`):** Semantic representations saturate near the middle of modern causal decoders (`L14/28` on `Qwen3-0.6B`, `L18/36` on `Qwen3-4B`, `L20/32` on `Qwen3.5-9B`). Graft physically discards the upper layers and deletes `lm_head`, cutting trunk VRAM to **716.8 MB** (3.2% of a single 24 GB L4 GPU) and unlocking **3.77 ms** CUDA Graph inference.
|
|
141
|
+
2. **Zero-Backprop FlashLoRA-Ridge (`graft.compiler`):** Given a scanned codebase or labeled support set, Graft extracts the top-*r* task subspace via thin SVD to synthesize per-layer residual + MLP rank-*r* LoRA factors, re-encodes with those adapters active, and solves `(Z Zᵀ + λI) α = Y` in one closed-form linear solve. No optimizer, no epochs, no catastrophic forgetting.
|
|
142
|
+
3. **Multi-Adapter Hot-Swap Runtime (`graft.runtime`):** Every specialist is a standalone **~3.54 MB `.safetensors`** file. One GPU holds ~35,000 active specialists in VRAM, streams cold adapters from NVMe in **0.284 ms**, DMAs pinned host adapters in **295.6 µs**, and executes heterogeneous batches where every item runs a *different* specialist at **+0.3% overhead**.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Benchmarks
|
|
147
|
+
|
|
148
|
+
### 10-System Live NVIDIA L4 GPU vs. Live Claude Opus 5.5 Study
|
|
149
|
+
|
|
150
|
+
Measured on an AWS `g6.2xlarge` (1× NVIDIA L4 24 GB, `$0.9776/hr` on-demand) across **10 distinct engineering & enterprise specialist systems** (PR Guardrail, API Auditor, Incident Router, Cloud IAM Guard, SQL Guard, CI Root-Cause, Support Policy, Contract Checker, UI Action Grounder, Hardware BOM) evaluated on **240 unseen held-out queries**, compared head-to-head against **80 live untruncated Claude Opus 5.5 API calls** (`$4/1M` input, `$20/1M` output):
|
|
151
|
+
|
|
152
|
+
| Metric | Graft 3.5 MB (`Qwen3-0.6B L14`) | Graft 3.8 MB (`Qwen3-4B L18`) | Live Claude Opus 5.5 (Full Prompt) | Advantage |
|
|
153
|
+
|---|---:|---:|---:|---|
|
|
154
|
+
| **Adapter Size on Disk** | **3.54 MB** (`.safetensors`) | **3.84 MB** (`.safetensors`) | N/A (962 tok re-sent every call) | **0 policy tokens at query** |
|
|
155
|
+
| **Compile Time (0 gradient steps)** | **145.3 ms** (p50) | **639.1 ms** | N/A | **Instant compilation** |
|
|
156
|
+
| **Held-Out Accuracy (240 unseen / 80 matched)** | **91.25%** / `92.50%` | **94.58%** / **`96.25%`** | **`98.75%`** (79/80) | **Within 2.5 pts at 104×–543× speed** |
|
|
157
|
+
| **Zero-Shot Chopped Base Floor** | `13.33%` | `19.17%` | — | **`+77.9` / `+75.4` pts from weights** |
|
|
158
|
+
| **Wrong-Adapter Causal Swap Control** | **`12.08%`** (**`-79.2 pt`**) | **`13.75%`** (**`-80.8 pt`**) | — | **Causal proof weights hold knowledge** |
|
|
159
|
+
| **Inference Latency (p50)** | **`3.77 ms`** (CUDA Graph) | **`19.76 ms`** (CUDA Graph) | **`2,046.1 ms`** | **`543×` faster (0.6B) · `104×` (4B)** |
|
|
160
|
+
| **Cost / 1,000 Queries (B=1 / B=16)** | **`$0.00102`** / **`$0.00031`** | **`$0.00537`** / — | **`$6.681`** | **`6,537×`–`21,761×` cheaper** |
|
|
161
|
+
|
|
162
|
+
**1,000-Adapter Live L4 Scaling Receipts:**
|
|
163
|
+
- **Shared Chopped Trunk VRAM:** `716.8 MB` (`Qwen3-0.6B L14`, 375.8M active params)
|
|
164
|
+
- **Per-Specialist Disk Footprint:** `3.539 MB` → **1,000,000 specialists = `3.375 TB`** (one 4 TB NVMe SSD)
|
|
165
|
+
- **NVMe → DDR Cold Read:** `0.284 ms` p50 · **Pinned DDR → HBM DMA:** `295.6 µs` p50 (active residual `57.1 µs`)
|
|
166
|
+
- **Heterogeneous Multi-Adapter Batching (B=16 distinct specialists in one pass):** **`883 QPS`** at `+0.06 ms` (`+0.3%`) overhead
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 4-Repo Real-Code Refactor Case Study
|
|
171
|
+
|
|
172
|
+
We ran an identical production cross-repo refactor (pure ASGI request tracing, `Server-Timing`, non-clobbering security headers, `RequestIdFilter`, and tests) across **4 real Python production services** (**24,271 total Python SLOC**, **691 existing passing pytest tests**) in isolated sandboxes — comparing **Arm A (Claude Opus 5.5 only)** vs. **Arm B (6 compiled 3.54 MB Graft specialists + surgical Opus 5.5)**:
|
|
173
|
+
|
|
174
|
+
| Metric | Arm A — Frontier Only (Opus 5.5) | Arm B — 6 Graft Specialists + Surgical Opus | Measured Delta |
|
|
175
|
+
|---|---:|---:|---:|
|
|
176
|
+
| **Codebase Scale** | 4 repos · 24,271 Python SLOC | 4 repos · 24,271 Python SLOC | Identical sandboxes |
|
|
177
|
+
| **Compile Time (All 6 Specialists)** | — | **1.24 s** (`51 ms / kSLOC`, 21.2 MB total) | 0 gradient steps |
|
|
178
|
+
| **Agent / AI Time (excl. pytest)** | 386.86 s (6m 27s) | **108.63 s** (1m 49s, incl. 1.24 s compile) | **`3.56×` faster** (-71.9%) |
|
|
179
|
+
| **End-to-End Wall Time (incl. pytest)** | 465.63 s (7m 46s) | **185.89 s** (3m 06s) | **`2.50×` faster** (-60.1%) |
|
|
180
|
+
| **Frontier Prompt (Input) Tokens** | 117,647 tok | **10,622 tok** | **`-91.0%` fewer tokens** |
|
|
181
|
+
| **Total Frontier Tokens (In + Out)** | 162,655 tok | **23,089 tok** | **`-85.8%` fewer tokens** |
|
|
182
|
+
| **Total Cost (Active L4 GPU + Opus)** | $1.3707 | **$0.2923** | **`4.69×` cheaper** (-78.7%) |
|
|
183
|
+
| **Existing Real Pytest Suite** | 691 / 691 (100%) | **691 / 691 (100%)** | Zero regressions |
|
|
184
|
+
| **Independent 40-Check Live ASGI Probe** | 40 / 40 (100%) | **40 / 40 (100%)** | Tie (100% pass) |
|
|
185
|
+
| **Blind Staff-Engineer Review** | 8.7 / 10 | **8.9 / 10** | **+0.2 overall** |
|
|
186
|
+
|
|
187
|
+
*Honest caveats:* Live runtime accuracy across the 29 specialist calls was 25/29 (86.2%) — 4 low-confidence (`0.27–0.58`) raw-code-snippet classifications missed and were safely absorbed by the surgical frontier step. Confidence-gated fallback (`conf < 0.65`) or upgrading noisy code-snippet specialists to `qwen3-4b` (`L18/36`) closes that gap.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## CLI Reference
|
|
192
|
+
|
|
193
|
+
| Command | Description |
|
|
194
|
+
|---|---|
|
|
195
|
+
| `graft scan [repo]` | Count files, exact SLOC, languages, prompt-token equivalent, and estimated adapter size. |
|
|
196
|
+
| `graft compile [repo] --out adapter.graft.safetensors` | Scan & compile a repository (or `--examples specialists.json` bundle) into 3.5 MB `.safetensors` specialist(s) + `.manifest.json` with exact `compile_ms` and `ms / kSLOC`. |
|
|
197
|
+
| `graft query <adapter.safetensors> "<question or diff>"` | Run instant structured inference against a compiled specialist (returns verdict, confidence, latency ms, and tokens saved). |
|
|
198
|
+
| `graft serve <adapters_dir> --port 8787` | Start the FastAPI multi-adapter hot-swap HTTP server (`/query`, `/query/batch`, `/swap`, `/adapters`, `/health`). |
|
|
199
|
+
| `graft bench` | Reproduce compile speed, warm query latency, hot-swap cache timing, and causal wrong-adapter accuracy collapse locally. |
|
|
200
|
+
|
|
201
|
+
All commands support `--json` for clean machine consumption and `--device {numpy,auto,cpu,cuda}` plus `--backbone {qwen3-0.6b,qwen3-4b,qwen3.5-9b}`.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Python API
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
from graft import AdapterRuntime, compile_repo
|
|
209
|
+
|
|
210
|
+
# Compile any local repository into a 3.5 MB .safetensors specialist
|
|
211
|
+
result = compile_repo(".", "./myrepo.graft.safetensors", backbone="qwen3-0.6b")
|
|
212
|
+
print(f"{result.total_sloc:,} SLOC -> {result.file_mb:.2f} MB in {result.compile_ms:.1f} ms")
|
|
213
|
+
|
|
214
|
+
# Load & query with sub-millisecond hot-swapping
|
|
215
|
+
rt = AdapterRuntime(backbone="qwen3-0.6b")
|
|
216
|
+
rt.load_adapter(result.adapter_path, adapter_id="myrepo")
|
|
217
|
+
ans = rt.query("Where is the closed-form Ridge solver implemented?", adapter_id="myrepo")
|
|
218
|
+
print(ans.verdict, ans.confidence, f"{ans.latency_ms:.2f} ms")
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Development
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
uv venv --python 3.12
|
|
227
|
+
uv pip install --python .venv/bin/python -e ".[dev]"
|
|
228
|
+
.venv/bin/pytest -q
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT © 2026 Exowatt AI Lab / Couplet Physical AI. See [LICENSE](LICENSE).
|
graft_ml-0.1.0/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-dark.svg" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-light.svg" />
|
|
5
|
+
<img alt="graft" src="https://raw.githubusercontent.com/couplet-physical-ai/graft/main/assets/graft-lockup-dark.svg" width="280" />
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h3 align="center">Compile any codebase into a 3.5 MB neural specialist in milliseconds.</h3>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
Zero backprop · Physically chopped mid-layer decoders · Sub-4 ms GPU inference · 91% fewer frontier prompt tokens
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="#quickstart">Quickstart</a> ·
|
|
17
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
18
|
+
<a href="#benchmarks">Benchmarks</a> ·
|
|
19
|
+
<a href="#4-repo-real-code-refactor-case-study">4-Repo Case Study</a> ·
|
|
20
|
+
<a href="#cli-reference">CLI Reference</a> ·
|
|
21
|
+
<a href="LICENSE">MIT License</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
Every AI coding agent wakes up with amnesia — re-reading the same codebases, schemas, and guardrails over and over through massive frontier prompts.
|
|
27
|
+
|
|
28
|
+
**Graft** compiles a repository, API contract, or policy corpus directly into a **3.5 MB `.safetensors` specialist adapter** in **milliseconds** using closed-form **FlashLoRA-Ridge** — with **zero gradient descent** and **zero training epochs**. All specialists share one physically chopped mid-layer trunk (`Qwen3-0.6B L14/28`, `Qwen3-4B L18/36`, or `Qwen3.5-9B L20/32`, `lm_head` deleted) and hot-swap in **0.30 ms** over PCIe, letting a single GPU serve thousands of specialists at **883 queries/sec**.
|
|
29
|
+
|
|
30
|
+
Keep frontier models for the hard 20%. Let 3.5 MB compiled repo brains handle the rest.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quickstart
|
|
35
|
+
|
|
36
|
+
Install locally (runs out-of-the-box on any CPU laptop via pure-NumPy mode, or add `[cuda]` for full PyTorch + CUDA Graph mid-layer execution):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install graft-ml # CPU + CLI (lightweight core: numpy + safetensors)
|
|
40
|
+
pip install "graft-ml[server]" # + FastAPI multi-adapter hot-swap server
|
|
41
|
+
pip install "graft-ml[cuda]" # + PyTorch / Transformers / CUDA mid-layer trunk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Compile any repository into a 3.5 MB specialist and query it in 3 commands:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 1. Inspect files, SLOC, and estimated prompt tokens
|
|
48
|
+
graft scan .
|
|
49
|
+
|
|
50
|
+
# 2. Compile your codebase into a 3.5 MB .safetensors specialist (0 gradient steps)
|
|
51
|
+
graft compile . --out ./repo.graft.safetensors
|
|
52
|
+
|
|
53
|
+
# Or compile one or more labeled task specialists (e.g. PR guardrails, routers, auditors) on CUDA:
|
|
54
|
+
graft compile ./services --examples ./specialists.json --out ./adapters/ --device cuda
|
|
55
|
+
|
|
56
|
+
# 3. Query the compiled specialist with zero codebase context in the prompt
|
|
57
|
+
graft query ./repo.graft.safetensors "Where is the FlashLoRA-Ridge compiler implemented?"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Serve a whole directory of specialists on one shared trunk with sub-millisecond hot-swapping:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
graft serve ./adapters/ --port 8787
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Reproduce the compile speed, latency, memory footprint, and wrong-adapter causal-swap proof locally:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
graft bench
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## How It Works
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
Codebase / Policy Corpus ──▶ Mid-Layer Chopped Trunk (L14/28, lm_head deleted)
|
|
78
|
+
│
|
|
79
|
+
▼
|
|
80
|
+
Thin SVD + Closed-Form Dual Ridge
|
|
81
|
+
(0 backprop · ~145 ms · 3.54 MB)
|
|
82
|
+
│
|
|
83
|
+
▼
|
|
84
|
+
repo.graft.safetensors (3.54 MB)
|
|
85
|
+
│
|
|
86
|
+
┌──────────────────────────────┼──────────────────────────────┐
|
|
87
|
+
▼ ▼ ▼
|
|
88
|
+
graft query graft serve Frontier Agent
|
|
89
|
+
3.77 ms p50 (L4) 883 QPS · 0.30 ms hot-swap -91% prompt tokens
|
|
90
|
+
0 context tokens 1M models = 3.38 TB NVMe 4.7× lower API spend
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
1. **Physical Mid-Layer Chop (`graft.chop`):** Semantic representations saturate near the middle of modern causal decoders (`L14/28` on `Qwen3-0.6B`, `L18/36` on `Qwen3-4B`, `L20/32` on `Qwen3.5-9B`). Graft physically discards the upper layers and deletes `lm_head`, cutting trunk VRAM to **716.8 MB** (3.2% of a single 24 GB L4 GPU) and unlocking **3.77 ms** CUDA Graph inference.
|
|
94
|
+
2. **Zero-Backprop FlashLoRA-Ridge (`graft.compiler`):** Given a scanned codebase or labeled support set, Graft extracts the top-*r* task subspace via thin SVD to synthesize per-layer residual + MLP rank-*r* LoRA factors, re-encodes with those adapters active, and solves `(Z Zᵀ + λI) α = Y` in one closed-form linear solve. No optimizer, no epochs, no catastrophic forgetting.
|
|
95
|
+
3. **Multi-Adapter Hot-Swap Runtime (`graft.runtime`):** Every specialist is a standalone **~3.54 MB `.safetensors`** file. One GPU holds ~35,000 active specialists in VRAM, streams cold adapters from NVMe in **0.284 ms**, DMAs pinned host adapters in **295.6 µs**, and executes heterogeneous batches where every item runs a *different* specialist at **+0.3% overhead**.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Benchmarks
|
|
100
|
+
|
|
101
|
+
### 10-System Live NVIDIA L4 GPU vs. Live Claude Opus 5.5 Study
|
|
102
|
+
|
|
103
|
+
Measured on an AWS `g6.2xlarge` (1× NVIDIA L4 24 GB, `$0.9776/hr` on-demand) across **10 distinct engineering & enterprise specialist systems** (PR Guardrail, API Auditor, Incident Router, Cloud IAM Guard, SQL Guard, CI Root-Cause, Support Policy, Contract Checker, UI Action Grounder, Hardware BOM) evaluated on **240 unseen held-out queries**, compared head-to-head against **80 live untruncated Claude Opus 5.5 API calls** (`$4/1M` input, `$20/1M` output):
|
|
104
|
+
|
|
105
|
+
| Metric | Graft 3.5 MB (`Qwen3-0.6B L14`) | Graft 3.8 MB (`Qwen3-4B L18`) | Live Claude Opus 5.5 (Full Prompt) | Advantage |
|
|
106
|
+
|---|---:|---:|---:|---|
|
|
107
|
+
| **Adapter Size on Disk** | **3.54 MB** (`.safetensors`) | **3.84 MB** (`.safetensors`) | N/A (962 tok re-sent every call) | **0 policy tokens at query** |
|
|
108
|
+
| **Compile Time (0 gradient steps)** | **145.3 ms** (p50) | **639.1 ms** | N/A | **Instant compilation** |
|
|
109
|
+
| **Held-Out Accuracy (240 unseen / 80 matched)** | **91.25%** / `92.50%` | **94.58%** / **`96.25%`** | **`98.75%`** (79/80) | **Within 2.5 pts at 104×–543× speed** |
|
|
110
|
+
| **Zero-Shot Chopped Base Floor** | `13.33%` | `19.17%` | — | **`+77.9` / `+75.4` pts from weights** |
|
|
111
|
+
| **Wrong-Adapter Causal Swap Control** | **`12.08%`** (**`-79.2 pt`**) | **`13.75%`** (**`-80.8 pt`**) | — | **Causal proof weights hold knowledge** |
|
|
112
|
+
| **Inference Latency (p50)** | **`3.77 ms`** (CUDA Graph) | **`19.76 ms`** (CUDA Graph) | **`2,046.1 ms`** | **`543×` faster (0.6B) · `104×` (4B)** |
|
|
113
|
+
| **Cost / 1,000 Queries (B=1 / B=16)** | **`$0.00102`** / **`$0.00031`** | **`$0.00537`** / — | **`$6.681`** | **`6,537×`–`21,761×` cheaper** |
|
|
114
|
+
|
|
115
|
+
**1,000-Adapter Live L4 Scaling Receipts:**
|
|
116
|
+
- **Shared Chopped Trunk VRAM:** `716.8 MB` (`Qwen3-0.6B L14`, 375.8M active params)
|
|
117
|
+
- **Per-Specialist Disk Footprint:** `3.539 MB` → **1,000,000 specialists = `3.375 TB`** (one 4 TB NVMe SSD)
|
|
118
|
+
- **NVMe → DDR Cold Read:** `0.284 ms` p50 · **Pinned DDR → HBM DMA:** `295.6 µs` p50 (active residual `57.1 µs`)
|
|
119
|
+
- **Heterogeneous Multi-Adapter Batching (B=16 distinct specialists in one pass):** **`883 QPS`** at `+0.06 ms` (`+0.3%`) overhead
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 4-Repo Real-Code Refactor Case Study
|
|
124
|
+
|
|
125
|
+
We ran an identical production cross-repo refactor (pure ASGI request tracing, `Server-Timing`, non-clobbering security headers, `RequestIdFilter`, and tests) across **4 real Python production services** (**24,271 total Python SLOC**, **691 existing passing pytest tests**) in isolated sandboxes — comparing **Arm A (Claude Opus 5.5 only)** vs. **Arm B (6 compiled 3.54 MB Graft specialists + surgical Opus 5.5)**:
|
|
126
|
+
|
|
127
|
+
| Metric | Arm A — Frontier Only (Opus 5.5) | Arm B — 6 Graft Specialists + Surgical Opus | Measured Delta |
|
|
128
|
+
|---|---:|---:|---:|
|
|
129
|
+
| **Codebase Scale** | 4 repos · 24,271 Python SLOC | 4 repos · 24,271 Python SLOC | Identical sandboxes |
|
|
130
|
+
| **Compile Time (All 6 Specialists)** | — | **1.24 s** (`51 ms / kSLOC`, 21.2 MB total) | 0 gradient steps |
|
|
131
|
+
| **Agent / AI Time (excl. pytest)** | 386.86 s (6m 27s) | **108.63 s** (1m 49s, incl. 1.24 s compile) | **`3.56×` faster** (-71.9%) |
|
|
132
|
+
| **End-to-End Wall Time (incl. pytest)** | 465.63 s (7m 46s) | **185.89 s** (3m 06s) | **`2.50×` faster** (-60.1%) |
|
|
133
|
+
| **Frontier Prompt (Input) Tokens** | 117,647 tok | **10,622 tok** | **`-91.0%` fewer tokens** |
|
|
134
|
+
| **Total Frontier Tokens (In + Out)** | 162,655 tok | **23,089 tok** | **`-85.8%` fewer tokens** |
|
|
135
|
+
| **Total Cost (Active L4 GPU + Opus)** | $1.3707 | **$0.2923** | **`4.69×` cheaper** (-78.7%) |
|
|
136
|
+
| **Existing Real Pytest Suite** | 691 / 691 (100%) | **691 / 691 (100%)** | Zero regressions |
|
|
137
|
+
| **Independent 40-Check Live ASGI Probe** | 40 / 40 (100%) | **40 / 40 (100%)** | Tie (100% pass) |
|
|
138
|
+
| **Blind Staff-Engineer Review** | 8.7 / 10 | **8.9 / 10** | **+0.2 overall** |
|
|
139
|
+
|
|
140
|
+
*Honest caveats:* Live runtime accuracy across the 29 specialist calls was 25/29 (86.2%) — 4 low-confidence (`0.27–0.58`) raw-code-snippet classifications missed and were safely absorbed by the surgical frontier step. Confidence-gated fallback (`conf < 0.65`) or upgrading noisy code-snippet specialists to `qwen3-4b` (`L18/36`) closes that gap.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## CLI Reference
|
|
145
|
+
|
|
146
|
+
| Command | Description |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `graft scan [repo]` | Count files, exact SLOC, languages, prompt-token equivalent, and estimated adapter size. |
|
|
149
|
+
| `graft compile [repo] --out adapter.graft.safetensors` | Scan & compile a repository (or `--examples specialists.json` bundle) into 3.5 MB `.safetensors` specialist(s) + `.manifest.json` with exact `compile_ms` and `ms / kSLOC`. |
|
|
150
|
+
| `graft query <adapter.safetensors> "<question or diff>"` | Run instant structured inference against a compiled specialist (returns verdict, confidence, latency ms, and tokens saved). |
|
|
151
|
+
| `graft serve <adapters_dir> --port 8787` | Start the FastAPI multi-adapter hot-swap HTTP server (`/query`, `/query/batch`, `/swap`, `/adapters`, `/health`). |
|
|
152
|
+
| `graft bench` | Reproduce compile speed, warm query latency, hot-swap cache timing, and causal wrong-adapter accuracy collapse locally. |
|
|
153
|
+
|
|
154
|
+
All commands support `--json` for clean machine consumption and `--device {numpy,auto,cpu,cuda}` plus `--backbone {qwen3-0.6b,qwen3-4b,qwen3.5-9b}`.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Python API
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from graft import AdapterRuntime, compile_repo
|
|
162
|
+
|
|
163
|
+
# Compile any local repository into a 3.5 MB .safetensors specialist
|
|
164
|
+
result = compile_repo(".", "./myrepo.graft.safetensors", backbone="qwen3-0.6b")
|
|
165
|
+
print(f"{result.total_sloc:,} SLOC -> {result.file_mb:.2f} MB in {result.compile_ms:.1f} ms")
|
|
166
|
+
|
|
167
|
+
# Load & query with sub-millisecond hot-swapping
|
|
168
|
+
rt = AdapterRuntime(backbone="qwen3-0.6b")
|
|
169
|
+
rt.load_adapter(result.adapter_path, adapter_id="myrepo")
|
|
170
|
+
ans = rt.query("Where is the closed-form Ridge solver implemented?", adapter_id="myrepo")
|
|
171
|
+
print(ans.verdict, ans.confidence, f"{ans.latency_ms:.2f} ms")
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Development
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
uv venv --python 3.12
|
|
180
|
+
uv pip install --python .venv/bin/python -e ".[dev]"
|
|
181
|
+
.venv/bin/pytest -q
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT © 2026 Exowatt AI Lab / Couplet Physical AI. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="335" height="128" viewBox="0 0 335 128" fill="none">
|
|
2
|
+
<g transform="translate(-6.080, 12.560) scale(0.92000)">
|
|
3
|
+
<path d="M 72.719,43.983 L 87.406,36.174 A 33.000,33.000 0 0 1 90.000,49.000 L 90.000,77.500 A 33.000,33.000 0 0 1 34.076,101.238 A 8.250,8.250 0 0 1 45.538,89.369 A 16.500,16.500 0 0 0 73.500,77.579 A 33.000,33.000 0 0 1 29.364,67.035 L 44.051,59.226 A 16.500,16.500 0 0 0 72.719,43.983 Z" fill="#F4F1EA"/>
|
|
4
|
+
<path d="M 26.594,61.826 A 33.000,33.000 0 0 1 57.000,16.000 C 74.000,16.000 88.500,16.200 98.213,20.574 Q 102.455,20.244 99.528,23.047 L 69.949,38.774 A 16.500,16.500 0 0 0 41.281,54.017 Z" fill="#7FC48F"/>
|
|
5
|
+
</g>
|
|
6
|
+
<g transform="translate(113.600, 87.000)">
|
|
7
|
+
<path d="M620 -442Q418 -442 296.0 -368.0Q174 -294 132 -183L352 -104Q378 -152 437.5 -198.0Q497 -244 619 -244Q740 -244 813.0 -187.5Q886 -131 886 -11V200H864Q844 160 807.0 117.0Q770 74 708.0 45.5Q646 17 549 17Q421 17 316.5 77.5Q212 138 150.5 259.0Q89 380 89 562Q89 745 150.5 872.5Q212 1000 317.0 1066.0Q422 1132 551 1132Q650 1132 714.0 1099.0Q778 1066 816.0 1019.5Q854 973 874 933H888V1118H1143V-3Q1143 -153 1075.0 -250.0Q1007 -347 889.0 -394.5Q771 -442 620 -442ZM622 222Q749 222 818.0 313.0Q887 404 887 564Q887 723 819.0 820.5Q751 918 622 918Q490 918 422.5 817.0Q355 716 355 564Q355 409 423.0 315.5Q491 222 622 222Z" transform="translate(-4.304, 0) scale(0.048358, -0.048358)" fill="#F4F1EA"/>
|
|
8
|
+
<path d="M138 0V1118H390V931H402Q432 1028 507.0 1080.5Q582 1133 678 1133Q728 1133 773 1126V887Q757 891 721.0 895.5Q685 900 650 900Q541 900 469.5 832.5Q398 765 398 658V0Z" transform="translate(52.691, 0) scale(0.048358, -0.048358)" fill="#F4F1EA"/>
|
|
9
|
+
<path d="M450 -23Q344 -23 259.0 15.5Q174 54 125.0 129.0Q76 204 76 314Q76 440 137.5 509.5Q199 579 296.5 610.5Q394 642 502 653Q648 669 713.0 682.5Q778 696 778 754V759Q778 841 728.0 886.5Q678 932 583 932Q485 932 427.0 889.0Q369 846 349 791L108 840Q157 988 285.5 1060.0Q414 1132 582 1132Q661 1132 741.5 1113.5Q822 1095 889.0 1051.5Q956 1008 997.0 933.5Q1038 859 1038 747V0H789V154H779Q742 82 661.0 29.5Q580 -23 450 -23ZM517 170Q637 170 708.5 239.0Q780 308 780 401V533Q762 519 716.0 508.5Q670 498 618.5 490.5Q567 483 533 478Q445 466 386.5 430.0Q328 394 328 317Q328 245 381.0 207.5Q434 170 517 170Z" transform="translate(85.668, 0) scale(0.048358, -0.048358)" fill="#F4F1EA"/>
|
|
10
|
+
<path d="M726 1118V914H484V0H225V914H20V1118H225V1225Q225 1336 272.0 1410.5Q319 1485 397.5 1522.5Q476 1560 572 1560Q641 1560 694.0 1549.0Q747 1538 772 1529L719 1327Q702 1332 677.5 1337.5Q653 1343 620 1343Q547 1343 515.5 1307.0Q484 1271 484 1205V1118Z" transform="translate(137.783, 0) scale(0.048358, -0.048358)" fill="#F4F1EA"/>
|
|
11
|
+
<path d="M655 1118V914H439V315Q439 254 464.5 225.5Q490 197 550 197Q568 197 597.0 201.5Q626 206 645 210L686 9Q643 -4 598.0 -9.5Q553 -15 512 -15Q351 -15 265.0 65.0Q179 145 179 293V914H20V1118H179V1384H439V1118Z" transform="translate(169.937, 0) scale(0.048358, -0.048358)" fill="#F4F1EA"/>
|
|
12
|
+
</g>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="335" height="128" viewBox="0 0 335 128" fill="none">
|
|
2
|
+
<g transform="translate(-6.080, 12.560) scale(0.92000)">
|
|
3
|
+
<path d="M 72.719,43.983 L 87.406,36.174 A 33.000,33.000 0 0 1 90.000,49.000 L 90.000,77.500 A 33.000,33.000 0 0 1 34.076,101.238 A 8.250,8.250 0 0 1 45.538,89.369 A 16.500,16.500 0 0 0 73.500,77.579 A 33.000,33.000 0 0 1 29.364,67.035 L 44.051,59.226 A 16.500,16.500 0 0 0 72.719,43.983 Z" fill="#141413"/>
|
|
4
|
+
<path d="M 26.594,61.826 A 33.000,33.000 0 0 1 57.000,16.000 C 74.000,16.000 88.500,16.200 98.213,20.574 Q 102.455,20.244 99.528,23.047 L 69.949,38.774 A 16.500,16.500 0 0 0 41.281,54.017 Z" fill="#2A6B45"/>
|
|
5
|
+
</g>
|
|
6
|
+
<g transform="translate(113.600, 87.000)">
|
|
7
|
+
<path d="M620 -442Q418 -442 296.0 -368.0Q174 -294 132 -183L352 -104Q378 -152 437.5 -198.0Q497 -244 619 -244Q740 -244 813.0 -187.5Q886 -131 886 -11V200H864Q844 160 807.0 117.0Q770 74 708.0 45.5Q646 17 549 17Q421 17 316.5 77.5Q212 138 150.5 259.0Q89 380 89 562Q89 745 150.5 872.5Q212 1000 317.0 1066.0Q422 1132 551 1132Q650 1132 714.0 1099.0Q778 1066 816.0 1019.5Q854 973 874 933H888V1118H1143V-3Q1143 -153 1075.0 -250.0Q1007 -347 889.0 -394.5Q771 -442 620 -442ZM622 222Q749 222 818.0 313.0Q887 404 887 564Q887 723 819.0 820.5Q751 918 622 918Q490 918 422.5 817.0Q355 716 355 564Q355 409 423.0 315.5Q491 222 622 222Z" transform="translate(-4.304, 0) scale(0.048358, -0.048358)" fill="#141413"/>
|
|
8
|
+
<path d="M138 0V1118H390V931H402Q432 1028 507.0 1080.5Q582 1133 678 1133Q728 1133 773 1126V887Q757 891 721.0 895.5Q685 900 650 900Q541 900 469.5 832.5Q398 765 398 658V0Z" transform="translate(52.691, 0) scale(0.048358, -0.048358)" fill="#141413"/>
|
|
9
|
+
<path d="M450 -23Q344 -23 259.0 15.5Q174 54 125.0 129.0Q76 204 76 314Q76 440 137.5 509.5Q199 579 296.5 610.5Q394 642 502 653Q648 669 713.0 682.5Q778 696 778 754V759Q778 841 728.0 886.5Q678 932 583 932Q485 932 427.0 889.0Q369 846 349 791L108 840Q157 988 285.5 1060.0Q414 1132 582 1132Q661 1132 741.5 1113.5Q822 1095 889.0 1051.5Q956 1008 997.0 933.5Q1038 859 1038 747V0H789V154H779Q742 82 661.0 29.5Q580 -23 450 -23ZM517 170Q637 170 708.5 239.0Q780 308 780 401V533Q762 519 716.0 508.5Q670 498 618.5 490.5Q567 483 533 478Q445 466 386.5 430.0Q328 394 328 317Q328 245 381.0 207.5Q434 170 517 170Z" transform="translate(85.668, 0) scale(0.048358, -0.048358)" fill="#141413"/>
|
|
10
|
+
<path d="M726 1118V914H484V0H225V914H20V1118H225V1225Q225 1336 272.0 1410.5Q319 1485 397.5 1522.5Q476 1560 572 1560Q641 1560 694.0 1549.0Q747 1538 772 1529L719 1327Q702 1332 677.5 1337.5Q653 1343 620 1343Q547 1343 515.5 1307.0Q484 1271 484 1205V1118Z" transform="translate(137.783, 0) scale(0.048358, -0.048358)" fill="#141413"/>
|
|
11
|
+
<path d="M655 1118V914H439V315Q439 254 464.5 225.5Q490 197 550 197Q568 197 597.0 201.5Q626 206 645 210L686 9Q643 -4 598.0 -9.5Q553 -15 512 -15Q351 -15 265.0 65.0Q179 145 179 293V914H20V1118H179V1384H439V1118Z" transform="translate(169.937, 0) scale(0.048358, -0.048358)" fill="#141413"/>
|
|
12
|
+
</g>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128" fill="none">
|
|
2
|
+
<path d="M 72.719,43.983 L 87.406,36.174 A 33.000,33.000 0 0 1 90.000,49.000 L 90.000,77.500 A 33.000,33.000 0 0 1 34.076,101.238 A 8.250,8.250 0 0 1 45.538,89.369 A 16.500,16.500 0 0 0 73.500,77.579 A 33.000,33.000 0 0 1 29.364,67.035 L 44.051,59.226 A 16.500,16.500 0 0 0 72.719,43.983 Z" fill="#F4F1EA"/>
|
|
3
|
+
<path d="M 26.594,61.826 A 33.000,33.000 0 0 1 57.000,16.000 C 74.000,16.000 88.500,16.200 98.213,20.574 Q 102.455,20.244 99.528,23.047 L 69.949,38.774 A 16.500,16.500 0 0 0 41.281,54.017 Z" fill="#7FC48F"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128" fill="none">
|
|
2
|
+
<path d="M 72.719,43.983 L 87.406,36.174 A 33.000,33.000 0 0 1 90.000,49.000 L 90.000,77.500 A 33.000,33.000 0 0 1 34.076,101.238 A 8.250,8.250 0 0 1 45.538,89.369 A 16.500,16.500 0 0 0 73.500,77.579 A 33.000,33.000 0 0 1 29.364,67.035 L 44.051,59.226 A 16.500,16.500 0 0 0 72.719,43.983 Z" fill="#141413"/>
|
|
3
|
+
<path d="M 26.594,61.826 A 33.000,33.000 0 0 1 57.000,16.000 C 74.000,16.000 88.500,16.200 98.213,20.574 Q 102.455,20.244 99.528,23.047 L 69.949,38.774 A 16.500,16.500 0 0 0 41.281,54.017 Z" fill="#2A6B45"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "graft-ml"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Compile any codebase into a 3.5 MB neural specialist in milliseconds. Zero backprop, sub-4ms inference, 91% fewer frontier tokens."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Exowatt AI Lab", email = "ai-lab@exowatt.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"lora",
|
|
17
|
+
"weights",
|
|
18
|
+
"specialists",
|
|
19
|
+
"codebase",
|
|
20
|
+
"flashlora",
|
|
21
|
+
"ridge",
|
|
22
|
+
"inference",
|
|
23
|
+
"safetensors",
|
|
24
|
+
"ml",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Intended Audience :: Science/Research",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
36
|
+
"Topic :: Software Development :: Compilers",
|
|
37
|
+
]
|
|
38
|
+
dependencies = [
|
|
39
|
+
"numpy>=1.24",
|
|
40
|
+
"safetensors>=0.4.3",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
server = [
|
|
45
|
+
"fastapi>=0.111",
|
|
46
|
+
"uvicorn>=0.30",
|
|
47
|
+
"pydantic>=2.7",
|
|
48
|
+
]
|
|
49
|
+
torch = [
|
|
50
|
+
"torch>=2.3",
|
|
51
|
+
"transformers>=4.45",
|
|
52
|
+
"accelerate>=0.33",
|
|
53
|
+
]
|
|
54
|
+
cuda = [
|
|
55
|
+
"torch>=2.3",
|
|
56
|
+
"transformers>=4.45",
|
|
57
|
+
"accelerate>=0.33",
|
|
58
|
+
"fastapi>=0.111",
|
|
59
|
+
"uvicorn>=0.30",
|
|
60
|
+
"pydantic>=2.7",
|
|
61
|
+
]
|
|
62
|
+
dev = [
|
|
63
|
+
"pytest>=8.2",
|
|
64
|
+
"httpx>=0.27",
|
|
65
|
+
"fastapi>=0.111",
|
|
66
|
+
"uvicorn>=0.30",
|
|
67
|
+
"pydantic>=2.7",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[project.scripts]
|
|
71
|
+
graft = "graft.cli:main"
|
|
72
|
+
|
|
73
|
+
[project.urls]
|
|
74
|
+
Homepage = "https://github.com/couplet-physical-ai/graft"
|
|
75
|
+
Repository = "https://github.com/couplet-physical-ai/graft"
|
|
76
|
+
Issues = "https://github.com/couplet-physical-ai/graft/issues"
|
|
77
|
+
|
|
78
|
+
[tool.hatch.build.targets.wheel]
|
|
79
|
+
packages = ["src/graft"]
|
|
80
|
+
|
|
81
|
+
[tool.pytest.ini_options]
|
|
82
|
+
testpaths = ["tests"]
|
|
83
|
+
addopts = "-q"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Graft: Compile any codebase into a 3.5 MB neural specialist in milliseconds."""
|
|
2
|
+
|
|
3
|
+
from graft.chop import CHOP_PRESETS, ChopSpec, get_chop_spec
|
|
4
|
+
from graft.compiler import CompileResult, FlashLoRARidgeCompiler, compile_repo, compile_examples
|
|
5
|
+
from graft.runtime import AdapterRuntime, QueryResult
|
|
6
|
+
from graft.scanner import RepoScan, scan_repo
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"AdapterRuntime",
|
|
10
|
+
"CHOP_PRESETS",
|
|
11
|
+
"ChopSpec",
|
|
12
|
+
"CompileResult",
|
|
13
|
+
"FlashLoRARidgeCompiler",
|
|
14
|
+
"QueryResult",
|
|
15
|
+
"RepoScan",
|
|
16
|
+
"__version__",
|
|
17
|
+
"compile_examples",
|
|
18
|
+
"compile_repo",
|
|
19
|
+
"get_chop_spec",
|
|
20
|
+
"scan_repo",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
__version__ = "0.1.0"
|