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 | Checkpoints | Support Matrix | Benchmarks | 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

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.2.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.2.1
File Size Uploaded Provenance Actions
mate_llm-0.2.1.tar.gz 2.5 MB Without provenance Details for mate_llm-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 4.3 MB

Release files / mate_llm-0.2.1.tar.gz

Download URL mate_llm-0.2.1.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
edf99be9341790ff6dcb112c4fb809115c5b57dae2108265d5d7ddf77282295e
BLAKE2b-256 checksum
How to use checksums
acd6564fd92bc8301c7e29bf1702fd836166ee84a545a2e739591de8c9bbbbc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL mate_llm-0.2.1-py3-none-any.whl
Size 1.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f83305f7537d359b77e5ac2d27bd789035ce8428ce78786c098f1eb6a5c77faf
BLAKE2b-256 checksum
How to use checksums
a15bd6c81c7c01657b739f221a8a36ac3849bfc3ba244007063ade6824b1548d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mate-llm 0.2.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