Skip to main content

MATE: Memory-Aligned Trellis Engine

2-to-4 bit trellis quantization, compressed-KV CUDA/Mojo inference, bare-metal C++20 serving, 3-tier MoE offload, and zero-materialization Trellis-QLoRA fine-tuning for local GPUs and CPUs.

Quickstart | Benchmarks | Support Matrix | Documentation

Highlights

  • 2-4 bit CPTC-TQIR weights: Hessian-aware sequential GPTAQ LDLQ with GPU curvature-weighted Viterbi, per-head V-O Hadamard folding (R2), KL tile-scale distillation, 6-bit trellis / probability-banded lm_head export, and universal GGUF v2/v3, EXL3, MLX, and Hugging Face import.
  • Native Blackwell/Ada CUDA + Mojo 1.2 CPU kernels: Zero-SMEM pure-ALU trellis_gemv_v3 (dp4a + svh epilogue + Stream-K), zero-spill r4kv_decode_attn with 128-split Blackwell merge, fused conv1d+GDN with L2 state persistence, and zero-libmax.so Mojo AVX-512 VNNI / AVX2 CPU SIMD decode.
  • 4.5x-6.4x compressed KV caches: Default rotated 4-bit/2-bit R4KV (up to 1M-token context in 24.3 GB VRAM), 8D E8 lattice (2.0-4.0 bpw), dual-scaled KVarN, and 3-bit IsoQuant.
  • Dual Python + bare-metal C++20 serving: Continuous batching (B=64), OpenAI /v1/chat/completions and Anthropic /v1/messages APIs, confidence-gated speculative decoding (UnifiedSpeculatorRouter, Suffix/SAM, Native MTP, DFlash 2), and standalone zero-Python C++20 mate-serve (mate/csrc/runtime/).
  • Frontier MoE & Trellis-QLoRA: 3-tier GPU doorbell MoE offload (VRAM hot pool + pinned RAM victim cache + 4 KiB-aligned NVMe), exact Qwen3.8-Flash-Next / Hy4-Flash / Inkling-2-Mini hybrid runners, and frozen-base Trellis-QLoRA + LoftQ fine-tuning.

Quickstart

Install

Requires Python 3.11+ and PyTorch 2.6+. On NVIDIA GPUs with nvcc and ninja, mate JIT-compiles its CUDA extension (mate/csrc/) natively with no Mojo dependency. Mojo 1.2+ is optional on CUDA machines and is only needed for CPU SIMD (mate/libmate.so).

pip install "mate-llm[hf]"

For local development from source:

pip install -e ".[hf]"

To build the optional standalone bare-metal C++20 server (mate-serve + libmate_runtime.so):

cmake -S mate/csrc/runtime -B build/runtime -DCMAKE_BUILD_TYPE=Release
cmake --build build/runtime -j

Run, Serve, or Quantize

# Run a pre-quantized MATE checkpoint directly from Hugging Face
mate run Honkware/Qwen3-8B-MATE-4b --ctx 32768 --serve

# Check hardware memory fit offline (no weight download)
mate fit Qwen/Qwen3-8B --ctx 32768

# Interactive chat or OpenAI/Anthropic HTTP server
mate chat Qwen/Qwen3-8B --bits 4
mate serve Qwen/Qwen3-8B --bits 4 --max-seq-len 32768 --host 127.0.0.1 --port 8000

# Quantize a Hugging Face model or GGUF checkpoint to .mate.safetensors
mate quantize Qwen/Qwen3-8B -o qwen3-8b-4b.mate.safetensors --bits 4 --depth 10
mate inspect qwen3-8b-4b.mate.safetensors

Query the server with any OpenAI or Anthropic client (OPENAI_BASE_URL=http://127.0.0.1:8000/v1, ANTHROPIC_BASE_URL=http://127.0.0.1:8000):

curl http://127.0.0.1:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"Qwen/Qwen3-8B","messages":[{"role":"user","content":"Write a C++20 lock-free ring buffer."}]}'

Python API

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from mate.double_hadamard import fold_vo_head_hadamard
from mate.fast_decode import FastDecodeRunner
from mate.hf import quantize_model
from mate._policy import RoleQuantPolicy

model_id = "Qwen/Qwen3-8B"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda").eval()

fold_vo_head_hadamard(model)
quantize_model(model, policy=RoleQuantPolicy(dense_bits=4, trellis_depth=10), mode="mse")

runner = FastDecodeRunner(model, max_seq_len=32768, kv_mode="r4kv")
prompt = tok.encode("Explain tail-biting trellis quantization in two sentences.", return_tensors="pt").cuda()
out = runner.generate(prompt, max_new_tokens=128)
print(tok.decode(out[0], skip_special_tokens=True))

Pre-Quantized Checkpoints

Ready-to-run .mate.safetensors checkpoints are published in the Honkware MATE collection on Hugging Face:

Model Family Variants Architecture
Qwen/Qwen3-8B 4b, 3b, 2b Dense GQA
meta-llama/Llama-3.1-8B-Instruct 4b, 3b, 2b Dense GQA
Qwen/Qwen3-14B 4b, 3b, 2b Dense GQA
google/gemma-4-12B-it 4b, 3b, 2b Sliding + Global Hybrid
Qwen3.8-27B 4b, 3b, 2b 64L GDN + Full Attention
Inkling-2-Mini 13GB, 8.3GB Looped MoE
Qwen3.8-Flash-Next 3b, mixed-45GB 512-Expert MoE + Sparse-QSA
Hy4-Flash 3b LatentMoE + MLA + Engram

Benchmarks

All numbers below are measured live on single GPUs (sm_120a Blackwell PRO 6000, R4KV 4-bit KV cache, CUDA Graphs). Full tables covering 2b/3b/4b, NVIDIA L4 (sm_89), RTX 5090, batched decode (803 tok/s at B=48 on Qwen3-8B-4b; 6,728 tok/s at B=64 on Inkling-2-Mini), 1M-token context, and Mojo CPU SIMD kernels are in docs/benchmarks.md.

4-Bit & 3-Bit Dense / Hybrid Quality & Single-Stream Decode (PRO 6000, 96 GB)

Evaluated on wikitext-2-raw-v1:test at seq_len=2048 (100 windows) against BF16 reference:

Model Variant Size WT-2 PPL (delta) KLD Top-1 d=128 (tok/s) d=32,768 (tok/s) Peak VRAM (32K)
Qwen3-8B CPTC-4b 5.67 GiB 9.581 (+0.11%) 0.0315 93.23% 196.2 123.6 7.36 GB
Qwen3-8B CPTC-3b 4.86 GiB 10.009 (+4.58%) 0.1119 87.29% 244.9 142.2 6.67 GB
Llama-3.1-8B-Instruct CPTC-4b 5.33 GiB 7.378 (+2.23%) 0.0277 93.13% 208.4 134.2 7.25 GB
Qwen3-14B CPTC-4b 9.26 GiB 8.505 (+0.65%) 0.0231 94.08% 124.2 95.1 11.82 GB
gemma-4-12B-it CPTC-4b 7.15 GiB 13.283 (-0.09%) 0.0682 90.97% 113.8 78.9 9.90 GB
Qwen3.8-27B CPTC-4b 16.50 GiB 6.714 (-0.72%) 0.0245 94.25% 64.8 60.3 17.49 GB
Qwen3.8-27B CPTC-3b 13.67 GiB 6.922 (+2.36%) 0.0662 90.03% 80.6 73.9 14.72 GB

Frontier & Batched Highlights (PRO 6000, 96 GB)

Model Config Context d Throughput (tok/s) Peak VRAM
Inkling-2-Mini FP8Dense (B=64, k=7, Native DSpark) 640 6,728.60 (105.13/user) 43.14 GB
Inkling-2-Mini BF16Dense lossless (B=64, k=7, Native DSpark) 640 6,514.88 (101.79/user) 43.16 GB
Inkling-2-Mini FP8Dense (M=1, r4k_r2v KV, CPU embed offload) 1,048,576 54.00 23.04 GB
Qwen3-8B CPTC-4b (B=48, ragged R4KV) 128 803.08 (16.73/user) 8.73 GB

Support Matrix

Hardware Backends

Target Compute Path Requirements Notes
NVIDIA Blackwell (sm_120a) Native CUDA (trellis_gemv_v3, r4kv, gdn, t2tc, nvfp4_moe) CUDA 12.8+, nvcc, ninja Full DP4A, PDL, Stream-K, 128-split R4KV, L2 GDN persistence
NVIDIA Hopper / Ada (sm_90 / sm_89) Native CUDA (trellis_gemv_v3, r4kv, gdn, e8_v3) CUDA 12.1+, nvcc, ninja Full CUDA-Graph decode and compressed KV
NVIDIA Ampere (sm_80 / sm_86) Native CUDA (trellis_gemv_v3, r4kv, e8_v3) CUDA 12.1+, nvcc, ninja DP4A GEMV and compressed KV
x86-64 AVX-512 VNNI / AVX2 Mojo 1.2 mate/libmate.so (IH4-VNNI-BiasHoist) Mojo 1.2+ Zero libmax.so runtime dependency
Fallback (non-CUDA / CPU) PyTorch reference Python 3.11+, PyTorch 2.6+ Functional fallback for testing and export

Capabilities

  • Model families: Llama / Mistral / Qwen2 / Qwen3 (FastDecodeRunner), Qwen3.5 / Qwen3.8 Gated DeltaNet + Full Attention, Gemma 4 heterogeneous sliding/global attention, Inkling-2-Mini looped MoE, Qwen3.8-Flash-Next (512-expert MoE + Sparse-QSA + Layer-1 Engram), and Hy4-Flash (iHC + MLA + Engram + DFly2 drafter hooks).
  • Input formats: Hugging Face (BF16/FP16/FP8/NVFP4/MXFP4/AWQ/GPTQ/NF4), GGUF v2/v3 (all 36 GGML types), EXL3, and MLX.
  • KV backends (--kv-backend): r4kv (4b/2b rotated, default on CUDA), e8 (8D lattice 2.0-4.0 bpw), kvarn (k4v2/k4v4/k2v2), isoquant (3b scalar / HF cache), fp16.
  • Speculative modes (--speculative): auto, router (UnifiedSpeculatorRouter), suffix / sam, mtp, dflash2 / dspark / dspine, --draft-model, none.

Documentation

  • docs/benchmarks.md: Full single-GPU-per-table Blackwell PRO 6000, RTX 5090, and Mojo CPU benchmark reports.
  • docs/architecture.md: Repository layout, CPTC-TQIR weight format, CUDA/Mojo kernels, and bare-metal C++20 mate-serve runtime.
  • docs/serving.md: CLI reference (mate fit, mate run, mate serve, mate quantize), OpenAI and Anthropic HTTP endpoints, and speculative decoding controls.

License

Apache-2.0. See LICENSE.

Metadata

Release files for mate-llm 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mate-llm 0.1.1
File Size Uploaded Provenance Actions
mate_llm-0.1.1.tar.gz 2.1 MB Without provenance Details for mate_llm-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mate-llm 0.1.1
File Interpreter ABI Platform Actions
mate_llm-0.1.1-py3-none-any.whl Python 3 none any Details for mate_llm-0.1.1-py3-none-any.whl

Total release size: 3.7 MB

Release files / mate_llm-0.1.1.tar.gz

Download URL mate_llm-0.1.1.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
795551a93462e091abe282662e029533effe4ec34fe39f3d6283e988ca118e40
BLAKE2b-256 checksum
How to use checksums
f0d16827ddfd4850b5f217aaa13fd5c32d05ecfdc111c76ebf5b44f4296f9471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / mate_llm-0.1.1-py3-none-any.whl

Download URL mate_llm-0.1.1-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6e4ee5ab248dd4d60e030989faacc7c8d63cd7e352014a67dcfc414e6510dbd1
BLAKE2b-256 checksum
How to use checksums
7d381024602fa2b598f790dd8e067912ab35a6890dff784f721a7e35574b9155
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for mate-llm 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page