Repository navigation
Replies: 2 comments
|
Thanks for all this research! 20+ tok/s on Qwen3.6 35B is great to hear (my M2 Air gets about 9.7). You're right that prefill is the still pretty slow. I've opened issues for the ideas worth pursuing: #22 Reuse a shared prompt prefix across conversations (your 9K OpenCode prefix) Some of this is already in TUFF: prompts are processed in chunks with batched expert reads, the next layer's experts are prefetched, and follow-ups in the same conversation reuse saved state (Flash Next's recurrent state included). MTP is deferred for the same reason TinyTitan gave. You're welcome to pick any of these up. Otherwise I'll get to them over time. If you get a chance, running tuff bench --models gemma4,qwen36 --share on 8.1.1 would put the first M5 on the leaderboard. Thanks again! |
|
@cagonima I have now implemented a lot of these performance improvements. Would love more ideas for TUFF : D If you are interested on actually working on TUFF as well, feel free to open PRs. |
Uh oh!
There was an error while loading. Please reload this page.
The idea
M5 16 GB field report — TUFF performance, long-prefill bottlenecks, prompt reuse and OpenAI API integration
Hi! Following our conversation on Reddit, I'm moving my findings here as requested.
First, thanks for the work on TUFF. Being able to run models substantially larger than the available unified memory is exactly what makes projects like this so interesting to me.
I've been experimenting with local AI extensively on a base M5 MacBook Pro with 16 GB RAM, using several native Apple Silicon inference engines and a custom OpenAI-compatible client for coding agents, tool calling and multi-turn workflows.
I'm sharing the results and engineering observations below in case they're useful for further TUFF optimization, especially on memory-constrained M5 Macs.
I've separated actual TUFF observations from findings obtained with other runtimes, since they should not be treated as equivalent benchmarks.
1. Hardware and environment
Component | Configuration -- | -- Machine | MacBook Pro, Mac17,2 Chip | Base Apple M5 Unified memory | 16 GB GPU | 10 cores Storage | Internal SSD macOS during tests | 27.0.1, build 26A434 Workload | Local coding agents, tool calling, multi-turn chat, long prompts API usage | Local OpenAI-compatible Chat Completions, including SSE Typical requirement | Responsive coding workflows with 4K–64K+ working contextsIncreasing the expert cache improved the hit rate but quickly ran into diminishing returns and additional memory pressure.
ANE-assisted prefill:
For a 6.6K-token input, a separate runtime's Core ML ANE-assisted attention path reduced prefill from 121 seconds to 52.5 seconds.
At 12.4K, prefill also improved, but decode slowed and swap increased substantially.
The broader lesson seems to be that cache size, chunk size and accelerator placement need to be evaluated against the entire task, not just one kernel or one decode metric.
I'd be curious whether TUFF's current long-prompt profiling separates:
SSD expert-read wait.
Attention compute.
Routed expert compute.
Buffer/synchronization overhead.
GPU/ANE residency pressure.
Prompt-cache restoration time.
7. OpenAI-compatible server observations
Because I use TUFF through an external coding-agent client, I've also looked at API-level correctness and performance.
Three areas might be of interest.
A. Native app versus server greedy execution
In an older inspected source revision, the routed/server model provider appeared to force a logits-head path, while the app's inference client could select an optimized greedy path when sampling conditions permitted it.
I have not measured a TUFF speed difference attributable to this.
It may already have been fixed or redesigned upstream.
If such a distinction still exists, a controlled app-versus-server benchmark using identical greedy sampling might be worthwhile.
B. Harmony end-of-turn classification
While integrating a locally built TUFF helper, I encountered a GPT-OSS Harmony stop-classification issue involving
<|return|>and whether a generated response was interpreted as a final assistant answer or a continuation.I carried a local compatibility patch, but I have not reproduced the issue on a clean current upstream release.
I'm mentioning it as an area worth regression coverage, especially for multi-turn API clients and subsequent cache reuse.
C. Tool-call continuation and serialization
Reliable external coding agents depend on:
Preserving function call IDs.
Correct assistant/tool-role sequencing.
JSON argument round-tripping.
Correct end-of-turn classification.
Stable continuation after tool results.
Accurate token-usage accounting.
Cancellation behavior that doesn't corrupt state.
A small public server regression suite that covers these cases would be valuable for third-party integrations.
8. Caution about displayed throughput
In my external client, I initially saw apparent generation speeds that could be roughly half of what I expected.
Further investigation showed that its live throughput display estimated tokens using characters divided by four.
Depending on the output, that can significantly over- or underestimate actual token throughput.
For matched requests through direct engine and client-adapter paths, I did not reproduce a universal 2x inference slowdown.
That was a client-side measurement problem, not an established TUFF engine performance defect.
I now prefer engine-native timings and explicit separation of:
Model loading.
Prefill.
First token.
Decode.
Streaming/transport.
UI rendering.
If TUFF exposes these counters through its API, keeping their definitions consistent and documented would make third-party performance reporting substantially more useful.
9. Memory-constrained hardware considerations
My 16 GB Mac has enough RAM for several local SSD-streaming models to be genuinely useful, but not enough to run multiple heavyweight inference workloads without careful scheduling.
One client-side issue I discovered was that a fresh background-job environment could automatically load a second large model while another model was already resident.
I resolved this in the client by deferring optional background model composition when a different heavyweight inference engine was already active.
This wasn't a TUFF bug, but it illustrates a practical integration requirement: applications should distinguish a running API service from an actually resident model, and avoid unnecessary load/unload cycles.
10. What I'd most like to help test
I'm happy to contribute additional controlled measurements on the base M5 / 16 GB if they're useful.
My main interests would be:
TUFF's native benchmark suite for Gemma 4 26B-A4B and Qwen3.6 35B-A3B on M5.
More detailed short-versus-long-prompt performance, including 4K, 8K and larger effective prompt sizes.
Cache reuse across growing agent conversations.
Cache behavior when interleaving another request.
Whether server and native app throughput match with equivalent sampling settings.
The effects of different expert-cache and prefill-chunk settings within a safe memory budget.
Reproducible model-load and runtime-reconfiguration costs.
I also have additional raw logs and test harnesses for some of the cross-runtime experiments, although they would need to be converted to TUFF-specific tests before being suitable for the official benchmark database.
Important: I haven't run the official current-version
tuff benchsuite for this post, so please treat the direct TUFF performance observations as preliminary rather than standardized benchmark submissions.Thanks again for TUFF. I'd be especially interested in which of these areas you consider the most useful contribution for the project, and whether there is a preferred diagnostics format for capturing prefill, prompt reuse and native decode timings on an M5.
Would you like to help build it?
Maybe, with some guidance
All reactions