Ling-3.1-flash, streaming EXL3 packs for mlx-serve

"We" is OpensourceWTF (David Tai).

Each branch of this repo holds one of turboderp's EXL3 quantizations of inclusionAI's Ling-3.1-flash. We repacked each one so that mlx-serve can read its routed experts from the SSD on Apple silicon. turboderp made the quantizations with exllamav3 and publishes them in turboderp/Ling-3.1-flash-exl3. The quantized weights are his, byte for byte. We did not quantize anything again, so please credit turboderp when you use them.

Status. mlx-serve main at a5e30916 or later serves these packs with its built-in bailing_hybrid model. a5e30916 is the merge of ddalcu/mlx-serve#1229. The quant plugin turboexl3_ling is in the plugin's open pull request (CommunityServe/plugins#53). It needs a plugin-kit release that includes #1229.

The quant plugin runs the EXL3 weights and streams the experts. Each bitrate is a branch, and main holds only this card, the license and Hugging Face's .gitattributes.

Branches

Branch Routed experts Trunk Branch size Source and credit
2.60bpw EXL3 2.5 bpw (K2.5) K6; K4 for the dense MLPs of layers 0-3 and the MTP layer's eh_proj 188.3 GB turboderp's 2.60bpw branch (revision 5368b6b9)
2.10bpw EXL3 2 bpw (K2) K6; K4 for the dense MLPs of layers 0-3 and the MTP layer's eh_proj 153.5 GB turboderp's 2.10bpw branch (revision ebce035f)
  • Sizes are in GB, where 1 GB is 10^9 bytes. A branch size is the sum of the pack's files.
  • K is the number of bits per weight of an EXL3 tensor. A branch's name is turboderp's average over all weights: his config.json gives 2.59 and 2.1.
  • The trunk is every weight that is not a routed expert of layers 4-71 or the MTP layer: attention, the shared experts, the dense layers and the output head.
  • Each branch card lists its files and how they were made.

Which branch to use

Use 2.10bpw for speed, and 2.60bpw for the higher bitrate. In the context sweep, 2.10bpw had higher prefill and decode than 2.60bpw at every prompt size. At 18,706 prompt tokens, greedy decode was 16.30 tok/s for 2.10bpw and 12.90 tok/s for 2.60bpw. 2.10bpw's expert records are 3,964,928 B, against 4,947,968 B. A smaller record means fewer SSD bytes for each expert read, and more slot rows in the same memory. We did not measure the quality of either pack through mlx-serve. turboderp's KL divergence chart compares his quants (Quality).

At long prompts, prefill is slow. These are the greedy means at the top point of each pack in the sweep:

Branch Prompt tokens Prefill tok/s Decode tok/s TTFT
2.60bpw 139,264 49.7 3.40 2,801 s (47 min)
2.10bpw 143,360 58.0 3.70 2,471 s (41 min)

Related repositories

Repo What it holds
turboderp/Ling-3.1-flash-exl3 turboderp's EXL3 quantizations for exllamav3, a branch per bitrate, with his KL divergence chart. It is the source of every branch here.
inclusionAI/Ling-3.1-flash The original model, its model card and its recommended sampling settings.
OpenSourceWTF/mlx-serve-streaming-pack-converters, ling31/ The converter that repacks his branches into this layout.

How a pack works

Ling-3.1-flash is a mixture-of-experts (MoE) model. inclusionAI's card gives it 560B total parameters and 25B active parameters per token. It has 72 main layers (0-71) and one MTP layer (72). Layers 0-3 are dense. Each of layers 4-71 has 512 routed experts (small feed-forward networks), and a router picks 8 of them for each token. The routed experts are most of each pack, and each pack is larger than the memory of a 128 GB Mac. The server keeps the rest of the model and part of the routed experts in GPU memory, and it reads the other experts from the SSD when a token needs them. MTP (multi-token prediction) is the extra layer that drafts tokens for the main model to check.

A pack is one of turboderp's branches with its routed experts moved out of the safetensors shards:

  • experts.bin holds the routed experts of layers 4-71, one record for each expert: 68 layers x 512 experts = 34,816 records. A record is the expert's gate, up and down projections in turboderp's bytes, padded with zeros to a multiple of 4,096 B.
  • mtp-nonbank.safetensors holds every tensor of the MTP layer, its experts included.
  • The expert manifests give the offset, size and sha256 of each record.
  • Every other tensor stays in -nonexpert safetensors shards with turboderp's names, dtypes and bytes. We call these tensors the trunk. The trunk stays in memory.
Every file in a branch
File What it is Source
experts.bin The routed experts of layers 4-71: 68 layers x 512 records. turboderp's bytes, in records
expert-manifest-v2.json, expert-manifest.json The record table of experts.bin (offset, size and sha256 of each record, bits per weight of each layer). ours
model-000NN-of-00024-nonexpert.safetensors (23 files) The trunk: one shard for each of turboderp's shards 1 to 23, with every tensor of it that is not a routed expert of layers 4-71 or an MTP tensor. His shard 24 held only MTP tensors. turboderp's tensors, unchanged
mtp-nonbank.safetensors The MTP layer (layer 72), its experts included. turboderp's tensors
model.safetensors.index.json The index of the trunk's tensors. ours
config.json, tokenizer.json, tokenizer_config.json, special_tokens_map.json, chat_template.jinja, configuration_bailing_moe_v3.py, modeling_bailing_moe_v3.py, .gitattributes turboderp's files of the branch. turboderp's, unchanged
LING-REPACK-RECEIPT.json, receipts/ How the pack was made and checked. ours
assets/, sweep/ The context sweep's charts and data. 2.60bpw's assets/family/ also holds this card's sweep charts, because main holds only this card and the license. ours
README.md, LICENSE The branch's card and the MIT license. ours

His README.md (inclusionAI's model card) and his quantization_config.json are not in the branches. mlx-serve serves the packs without quantization_config.json.

Memory: the bank and its slot rows

The bank is the GPU memory that holds routed experts read from the SSD. A slot row holds one expert of each of the 68 routed layers, so a bank of N slot rows holds N experts of each layer. When a token routes to an expert that is not in the bank, the server reads its record from the SSD. More slot rows mean fewer SSD reads and faster decode.

When the bank opens, mlx-serve decides how many slot rows the bank gets in the prompt phase and in the decode phase. It plans against the memory ceiling: the limit on the whole Mac's non-file memory, not on the server alone. Our tests set the ceiling to 118.1 GB (MLX_SERVE_GPU_CEILING_MB=112640, 110 GiB). mlx-serve plans from a bank fit when the pack has one that applies, and from its bills otherwise. A bill is mlx-serve's upper bound on the memory that a phase of one request uses. A bank fit holds measured memory peaks in place of the bills. No branch holds a bank fit (Bank fit).

A --ctx-size above the request that a fit measured makes the bank smaller: mlx-serve takes the bills' growth past that length out of the bank.

How to download and run

Requirements

  • A Mac with an M5-class GPU. turboexl3's prompt kernels run on the matrix units of the M5 GPU (NAX). On another GPU, the plugin refuses to load with an M5-class GPU (NAX) is needed.
  • Xcode with its Metal toolchain, and Homebrew, to build mlx-serve.
  • mlx-serve built from source at main a5e30916 or later.
  • The quant plugin turboexl3_ling 0.2.0, built from source, from the plugin's open pull request (CommunityServe/plugins#53). It needs a plugin-kit release that includes #1229.
  • Memory: we tested only a Mac with 128 GB. We do not know if the packs run with less memory.
  • Free disk for the branch: 188.3 GB for 2.60bpw, or 153.5 GB for 2.10bpw.
  • The Hugging Face CLI hf, which comes with huggingface_hub (pip install -U huggingface_hub).

We tested the packs only on one Apple M5 Max with 128 GB of unified memory. A streaming pack serves one request at a time. The packs do not load in exllamav3, transformers, vLLM, SGLang or mlx-lm. For exllamav3, use turboderp's repository.

Download a branch

Pass the branch name to --revision. This downloads 2.60bpw only:

hf download OpensourceWTF/Ling-3.1-Flash-streaming-repack-exl3 --revision 2.60bpw \
  --local-dir ~/models/Ling-3.1-Flash-streaming-repack-exl3-2.60bpw

Build mlx-serve

These commands build the server and its plugin kit from main at a5e30916. A later main also has the changes.

git clone --recurse-submodules https://github.com/ddalcu/mlx-serve && cd mlx-serve
git checkout a5e30916 && git submodule update --init
brew bundle install --file=Brewfile
./scripts/fetch-zig.sh && export PATH="$PWD/.zig-toolchain:$PATH"
./scripts/fetch-llama.sh && ./scripts/build-mlx.sh
zig build -Doptimize=ReleaseFast && zig build kit
export PATH="$PWD/zig-out/bin:$PATH"   # the server, zig-out/bin/mlx-serve
KIT=$(ls -d "$PWD"/zig-out/kit/mlx-serve-plugin-kit-*/) && export MLX_SERVE_KIT="${KIT%/}"
cd ..

Build and install the plugin

Build the plugin against the kit of the same mlx-serve checkout. The server refuses a plugin that was built against another MLX version.

git clone https://github.com/CommunityServe/plugins && cd plugins
git fetch origin pull/53/head:turboexl3_ling && git checkout turboexl3_ling
scripts/install.sh turboexl3_ling
printf '{"disabled": [], "enabled": true}\n' > ~/.mlx-serve/plugins.json

scripts/install.sh builds the plugin, runs its unit tests and installs it into ~/.mlx-serve/plugins/. The sweep used turboexl3_ling 0.2.0 built from source commit 79baca4. We checked on an M5 Max that mlx-serve a5e30916 with #53's head (20b246e2) loads the 2.60 pack without a fit and writes the same greedy text as the sweep at 1,141 tokens. We did not measure its speed. mlx-serve loads no plugin unless ~/.mlx-serve/plugins.json holds "enabled": true. The printf line writes that file, and it replaces any file that is there.

Start the server

These are the settings of the context sweep on a 128 GB Mac, with --ctx-size at 32,768:

sudo sysctl iogpu.wired_limit_mb=114688
MLX_SERVE_GPU_CEILING_MB=112640 MLX_SERVE_CACHE_LIMIT=2147483648 \
mlx-serve --model ~/models/Ling-3.1-Flash-streaming-repack-exl3-2.60bpw --serve --host 127.0.0.1 --port 8080 \
  --ctx-size 32768 --prefill-chunk 16384 --wired-margin-gib 2 --mtp-min-depth 2 --mtp-max-depth 2
Setting What it does
iogpu.wired_limit_mb=114688 The macOS limit on GPU-wired memory (112 GiB). Our test Mac had this value. The setting lasts until a restart.
MLX_SERVE_GPU_CEILING_MB=112640 The memory ceiling, 110 GiB. Despite its name, it bounds the whole Mac's non-file memory. Set it only on a 128 GB Mac: the server plans with this value in place of the Mac's limit.
MLX_SERVE_CACHE_LIMIT=2147483648 Caps MLX's buffer cache at 2 GiB.
--ctx-size 32768 The longest context: the prompt and the reply together. A larger value takes memory from the bank.
--prefill-chunk 16384 The most prompt tokens in one forward pass.
--wired-margin-gib 2 How far under iogpu.wired_limit_mb a memory plan may reach.
--mtp-min-depth 2 --mtp-max-depth 2 Fixes the MTP draft at 2 tokens a round.

On a Mac with less memory, leave MLX_SERVE_GPU_CEILING_MB and the sysctl unset. The server then plans with the Mac's own limit and the bills. We did not test that.

The load log shows these lines:

  • [diag] GPU ceiling forced to 112640 MB (MLX_SERVE_GPU_CEILING_MB): expected with that setting.
  • [plugins] loaded turboexl3_ling (...): the plugin loaded.
  • bailing_hybrid: bank fit key id=... build=... | machine=... | quant_plugin=... | model_plugin=... | pack=...: the key that a bank fit must carry to apply on this server.
  • bailing_hybrid: streamed experts, ...: N prompt / M decode slot rows per layer: the slot rows that the bank got.

The server has an OpenAI-style API. This command sends one request:

curl http://127.0.0.1:8080/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256}'

Troubleshooting

Log line or error Cause What to do
[plugins] refused <path>: plugin was built against another MLX: rebuild it with this release's kit The plugin was built against the kit of another mlx-serve build. Build the plugin again with MLX_SERVE_KIT set to the kit of the server's checkout.
[plugins] refused <path>: has no install receipt: install it with `mlx-serve plugin install` The plugin file was copied in by hand. Run scripts/install.sh turboexl3_ling again.
an M5-class GPU (NAX) is needed The GPU is not M5-class. Use an M5-class Mac.
bailing_hybrid: bank-fit.json not applied (<reason>): the bank fits by the bills A fit file in the pack does not apply to this server (Bank fit). Nothing: the server runs on the bills.

Quality

turboderp measured the KL divergence of each quantization against the original model, with exllamav3 on his files. His chart is on his model card. The packs hold his quantized bytes in a different file layout, so his numbers describe the weights in these packs. They do not include mlx-serve's kernels. We did not measure quality through mlx-serve, and we have no task-level test (such as HumanEval) on this path.

Context sweep

Measured stack. Measured on a local build with the Ling changes that mlx-serve #1229 merged (a5e30916), using a v2 bank fit. Main now refuses v2 fits and runs the bank on its bills until a v3 fit for the release ships (see Bank fit). The model was mlx-serve's own bailing_hybrid, with the quant plugin turboexl3_ling 0.2.0 built from source commit 79baca4, on an Apple M5 Max with 128 GB, macOS 27.2, with the fans at maximum.

A context sweep runs the same task at prompts of more and more tokens, and it measures speed and memory at each size. We ran one for each of 2.60bpw and 2.10bpw, at 8 prompt sizes each: from 1,141 tokens to a top point of 139,264 tokens (2.60bpw) or 143,360 tokens (2.10bpw). A check run is one extra greedy run at a top point, before that point's measured runs, to check the memory. It is not in the tables here.

The prompts are one coding task, built at 7 lengths for our GLM-5.3-Flash sweep: 1K, 2K, 4K, 8K, 16K, 32K and 64K tokens of GLM's tokenizer. Ling's tokenizer makes more tokens of the same text. The server counted 1,141, 2,312, 4,610, 9,292, 18,706, 37,327 and 74,767 tokens, and the tables use these counts. Each top point is the start of the 256K file, cut at a token boundary.

We chose each top point before the runs, from the plan's estimate of the bank's prompt budget: the memory that the bank gets for the prompt phase. The estimate allowed up to 139,687 tokens (2.60bpw) and 143,730 tokens (2.10bpw) at 32 prompt slot rows. We took the largest multiple of 4,096 under each: 139,264 and 143,360 tokens. By the ratio of the counts, the 128K file is about 149,300 to 149,700 Ling tokens. That is past both packs' estimates for 32 prompt slot rows, so the sweep has no 128K point. We did not count it. In Ling tokens, the whole 256K file is longer than the model's window of 262,144 tokens, so we did not run it.

At each size, 4 new server processes each ran one request. Before each server started, we evicted the pack's files from the page cache. Two requests were greedy, with seeds 1234 and 4321. Two used inclusionAI's recommended sampling (temperature 1.0, top_p 0.95, top_k 20) with the same seeds; the charts and tables call it "card". Each request went out after the model had loaded and the chip had cooled below 40 ยฐC. Every request stopped at max_tokens 1,024, so each decode figure covers the first 1,024 output tokens.

The server ran with the settings of Start the server, except --ctx-size, which was the prompt plus 1,024, rounded up to a multiple of 1,024.

Branch Runs Top point, tokens Bank fit (sha256 starts) Every run, method and raw data
2.60bpw 32, and 1 check run 139,264 bbc665c6b21c branch card, sweep/
2.10bpw 32, and 1 check run 143,360 fd95b64a46ca branch card, sweep/

Prefill and decode speed by prompt size, one line per pack, greedy and card sampling

Time to first token and wall time by prompt size, one line per pack, greedy and card sampling

Spec-decode hit rate by prompt size, one line per pack, greedy and card sampling

Memory by prompt size, one line per pack: whole machine, server peak and slot rows

Speed, latency and hit rate per prompt size

Each value is the mean of the 2 seeds. "Prompt file" is the GLM prompt length that the prompt came from. In the last row, the two packs' top points differ by 4,096 tokens. Prefill and decode tok/s come from the server's own timings. Prefill is prompt tokens over prompt time. Decode is output tokens per second after the first token, with the accepted MTP draft tokens included. TTFT runs from the request to the first token, and wall time from the request to the last token, both on the client's clock. The spec-decode hit rate is the MTP acceptance: the share of MTP draft tokens that the model accepted.

Under greedy decoding, both seeds wrote the same text at every size, for both packs. Each sampled run wrote its own text, and a different text decodes at a different speed. Both packs' prefill was fastest at 4,610 tokens and fell at longer prompts. We did not measure the cause of the fall.

Prefill (tok/s)

Prompt tokens Prompt file 2.60bpw greedy 2.60bpw card 2.10bpw greedy 2.10bpw card
1,141 1K 83.5 79.8 111.3 100.1
2,312 2K 135.5 136.2 165.3 165.3
4,610 4K 210.5 210.6 243.3 243.3
9,292 8K 175.9 176.0 202.6 203.0
18,706 16K 108.9 108.0 136.0 135.3
37,327 32K 53.4 54.8 86.5 85.7
74,767 64K 52.6 52.7 64.2 64.5
139,264 / 143,360 256K, cut 49.7 49.8 58.0 58.2

Decode (tok/s)

Prompt tokens Prompt file 2.60bpw greedy 2.60bpw card 2.10bpw greedy 2.10bpw card
1,141 1K 15.90 15.75 22.25 21.55
2,312 2K 16.80 16.15 21.50 20.85
4,610 4K 15.55 15.20 20.70 19.85
9,292 8K 14.30 14.90 18.90 17.95
18,706 16K 12.90 12.30 16.30 15.05
37,327 32K 9.75 9.40 11.60 11.55
74,767 64K 6.00 5.90 6.80 6.85
139,264 / 143,360 256K, cut 3.40 3.20 3.70 3.45

TTFT (s)

Prompt tokens Prompt file 2.60bpw greedy 2.60bpw card 2.10bpw greedy 2.10bpw card
1,141 1K 13.71 14.30 10.36 11.39
2,312 2K 17.06 16.98 14.00 14.00
4,610 4K 21.91 21.90 18.95 18.95
9,292 8K 52.84 52.81 45.88 45.80
18,706 16K 171.77 173.26 137.56 138.20
37,327 32K 699.81 681.69 431.25 435.94
74,767 64K 1,421.33 1,419.53 1,163.09 1,159.01
139,264 / 143,360 256K, cut 2,800.59 2,795.63 2,471.32 2,465.11

Wall time (s)

Prompt tokens Prompt file 2.60bpw greedy 2.60bpw card 2.10bpw greedy 2.10bpw card
1,141 1K 78.25 79.58 56.48 58.99
2,312 2K 78.04 80.72 61.67 63.14
4,610 4K 87.96 89.38 68.58 70.72
9,292 8K 124.44 121.75 100.15 103.00
18,706 16K 251.51 256.87 200.48 206.37
37,327 32K 805.09 791.34 519.48 524.87
74,767 64K 1,591.87 1,592.90 1,314.01 1,309.09
139,264 / 143,360 256K, cut 3,100.32 3,116.43 2,752.07 2,761.59

Spec-decode hit rate (%)

Prompt tokens Prompt file 2.60bpw greedy 2.60bpw card 2.10bpw greedy 2.10bpw card
1,141 1K 64.2 61.6 71.0 67.7
2,312 2K 62.3 64.8 67.1 62.3
4,610 4K 73.8 65.2 67.4 63.5
9,292 8K 74.1 70.0 73.1 60.8
18,706 16K 74.2 66.2 77.4 64.2
37,327 32K 74.5 62.2 68.0 70.8
74,767 64K 74.6 72.0 71.0 70.8
139,264 / 143,360 256K, cut 75.9 67.1 72.6 64.8

Memory per prompt size

The bank takes the room under the ceiling, so a peak shows the server's plan, not the least memory that the pack needs. "Whole machine" is the Mac's non-file memory: app and GPU memory, not the file cache, sampled each second. Each pack's bank fit holds the memory peaks of one greedy request of our standard test on the sweep's build: an 18,380-token prompt and 1,024 output tokens, 19,404 tokens in all. For a longer context, mlx-serve takes the growth of its bills past those 19,404 tokens out of the bank budget, the memory that the plan gives the bank when the server starts. So the bank holds fewer slot rows as the prompt grows. Margins under the ceiling are in GiB, like the ceiling. A negative margin is over the ceiling.

A slot row is 336,427,008 B for 2.60bpw and 269,580,288 B for 2.10bpw. One decode round at MTP depth 2 checks 3 tokens, and the router picks 8 experts for each token. So one layer can need 24 experts at once, and 24 rows is the floor for decode. We planned for at least 32, and we used the same floor and target for the prompt rows. We did not measure a separate floor for the prompt phase.

We fitted a straight line through each pack's mean prompt budgets at 37,327 and 74,767 tokens. By these lines, 32 prompt rows hold a prompt of up to 136,192 tokens for 2.60bpw and 147,456 tokens for 2.10bpw. 24 rows hold up to 141,312 and 150,528 tokens. Each check run measured the rows that its line predicted at the top point: 28 for 2.60bpw and 40 for 2.10bpw.

  • 2.60bpw: the top point, 139,264 tokens, is past its 32-row limit, because the plan's estimate was higher than the line. Its 4 runs held 27 or 28 prompt rows and 34 or 35 decode rows, and all 4 served. In all 32 runs and in the check run, the whole machine stayed under the ceiling. The lowest margin in the 32 runs was 0.54 GiB, at the top point, and the check run's was 0.47 GiB.
  • 2.10bpw: the top point, 143,360 tokens, is under its 32-row limit. Its 4 runs held 36 to 39 prompt rows and 45 to 47 decode rows, and all 4 served. At the top point, the whole machine's highest sample reached 117.8 to 118.3 GB. That is from 0.28 GiB under the ceiling of 118.1 GB to 0.15 GiB over it. In the two greedy runs at the top point, the whole machine passed the ceiling, by 0.15 GiB and 0.02 GiB, and both runs finished normally. In the other 30 runs and in the check run, it stayed under the ceiling.

Both check runs served, at a server peak of 106.3 GB for 2.60bpw and 109.5 GB for 2.10bpw. They are in each branch's sweep/check_runs.tsv. Our test harness, not mlx-serve, stops a test when its own memory reading passes 117 GiB (125.6 GB). That reading was higher than the whole machine's non-file memory. Its highest was 116.0 GiB in the 2.60bpw runs and 115.2 GiB in the 2.10bpw runs, and it stopped no run.

Whole machine, highest of the size's runs (GB)

Prompt tokens Prompt file 2.60bpw 2.10bpw
1,141 1K 106.3 106.9
2,312 2K 107.0 107.2
4,610 4K 108.2 108.4
9,292 8K 110.8 111.0
18,706 16K 114.4 114.4
37,327 32K 116.8 116.8
74,767 64K 117.1 116.8
139,264 / 143,360 256K, cut 117.5 118.3

Under the ceiling, lowest of the size's runs (GiB)

Prompt tokens Prompt file 2.60bpw 2.10bpw
1,141 1K 11.01 10.44
2,312 2K 10.32 10.17
4,610 4K 9.28 9.07
9,292 8K 6.78 6.65
18,706 16K 3.44 3.44
37,327 32K 1.25 1.24
74,767 64K 0.91 1.18
139,264 / 143,360 256K, cut 0.54 -0.15

Server peak, highest of the size's runs (GB)

Prompt tokens Prompt file 2.60bpw 2.10bpw
1,141 1K 96.6 100.3
2,312 2K 96.8 99.0
4,610 4K 99.3 101.4
9,292 8K 100.8 102.9
18,706 16K 105.3 107.0
37,327 32K 106.7 108.7
74,767 64K 106.5 108.6
139,264 / 143,360 256K, cut 106.3 109.2

Slot rows, prompt / decode (the fewest of the size's runs)

Prompt tokens Prompt file 2.60bpw 2.10bpw
1,141 1K 213 / 226 277 / 293
2,312 2K 212 / 226 276 / 292
4,610 4K 213 / 226 276 / 292
9,292 8K 212 / 226 275 / 291
18,706 16K 211 / 225 272 / 289
37,327 32K 194 / 195 253 / 254
74,767 64K 131 / 134 175 / 179
139,264 / 143,360 256K, cut 27 / 34 36 / 45

Bank fit

No branch holds a bank fit. mlx-serve main at a5e30916 applies only a v3 fit (mlx-serve-bank-fit-v3). A v3 fit carries a key: the server build, the machine, the quant plugin, the model plugin and the pack. The server applies a fit only when every part of the key, the ceiling and the reference request match its own, so each release needs its own fit. It reads bank-fit/<id>.json, where <id> is its key's id, or bank-fit.json when the pack has no file for its key. Without a fit that applies, the server sizes the bank from the bills. A bill is an upper bound, so the bank can get fewer slot rows than the memory allows.

The context sweep used a v2 fit (mlx-serve-bank-fit-v2) for each pack. We made each one on the sweep's own build, from one greedy request of our standard test (an 18,380-token coding prompt and 1,024 output tokens), at the ceiling of 118,111,600,640 B (MLX_SERVE_GPU_CEILING_MB=112640). We do not ship them. A v2 fit has no key, and main refuses it with the log line bailing_hybrid: bank-fit.json not applied (BankFitUnkeyed): the bank fits by the bills. We plan a v3 fit for each release and each branch, under the server's own key. Until one is in a branch, the server sizes the bank from the bills. The bank can then get fewer slot rows than in the sweep, and the sweep's memory figures do not describe it. We did not measure main without a fit.

The sweep's two v2 fits
Field 2.60bpw 2.10bpw Meaning
sha256 starts bbc665c6b21c fd95b64a46ca The file's hash.
ceiling_bytes 118,111,600,640 118,111,600,640 The ceiling that the fit applies at.
cell_tokens 17,408 17,408 mlx-serve's fixed reference request: a 16,384-token prompt and a 1,024-token reply.
evidence_tokens 19,404 19,404 The measured request: an 18,380-token prompt and 1,024 output tokens.
base_prompt_bytes 44,913,379,776 40,568,200,128 The Mac's peak non-file memory in the prompt phase, less the bank's bytes, plus the 2 GiB MLX cache cap (MLX_SERVE_CACHE_LIMIT).
base_decode_bytes 40,190,901,888 36,047,908,160 The same in the decode phase.
rest_bytes 9,733,931,008 6,072,303,616 The non-file memory outside the server when the bank opened.

The code is bankFit in src/sdk/bases/kda_hybrid/trunk.zig and parseBankFit in src/sdk/quant/outside_model.zig (mlx-serve a5e30916). We have not published the tool that writes a fit.

Limits

  • We measured the packs on one Apple M5 Max with 128 GB only.
  • A streaming pack serves one request at a time.
  • The context sweep ran one request at a time, on one coding task built to each size, with replies of 1,024 tokens. It used a v2 bank fit, which main refuses. We did not run it on main itself or without a fit.
  • We checked on an M5 Max that mlx-serve a5e30916 with #53's head (20b246e2) loads the 2.60 pack without a fit and writes the same greedy text as the sweep at 1,141 tokens. We did not measure its speed.
  • By the sweep's measured lines, 32 prompt slot rows hold a prompt of up to 136,192 tokens for 2.60bpw and 147,456 tokens for 2.10bpw. Past these limits the bank holds fewer than 32 prompt rows. The 2.60bpw top point is already past its limit, at 27 or 28 rows.
  • The packs' config.json sets a window of 262,144 tokens. The prompt and the reply must fit in it together.
  • We did not measure quality through mlx-serve.
  • We did not measure: a Mac with less than 128 GB or another M5 chip; more than one request at a time; replies longer than 1,024 tokens; prompts other than the one coding task; prompts past each top point.

How the packs were made

The converter's scripts/ling_exl3_to_streaming.py made both packs. It runs on the CPU and copies bytes. It takes a source shard only when the shard's size and sha256 match turboderp's LFS record. It moves the routed experts of layers 4-71 into one file, experts.bin, with one record for each expert. It keeps every other tensor of each shard in a matching -nonexpert shard, and it puts the MTP layer in mtp-nonbank.safetensors. After it writes a shard, it reads every record back and compares it byte for byte with the source. The receipts in each branch record each check.

The receipts do not record a hash of the script that ran. 2.10bpw ran from a copy that is byte-identical to commit 899fe84. 2.60bpw ran from uncommitted copies from before 899fe84, which already wrote the same record layout. 899fe84 changes only the text of the receipt's description. The non-expert tensors have the same names, shapes and types in both branches, and the 23 -nonexpert shard headers of the two packs are byte-identical. We did not run 899fe84 again on 2.60bpw to compare every byte.

Credits

  • inclusionAI made Ling-3.1-flash and released it under the MIT license: inclusionAI/Ling-3.1-flash.
  • turboderp made the EXL3 quantizations that these packs hold, turboderp/Ling-3.1-flash-exl3. He also created exllamav3 and the EXL3 format, which is based on QTIP by Cornell RelaxML.
  • ddalcu maintains mlx-serve, which has the bailing_hybrid model, the plugin kit and the expert stream.
  • turboexl3 has the Metal kernels that the plugin runs for the EXL3 weights. The repacks are by David Tai.

License

inclusionAI released Ling-3.1-flash under the MIT license, and turboderp's repository uses the same license. Neither repository has a LICENSE file, so the LICENSE file here is the standard MIT text with inclusionAI as the copyright holder. The code (mlx-serve, the plugin, turboexl3 and exllamav3) has its own licenses.

Terms

Term Meaning
EXL3 The quantization format of turboderp's exllamav3
bpw, K Bits per weight. K is the bits per weight of one EXL3 tensor.
Routed expert One of the 512 small feed-forward networks of an MoE layer; the router picks 8 for each token
Record The bytes of one expert of one layer in experts.bin
Trunk Every weight that is not a routed expert of layers 4-71 or the MTP layer
MTP layer The multi-token prediction layer (layer 72), which drafts tokens for the main model to check
Bank, slot row The GPU memory that holds routed experts read from the SSD. A slot row holds one expert of each routed layer.
Bill mlx-serve's upper bound on the memory that a phase of one request uses
Bank fit Measured memory peaks of one request (bank-fit.json), which replace the bills when the fit applies
Ceiling The limit on the whole Mac's non-file memory that the server plans against (MLX_SERVE_GPU_CEILING_MB)
Whole machine The Mac's non-file memory (app and GPU memory, not the file cache): what the ceiling bounds
Prefill, decode Prefill processes the prompt. Decode makes the reply, one round of drafts and checks at a time.
TTFT Time to first token, from the request to the first output token, on a loaded model
Wall time The time from the request to the last output token, on the client's clock
Context sweep The same test at a series of prompt sizes
Check run One greedy run at a context sweep's top point, before that point's measured runs, to check the memory; it is not in the means
Card sampling inclusionAI's recommended sampling settings: temperature 1.0, top_p 0.95 and top_k 20
NAX The matrix units of the M5 GPU
GB, GiB GB is 10^9 bytes. GiB is 2^30 bytes.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for OpensourceWTF/Ling-3.1-Flash-streaming-repack-exl3

Quantized
(1)
this model

Collection including OpensourceWTF/Ling-3.1-Flash-streaming-repack-exl3