ds4 icon indicating copy to clipboard operation
ds4 copied to clipboard

Many prefills while using Claude Code extension

Open liqili opened this issue 4 months ago • 17 comments

Hi @antirez, Thank you so much for your great work. I have run ds4 Q2 model on my Mac Studio 128GB. The only issue I came across is the prefills which make the prompt very slow. This happens when I try to ask Claude to summarize my code base and give plans. Any idea how I can improve the performance?

./ds4-server
--model ds4flash.gguf
--host 0.0.0.0
--port 8080
--ctx 65536
--kv-disk-dir ./cache/kv
--kv-disk-space-mb 8192 ds4: Metal device Apple M4 Max, 128.00 GiB RAM ds4: Metal 4 tensor API disabled for pre-M5/pre-A19 devices ds4: drift-patch flags hc_stable=on norm_unify=on kv_raw_f32=off rope_exp2_log2=off math_safe=off tensor_matmul=off ds4: requesting Metal residency (may take tens of seconds)... done ds4: warming Metal model views... done ds4: Metal model views created in 1.617 ms, residency requested in 31074.930 ms, warmup 4.012 ms (mapped 93065.67 MiB from offset 5.09 MiB) ds4: Metal mapped mmaped model as 2 overlapping shared buffers ds4: metal backend initialized for graph diagnostics 0705 16:36:50 ds4-server: context buffers 1393.67 MiB (ctx=65536, backend=metal, prefill_chunk=4096, raw_kv_rows=4352, compressed_kv_rows=16386) 0705 16:36:50 ds4-server: KV disk cache ./cache/kv (budget=8192 MiB, cross-quant=accept, min=512, cold_max=30000, continued=10000, trim=32, align=2048, hit_half_life=21600s) 0705 16:36:50 ds4-server: listening on http://0.0.0.0:8080 0705 16:42:19 ds4-server: chat ctx=0..24527:24527 TOOLS prompt start 0705 16:42:19 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 0/24527 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.001s 0705 16:42:32 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 4096/24527 (16.7%) chunk=316.37 t/s avg=316.35 t/s 12.947s 0705 16:42:45 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 8192/24527 (33.4%) chunk=312.70 t/s avg=314.52 t/s 26.046s 0705 16:42:59 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 12288/24527 (50.1%) chunk=300.16 t/s avg=309.58 t/s 39.692s 0705 16:43:13 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 16384/24527 (66.8%) chunk=293.22 t/s avg=305.32 t/s 53.661s 0705 16:43:28 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 20102/24527 (82.0%) chunk=249.51 t/s avg=293.19 t/s 68.562s 0705 16:43:28 ds4-server: kv cache evicted reason=disk-cache-full tokens=10240 hits=0 size=157.34 MiB file=./cache/kv/be1abb4b15f7cf5863991377b9c8e9efd09fb794.kv 0705 16:43:28 ds4-server: kv cache stored tokens=20102 trimmed=4425 reason=cold key=token-text size=286.80 MiB save=34.9 ms 0705 16:43:30 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 20480/24527 (83.5%) chunk=157.21 t/s avg=288.59 t/s 70.967s 0705 16:43:30 ds4-server: kv cache evicted reason=disk-cache-full tokens=20102 hits=0 size=286.80 MiB file=./cache/kv/34ebbe2c6391c97a13048c1d08cf4b28f84a4908.kv 0705 16:43:30 ds4-server: kv cache stored tokens=20480 trimmed=0 reason=continued key=token-text size=291.79 MiB save=29.1 ms 0705 16:43:47 ds4-server: chat ctx=0..24527:24527 TOOLS prefill chunk 24527/24527 (100.0%) chunk=242.85 t/s avg=279.89 t/s 87.631s 0705 16:43:47 ds4-server: chat ctx=0..24527:24527 TOOLS prompt done 87.631s 0705 16:43:49 ds4-server: chat ctx=24527..24577:50 gen=50 TOOLS DSML_START decoding chunk=23.74 t/s avg=23.74 t/s 2.106s 0705 16:43:51 ds4-server: chat ctx=24577..24627:50 gen=100 TOOLS DSML_START decoding chunk=24.06 t/s avg=23.90 t/s 4.185s 0705 16:43:53 ds4-server: chat ctx=24627..24677:50 gen=150 TOOLS DSML_START decoding chunk=23.79 t/s avg=23.86 t/s 6.287s 0705 16:43:55 ds4-server: chat ctx=24677..24727:50 gen=200 TOOLS DSML_START decoding chunk=23.81 t/s avg=23.85 t/s 8.387s 0705 16:43:55 ds4-server: chat ctx=24727..24732:5 gen=205 TOOLS DSML_START DSML_END decoding chunk=23.76 t/s avg=23.85 t/s 8.597s 0705 16:43:55 ds4-server: tool calls ctx=0..24527:24527 n=3 raw_dsml=1 ids=[toolu_c328cf6a3554972802794e57c9042e6e,toolu_bef80c046ceba19c46b6bba0b13b8770,toolu_fb6e0342892d21c8dd6c8aa74cdb097e] names=[Read,Read,Read] 0705 16:43:55 ds4-server: chat ctx=0..24527:24527 gen=205 TOOLS DSML_START DSML_END finish=tool_calls 96.229s 0705 16:43:55 ds4-server: anthropic live continuation match=tool-output-ids ids=3 cached=24732 prompt=39299 0705 16:43:55 ds4-server: chat ctx=24732..39299:14567 TOOLS prompt start 0705 16:43:55 ds4-server: chat ctx=24732..39299:14567 TOOLS prefill chunk 0/14567 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0705 16:44:10 ds4-server: chat ctx=24732..39299:14567 TOOLS prefill chunk 3940/14567 (27.0%) chunk=265.76 t/s avg=265.75 t/s 14.826s 0705 16:44:25 ds4-server: chat ctx=24732..39299:14567 TOOLS prefill chunk 8036/14567 (55.2%) chunk=266.76 t/s avg=266.27 t/s 30.180s 0705 16:44:41 ds4-server: chat ctx=24732..39299:14567 TOOLS prefill chunk 12132/14567 (83.3%) chunk=259.29 t/s avg=263.87 t/s 45.977s 0705 16:44:52 ds4-server: chat ctx=24732..39299:14567 TOOLS prefill chunk 14567/14567 (100.0%) chunk=221.09 t/s avg=255.60 t/s 56.991s 0705 16:44:52 ds4-server: chat ctx=24732..39299:14567 TOOLS prompt done 56.991s

liqili avatar Jul 05 '26 04:07 liqili

@liqili try running ./ds4-server with --kv-disk-space-mb 16384 --kv-cache-min-tokens 256 --kv-cache-continued-interval-tokens 12288 --kv-cache-cold-max-tokens 65536 --prefill-chunk 2048, then do the same but with --kv-disk-space-mb 24576 or --kv-disk-space-mb 32768 and see how much it improves. Apple Silicon GPUs are not known to generate videos or images fast and are also not known for fast prefills. You might want to out https://github.com/GiorgioOppo/ds4 instead if you need a more polished Mac experience or just cope with slow prefills. Claude Code injects obnoxiously long prompts, and I think you're working on a 2500+-loc codebase based on the total amount of tokens prefilled. If you can, you can share your .kv files or your KV cache folder here.

OPS-NeoRetro avatar Jul 09 '26 05:07 OPS-NeoRetro

If you have problems with KV cache eviction, delete all of the .kv files in your KV cache folder first

OPS-NeoRetro avatar Jul 09 '26 05:07 OPS-NeoRetro

Thanks, after I increase the context size to 256k, it's getting better. The only thing is I still have a slow initial prefill then it's fine. Do I need manually clear kv cache when I get kv cache full? or I need start a new Claude session.

0710 11:22:13 ds4-server: kv cache evicted reason=disk-cache-full tokens=81920 hits=0 size=1098.53 MiB file=./cache/kv/7c50effbdd21e95af0c2d454a2bf2bddffdcffe5.kv

liqili avatar Jul 09 '26 23:07 liqili

Do I need [to] manually clear [the] kv cache when I get [the] kv cache full? or I need [to] start a new Claude session.

ds4-server: kv cache evicted reason=disk-cache-full tokens=81920 hits=0 size=1098.53 MiB

You really need a ton of context since you work with pretty big codebases. You have to try this on Macs like your 128GB M4 Max

rm -rf ./cache/kv
./ds4-server \
--host 0.0.0.0 \
--port 8080 \
--cors \
--ctx 131072 \
--tokens 12288 \
--kv-disk-dir ./cache/kv \
--kv-disk-space-mb 32768 \
--kv-cache-min-tokens 1024 \
--kv-cache-continued-interval-tokens 12288 \
--kv-cache-cold-max-tokens 65536 \
--prefill-chunk 8192 \ # increase or decrease this depending on how big your GPU is
--kv-cache-continued-interval-tokens 131072 \
--kv-cache-reject-different-quant \
--kv-cache-boundary-trim-tokens 16 \
--kv-cache-boundary-align-tokens 1024 \
--tool-memory-max-ids 32768 \
--warm-weights \
--temp 1.0 \
--top-p 1.0 \
--min-p 0.05

If you can, you have to make sure that your ~/.claude/config.json points to deepseek-v4-flash

OPS-NeoRetro avatar Jul 10 '26 11:07 OPS-NeoRetro

@liqili does it run better now

OPS-NeoRetro avatar Jul 13 '26 12:07 OPS-NeoRetro

Thanks @OPS-NeoRetro. I can see improvements. However after a few hours, the initial prefill still gets very slow. I configured 256k context though. I can see there was 18GB memory idle not sure how to leverage as much as possible.

liqili avatar Jul 13 '26 20:07 liqili

@liqili now, run this

rm -rf ./cache/kv
./ds4-server \
--host 0.0.0.0 \
--port 8080 \
--cors \
--ctx 393216 \
--tokens 32768 \
--kv-disk-dir ./cache/kv \
--kv-disk-space-mb 65536 \
--kv-cache-min-tokens 1024 \
--kv-cache-continued-interval-tokens 16384 \
--kv-cache-cold-max-tokens 131072 \
--prefill-chunk 16384 \ # should this be the same as max continued interval tokens for .kv files or max response length?
--kv-cache-continued-interval-tokens 393216 \
--kv-cache-reject-different-quant \
--kv-cache-boundary-trim-tokens 16 \
--kv-cache-boundary-align-tokens 1024 \
--tool-memory-max-ids 32768 \
--ssd-streaming \
--ssd-streaming-cache-experts 5208 \
--ssd-streaming-preload-experts 320 \
--warm-weights \
--temp 1.0 \
--top-p 1.0 \
--min-p 0.05 \ # turn this up a little bit if something in the output feels loose
--trace ./traces/log-1.log \
-m ./gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf

What other applications do you use ds4-server for? Try switching between the q2-imatrix and q2-q4-imatrix Flash versions and see which is better in quality.

OPS-NeoRetro avatar Jul 15 '26 15:07 OPS-NeoRetro

Thanks, I adjusted the command and it's now running better. I will keep monitoring how it performs and let you know then.

./ds4-server
--host 0.0.0.0
--port 8080
--cors
--ctx 393216
--tokens 32768
--kv-disk-dir ./cache/kv
--kv-disk-space-mb 65536
--kv-cache-min-tokens 4096
--kv-cache-continued-interval-tokens 32768
--kv-cache-cold-max-tokens 393216
--prefill-chunk 8192
--kv-cache-reject-different-quant
--kv-cache-boundary-trim-tokens 0
--kv-cache-boundary-align-tokens 4096
--tool-memory-max-ids 32768
--warm-weights

liqili avatar Jul 16 '26 03:07 liqili

@liqili does it run better in the few days that you used your new server options

OPS-NeoRetro avatar Jul 20 '26 07:07 OPS-NeoRetro

Hi @OPS-NeoRetro , It's working okay as I use 393k context, so the initial prompt with token mismatch will take 2-5mins, after that it's fine. My actual run options:

./ds4-server
--host 0.0.0.0
--port 8080
--cors
--ctx 393216
--tokens 32768
--kv-disk-dir ./cache/kv
--kv-disk-space-mb 131072
--kv-cache-min-tokens 4096
--kv-cache-continued-interval-tokens 4096
--kv-cache-cold-max-tokens 393216
--prefill-chunk 8192
--kv-cache-reject-different-quant
--kv-cache-boundary-trim-tokens 64
--kv-cache-boundary-align-tokens 2048
--tool-memory-max-ids 32768
--warm-weights
--ssd-streaming

Here is a piece of log: 0720 21:18:14 ds4-server: live kv cache miss live=84099 prompt=84581 common=26163 reason=token-mismatch 0720 21:18:15 ds4-server: kv cache stored tokens=84099 trimmed=0 reason=evict key=token-text size=1127.09 MiB save=404.7 ms 0720 21:18:15 ds4-server: kv cache hit text tokens=24576 text=96648 quant=2 key=token-text load=129.8 ms file=./cache/kv/47c14b7eaae5667d85fcc314a3d477ae0707f2e6.kv 0720 21:18:15 ds4-server: chat ctx=24576..84581:60005 TOOLS prompt start 0720 21:18:15 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 0/60005 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0720 21:18:50 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 8192/60005 (13.7%) chunk=236.58 t/s avg=236.58 t/s 34.626s 0720 21:18:50 ds4-server: kv cache stored tokens=32768 trimmed=0 reason=continued key=token-text size=453.14 MiB save=62.9 ms 0720 21:19:26 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 16384/60005 (27.3%) chunk=222.18 t/s avg=229.16 t/s 71.497s 0720 21:19:27 ds4-server: kv cache stored tokens=40960 trimmed=0 reason=continued key=token-text size=560.70 MiB save=95.3 ms 0720 21:20:05 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 24576/60005 (41.0%) chunk=213.95 t/s avg=223.85 t/s 109.787s 0720 21:20:05 ds4-server: kv cache stored tokens=49152 trimmed=0 reason=continued key=token-text size=668.27 MiB save=97.5 ms 0720 21:20:45 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 32768/60005 (54.6%) chunk=205.52 t/s avg=218.97 t/s 149.647s 0720 21:20:45 ds4-server: kv cache stored tokens=57344 trimmed=0 reason=continued key=token-text size=775.83 MiB save=119.7 ms 0720 21:21:26 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 40960/60005 (68.3%) chunk=198.42 t/s avg=214.53 t/s 190.932s 0720 21:21:26 ds4-server: kv cache stored tokens=65536 trimmed=0 reason=continued key=token-text size=883.41 MiB save=145.8 ms 0720 21:22:09 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 49152/60005 (81.9%) chunk=190.85 t/s avg=210.18 t/s 233.855s 0720 21:22:09 ds4-server: kv cache stored tokens=73728 trimmed=0 reason=continued key=token-text size=990.96 MiB save=172.9 ms 0720 21:22:53 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 57344/60005 (95.6%) chunk=183.13 t/s avg=205.84 t/s 278.589s 0720 21:22:54 ds4-server: kv cache stored tokens=81920 trimmed=0 reason=continued key=token-text size=1098.52 MiB save=191.4 ms 0720 21:23:17 ds4-server: chat ctx=24576..84581:60005 TOOLS prefill chunk 60005/60005 (100.0%) chunk=112.58 t/s avg=198.54 t/s 302.226s 0720 21:23:17 ds4-server: chat ctx=24576..84581:60005 TOOLS prompt done 302.227s 0720 21:23:17 ds4-server: chat ctx=24576..84581:60005 TOOLS stream closed during prefill 0720 21:23:17 ds4-server: chat ctx=84581..84581:0 TOOLS prompt start 0720 21:23:17 ds4-server: chat ctx=84581..84581:0 TOOLS prompt done 0.000s 0720 21:23:25 ds4-server: chat ctx=84581..84631:50 gen=50 TOOLS THINKING decoding chunk=6.20 t/s avg=6.20 t/s 8.061s 0720 21:23:28 ds4-server: chat ctx=84631..84681:50 gen=100 TOOLS DSML_START decoding chunk=16.96 t/s avg=9.08 t/s 11.009s 0720 21:23:30 ds4-server: chat ctx=84681..84720:39 gen=139 TOOLS DSML_START DSML_END decoding chunk=16.61 t/s avg=10.41 t/s 13.357s 0720 21:23:30 ds4-server: tool calls ctx=84581..84581:0 n=1 raw_dsml=1 ids=[toolu_d8b82ac7b2e725de282bbe84db2cc8ab] names=[Read] 0720 21:23:30 ds4-server: chat ctx=84581..84581:0 gen=139 TOOLS DSML_START DSML_END finish=tool_calls 13.357s 0720 21:23:31 ds4-server: anthropic live continuation match=tool-output-ids ids=1 cached=84720 prompt=85642 0720 21:23:31 ds4-server: chat ctx=84720..85642:922 TOOLS prompt start 0720 21:23:31 ds4-server: chat ctx=84720..85642:922 TOOLS prefill chunk 0/922 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0720 21:23:49 ds4-server: chat ctx=84720..85642:922 TOOLS prefill chunk 922/922 (100.0%) chunk=49.48 t/s avg=49.48 t/s 18.635s 0720 21:23:49 ds4-server: chat ctx=84720..85642:922 TOOLS prompt done 18.635s 0720 21:23:58 ds4-server: chat ctx=85642..85692:50 gen=50 TOOLS DSML_START decoding chunk=5.87 t/s avg=5.87 t/s 8.513s 0720 21:24:00 ds4-server: chat ctx=85692..85731:39 gen=89 TOOLS DSML_START DSML_END decoding chunk=16.76 t/s avg=8.21 t/s 10.839s 0720 21:24:00 ds4-server: tool calls ctx=84720..85642:922 n=1 raw_dsml=1 ids=[toolu_cc62e5c268f5bd74630a076a33f3ac79] names=[Read] 0720 21:24:00 ds4-server: chat ctx=84720..85642:922 gen=89 TOOLS DSML_START DSML_END finish=tool_calls 29.475s 0720 21:24:00 ds4-server: anthropic live continuation match=tool-output-ids ids=1 cached=85731 prompt=86122 0720 21:24:00 ds4-server: chat ctx=85731..86122:391 TOOLS prompt start 0720 21:24:00 ds4-server: chat ctx=85731..86122:391 TOOLS prefill chunk 0/391 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0720 21:24:07 ds4-server: chat ctx=85731..86122:391 TOOLS prefill chunk 391/391 (100.0%) chunk=59.41 t/s avg=59.41 t/s 6.582s 0720 21:24:07 ds4-server: chat ctx=85731..86122:391 TOOLS prompt done 6.582s 0720 21:24:11 ds4-server: chat ctx=86122..86172:50 gen=50 TOOLS DSML_START decoding chunk=12.58 t/s avg=12.58 t/s 3.976s 0720 21:24:12 ds4-server: chat ctx=86172..86197:25 gen=75 TOOLS DSML_START DSML_END decoding chunk=16.70 t/s avg=13.71 t/s 5.472s 0720 21:24:12 ds4-server: tool calls ctx=85731..86122:391 n=1 raw_dsml=1 ids=[toolu_10d86b68117a90fcdee70fbf3d6aeb8c] names=[Read] 0720 21:24:12 ds4-server: chat ctx=85731..86122:391 gen=75 TOOLS DSML_START DSML_END finish=tool_calls 12.054s 0720 21:24:13 ds4-server: anthropic live continuation match=tool-output-ids ids=1 cached=86197 prompt=86928 0720 21:24:13 ds4-server: chat ctx=86197..86928:731 TOOLS prompt start 0720 21:24:13 ds4-server: chat ctx=86197..86928:731 TOOLS prefill chunk 0/731 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0720 21:24:21 ds4-server: chat ctx=86197..86928:731 TOOLS prefill chunk 731/731 (100.0%) chunk=87.05 t/s avg=87.05 t/s 8.397s 0720 21:24:21 ds4-server: chat ctx=86197..86928:731 TOOLS prompt done 8.397s 0720 21:24:25 ds4-server: chat ctx=86928..86978:50 gen=50 TOOLS THINKING decoding chunk=12.42 t/s avg=12.42 t/s 4.026s 0720 21:24:28 ds4-server: chat ctx=86978..87028:50 gen=100 TOOLS THINKING decoding chunk=17.14 t/s avg=14.40 t/s 6.942s 0720 21:24:31 ds4-server: chat ctx=87028..87078:50 gen=150 TOOLS THINKING decoding chunk=17.12 t/s avg=15.21 t/s 9.864s 0720 21:24:34 ds4-server: chat ctx=87078..87128:50 gen=200 TOOLS THINKING decoding chunk=16.82 t/s avg=15.58 t/s 12.836s 0720 21:24:37 ds4-server: chat ctx=87128..87178:50 gen=250 TOOLS DSML_START decoding chunk=16.97 t/s avg=15.84 t/s 15.782s 0720 21:24:38 ds4-server: chat ctx=87178..87204:26 gen=276 TOOLS DSML_START DSML_END decoding chunk=16.63 t/s avg=15.91 t/s 17.345s 0720 21:24:38 ds4-server: tool calls ctx=86197..86928:731 n=1 raw_dsml=1 ids=[toolu_22e0efafbb7d2688b417ca3954e944b7] names=[Read] 0720 21:24:38 ds4-server: chat ctx=86197..86928:731 gen=276 TOOLS DSML_START DSML_END finish=tool_calls 25.743s 0720 21:24:39 ds4-server: anthropic live continuation match=tool-output-ids ids=1 cached=87204 prompt=89703 0720 21:24:39 ds4-server: chat ctx=87204..89703:2499 TOOLS prompt start 0720 21:24:39 ds4-server: chat ctx=87204..89703:2499 TOOLS prefill chunk 0/2499 (0.0%) chunk=0.00 t/s avg=0.00 t/s 0.000s 0720 21:25:00 ds4-server: chat ctx=87204..89703:2499 TOOLS prefill chunk 2499/2499 (100.0%) chunk=117.84 t/s avg=117.83 t/s 21.208s 0720 21:25:00 ds4-server: chat ctx=87204..89703:2499 TOOLS prompt done 21.208s 0720 21:25:08 ds4-server: chat ctx=89703..89753:50 gen=50 TOOLS THINKING decoding chunk=6.04 t/s avg=6.04 t/s 8.272s 0720 21:25:11 ds4-server: chat ctx=89753..89803:50 gen=100 TOOLS THINKING decoding chunk=16.99 t/s avg=8.92 t/s 11.215s 0720 21:25:14 ds4-server: chat ctx=89803..89853:50 gen=150 TOOLS DSML_START decoding chunk=16.59 t/s avg=10.54 t/s 14.229s 0720 21:25:17 ds4-server: chat ctx=89853..89903:50 gen=200 TOOLS DSML_START decoding chunk=16.41 t/s avg=11.58 t/s 17.276s 0720 21:25:20 ds4-server: chat ctx=89903..89953:50 gen=250 TOOLS DSML_START decoding chunk=16.63 t/s avg=12.33 t/s 20.282s 0720 21:25:23 ds4-server: chat ctx=89953..90003:50 gen=300 TOOLS DSML_START decoding chunk=16.85 t/s avg=12.90 t/s 23.249s 0720 21:25:26 ds4-server: chat ctx=90003..90053:50 gen=350 TOOLS DSML_START decoding chunk=16.89 t/s avg=13.35 t/s 26.209s 0720 21:25:29 ds4-server: chat ctx=90053..90103:50 gen=400 TOOLS DSML_START decoding chunk=16.68 t/s avg=13.70 t/s 29.206s 0720 21:25:32 ds4-server: chat ctx=90103..90153:50 gen=450 TOOLS DSML_START decoding chunk=16.65 t/s avg=13.97 t/s 32.209s 0720 21:25:35 ds4-server: chat ctx=90153..90203:50 gen=500 TOOLS DSML_START decoding chunk=16.67 t/s avg=14.20 t/s 35.207s 0720 21:25:38 ds4-server: chat ctx=90203..90253:50 gen=550 TOOLS DSML_START decoding chunk=16.41 t/s avg=14.38 t/s 38.254s 0720 21:25:41 ds4-server: chat ctx=90253..90303:50 gen=600 TOOLS DSML_START decoding chunk=16.19 t/s avg=14.51 t/s 41.343s 0720 21:25:44 ds4-server: chat ctx=90303..90353:50 gen=650 TOOLS DSML_START decoding chunk=16.41 t/s avg=14.64 t/s 44.391s

liqili avatar Jul 20 '26 09:07 liqili

@liqili just bear with me. Apple Silicon is not that fast at prefill. If you really need as much performance as possible, the coder or software maker must do a ton of warp pre-scheduling in Metal or MPS shader code, while NVIDIA CUDA and AMD ROCm had been better at compute due to chonky warps, where there is 1 ALU for one warp thread, and also extremely parallel register files and caches. Apple Silicon GPUs only have 8 ALUs or shader units each warp, or block, or grid, I think, inside each GPU core. Try out #555. It became draft now. It's now proven to be faster than mainline. @antirez even listened.

OPS-NeoRetro avatar Jul 20 '26 09:07 OPS-NeoRetro

Thanks, I'm currently trying the new fork branch you mentioned. Seems working okay either or a little better.

liqili avatar Jul 21 '26 06:07 liqili

@liqili pull from upstream now, seems like @antirez merged #555 as a commit

OPS-NeoRetro avatar Jul 22 '26 09:07 OPS-NeoRetro

Opened #609 for the OpenAI-protocol side of this — same slow-tool-rounds symptom, but the anthropic live continuation path that makes your later logs fast never fires on /v1/chat/completions.

starforge-labs avatar Jul 26 '26 14:07 starforge-labs

Related: opened #611 adding the tool-output-ids continuation to the OpenAI chat endpoint — same slow-tool-rounds symptom as this issue, but the anthropic live continuation fast path that makes your later logs fast never fires on /v1/chat/completions. With the patch, tool rounds at 24k context drop from 45–90s re-prefill to 0.2–11s deltas.

starforge-labs avatar Jul 26 '26 14:07 starforge-labs

Thanks, how do I apply this patch?

liqili avatar Jul 26 '26 23:07 liqili

Thanks, how do I apply this patch?

Worth flagging before you build this — I think our situations differ. Your logs show the Anthropic continuation already firing correctly (anthropic live continuation match=tool-output-ids); your slow prefill looks like it's about initial context size on a big codebase, which is what OPS-NeoRetro's context/budget tuning above is addressing.

My patch fixes a different thing: OpenAI-protocol clients (Open WebUI native function calling, not Claude Code) never getting that continuation at all. If you're on Claude Code, this branch probably won't change anything for you — but happy to be proven wrong if you try it.

To apply it either way:

  1. Pull the branch directly:
git fetch https://github.com/starforge-labs/ds4 chat-live-continuation && git checkout FETCH_HEAD && make
  1. Or wait for PR #611 to merge into main.

Full before/after benchmarks and design notes are in the PR if useful: #611

starforge-labs avatar Jul 27 '26 00:07 starforge-labs