Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -74,7 +74,8 @@ smart-tree = { git = "https://github.com/peterlodri-sec/smart-tree" }
|
|
| 74 |
```
|
| 75 |
|
| 76 |
```rust
|
| 77 |
-
use smart_tree::{BitNetWave64, gguf_interop::{I2SPacker, GgufI2SBridge}
|
|
|
|
| 78 |
|
| 79 |
// Pack ternary weights to GGUF I2_S format
|
| 80 |
let packed = I2SPacker::pack_trits(&[-1, 0, 1, 0, -1, 1]);
|
|
@@ -82,13 +83,17 @@ let packed = I2SPacker::pack_trits(&[-1, 0, 1, 0, -1, 1]);
|
|
| 82 |
// Full Wave64 β I2_S roundtrip
|
| 83 |
let i2s_bytes = GgufI2SBridge::wave64_to_i2s(&wave)?;
|
| 84 |
let recovered = GgufI2SBridge::i2s_to_wave64(&i2s_bytes)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
```
|
| 86 |
|
| 87 |
---
|
| 88 |
|
| 89 |
## Architecture Highlights
|
| 90 |
|
| 91 |
-
### Ternary Bridge (Lossless)
|
| 92 |
```
|
| 93 |
BF16 βββΊ INT8 ββββ
|
| 94 |
FP8(E4M3)βββββββββΌββΊ TERNARY {-1,0,+1} βββΊ I2_S (GGUF type 36)
|
|
@@ -96,22 +101,25 @@ FP8(E5M2)βββββββββ
|
|
| 96 |
```
|
| 97 |
Zero-copy conversions with exact arithmetic guarantees.
|
| 98 |
|
| 99 |
-
###
|
| 100 |
-
- **ARM64 NEON**: 128-bit loads, `tbl` lut unpack, pairwise madd
|
| 101 |
-
- **AVX2**: VPBLENDVB mask blend, VPMADDWD horizontal sum
|
| 102 |
-
- **Scalar fallback**: Branch-free, predictable latency
|
| 103 |
-
|
| 104 |
-
### GGUF Native
|
| 105 |
First-class support for `quantization_type = 36 (I2_S)`:
|
| 106 |
- MSB-first 4-trits/byte (Bits 6-7, 4-5, 2-3, 0-1)
|
| 107 |
- Embedded/scales/env-configurable dequantization
|
| 108 |
- Falcon3, BitNet.cpp, llama.cpp compatible
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
---
|
| 111 |
|
| 112 |
## Roadmap
|
| 113 |
|
| 114 |
-
- [
|
|
|
|
|
|
|
| 115 |
- [ ] **Experiment 4**: QLoRA-style ternary fine-tuning (LoRA-T)
|
| 116 |
- [ ] **Experiment 5**: Mixed-precision profiler (layer-wise sensitivity)
|
| 117 |
- [ ] **Experiment 6**: Residual injection scheduler (dynamic precision)
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
```rust
|
| 77 |
+
use smart_tree::{BitNetWave64, gguf_interop::{I2SPacker, GgufI2SBridge},
|
| 78 |
+
simd_ternary::{simd_ternary_gemm_i2s, simd_backend}};
|
| 79 |
|
| 80 |
// Pack ternary weights to GGUF I2_S format
|
| 81 |
let packed = I2SPacker::pack_trits(&[-1, 0, 1, 0, -1, 1]);
|
|
|
|
| 83 |
// Full Wave64 β I2_S roundtrip
|
| 84 |
let i2s_bytes = GgufI2SBridge::wave64_to_i2s(&wave)?;
|
| 85 |
let recovered = GgufI2SBridge::i2s_to_wave64(&i2s_bytes)?;
|
| 86 |
+
|
| 87 |
+
// SIMD-accelerated GEMM
|
| 88 |
+
println!("Backend: {}", simd_backend()); // "NEON (AArch64)" on Apple Silicon
|
| 89 |
+
simd_ternary_gemm_i2s(&weights_i2s, rows, cols, &acts, &mut out, scales);
|
| 90 |
```
|
| 91 |
|
| 92 |
---
|
| 93 |
|
| 94 |
## Architecture Highlights
|
| 95 |
|
| 96 |
+
### Ternary Bridge (Lossless) β Experiment 1 β
|
| 97 |
```
|
| 98 |
BF16 βββΊ INT8 ββββ
|
| 99 |
FP8(E4M3)βββββββββΌββΊ TERNARY {-1,0,+1} βββΊ I2_S (GGUF type 36)
|
|
|
|
| 101 |
```
|
| 102 |
Zero-copy conversions with exact arithmetic guarantees.
|
| 103 |
|
| 104 |
+
### GGUF Native I2_S Support β Experiment 2 β
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
First-class support for `quantization_type = 36 (I2_S)`:
|
| 106 |
- MSB-first 4-trits/byte (Bits 6-7, 4-5, 2-3, 0-1)
|
| 107 |
- Embedded/scales/env-configurable dequantization
|
| 108 |
- Falcon3, BitNet.cpp, llama.cpp compatible
|
| 109 |
|
| 110 |
+
### SIMD Kernels β Experiment 3 β
|
| 111 |
+
- **ARM64 NEON**: 8-lane vectorized, `vld1q_s16` + `vmull` + `vpadal`
|
| 112 |
+
- **AVX2**: 8-lane `VPBLENDVB` mask blend, `VPMADDWD` horizontal sum
|
| 113 |
+
- **Scalar fallback**: Branch-free, predictable latency
|
| 114 |
+
- Integrated FELIX sovereign assembly engine
|
| 115 |
+
|
| 116 |
---
|
| 117 |
|
| 118 |
## Roadmap
|
| 119 |
|
| 120 |
+
- [x] **Experiment 1**: Ternary β INT8/FP8/E4M3/E5M2 Lossless Bridge
|
| 121 |
+
- [x] **Experiment 2**: GGUF I2_S (type 36) Interop
|
| 122 |
+
- [x] **Experiment 3**: ARM64 NEON / AVX2 SIMD kernels for ternary GEMM
|
| 123 |
- [ ] **Experiment 4**: QLoRA-style ternary fine-tuning (LoRA-T)
|
| 124 |
- [ ] **Experiment 5**: Mixed-precision profiler (layer-wise sensitivity)
|
| 125 |
- [ ] **Experiment 6**: Residual injection scheduler (dynamic precision)
|