File size: 5,491 Bytes
b3aad55 5293b48 b3aad55 5293b48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | ---
tags:
- rust
- quantization
- ternary
- bitnet
- ggml
- simd
- lora
- finetuning
- edge-ai
license: mit
library_name: smart-tree
---
# π§ eightb β Eight-Bit Intelligence Systems
<p align="center">
<img src="https://img.shields.io/badge/rust-%23dea584.svg?logo=rust&logoColor=white"/>
<img src="https://img.shields.io/badge/webassembly-654FF0?logo=webassembly&logoColor=white"/>
<img src="https://img.shields.io/badge/mlx-ECEEF1?logo=apple&logoColor=black"/>
</p>
**Ultra-low precision neural networks β’ Quantization-native architectures β’ Edge-first inference**
---
## Philosophy
Modern LLMs are bloated. We believe intelligence doesn't need FP32βor even FP16. By designing **from the ground up for ternary (-1, 0, +1) and low-bit representations**, we unlock:
| Precision | Storage | MAC Energy | Typical Quality |
|-----------|---------|------------|-----------------|
| BF16 | 2Γ | 1Γ | Baseline |
| INT8 | ΒΌΓ | ~β
Γ | Near-baseline |
| **INT2/I2_S** | **β
Γ** | **~ΒΉβββΓ** | **Surprisingly good** |
Our flagship: **BitNet 1.58-bit** β ternary weights trained straight-through estimator, no distillation tax.
---
## Repositories
| Repo | Description | Status |
|------|-------------|--------|
| [`smart-tree`](https://huggingface.co/eightb/smart-tree) | SIMD-accelerated ternary inference engine (ARM NEON / AVX2 / WASM) | β
Active |
| [`enthea`](https://github.com/peterlodri-sec/enthea) | Pure-Rust quantized linear algebra: GEMM, attention, MoE routing | β
Active |
| [`felix-assembly`](https://github.com/peterlodri-sec/felix-assembly) | CPU-agnostic FELIX ISA for portable SIMD kernels | π¬ Experimental |
| [`quantlab`](https://github.com/peterlodri-sec/quantlab) | Automated quantization search: Pareto-Q, KD pipelines, RL tuning | π§ Building |
---
## Quick Start: `smart-tree` Binary
```bash
# Download latest release
curl -LO https://huggingface.co/eightb/smart-tree/resolve/main/st
chmod +x st
# Validate GGUF I2_S (Falcon3-3B-I2_S compatible)
./st gguf validate
# Convert BitNetWave64 β I2_S hex
./st gguf convert --wave DEADBEEFDEADBEEF:FEEDFACEFEEDFACE
# Inspect GGUF for ternary tensors
./st gguf inspect --file falcon3-3b-i2s.gguf
```
### As Library
```toml
[dependencies]
smart-tree = { git = "https://github.com/peterlodri-sec/smart-tree" }
```
```rust
use smart_tree::{BitNetWave64, gguf_interop::{I2SPacker, GgufI2SBridge},
simd_ternary::{simd_ternary_gemm_i2s, simd_backend},
lora_ternary::{lorat_qwen2_5_05b, LoraTTrainer, LoraTConfig}};
// Pack ternary weights to GGUF I2_S format
let packed = I2SPacker::pack_trits(&[-1, 0, 1, 0, -1, 1]);
// Full Wave64 β I2_S roundtrip
let i2s_bytes = GgufI2SBridge::wave64_to_i2s(&wave)?;
let recovered = GgufI2SBridge::i2s_to_wave64(&i2s_bytes)?;
// SIMD-accelerated GEMM
println!("Backend: {}", simd_backend()); // "NEON (AArch64)" on Apple Silicon
simd_ternary_gemm_i2s(&weights_i2s, rows, cols, &acts, &mut out, scales);
// LoRA-T fine-tuning
let mut model = lorat_qwen2_5_05b(LoraTConfig { rank: 16, ..Default::default() });
let mut trainer = LoraTTrainer::new(&mut model, 1e-4);
// ... training loop ...
```
---
## Architecture Highlights
### Ternary Bridge (Lossless) β Experiment 1 β
```
BF16 βββΊ INT8 ββββ
FP8(E4M3)βββββββββΌββΊ TERNARY {-1,0,+1} βββΊ I2_S (GGUF type 36)
FP8(E5M2)βββββββββ
```
Zero-copy conversions with exact arithmetic guarantees.
### GGUF Native I2_S Support β Experiment 2 β
First-class support for `quantization_type = 36 (I2_S)`:
- MSB-first 4-trits/byte (Bits 6-7, 4-5, 2-3, 0-1)
- Embedded/scales/env-configurable dequantization
- Falcon3, BitNet.cpp, llama.cpp compatible
### SIMD Kernels β Experiment 3 β
- **ARM64 NEON**: 8-lane vectorized, `vld1q_s16` + `vmull` + `vpadal`
- **AVX2**: 8-lane `VPBLENDVB` mask blend, `VPMADDWD` horizontal sum
- **Scalar fallback**: Branch-free, predictable latency
- Integrated FELIX sovereign assembly engine
### LoRA-T Fine-Tuning β Experiment 4 β
- **Freeze** pretrained ternary weights (I2_S / BitNetWave64)
- **Inject** trainable low-rank adapters (A @ B) in FP32
- **Forward**: `y = W_ternary @ x + Ξ± * (A @ B) @ x`
- **Gradient** flows only through A, B (ranks 8-64)
- **Fusion** for zero-overhead inference deployment
- Factories for Qwen2.5-0.5B, custom transformers
---
## Roadmap
- [x] **Experiment 1**: Ternary β INT8/FP8/E4M3/E5M2 Lossless Bridge
- [x] **Experiment 2**: GGUF I2_S (type 36) Interop
- [x] **Experiment 3**: ARM64 NEON / AVX2 SIMD kernels for ternary GEMM
- [x] **Experiment 4**: QLoRA-style ternary fine-tuning (LoRA-T)
- [ ] **Experiment 5**: Mixed-precision profiler (layer-wise sensitivity)
- [ ] **Experiment 6**: Residual injection scheduler (dynamic precision)
- [ ] **Experiment 7**: Pareto-Q sequential allocator
- [ ] **Experiment 8**: KD pipeline teacherβstudent (ternary)
- [ ] **Experiment 9**: BITCOS cosine similarity retrieval
---
## Community
- Discord: coming soon
- Issues: [GitHub](https://github.com/peterlodri-sec/smart-tree/issues)
- Papers: See [`SCIENCE.md`](https://github.com/peterlodri-sec/enthea/blob/main/SCIENCE.md)
---
## License
MIT OR Apache-2.0 β Choose your adventure.
---
<div align="center">
**"Eight bits ought to be enough for anybody"** β *Probably not Bill Gates*
Built with β€οΈ by the eightb collective
</div> |