Skip to content

Update (M5 Pro 48GB): Peak performance leaps to Max ~85 TPS Avg 50TPS, but rigid constraints hit a wall at 61k prompt limits. #55

Closed

Description

@Deesha08

Update: Peak performance leaps to ~85 TPS, but rigid constraints hit a wall at 61k prompt limits

Hi @ashhart,

I wanted to share a massive update on this! I've been running more extensive tests with TensorFold, and the raw performance optimization since my last issue [ https://github.com//issues/36 ] is incredible.

🏆 The Wins: Massive Throughput Leaps

When the cache is warmed up and context lengths are under 10k tokens, generation speeds reach a peak of 85.0 tokens per second (tok/s) (up from 59.6 tok/s), maintaining an average of 51.15 tok/s across 21 sequential requests. Even in a 40k–50k context window, generation stays resilient between 33.0 and 48.0 tok/s.


🛑 The New Roadblock: Hard 61k Token Ceiling

The engine hits a usability wall with continuous developer workflows (like OpenCode) as context budgets saturate quickly, leading to hard server rejections regarding token limits (e.g., requests exceeding the 61,440 window). Starting with --max-tokens 8192 limits prompt headroom to 53,248 tokens, complicating large codebase inputs, and deep context mismatches cause prefill times to spike up to 158–179 seconds.


📊 Fresh Local Benchmarks (Selected Logs)

Sample logs illustrating light, mid, and extreme context scaling and prefill bottlenecks can be found in the active session logs, where prefill times reach up to 179.26s under extreme cache eviction pressure.


💡 Questions & Suggestions Needed

  1. Harness Settings: Recommended serving parameters for integrating TensorFold with developer tools?
  2. Context vs Memory Window: Solutions for sliding context windows or dynamic token allocation to avoid rigid prompt truncation?
  3. Prefill Mitigation: Strategies to reduce long prefill delays when conversation history breaks the snapshot cache?

48GB MacBook Pro - M5 Pro Chip

Logs below for reference:

tensorfold serve Vontra/Qwen3.8-27B-MLX-4bit --max-tokens 8192
[tensorfold] memory budget 33.6 GiB: MLX's buffers up to 30.6 GiB, 3 GiB for the rest of the process
[tensorfold] loading Qwen3.8-27B-MLX-4bit: Qwen3.8 dense (qwen3_5)
[tensorfold] lane kernels on: 9 matmul shapes warmed, fused projections {'zba': 48, 'kv': 16, 'gu': 64}
[tensorfold] drafter /Users/deesha/.cache/huggingface/hub/models--z-lab--Qwen3.8-27B-DFlash2/snapshots/50307d4c4cde6860d4eee73e2547cd786fe8e8a4 block=8 bits=4
[tensorfold] lane kernels: windows of up to 32 rows reproduce one-row steps here (ms by rows 1: 60.2, 2: 60.7, 4: 65.5, 8: 67.0, 16: 68.5, 17: 81.6, 32: 81.3, 64: 147.4, 128: 270.6)
[tensorfold] concurrency: up to 8 requests share each round; memory budget 29.0 GB (MLX's share 30.6 GB, or 70% of 48 GB less 4.6 GB in use elsewhere); a stream 163 MB at 64 tokens, 394 MB at 2,112, then 114.0 KB a token; a shared round up to 1.42 GB; 5 streams of 12,288 tokens fit now (more wait their turn)
[tensorfold] loaded system-block snapshot tokens=2048 in 0.1s
[tensorfold] loaded system-block snapshot tokens=3236 in 0.1s
[tensorfold] loaded system-block snapshot tokens=10240 in 0.1s
[tensorfold] context window 61,440 tokens: the most one request can use in the 33.6 GiB memory budget (the model's window is 262,144); have clients compact before it
[tensorfold] serving Qwen3.8-27B-MLX-4bit at http://127.0.0.1:8080/v1 (sampling: temperature 1.0, top_k 20, top_p 0.95; drafts: on; context: 61440; loaded in 29.7s)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-a1a795beed88 prompt=10411 cached=10240 thinking=True effort=medium tokens=351 sha=4fcb340c7610 finish=stop tok/s=43.7 ttft=0.75s prefill=0.68s rounds=99 accepted=252/1453 ms/round=80.8 forward=80.8 draft=0.0 post=0.0 rows=15.7 checkpoints=3 (1.38 GiB, hits=1 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-83dbf16716c7 prompt=3451 cached=3236 thinking=True effort=medium tokens=217 sha=5e4614168a10 finish=stop tok/s=85.0 ttft=0.69s prefill=0.68s rounds=33 accepted=184/531 ms/round=76.9 forward=76.9 draft=0.0 post=0.0 rows=17.1 checkpoints=3 (1.38 GiB, hits=2 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-89b47563497f prompt=4881 cached=3236 thinking=True effort=medium tokens=254 sha=1acfe71cae62 finish=stop tok/s=77.5 ttft=4.16s prefill=4.15s rounds=38 accepted=215/654 ms/round=85.9 forward=85.9 draft=0.0 post=0.0 rows=18.2 checkpoints=4 (1.91 GiB, hits=3 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-53046c868dde prompt=6921 cached=4876 thinking=True effort=medium tokens=272 sha=ed2d70dfb46a finish=stop tok/s=73.2 ttft=5.43s prefill=5.39s rounds=42 accepted=230/715 ms/round=88.1 forward=88.1 draft=0.0 post=0.0 rows=18.0 checkpoints=5 (2.58 GiB, hits=4 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-633da2d51269 prompt=9197 cached=6916 thinking=True effort=medium tokens=248 sha=1c0563c4f743 finish=stop tok/s=83.0 ttft=6.14s prefill=6.09s rounds=36 accepted=212/575 ms/round=82.6 forward=82.6 draft=0.0 post=0.0 rows=17.0 checkpoints=6 (3.36 GiB, hits=5 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-a7099b6719e5 prompt=13619 cached=8964 thinking=True effort=medium tokens=276 sha=5ab5e8525352 finish=stop tok/s=38.8 ttft=14.64s prefill=14.59s rounds=53 accepted=222/902 ms/round=133.7 forward=133.7 draft=0.0 post=0.0 rows=18.0 checkpoints=7 (4.45 GiB, hits=6 misses=0 evictions=0)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-788493a7c367 prompt=24882 cached=13614 thinking=True effort=medium tokens=208 sha=60df15723d45 finish=stop tok/s=42.4 ttft=47.54s prefill=47.42s rounds=46 accepted=164/740 ms/round=106.2 forward=106.2 draft=0.0 post=0.0 rows=17.1 checkpoints=6 (5.02 GiB, hits=7 misses=0 evictions=2)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-7ab9249d7c4c prompt=35530 cached=24877 thinking=True effort=medium tokens=366 sha=71a4b17b3352 finish=stop tok/s=38.5 ttft=45.20s prefill=45.11s rounds=78 accepted=287/1219 ms/round=121.5 forward=121.5 draft=0.0 post=0.0 rows=16.6 checkpoints=2 (2.76 GiB, hits=8 misses=0 evictions=7)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] slow round 1543 ms streams=1 width=15 rows=15 forward=1543
[tensorfold] done req-3558d6083cbb prompt=48958 cached=35525 thinking=True effort=medium tokens=579 sha=420398f3c647 finish=stop tok/s=28.8 ttft=78.67s prefill=78.56s rounds=145 accepted=433/2228 ms/round=138.1 forward=138.1 draft=0.0 post=0.0 rows=16.4 checkpoints=0 (0.00 GiB, hits=9 misses=0 evictions=9)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] read system-block snapshot tokens=10240 from disk in 0.16s
[tensorfold] done req-0dd60a773024 prompt=11000 cached=10240 thinking=True effort=medium tokens=153 sha=44022e4cabd0 finish=stop tok/s=52.8 ttft=2.97s prefill=2.94s rounds=28 accepted=125/448 ms/round=102.8 forward=102.8 draft=0.0 post=0.0 rows=17.0 checkpoints=2 (1.62 GiB, hits=10 misses=0 evictions=9)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-35025fd51464 prompt=28420 cached=10995 thinking=True effort=medium tokens=249 sha=c55e8c629822 finish=stop tok/s=46.3 ttft=67.42s prefill=67.33s rounds=47 accepted=201/716 ms/round=114.0 forward=114.0 draft=0.0 post=0.0 rows=16.2 checkpoints=3 (3.61 GiB, hits=11 misses=0 evictions=9)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-5cf6debea42e prompt=31841 cached=28415 thinking=True effort=medium tokens=175 sha=d09703aa15bf finish=stop tok/s=61.5 ttft=16.31s prefill=16.21s rounds=26 accepted=148/432 ms/round=108.7 forward=108.7 draft=0.0 post=0.0 rows=17.6 checkpoints=3 (4.95 GiB, hits=12 misses=0 evictions=10)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-29c7695e77e3 prompt=43082 cached=31836 thinking=True effort=medium tokens=179 sha=6a77d66270ca finish=stop tok/s=42.5 ttft=55.03s prefill=54.91s rounds=31 accepted=148/517 ms/round=134.9 forward=134.9 draft=0.0 post=0.0 rows=17.7 checkpoints=2 (3.64 GiB, hits=13 misses=0 evictions=11)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-60a14edaa07b prompt=48946 cached=43077 thinking=True effort=medium tokens=199 sha=96e7303393a1 finish=stop tok/s=36.7 ttft=34.02s prefill=33.89s rounds=40 accepted=159/625 ms/round=134.7 forward=134.7 draft=0.0 post=0.0 rows=16.6 checkpoints=0 (0.00 GiB, hits=14 misses=0 evictions=13)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] read system-block snapshot tokens=10240 from disk in 0.26s
[tensorfold] done req-5bc95b1a0b4d prompt=49301 cached=10240 thinking=True effort=medium tokens=181 sha=3d4927281216 finish=stop tok/s=33.0 ttft=158.63s prefill=158.43s rounds=37 accepted=144/652 ms/round=147.0 forward=147.0 draft=0.0 post=0.0 rows=18.6 checkpoints=0 (0.00 GiB, hits=15 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] read system-block snapshot tokens=10240 from disk in 0.53s
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-8d3641176a3e prompt=10411 cached=10240 thinking=True effort=medium tokens=351 sha=4fcb340c7610 finish=stop tok/s=40.0 ttft=5.72s prefill=5.66s rounds=99 accepted=252/1452 ms/round=88.4 forward=88.4 draft=0.0 post=0.0 rows=15.7 checkpoints=1 (0.77 GiB, hits=16 misses=0 evictions=14)
[tensorfold] read system-block snapshot tokens=3236 from disk in 0.03s
[tensorfold] done req-cf77f9609362 prompt=3451 cached=3236 thinking=True effort=medium tokens=217 sha=5e4614168a10 finish=stop tok/s=79.8 ttft=0.74s prefill=0.73s rounds=33 accepted=184/531 ms/round=81.9 forward=81.9 draft=0.0 post=0.0 rows=17.1 checkpoints=2 (1.11 GiB, hits=17 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-70effadd120e prompt=4881 cached=3236 thinking=True effort=medium tokens=243 sha=41289571c044 finish=stop tok/s=82.4 ttft=6.92s prefill=6.89s rounds=32 accepted=211/569 ms/round=91.8 forward=91.8 draft=0.0 post=0.0 rows=18.8 checkpoints=3 (1.64 GiB, hits=18 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-5836a9d146e5 prompt=6906 cached=4876 thinking=True effort=medium tokens=245 sha=8f522406df7c finish=stop tok/s=64.8 ttft=5.04s prefill=4.98s rounds=45 accepted=200/707 ms/round=83.6 forward=83.6 draft=0.0 post=0.0 rows=16.7 checkpoints=4 (2.31 GiB, hits=19 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-665eb219462a prompt=16513 cached=6901 thinking=True effort=medium tokens=271 sha=bc40360c73f4 finish=stop tok/s=71.0 ttft=26.32s prefill=26.28s rounds=40 accepted=231/676 ms/round=95.1 forward=95.1 draft=0.0 post=0.0 rows=17.9 checkpoints=5 (3.56 GiB, hits=20 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-eb6f78ca4768 prompt=19538 cached=16508 thinking=True effort=medium tokens=372 sha=976d11c7da8b finish=stop tok/s=39.2 ttft=9.91s prefill=9.84s rounds=93 accepted=279/1487 ms/round=101.6 forward=101.6 draft=0.0 post=0.0 rows=17.0 checkpoints=6 (5.00 GiB, hits=21 misses=0 evictions=14)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-88a24792a368 prompt=21993 cached=19533 thinking=True effort=medium tokens=444 sha=9af6c03591c3 finish=stop tok/s=43.7 ttft=8.46s prefill=8.39s rounds=102 accepted=342/1567 ms/round=99.3 forward=99.3 draft=0.0 post=0.0 rows=16.4 checkpoints=5 (5.40 GiB, hits=22 misses=0 evictions=16)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-ddb8281cda27 prompt=27137 cached=21988 thinking=True effort=medium tokens=112 sha=ca05076da215 finish=stop tok/s=52.4 ttft=19.48s prefill=19.39s rounds=21 accepted=91/314 ms/round=100.8 forward=100.8 draft=0.0 post=0.0 rows=16.0 checkpoints=4 (4.62 GiB, hits=23 misses=0 evictions=18)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-b1b8d1253402 prompt=42319 cached=27132 thinking=True effort=medium tokens=199 sha=4878cc4b1a1e finish=stop tok/s=48.0 ttft=62.45s prefill=62.35s rounds=34 accepted=164/617 ms/round=120.9 forward=120.9 draft=0.0 post=0.0 rows=19.1 checkpoints=0 (0.00 GiB, hits=24 misses=0 evictions=22)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] read system-block snapshot tokens=3236 from disk in 0.17s
[tensorfold] done req-0d4ea08e0da5 prompt=50769 cached=3236 thinking=True effort=medium tokens=171 sha=e313b83fb682 finish=stop tok/s=45.9 ttft=179.39s prefill=179.26s rounds=26 accepted=145/481 ms/round=142.0 forward=142.0 draft=0.0 post=0.0 rows=19.5 checkpoints=0 (0.00 GiB, hits=25 misses=0 evictions=23)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] read system-block snapshot tokens=10240 from disk in 0.13s
[tensorfold] done req-729cee043139 prompt=11013 cached=10240 thinking=True effort=medium tokens=250 sha=bebb5e7c6f5a finish=stop tok/s=59.9 ttft=2.80s prefill=2.77s rounds=40 accepted=209/640 ms/round=103.8 forward=103.8 draft=0.0 post=0.0 rows=17.0 checkpoints=2 (1.62 GiB, hits=26 misses=0 evictions=23)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-6807e92ebf59 prompt=21820 cached=11008 thinking=True effort=medium tokens=224 sha=5f1b3bf7ab43 finish=stop tok/s=51.7 ttft=35.74s prefill=35.68s rounds=41 accepted=183/626 ms/round=105.1 forward=105.1 draft=0.0 post=0.0 rows=16.3 checkpoints=3 (3.20 GiB, hits=27 misses=0 evictions=23)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-b3b4a4f18dd9 prompt=38139 cached=21815 thinking=True effort=medium tokens=440 sha=6ea2e368c7b9 finish=stop tok/s=42.8 ttft=63.74s prefill=63.64s rounds=82 accepted=357/1304 ms/round=125.1 forward=125.1 draft=0.0 post=0.0 rows=16.9 checkpoints=1 (2.57 GiB, hits=28 misses=0 evictions=26)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -
[tensorfold] done req-3aef72949b67 prompt=51625 cached=38134 thinking=True effort=medium tokens=230 sha=d4c7e4063234 finish=stop tok/s=42.1 ttft=61.72s prefill=61.59s rounds=40 accepted=190/712 ms/round=135.8 forward=135.8 draft=0.0 post=0.0 rows=18.8 checkpoints=0 (0.00 GiB, hits=29 misses=0 evictions=27)
[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 -

Activity

  1. added a commit that references this issue on Sep 28, 2026
  2. ashhart commented on Sep 28, 2026

    @ashhart
    Owner

    Thanks @Deesha08, and thanks for the detailed logs. 85 tok/s on an M5 Pro is good to see.

    The 61,440 window is what your default budget fits: 33.6 GiB, 70% of 48 GB, with room to keep each prompt for its
    next turn. 0.3.6.2 lets you raise that budget with TENSORFOLD_MEMORY_LIMIT_GB, and the startup line now prints the
    most your Mac allows. I emulated your class on an M5 Max with the 27B at 4 bits plus DFlash2. That's not your
    machine, so treat these as a guide:

    • 33.6 GiB: a 58k window (you got 61k; my checkpoint is slightly larger)
    • 36 GiB: 75k
    • 38.4 GiB: 91k
    • 40.8 GiB: 108k. A 69k-token prompt ran with MLX peaking at 32.5 of its 37.8 GiB.

    Your long prefills look like cache misses rather than slow prefill: at 40-50k, your log shows several turns with
    checkpoints=0 and evictions. I reproduced it with two 35k-token conversations taking turns. At 33.6 GiB, the second
    pushed out the first's saved state, so returning to the first re-prefilled everything. At 40.8 GiB both states stayed
    and the return started in 0.2 s.

    0.3.6.2 also fixes this without a bigger budget. @gilby's #68 adds --spill-gib N: a conversation pushed out of
    memory is written to disk and read back when it returns. In the same test at your default 33.6 GiB with
    --spill-gib 20, the return to the first conversation started in 0.27 s instead of 75 s. It was read back in 0.08 s
    after a 1.6 s write, with output identical to a cold prefill. It's off by default. --spill-gib 20 keeps up to 20 GiB
    of this model's conversations on disk, oldest dropped first. On your Mac, that should turn the 158-179 s turns into a
    second or two.

    Other options, each a trade:

    • --context N can go past the fitted window. At 33.6 GiB one request can use up to 105k, but beyond the fitted window
      a turn can't also keep its prompt, so the next turn re-prefills.
    • --drafter none gives 71k at the default budget, but decoding without the draft model is much slower.
    • --max-tokens is only the reply reserve when the client doesn't send max_tokens; lowering it leaves more room
      for the prompt.

    We don't have a sliding window. For OpenCode I'd start with --spill-gib 20 at the default budget. Raising the budget
    too gives you a longer window, but leaves less memory for your other apps, so I'd pick a value a few GiB under the
    ceiling the startup line shows. If you try it, I'd like to know the ceiling your M5 Pro reports. Release: https://github.com/ashhart/TensorFold/releases/tag/v0.3.6.2

  3. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions