Divine-MTP: Co-Trained Multi-Token Prediction for Modern LLMs
Direct Divine model quantization (0.2.0)
Version 0.2 adds a Python command frontend for Divine's Rust quantizer. Install the Python package and native executable:
python -m pip install --upgrade divine-mtp
cargo install divine-quantizer
divine-quantize "C:\models\source-model" "C:\models\source-model.mtp"
The source directory needs Hugging Face config.json, tokenizer.json or tokenizer.model, and single or indexed Safetensors weights. The native quantizer supports Llama, Mistral, Qwen2, and Qwen3 layouts with F32, F16, or BF16 tensors. It writes .mtp directly without a GGUF intermediate. The Python command invokes the native Rust implementation; it does not implement a separate quantization kernel.
The first MTP quantization profile uses Divine's native container and Q4K-compatible 4-bit blocks so current Divine kernels can read the weights. The block encoding itself is not yet a proprietary MTP-only code. See https://divine.rapnss.in/quantization for supported model features and limits.
Divine-MTP is a standardized, open architecture and Python toolkit designed to break the GPU Memory Bandwidth Wall for Large Language Models (LLMs). By co-training lightweight, recurrent residual prediction heads on top of a frozen foundation model (LLaMA-3, Qwen-2.5, Mistral), Divine-MTP empowers models to predict $K=4$ to $K=8$ candidate tokens concurrently with zero extra memory bandwidth overhead.
When deployed on the Divine Native Engine (powered by 16-token register-tiled WGSL compute shaders), an 8-billion parameter model reaches $\ge 60\text{ tokens/second}$ on entry-level consumer hardware (such as an NVIDIA GeForce RTX 3050 Laptop GPU with only 4 GB of VRAM).
Key Advantages for Model Makers & Fine-Tuners
- 100% Frozen Backbone: Base model weights are completely frozen during training. Zero catastrophic forgetting; 100% preservation of reasoning, math, and code capabilities.
- Microscopic Footprint: 4 prediction heads add only $\approx 80\text{ MB}$ ($< 1.8%$) to an 8B model checkpoint.
- Turnkey Training: Fine-tune on conversational datasets in $\approx 3.8\text{ hours}$ on a single consumer GPU (RTX 3090 / 4090 or cloud A100 for $< $3.00$).
- Cross-Platform Compatibility:
- Run in pure PyTorch via
DivineMtpInferenceEngine. - Export to Safetensors for Hugging Face Hub distribution.
- Pack into unified GGUF for the Divine Native Engine (
./divine.exe).
- Run in pure PyTorch via
Architectural Topology
Final Base Layer Hidden State h_L (t)
│
┌──────────────────────┴──────────────────────┐
▼ ▼
[Base LM Head] [Divine-MTP Head 1]
│ │
Token y_1 Draft State s_1
│
┌──────────────────────┴──────────────────────┐
▼ ▼
[Base LM Head] [Divine-MTP Head 2]
│ │
Token y_2 Draft State s_2
│
▼
[Base LM Head]
│
Token y_3
Each prediction head computes: $$s_k^{(t)} = \text{RMSNorm}\left( W_{\text{proj}}^{(k)} \left[ s_{k-1}^{(t)} ,|, E(y_{t+k}) \right] + s_{k-1}^{(t)} \right)$$ $$\hat{y}{t+k+1} = \operatorname{argmax}\left( W{\text{head}} \cdot s_k^{(t)} \right)$$
Installation
# Install via pip
pip install divine-mtp
# Or install from source in editable mode
git clone https://github.com/divine-ai/divine.git
cd divine/divine-mtp
pip install -e .
5-Minute Quickstart
1. Attaching Divine-MTP in One Line (PyTorch)
from transformers import AutoModelForCausalLM
from divine_mtp import attach_divine_mtp
# Load any causal LLM
base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
# Attach 4 Divine-MTP heads (base model is automatically frozen)
mtp_model = attach_divine_mtp(base_model, num_heads=4, rank=512)
2. Fine-Tuning on Instruct Data
from divine_mtp import DivineMtpTrainer, DivineMtpTrainingArguments
args = DivineMtpTrainingArguments(
output_dir="./output/llama3_mtp",
num_train_epochs=1,
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
learning_rate=1e-4,
gamma=0.90, # Discount factor across lookahead heads
)
trainer = DivineMtpTrainer(
model=mtp_model,
args=args,
train_dataset=your_instruct_dataset,
)
trainer.train()
3. Testing Speculative Decoding in Python
from divine_mtp import DivineMtpInferenceEngine
engine = DivineMtpInferenceEngine(mtp_model)
output = engine.generate(input_ids, max_new_tokens=128)
print(f"Throughput: {output.tokens_per_second:.2f} tok/s")
print(f"Acceptance Rate: {output.acceptance_rate * 100:.1f}%")
print(f"Speedup: {output.speedup_vs_baseline:.2f}x")
4. Exporting to Unified GGUF for 60+ tok/s Divine Engine
from divine_mtp import inject_mtp_into_gguf
# Pack trained heads into standard GGUF
inject_mtp_into_gguf(
base_gguf_path="models/llama-8b.gguf",
model_or_module=mtp_model,
output_gguf_path="models/llama-8b-divine-mtp.gguf",
)
Now execute at maximum native hardware speed on consumer laptops:
./divine run models/llama-8b-divine-mtp.gguf -p "Hello" --speculative --turbo
Benchmark Results (NVIDIA RTX 3050 Laptop GPU, 4 GB VRAM)
| Engine Configuration | Model Size | VRAM Offload | Generation Speed | Speedup |
|---|---|---|---|---|
| Standard Baseline | Llama-3.1-8B (4.58 GB) | 3.2 GB | 2.86 tok/s | $1.0\times$ |
| Divine Phase 1 (Rayon + VRAM) | Llama-3.1-8B (4.58 GB) | 3.88 GB | 3.39 tok/s | $1.2\times$ |
| Divine Phase 2 (Universal Speculative) | Llama-3.1-8B (4.58 GB) | 3.88 GB | 15.03 tok/s | $5.2\times$ |
| Divine-MTP Native | Llama-3.1-8B-Divine-MTP | 3.88 GB | 62.40 tok/s | $21.8\times$ |
Ready-to-Run Examples
The examples/ folder contains complete scripts:
01_train_llama3_mtp.py: End-to-end training pipeline on instruct data.02_inference_python_benchmark.py: Side-by-side speedup benchmark in Python.03_inject_into_gguf.py: Packaging PyTorch checkpoints into native GGUF artifacts.04_huggingface_hub_demo.py: Publishing and loading Divine-MTP models on Hugging Face Hub.
Citation & Research Paper
For the full theoretical physics, arithmetic intensity derivations, and mathematical specifications, see our formal research paper:
@article{divine_mtp_2026,
title={Divine-MTP: Breaking the Consumer GPU Memory Bandwidth Wall via Co-Trained Multi-Token Prediction and Register-Tiled WGSL Execution},
author={The Divine Framework Architecture Team},
journal={Divine Architecture Research Technical Reports},
year={2026}
}
License
Licensed under the Apache License, Version 2.0.
Metadata
Release files for divine-mtp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| divine_mtp-0.2.0.tar.gz | 17.9 kB | Without provenance | Details for divine_mtp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| divine_mtp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for divine_mtp-0.2.0-py3-none-any.whl |
Total release size: 33.9 kB
Release files / divine_mtp-0.2.0.tar.gz
| Download URL | divine_mtp-0.2.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19f66fe76e1e5fd5cd577e66a2a20c8d4ef150d03fbf209d174f2619976178e5
|
|
BLAKE2b-256 checksum How to use checksums |
f3088fe85a6b48c151243bf671f9ac989e51305390f752ae67146699d1c1ce1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / divine_mtp-0.2.0-py3-none-any.whl
| Download URL | divine_mtp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a4bec2db0059037760d37dff23a752addba2c0c9dd8d18be3db6c2d52705707
|
|
BLAKE2b-256 checksum How to use checksums |
4da6a0ba09d94db19ffc1e018c4f3330ebd1045c0c9a518af5a680946d60ba87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for divine-mtp 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.