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.1.2

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

Built distribution (wheel)

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

Total release size: 3.7 MB

Release files / mate_llm-0.1.2.tar.gz

Download URL mate_llm-0.1.2.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
5eb6d7dce9a9b7e0ad573505761bae7886b1dbfc33de095b781ee9d918b44284
BLAKE2b-256 checksum
How to use checksums
0711eb6ad91beded9a82ee1c4239047e659d875cd0982131e4223a30888580c8
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.2-py3-none-any.whl

Download URL mate_llm-0.1.2-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3a6b2ef1262fc3a9d3c2d8ae6c0daa9d651f796b66b1a9d099f2a1973bf29f85
BLAKE2b-256 checksum
How to use checksums
e34b4867aa06dde83c1f4967f64b282823b86a535e870a79e37b094cebf7c2e4
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.2

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