Laya MLX for Apple Silicon
Community-native MLX runtime for fast local typed decisions on M-series Macs without PyTorch.
pip install laya-mlxApple Silicon only. Check the runtime repository for converted checkpoint compatibility and version notes.
laya-mlx is an independent MLX port of Laya: the encoder, decision Transformer, scoring head and action head all run in Apple's MLX, with no PyTorch, Transformers runtime or cloud API at inference time. It keeps the original weights, prompt formatting, calibration and output schema.
Requirements
- Apple Silicon Mac, macOS 14+, Python 3.11+.
- The first load downloads the checkpoint; after that, inference is fully local.
Measured speed (project README, M3 Max, FP16)
| End-to-end | Laya 421M | Multilingual 322M |
|---|---|---|
| One short question, P50 | 13.42 ms | 7.39 ms |
| One short question, P95 | 13.92 ms | 7.79 ms |
| 50-question throughput | 146.8 q/s | 395.0 q/s |
| Peak MLX memory, one question | 943.6 MiB | 687.6 MiB |
Timing includes prompt preparation, tokenization, inference, calibration and formatting; model loading is excluded. Different hardware, lengths and question counts change these numbers.
Port fidelity: all three checkpoints matched the upstream answer on 63/63 validation questions in both FP32 and FP16 (378/378 comparisons). The README notes this measures fidelity on those fixtures, not accuracy in general.
Usage
import laya_mlx as laya
agent = laya.load("aac6fef/laya-mlx", dtype="float16")
result = agent.predict(
"I was billed twice. Please refund the duplicate today.",
{
"department": {"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {"billing": "invoices, payments, refunds",
"technical": "bugs and outages"}},
"refund": {"type": "noul", "instructions": "Does the customer ask for money back?"},
},
)
Pre-converted FP16 checkpoints: aac6fef/laya-mlx, aac6fef/laya-multilingual-mlx, aac6fef/laya-typed-decisions-mlx. The original IDs (convaiinnovations/laya, with subfolder=) also load.
Features worth knowing
- Router with upstream's language routing and presets, e.g.
Router(dtype="float16", max_loaded=2); Chinese text routes to the multilingual checkpoint. - Precision: FP16 by default;
dtype="float32"for closer numerical agreement with upstream. - Repeated workloads: opt into
compile=True,pad_to_multiple=16andcache_prompts=True. - Large label sets:
predict_shortlistkeeps the top-k labels by embedding similarity before one forward pass. - CLI and conversion:
laya-mlx predict ...andlaya-mlx convert --model convaiinnovations/laya --dtype float16. - Demo:
pip install 'laya-mlx[demo]'thenlaya-snakeplays Snake with a Laya decision on every move.
Limits
- Apple Silicon only.
- Inference and conversion only; RLCD training and fine-tuning stay in the upstream Python project.
- The port preserves the model's own limits: the English checkpoint is not a substitute for the multilingual one, and confidence does not guarantee accuracy.
Also on Apple Silicon: the MPS runtime (PyTorch on the Mac GPU, low-memory modes) and Arbiter, which can use this MLX port as an engine.
Source: mizorewww/laya-mlx · Apache 2.0 · independent port, not an official Convai Innovations release.
Last verified against the project README: September 24, 2026.