SLM750 Edge 1.58 Bit
bitnet-158
Modellquelle
- Art
- Embedding, Text model
- Dateigröße
- 879 MB
- Basismodell
- Qapdex/SLM750-Edge-1.58-bit
- Version
- vRevision d743592
- Aktualisiert
- 3. Okt. 2026
- Verleger
- @Qapdex
- Downloads
- 170
- Aufgaben
- Textgenerierung
- Quelle
- Hugging Face
Quellenbeschreibung
SLM750-Edge 1.58-bit — Q4_K_M Quantized GGUF
A compact, efficiently quantized BitNet b1.58 ternary model optimized for edge deployment. This repository provides a plug-and-play GGUF file ready for use with llama.cpp and its ecosystem (llama-cli, llama-cpp-python, text-generation-webui, and more).
⚠️ IMPORTANT — PLEASE READ: This model does NOT run with the standard
llama.cpp. It requires a patchedbitnet.cpp(see below). Without the patch, you will encountermissing tensor 'blk.0.attn_sub_norm.weight'or similar errors. The BitNet folder contains benchmark and automatic installation scripts & fixes for known problems during the installation of Python Torch and sentencepiece from python3.13/sitepackages.
SLM750-Edge: Distillation + GGUF Build Colab
slm750_edge_gpu_package.tgz.gz Google Drive
Model Highlights
| Attribute | Value |
|---|---|
| Architecture | BitNet b1.58 (ternary {-1, 0, +1} weights) |
| Parameters | ~1.4B |
| Embedding Dim | 1,536 |
| Attention Heads | 12 (4 KV heads, GQA) |
| Feed-Forward | 4,096 (ReLU2 activation) |
| Context Length | 8,192 tokens |
| Vocabulary | 256,000 tokens (Gemma-2 tokenizer) |
| Quantization | Q4_K_M (5.27 BPW) |
| File Size | 873 MB |
| License | BitNet 1.58 |
File Description
| File | Description |
|---|---|
quantized_q4km.gguf | — Q4_K_M quantized GGUF |
✅ Recommended | — Q4_K_M quantized GGUF quant_fixed_from_source_gguf (921 MB) |
Quick Start
Prerequisites
ik_llama This repository is a fork of llama.cpp with better CPU and hybrid GPU/CPU performance, new SOTA quantization types, // first-class Bitnet // support, better DeepSeek performance via MLA, FlashMLA, fused MoE operations and tensor overrides for hybrid GPU/CPU inference, row-interleaved quant packing, etc.
Building llama-cpp with BitNet Support
https://copilot.microsoft.com/shares/pages/kaesS7TdPccnaLsu4iQ9T
- llama.cpp built from source with BitNet support (commit
52b3df002or later), OR - llama-cpp-python v0.3.x+
Usage with llama-cli
# Basic text generation
./llama-cli -m quantized_q4km.gguf \
-p "Explain quantum computing in simple terms" \
-n 256 \
-t 4 \
--temp 0.7 \
--top-p 0.9
# Chat mode
./llama-cli -m quantized_q4km.gguf \
-p "You are a helpful assistant." \
--chat-template gemma \
-n 512 \
-t 4
Usage with llama-cpp-python (Python)
from llama_cpp import Llama
llm = Llama(
model_path="quantized_q4km.gguf",
n_ctx=8192,
n_threads=4,
verbose=False,
)
output = llm(
"What is the meaning of life?",
max_tokens=256,
temperature=0.7,
top_p=0.9,
echo=False,
)
print(output["choices"][0]["text"])
Usage with text-generation-webui
- Place quantized_q4km.gguf in the models/ directory.
- Launch text-generation-webui with --model quantized_q4km.gguf.
- Select the model in the UI under the "Model" tab.
Usage with LangChain
from langchain_community.llms import LlamaCpp
llm = LlamaCpp(
model_path="quantized_q4km.gguf",
n_ctx=8192,
n_threads=4,
temperature=0.7,
top_p=0.9,
verbose=False,
)
response = llm.invoke("Write a short poem about AI.")
print(response)
Performance
# SLM750-Edge: A 1.58-Bit Hybrid Edge Transformer
## Architectural Mathematics & Training Protocol
### "Null-Denkzeit für Tool-Calls. >120 tok/s auf mobiler Hardware."
---
## 1. Design Philosophy
SLM750-Edge combines three revolutionary advances:
1. **Hybrid Gemma-2/SmolLM2 architecture** — interleaved local+global attention with Gemma-2's logit softcapping, optimized to 750M
2. **BitNet b1.58 native quantization** — all weights constrained to {−1, 0, +1} during training, eliminating FP multiplications at inference
3. **GBNF grammar ejection** — tool-calling structure is *baked into the token distribution* so no CoT or post-processing is needed
**Result:** A 750M model that fits in 142 MB at 1.58-bit (≈ 750M × 1.58 bits ÷ 8 = 148 MB), runs entirely in CPU cache on modern phone SoCs, and produces guaranteed-JSON tool calls at wire speed.
---
## 2. Architecture Blueprint
### 2.1 Macro Architecture
SLM750-Edge( token_embed: Vocab(256k) → dim=1536 # embedding table layers: 24 × HybridDecoderLayer # 12 global + 12 local (interleaved) norm_final: SubLN # pre-RMSNorm + activation quantization lm_head: dim=1536 → Vocab(256k) # tied weights (optional) )
### 2.2 Layer Configuration
| Parameter | Value | Rationale |
|-----------|-------|-----------|
| `hidden_dim` | 1536 | Power-of-2 multiple for NEON/ARM dot-product efficiency |
| `intermediate_dim` | 4096 | ReLU2 activation: 1536 × 8/3 ≈ 4096 (SmolLM2 ratio) |
| `num_attention_heads` | 12 | 1536 ÷ 12 = 128 head_dim — optimal for FlashAttention-2 |
| `num_kv_heads` | 4 | GQA ratio 3:1 — 75% KV-cache reduction vs MHA |
| `head_dim` | 128 | FlashAttention-2 tile alignment (128 × 128 warp) |
| `num_layers` | 24 | 12 global + 12 sliding window (interleaved) |
| `sliding_window_size` | 1024 | Gemma-2 default — covers ~1K tokens of local context |
| `vocab_size` | 256000 | SmolLM2 tokenizer + tool-token extensions |
| `max_seq_len` | 8192 | 8K context for complex multi-step tool orchestration |
**Total parameters:** ~750M (exact: 748,634,112)
### 2.3 Parameter Budget (Exact)
| Component | Shape | Parameters |
|-----------|-------|------------|
| Embedding | 256000 × 1536 | 393,216,000 |
| Per-layer Attention Q | 1536 × 1536 | 2,359,296 |
| Per-layer Attention K | 1536 × 512 (GQA 4 KV heads) | 786,432 |
| Per-layer Attention V | 1536 × 512 | 786,432 |
| Per-layer Attention O | 1536 × 1536 | 2,359,296 |
| Per-layer FFN Gate | 1536 × 4096 | 6,291,456 |
| Per-layer FFN Up | 1536 × 4096 | 6,291,456 |
| Per-layer FFN Down | 4096 × 1536 | 6,291,456 |
| Per-layer SubLN (2x) | 2 × 1536 | 3,072 |
| **Per-layer total** | — | **25,164,288** |
| **24 layers total** | — | **603,942,912** |
| Norm final | 1536 | 1,536 |
| LM Head (tied w/ embed) | — | 0 |
| **Grand total** | — | **748,634,112** ≈ 749M |
---
## 3. The BitNet b1.58 Mathematical Core
### 3.1 Ternary Weight Quantization
Every linear weight tensor $W \in \mathbb{R}^{d \times k}$ is quantized during **both forward and backward passes**:
$$W_q = \text{round\_clip}\left(\frac{W}{\alpha}\right) \quad \text{where} \quad \alpha = \frac{1}{n}\sum_{ij} \max(|W_{ij}|)$$
$$\text{round\_clip}(x) =
\begin{cases}
+1, & x > 0.5 \\
0, & |x| \leq 0.5 \\
-1, & x < -0.5
\end{cases}$$
The **scale factor** $\alpha$ is per-output-channel (per-row), stored in FP16:
$$\alpha_j = \frac{1}{d}\sum_{i=1}^{d} \max_{j} |W_{ij}|$$
**Total storage:** $W_q$ fits in 1.58 bits/param (2 bits packed with ternary encoding), $\alpha$ is FP16 per row — negligible overhead.
### 3.2 Straight-Through Estimator (STE) for Gradient Flow
The round-clip step is non-differentiable. We use STE:
$$\frac{\partial \mathcal{L}}{\partial W} \approx \frac{\partial \mathcal{L}}{\partial W_q} \cdot \mathbf{1}_{|W| \leq \alpha}$$
This passes gradients through the quantization boundary while clamping outliers. The indicator function $\mathbf{1}_{|W| \leq \alpha}$ prevents weights from growing unboundedly.
### 3.3 Activation Quantization (8-bit Per-Token Abs-Max)
Activations are quantized to INT8 per-token:
$$X_q = \text{round}\left(\frac{X}{\gamma} \times 127\right) \quad \text{where} \quad \gamma = \max_{j} |X_{j}|$$
Dequantization: $X \approx X_q \times \frac{\gamma}{127}$
### 3.4 SubLN: Sub-Layer Normalization
Each sublayer (attention, FFN) uses this sequence:
1. **Pre-RMSNorm:** $x' = \text{RMSNorm}(x)$
2. **Quantize:** $x'_q = \text{activation\_quant}(x')$ (INT8, per-token abs-max)
3. **Compute:** $y = \text{BitLinear}(x'_q, W_q, \alpha)$ — ternary weights × INT8 activations
4. **Residual:** $z = x + y$
**Inference math:** $W_q \in \{-1, 0, +1\}$, $X_q \in \mathbb{Z}_{127}$, so the core computation is:
$$Y_{ij} = \alpha_j \cdot \sum_{k} W_{q_{jk}} \cdot X_{q_{ik}}$$
This is **pure integer addition** — the ternary weight selects between add, skip, or subtract of each activation. No FP multipliers needed until the final $\alpha_j$ scale.
### 3.5 Theoretical Speedup
| Operation | FP16 MAC | Ternary-INT8 Ops | Speedup |
|-----------|----------|-------------------|---------|
| Weight × Activation | FP16 multiply-add | INT8 add-with-sign | ~4× |
| Memory bandwidth | 2 bytes/param | 0.1975 bytes/param | ~10× |
| KV cache (4K seq) | 4K × 512 × 2B = 4 MB | 4K × 512 × 2B = 4 MB | Same (GQA) |
---
## 4. Hybrid Attention: Gemma-2 × FlashAttention-2
### 4.1 Interleaved Local-Global Pattern
Layer 0: Global Attention (full 8192 ctx) ← FlashAttention-2 Layer 1: Sliding Window (1024 local) ← FlashAttention-2 mask Layer 2: Global Attention Layer 3: Sliding Window ... (repeat) Layer 22: Global Attention Layer 23: Sliding Window
**Why:** Global at even layers captures long-range tool dependencies (passing variables between steps 1→8). Sliding window at odd layers provides 1024-token burst resolution for dense JSON structures.
### 4.2 Logit Softcapping (Gemma-2 Innovation)
After attention score computation and before softmax:
$$S'_{ij} = C_{\text{attn}} \cdot \tanh\left(\frac{S_{ij}}{C_{\text{attn}}}\right) \quad \text{where} \quad C_{\text{attn}} = 50$$
After the final FFN output projection:
$$Y' = C_{\text{final}} \cdot \tanh\left(\frac{Y}{C_{\text{final}}}\right) \quad \text{where} \quad C_{\text{final}} = 30$$
**Effect:** Prevents attention from becoming too diffuse or too peaked, critical for stable ternary training.
### 4.3 RoPE with Extended Frequency Scale
Using SmolLM2's RoPE implementation with base $f = 10000$:
$$\Theta = \{\theta_i = 10000^{-2i/d}\}_{i=0}^{d/2-1}$$
Extended to 8192 via linear frequency scaling (NTK-aware):
$$\theta'_i = \theta_i \cdot s^{-\frac{2i}{d}} \quad \text{where} \quad s = \frac{8192}{2048} = 4$$
---
## 5. ReLU2 Feed-Forward Network
SmolLM2-style FFN with squared ReLU activation:
$$\text{FFN}(x) = W_{\text{down}} \cdot \left(\text{ReLU}(W_{\text{up}} \cdot x)^2 \odot W_{\text{gate}} \cdot x\right)$$
Where $\odot$ is element-wise multiplication (SwiGLU-style gating but with ReLU2).
**Rationale:** ReLU2 produces sparser activations than GELU/SwiGLU at the same FLOPs, which synergizes with ternary weights — more zero activations mean more zero-selects in the INT8 adder tree.
---
## 6. Knowledge Distillation Protocol
### 6.1 Teacher-Student Setup
| Role | Model | Parameters | Format |
|------|-------|------------|--------|
| **Teacher (Reasoning)** | Gemma-2-2B (Open) | 2.6B | FP16, full precision |
| **Teacher (Tool Structure)** | LFM2-1.2B-Tool | 1.2B | Q4_K_M GGUF |
| **Student** | SLM750-Edge | 749M | 1.58-bit ternary |
### 6.2 Distillation Loss
$$\mathcal{L} = \lambda_1 \cdot \mathcal{L}_{\text{CE}}(y_s, y_t) + \lambda_2 \cdot \mathcal{L}_{\text{KD}}(p_s, p_t) + \lambda_3 \cdot \mathcal{L}_{\text{struct}}(z_s, z_t)$$
Where:
-...
Quellen
1 Quelle
Quellen
1 QuelleVerifiziert 3. Okt.
Modellartefakte
2 Artefakte
Modellartefakte
2 Artefakteslm750_edge_q4_k_m_quant_fixed_v2.gguf
gguf · 879 MB · SHA-256 880e2766a7e6…3a02 · Hugging Face
HerunterladenQuellenauszüge
3 Auszüge
Quellenauszüge
3 Auszüge--- license: mit license_name: bitnet-158 license_link: https://github.com/microsoft/bitnet/blob/main/LICENSE language: - en library_name: llama.cpp tags: - bitnet - ternary - 1.58-bit - quantized - q4_k_m - gguf - llama.cpp - edge - efficient-inference - cpu - tool-calling extra_gated_fields: Name: text Email: text Country: text Organization: text I agree to the terms of BitNet: checkbox datasets: - Qapdex/agentic-foresight-actions-2k base_model: - Qapdex/SLM750-Edge-1.58-bit pipeline_tag: text-generation --- # SLM750-Edge 1.58-bit — Q4_K_M Quantized GGUF A compact, efficiently quantized BitNet b1.58 ternary model optimized for edge deployment. This repository provides a plug-and-play GGUF file ready for use with llama.cpp and its ecosystem (llama-cli, llama-cpp-python, text-generation-webui, and more). > **⚠️ IMPORTANT — PLEASE READ:** This model does **NOT** run with the standard `llama.cpp`. It requires a **patched `bitnet.cpp`** (see below). Without the patch, you will encounter `missing tensor 'blk.0.attn_sub_norm.weight'` or similar errors. The BitNet folder contains benchmark and automatic installation scripts & fixes for known problems during the installation of Python Torch and sentencepiece from python3.13/sitepackages. --- # SLM750-Edge: Distillation + GGUF [Build Colab](https://colab.research.google.com/drive/1bhAMdQF8B7glFXV3lc6aRiX16V6sdPjk?usp=sharing) # slm750_edge_gpu_package.tgz.gz [Google Drive](https://drive.google.com/drive/folders/1saghK411OS7cP29TCCftuPhKm_-8Nl7W) --- # Model Highlights | Attribute | Value | |-----------|-------| | **Architecture** | BitNet b1.58 (ternary {-1, 0, +1} weights) | | **Parameters** | ~1.4B | | **Embedding Dim** | 1,536 | | **Attention Heads** | 12 (4 KV heads, GQA) | | **Feed-Forward** | 4,096 (ReLU² activation) | | **Context Length** | 8,192 tokens | | **Vocabulary** | 256,000 tokens (Gemma-2 tokenizer) | | **Quantization** | Q4_K_M (5.27 BPW) | | **File Size** | 873 MB | | **License** | BitNet 1.58 | ## File Description | File | Description | |------|-------------| | **`quantized_q4km.gguf`** | — Q4_K_M quantized GGUF | | ✅ **`Recommended`** | — Q4_K_M quantized GGUF [quant_fixed_from_source_gguf](https://huggingface.co/Qapdex/SLM750-Edge-1.58-bit/blob/main/README_quant_fixed_v2.gguf.md) (921 MB) | ## Quick Start ### Prerequisites [ik_llama](https://github.com/ikawrakow/ik_llama.cpp...
Source context: 170 downloads · 2 likes · Pipeline text-generation · Library llama.cpp · Repo Qapdex/SLM750-Edge-1.58-bit
Source context: 1805 downloads · 2 likes · Pipeline text-generation · Library llama.cpp · Repo Qapdex/SLM750-Edge-1.58-bit
