float16 MLX conversion of garagelm/hybrid-gpt-232m-chat for Apple Silicon. A 232M-parameter research model with hybrid local+global attention (sliding window w=64 on 12 of 16 layers, full causal attention on layers 3/7/11/15), pretrained on 1.0B tokens entirely on one Apple M4 Pro.
MLX is the deployment-relevant runtime for this project: it is what the efficiency claims were measured under, and it outperforms PyTorch+MPS for on-device inference.
M4 Pro (48GB), float16, 128 decode tokens, peak memory 1.17 GB. KV cache is read from the live cache arrays, not inferred.
| prompt | TTFT | prefill tok/s | decode tok/s | KV cache |
|---|---|---|---|---|
| 64 | 8 ms | 8,014 | 313 | 1.56 MB |
| 256 | 21 ms | 11,977 | 310 | 2.35 MB |
| 512 | 41 ms | 12,450 | 307 | 3.40 MB |
| 896 | 73 ms | 12,261 | 305 | 4.97 MB |
The bounded KV cache is the point of the architecture: 12 of 16 layers keep only their last 64 keys, so cache growth is dominated by the 4 global layers. At full 1024 context that is ~30% of an all-global equivalent.
Latency was measured on the base checkpoint; these weights are the same architecture and shapes, so throughput is identical.
model_type: hybrid_gpt is not in mlx-lm's registry yet, so pass the bundled
module explicitly. The module in this repo is written against mlx-lm's model
interface, so generate, streaming, prompt caching and the server all work.
import sys
from pathlib import Path
from huggingface_hub import snapshot_download
from mlx_lm.utils import load_model, load_tokenizer
from mlx_lm import generate
path = Path(snapshot_download("garagelm/hybrid-gpt-232m-chat-mlx"))
sys.path.insert(0, str(path))
import hybrid_gpt
model, _ = load_model(path, get_model_classes=lambda config: (hybrid_gpt.Model, hybrid_gpt.ModelArgs))
tok = load_tokenizer(path)
print(generate(model, tok, prompt='User: Why is the sky blue?\nAssistant:', max_tokens=100))
The chat variant uses a plain-text template with no special tokens beyond
gpt2's <|endoftext|>, which is also its assistant-turn terminator:
User: {message}
Assistant: {reply}<|endoftext|>
Two gates run before this repo is written, both in the research repo's
release/mlx/export.py:
hybrid_gpt.py shipped here matches the reference
MLX port on a 128-token prefill plus 8 cached decode steps
(max|logit diff| 1.6e-05, top-1 agreement
1.000). The gate runs on the fp32 weights, so it
is a property of the module rather than of this precision. That port is
itself logit-parity-gated against the PyTorch implementation, so the
module here is transitively pinned to PyTorch.export_stats.json.A 232M-parameter research artifact, not an assistant. Fluent text, unreliable facts, 1024-token context, English only. This is the DPO-tuned chat variant; it is format-reliable and politely confident about things it has no way to know.
Evaluations, training recipe and the full architecture writeup are on the upstream card: garagelm/hybrid-gpt-232m-chat.