README / README.md
PeetPedro's picture
Update README.md
5293b48 verified
|
Raw History Blame Contribute Delete
5.49 kB
---
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>