ds4 icon indicating copy to clipboard operation
ds4 copied to clipboard

glm 5.3 flash metal not optimized?

Open badelon opened this issue 2 months ago • 7 comments

i am testing glm 5.3 flash on m1 ultra i get 100 tok/sec prefil which is kinda slow on deepseek i got 170-200 tok/sec prefil i guess for glm we need to wait optimizing update?

Image

badelon avatar Sep 06 '26 03:09 badelon

I'm done a bunch of work to optimize prefill and generation on pre-M5 metal, I'm using an M3 Ultra.

I created this PR https://github.com/antirez/ds4/pull/964 and am waiting for a review. if you could test it that would be helpful. I mainly tested using the Q4_K gguf but the Q2 data would be ok too. here's how:

Please run a short benchmark on main, then on PR 964, and paste both raw results. Use the same GLM 5.3 Flash Q4_K model for both runs. On an M1 Ultra, this model needs --ssd-streaming.


MODEL="/absolute/path/to/GLM-5.3-Flash-Q4_K.gguf"

git switch main
git pull --ff-only
make clean && make -j "$(sysctl -n hw.logicalcpu)" ds4-bench

./ds4-bench -m "$MODEL" \
  --prompt-file speed-bench/promessi_sposi.txt \
  --ctx-start 512 --ctx-max 4096 --step-mul 2 \
  --gen-tokens 128 --ssd-streaming \
  2>&1 | tee ~/ds4-main-bench.txt

Then fetch and build PR 964:

git switch --detach FETCH_HEAD
make clean && make -j "$(sysctl -n hw.logicalcpu)" ds4-bench

./ds4-bench -m "$MODEL" \
  --prompt-file speed-bench/promessi_sposi.txt \
  --ctx-start 512 --ctx-max 4096 --step-mul 2 \
  --gen-tokens 128 --ssd-streaming \
  2>&1 | tee ~/ds4-pr964-bench.txt

Please paste both saved outputs, including the startup memory/cache information, and tell me your RAM capacity, GPU core count, and macOS version. Keep other GPU-heavy applications closed during both runs.

trueimage avatar Sep 11 '26 02:09 trueimage

#964

very nice do you have telegram? i also have m3 ultra 512 and m1 128gb we can work and test together

also i have q2 version which is 96gb so i guess i dont need ssd streaming

badelon avatar Sep 12 '26 14:09 badelon

Image

your pr is optimized for m3 right? still i got nice gains in prefil

badelon avatar Sep 12 '26 19:09 badelon

Getting 29tok/s with this branch on M3 ultra 256, 24 tok/s after ~100k context, maybe there's some tricks that could be ported over here.

But all its tool calls are empty, not sure what's going on there, makes it unusable in a harness. Homeboy disabled issues too so no way to inform them.

https://github.com/IngeniousIdiocy/ds4/blob/glm53-m3ultra/README.md#glm53_m3ultra

openSourcerer9000 avatar Sep 22 '26 01:09 openSourcerer9000

Getting 29tok/s with this branch on M3 ultra 256, 24 tok/s after ~100k context, maybe there's some tricks that could be ported over here.

But all its tool calls are empty, not sure what's going on there, makes it unusable in a harness. Homeboy disabled issues too so no way to inform them.

https://github.com/IngeniousIdiocy/ds4/blob/glm53-m3ultra/README.md#glm53_m3ultra

@openSourcerer9000 i'm sorry you are having issues. i'm just glad someone is using it. I only have used the anthropic tool calling paths as I use it inside claude code (it seems that's where GLM did most of their post training) and they work quite well. are you on the openai api side?

two other things jump out at me. your low decode numbers... did you run the conversion script to get 16 bit backbone weights down to 8? that's a big reduction in gigabytes per token and that is antirez's script after I pointed it out to him on X.

also, your significant drop in decode at 100k is concerning... are you getting memory pressure? did you run the mac command to hardwire more memory?

issues should be working on the repo

IngeniousIdiocy avatar Sep 22 '26 10:09 IngeniousIdiocy

I was trying it both with https://github.com/0xku/kon and pi.

I did not run a script, where is this documented? I'm on the 256gb variant, and the thing barely fits. I thought 25-29tok/s was screaming fast, I believe it was still a decent speedup from vanilla ds4 like 5 extra tok/s.

https://github.com/IngeniousIdiocy/ds4/issues/1

openSourcerer9000 avatar Sep 22 '26 16:09 openSourcerer9000

@openSourcerer9000

idk if you are on the 80 or 60 core gpu, both came at 256gb. minor slop below:

The Q4 conversion matters quite a bit for decode. A surprisingly large chunk of the bytes read every token are those non-expert/backbone weights. The file I benchmarked converts the eligible BF16 weights to Q8_0. My decode ledger is ~14.2 GB/token with that conversion; backing out just the KDA conversion puts the stock file around 18.5 GB/token.

So that’s roughly 23% fewer bytes/token from the KDA conversion alone. Since decode is heavily bandwidth-bound, I’d expect a pretty meaningful speedup — 29 t/s moving into the mid/high 30s would make sense on the 80-core machine, somewhat less on the 60-core.

The exact conversion recipe I used is here: https://github.com/IngeniousIdiocy/ds4/blob/glm53-m3ultra/docs/GLM53_M3ULTRA.md#reproducing-the-weights

Also saw your tool-call issue. we can cover that in the issue itself.

IngeniousIdiocy avatar Sep 23 '26 01:09 IngeniousIdiocy