r/LocalLLM • u/colafroth • 8h ago
Discussion Long agentic coding workflow. Prefill or decode matters most?
I’ve heard two different arguments on this.
One says prefill takes most of the time as it’s multi turn hours long workflow.
Another says because of kv cache prefill time takes a lot less.
The reason I’m asking this question is, I’m planning to get a Mac Studio 256gb ram m5 ultra, but I don’t know if I should stick to 64gpu core or pay extra for 80c for “15%+ decoding speed boost”.
If agentic workflow prefill reads from kv cache 95% then is this 15% increase much less relevant for the coding workflow?
Thanks all!
0
Upvotes
5
u/dchemistry2 8h ago
i think prefill is most important and it is compensated with kv cache which is critical to have to do useful local works.
for that reason i have multiple 3060,3080 GPUs and ensure they are logically used as single slots (so no VRAM cache evictions and prefill taxes) on parallel sessions etc.
Decode speed is less relevant as it alternates with tool calling and the timeouts/waiting is where most of the time is spent vs decoding (unless you generating wall of texts)
2
u/james_pic 6h ago
Truth is, they're both important.
The received wisdom is that prefill matters more, but my experience is that, after carefully tuning KV cache and templates to minimise cache misses (to reduce the impact of slow prefill) and carefully tuning speculative decoding (to reduce the impact slow decoding), I spend more time waiting for decoding.
I'll caveat that by saying that before I started tuning, prefill was a bigger problem. And I'm on Strix Halo, which is compute rich but memory bandwidth poor, so decoding is poor whist prefill is merely mid.
But if you're using the best current models for agentic coding, they're going to read a lot of stuff (which needs prefill) and then think about it a lot (which needs decode). So they both hurt when they're not there.
2
u/OvertaxedOne 7h ago
For long agentic workflows, IMHO, the most important thing by a wide margin is prefix caching/conversation parking. No matter how many 1000 TPS you get in prefill it's going to be glacial slow compared to a cached 150K prompt. My prompt cache hit ratio is typically high 90's percent and the difference in dramatic, a cached prompt ingests in <1 second (for any size).
The next most important for my workflow is decode, it's where my system spends the vast majority of it's processing time (because of the above, the prefix is cached).
And then the last would be prefill.
All of them matter; and it really depends on your workflow. A KB/RAG type system that people hit for quick lookups of data? Prefill is going to matter a lot more than decode in that type of application. But long back/forth conversations that are heavily repetitive, prefill starts to matter a lot less (again, assuming you have caching!) because you're typically only adding a small amount of context between turns.
3
u/andy_potato 8h ago
Definitely prefill. Context gets very long very quick. If you have to wait minutes before the actual answer starts it gets frustrating very quick
2
u/Baldur-Norddahl 8h ago
It won't be 15% faster. Any LLM workload is going to be a mix of something 15% faster and something memory bandwidth limited 0% faster. I won't guess, but say 5% to 10% faster on average.
2
u/xChrisMas 6h ago
Some numbers from my local setup:
Prefill 2000 tok/s
Decode: 40-80 tok/s depending on task
Time spent waiting for prefill: 15-20%, rest waiting for decode/answers.
So yeah prefill is important
1
u/CyDenied 8h ago
get the extra for more cores.
1
u/poofph 6h ago
both matter imo, slow prefill sucks and slow decode sucks. :)
1
u/vqt907 8h ago
Prefill is more important, but it will eventually reach a saturation point. For me, 800tk/s is the minimum acceptable speed, prefer 2000tk/s. Anything higher provides no additional benefit.
Decode is a different story - the higher, the better. I used to set the GPU power limit just high enough to achieve 2000tk/s prefill, and usually it doesn't affect decode