[GH-ISSUE #4950] [Engine] Mac (M3 Ultra, 96 GB): DeepSeek V4.1 answers short prompts but garbles prompts from ~100 tokens (chunked prompt pass) #2279

Open
opened 2026-11-04 01:58:07 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @2nd1st on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4950

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Terminal (the strata command)

What happened

DeepSeek-V4.1-Flash IST-DAS 2.25 bpw on a Mac Studio M3 Ultra answers short prompts correctly, but from about 100 prompt tokens the answers stop matching the prompt, as if the model read a garbled prompt. The engine log says prompts from 96 tokens take the chunked pass (prompt path: the chunked pass from 96 tokens, windows of 16 below), which lines up with where it breaks.

Same prompt shape each time: a Chinese paragraph repeated n times, then "问题:上面这段说明的主题是什么?用一句中文回答。" (what is the topic of the text above, one sentence).

prompt tokens answer
37–42 (short questions) correct and on topic, e.g. a correct is_prime function with explanation
162 starts with a leaked <thinking_process> block, then reasons about a problem that is not in the prompt
492 "这段文本内容混乱" (the model says the text it got is garbled)
1,372 says the content is "非常有限且混杂" (very limited and mixed up)
3,352 answers a different question (writes a deployment checklist)

Real documents fail the same way: a 2,878-token English doc + "summarise in three Chinese sentences" gets an unrelated plan or English text about something else; a 12,526-token doc gets "It's got a lot of formatting issues and references that don't seem to be real".

Decode itself looks healthy: 7–8 tok/s, coherent text on short prompts.

The other engine is fine on the same Mac: Qwen3.8-Flash-Next IQ3_S (Strata engine, Metal) finds a needle at 103K tokens and reads prompts at ~630 tok/s, so the GPU and the install look OK.

Things that did not change it:

  • more experts in memory (--set vram-experts=0.3, 2,245 of 15,360 experts in VRAM) vs the automatic 4 GB share
  • --set DS4_ENGRAM_THREADS=1
  • deleting ~/.local/state/strata/launch/ds4-slots before starting (so no reused conversation)
  • --set prefill-chunk=512
  • --set DS4_BUSY_CAP=2000 (from #4771; no speed or quality change here)

I have not tried the 2.00 bpw set. Only M5 Max is listed as tested in docs/DEEPSEEK_MAC.md, so this may be specific to M3-generation GPUs.

Smallest steps or command that reproduce it

strata launch --model ist-das-2.25bpw --family deepseek41 --context 32k --vision off --tune skip --access local --port 8080 --set vram-experts=0.3 --no-tui --yes
import json, urllib.request
base = "下面是一段关于本地大模型的说明。"
filler = "本地大模型可以在断网时继续工作,适合处理写作、翻译、总结和代码等任务。"
for n in (0, 5, 20, 150):
    q = base + filler * n + "\n\n问题:上面这段说明的主题是什么?用一句中文回答。"
    r = urllib.request.Request("http://127.0.0.1:8080/v1/chat/completions",
        data=json.dumps({"model": "deepseek-v4.1-flash", "messages": [{"role": "user", "content": q}], "max_tokens": 80}).encode(),
        headers={"Content-Type": "application/json", "Authorization": "Bearer strata-local"})
    d = json.load(urllib.request.urlopen(r, timeout=900))
    print(n, d["timings"]["prompt_n"], d["choices"][0]["message"]["content"][:120])

n=0 (about 40 tokens) answers on topic; n=5 and up do not.

Reproduction status

Reproduced locally (every run, across four engine restarts with different settings)

Strata version

Strata 0.2.9 · Terminal 0.1.55 · engine strata-dsv41 0.1.55-macos-arm64-metal

Graphics card, memory and system

Mac Studio (Mac15,14), Apple M3 Ultra (28-core CPU, 60-core GPU), 96 GB unified memory, macOS 26.6.2. Model on the internal SSD.

Model, size and settings

DeepSeek-V4.1-Flash IST-DAS 2.25 bpw (deepseek-v4.1-flash-ist-das-2.25bpw pack, downloaded by strata launch), 32K context, text only, Full quality (6 experts), DSpark off.

Logs

engine started: .../engine-dsv41/0.1.55-macos-arm64-metal/strata-dsv41 --serve --pack .../packs/deepseek-v4.1-flash-ist-das-2.25bpw --max-context 32768 --eos 1 --vision off --dspark none --vram-experts 0.3 --prefill-chunk 512
ds4: tensor parallel 2 -> 1: the experts' 256-value blocks split n_ff 2304 no other way (each GPU its own layers)
ds4: Engram rows are read with 2 threads (DS4_ENGRAM_THREADS=N sets another number)
ds4: the experts VRAM leaves over (~126.9 GB) are read in place from the model's files (--mmap-experts off copies them into RAM) (0.0 GB of RAM free to keep them: the most-routed 126.9 GB read ahead; prompts in chunks of 512)
ds4: prompt path: the chunked pass from 96 tokens, windows of 16 below
ds4: CUDA0 layers [0, 39] + head: weights 5.86 GB, experts 22.17 GB (2245 of 15360 in VRAM), caches 0.03 GB, 48616 MiB free
ds4: 13115 routed experts on the CPU lane (127.3 GB, in place in the model's files), 14 threads
maya ds4 serve: prompt 31 tokens = 0 reused + 31 read in 3977 ms (7.8 tok/s), 1 generated in 1 ms (1248.63 tok/s); CPU lane 65.1% of the experts
maya ds4 serve: prompt 492 tokens = 0 reused + 492 read in 6901 ms (71.3 tok/s), 30 generated in 4036 ms (7.43 tok/s); CPU lane 6.4% of the experts
maya ds4 serve: prompt 3352 tokens = 0 reused + 3352 read in 20647 ms (162.3 tok/s), 30 generated in 4121 ms (7.28 tok/s); CPU lane 1.5% of the experts

Two smaller things noticed on the way, in case they are useful:

  • The automatic expert share counts compressed and swapped pages as "anonymous memory" of other programs (other programs hold 85.2 GB of anonymous memory with 86% of RAM free per memory_pressure), so it fell back to 4 GB of experts.
  • --vram-experts takes a fraction; --set vram-experts=40 (meant as GB) tried to place every expert in memory and the start ran for 15 minutes. A note in --help that F is a fraction would help.
Originally created by @2nd1st on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4950 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Terminal (the `strata` command) ### What happened DeepSeek-V4.1-Flash IST-DAS 2.25 bpw on a Mac Studio M3 Ultra answers short prompts correctly, but from about 100 prompt tokens the answers stop matching the prompt, as if the model read a garbled prompt. The engine log says prompts from 96 tokens take the chunked pass (`prompt path: the chunked pass from 96 tokens, windows of 16 below`), which lines up with where it breaks. Same prompt shape each time: a Chinese paragraph repeated n times, then "问题:上面这段说明的主题是什么?用一句中文回答。" (what is the topic of the text above, one sentence). | prompt tokens | answer | |---:|---| | 37–42 (short questions) | correct and on topic, e.g. a correct `is_prime` function with explanation | | 162 | starts with a leaked `<thinking_process>` block, then reasons about a problem that is not in the prompt | | 492 | "这段文本内容混乱" (the model says the text it got is garbled) | | 1,372 | says the content is "非常有限且混杂" (very limited and mixed up) | | 3,352 | answers a different question (writes a deployment checklist) | Real documents fail the same way: a 2,878-token English doc + "summarise in three Chinese sentences" gets an unrelated plan or English text about something else; a 12,526-token doc gets "It's got a lot of formatting issues and references that don't seem to be real". Decode itself looks healthy: 7–8 tok/s, coherent text on short prompts. The other engine is fine on the same Mac: Qwen3.8-Flash-Next IQ3_S (Strata engine, Metal) finds a needle at 103K tokens and reads prompts at ~630 tok/s, so the GPU and the install look OK. Things that did not change it: - more experts in memory (`--set vram-experts=0.3`, 2,245 of 15,360 experts in VRAM) vs the automatic 4 GB share - `--set DS4_ENGRAM_THREADS=1` - deleting `~/.local/state/strata/launch/ds4-slots` before starting (so no reused conversation) - `--set prefill-chunk=512` - `--set DS4_BUSY_CAP=2000` (from #4771; no speed or quality change here) I have not tried the 2.00 bpw set. Only M5 Max is listed as tested in docs/DEEPSEEK_MAC.md, so this may be specific to M3-generation GPUs. ### Smallest steps or command that reproduce it ```sh strata launch --model ist-das-2.25bpw --family deepseek41 --context 32k --vision off --tune skip --access local --port 8080 --set vram-experts=0.3 --no-tui --yes ``` ```python import json, urllib.request base = "下面是一段关于本地大模型的说明。" filler = "本地大模型可以在断网时继续工作,适合处理写作、翻译、总结和代码等任务。" for n in (0, 5, 20, 150): q = base + filler * n + "\n\n问题:上面这段说明的主题是什么?用一句中文回答。" r = urllib.request.Request("http://127.0.0.1:8080/v1/chat/completions", data=json.dumps({"model": "deepseek-v4.1-flash", "messages": [{"role": "user", "content": q}], "max_tokens": 80}).encode(), headers={"Content-Type": "application/json", "Authorization": "Bearer strata-local"}) d = json.load(urllib.request.urlopen(r, timeout=900)) print(n, d["timings"]["prompt_n"], d["choices"][0]["message"]["content"][:120]) ``` n=0 (about 40 tokens) answers on topic; n=5 and up do not. ### Reproduction status Reproduced locally (every run, across four engine restarts with different settings) ### Strata version Strata 0.2.9 · Terminal 0.1.55 · engine `strata-dsv41` 0.1.55-macos-arm64-metal ### Graphics card, memory and system Mac Studio (Mac15,14), Apple M3 Ultra (28-core CPU, 60-core GPU), 96 GB unified memory, macOS 26.6.2. Model on the internal SSD. ### Model, size and settings DeepSeek-V4.1-Flash IST-DAS 2.25 bpw (`deepseek-v4.1-flash-ist-das-2.25bpw` pack, downloaded by `strata launch`), 32K context, text only, Full quality (6 experts), DSpark off. ### Logs ``` engine started: .../engine-dsv41/0.1.55-macos-arm64-metal/strata-dsv41 --serve --pack .../packs/deepseek-v4.1-flash-ist-das-2.25bpw --max-context 32768 --eos 1 --vision off --dspark none --vram-experts 0.3 --prefill-chunk 512 ds4: tensor parallel 2 -> 1: the experts' 256-value blocks split n_ff 2304 no other way (each GPU its own layers) ds4: Engram rows are read with 2 threads (DS4_ENGRAM_THREADS=N sets another number) ds4: the experts VRAM leaves over (~126.9 GB) are read in place from the model's files (--mmap-experts off copies them into RAM) (0.0 GB of RAM free to keep them: the most-routed 126.9 GB read ahead; prompts in chunks of 512) ds4: prompt path: the chunked pass from 96 tokens, windows of 16 below ds4: CUDA0 layers [0, 39] + head: weights 5.86 GB, experts 22.17 GB (2245 of 15360 in VRAM), caches 0.03 GB, 48616 MiB free ds4: 13115 routed experts on the CPU lane (127.3 GB, in place in the model's files), 14 threads maya ds4 serve: prompt 31 tokens = 0 reused + 31 read in 3977 ms (7.8 tok/s), 1 generated in 1 ms (1248.63 tok/s); CPU lane 65.1% of the experts maya ds4 serve: prompt 492 tokens = 0 reused + 492 read in 6901 ms (71.3 tok/s), 30 generated in 4036 ms (7.43 tok/s); CPU lane 6.4% of the experts maya ds4 serve: prompt 3352 tokens = 0 reused + 3352 read in 20647 ms (162.3 tok/s), 30 generated in 4121 ms (7.28 tok/s); CPU lane 1.5% of the experts ``` Two smaller things noticed on the way, in case they are useful: - The automatic expert share counts compressed and swapped pages as "anonymous memory" of other programs (`other programs hold 85.2 GB of anonymous memory` with 86% of RAM free per `memory_pressure`), so it fell back to 4 GB of experts. - `--vram-experts` takes a fraction; `--set vram-experts=40` (meant as GB) tried to place every expert in memory and the start ran for 15 minutes. A note in `--help` that F is a fraction would help.
Author
Owner

@mikog8tor commented on GitHub (Nov 2, 2026):

Environment

  • Hardware: Apple M4 Max, 128 GB (Mac16,9), macOS 27.2, model on an external NVMe SSD
  • Engine: strata-dsv41 0.1.55-macos-arm64-metal, shipped revision 4cf0d8cd38
  • Strata Terminal 0.1.55 (app feed 0.2.9), launch flags: --context 256k --vision off --parallel 1 --dspark none --tune skip --set cpu-threads=8 --set STRATA_METAL_LEAVE_SHARE=0.47
  • Model pack: ISTA-DASLab DeepSeek-V4.1-Flash-1017 IQ2_XXS "ist-das-2.00bpw" (138 GB + 111 GB n-gram table), 5/6 experts per word in the Faster runs, 6/6 in the Full runs
  • Thinking off (chat_template_kwargs.enable_thinking: false), temperature 0, greedy in all recall checks

Reproduction (independent confirmation of #4950 on M4 Max + 2.00 bpw)

Every symptom from #4950 reproduces here, so this is not a single-machine failure:

  1. Default (chunked) path garbles any prompt of ~100+ tokens. A 210-token "7 × 8?" prompt answers with echoed source text; a 583-token repo prompt + tool list answers with -- repetitions; a 26-token prompt answers correctly (-- only appears at ≥96 tokens, matching the chunked-pass threshold in the log).
  2. --set prefill-chunk=0 fixes quality completely but prefill is ~10x slower on this machine (numbers below).

Needle-recall check (code word hidden at 10/50/90% of a fixed haystack, exact-match answer)

Prompt Default (chunked) --set prefill-chunk=0
32,062 tokens, 1 marker missed, output is --/1.0 loops exact word found
32,109 tokens, 3 markers missed all all three found, exact
208,130 tokens, 3 markers missed all (222 tok/s prefill) not completed — hit a lab 30-min guard at ~38K tokens read

Real coding tasks (3 tiny repos, held-out hidden tests; greedy; tools: read/write files + run visible tests)

Mode Default (chunked) --set prefill-chunk=0
Full (6 experts) 0 of 3 tasks finished; every answer ran to the 2048 cap repeating filler; 0/15 hidden tests 3 of 3 tasks, 15/15 hidden tests
Faster (5 experts) one task looped tool calls until the cap; 0/15 hidden tests 3 of 3 tasks, 15/15 hidden tests

Prompt-read throughput (same hardware, same session settings)

Path 32K prompt 208K prompt
Default (chunked) ~154 tok/s 222 tok/s (936 s)
--set prefill-chunk=0 21 tok/s (1,530 s) not measured (est. ~2.5 h)

So on M4 Max the chunked path is not just wrong, it is also the only fast prefill available; the windows path is 7–10x slower. SSD expert streaming dominates both, but the windows path pays KWin-sized per-window work on the CPU lane (12.7–14K routed experts here).

Clue for the author

This Mac build also prints ds4: tensor parallel 2 -> 1: the experts' 256-value blocks split n_ff 2304 no other way (each GPU its own layers). Happy to run a bisect build or dump DS4_DUMP_L records if useful — the isolated source build here (0.1.55-metal, no code changed) reports the same garbling as the signed engine, so it reproduces from a clean source build.

Request

If the fix lands in an engine update, the ~10x prefill gap makes prefill-chunk=0 painful for 30K+ prompts; a correct-and-chunked path would restore the documented 600+ tok/s long-prompt prefill on the Mac. Happy to re-run the needle check and coding suite against a test build.

Raw result files (JSON, engine logs, memory samples) retained locally and can be attached on request.

<!-- gh-comment-id:6587317751 --> @mikog8tor commented on GitHub (Nov 2, 2026): ## Environment - Hardware: Apple M4 Max, 128 GB (Mac16,9), macOS 27.2, model on an external NVMe SSD - Engine: strata-dsv41 0.1.55-macos-arm64-metal, shipped revision 4cf0d8cd3809b5a3f220ea4e1abf024ac7365de9 - Strata Terminal 0.1.55 (app feed 0.2.9), launch flags: `--context 256k --vision off --parallel 1 --dspark none --tune skip --set cpu-threads=8 --set STRATA_METAL_LEAVE_SHARE=0.47` - Model pack: ISTA-DASLab DeepSeek-V4.1-Flash-1017 **IQ2_XXS "ist-das-2.00bpw"** (138 GB + 111 GB n-gram table), 5/6 experts per word in the Faster runs, 6/6 in the Full runs - Thinking off (`chat_template_kwargs.enable_thinking: false`), temperature 0, greedy in all recall checks ## Reproduction (independent confirmation of #4950 on M4 Max + 2.00 bpw) Every symptom from #4950 reproduces here, so this is not a single-machine failure: 1. **Default (chunked) path garbles any prompt of ~100+ tokens.** A 210-token "7 × 8?" prompt answers with echoed source text; a 583-token repo prompt + tool list answers with `--` repetitions; a 26-token prompt answers correctly (`--` only appears at ≥96 tokens, matching the chunked-pass threshold in the log). 2. **`--set prefill-chunk=0` fixes quality completely** but prefill is ~10x slower on this machine (numbers below). ### Needle-recall check (code word hidden at 10/50/90% of a fixed haystack, exact-match answer) | Prompt | Default (chunked) | `--set prefill-chunk=0` | |---|---|---| | 32,062 tokens, 1 marker | missed, output is `--`/`1.0` loops | exact word found | | 32,109 tokens, 3 markers | missed all | all three found, exact | | 208,130 tokens, 3 markers | missed all (222 tok/s prefill) | **not completed** — hit a lab 30-min guard at ~38K tokens read | ### Real coding tasks (3 tiny repos, held-out hidden tests; greedy; tools: read/write files + run visible tests) | Mode | Default (chunked) | `--set prefill-chunk=0` | |---|---|---| | Full (6 experts) | 0 of 3 tasks finished; every answer ran to the 2048 cap repeating filler; 0/15 hidden tests | **3 of 3 tasks, 15/15 hidden tests** | | Faster (5 experts) | one task looped tool calls until the cap; 0/15 hidden tests | **3 of 3 tasks, 15/15 hidden tests** | ### Prompt-read throughput (same hardware, same session settings) | Path | 32K prompt | 208K prompt | |---|---|---| | Default (chunked) | ~154 tok/s | 222 tok/s (936 s) | | `--set prefill-chunk=0` | **21 tok/s** (1,530 s) | not measured (est. ~2.5 h) | So on M4 Max the chunked path is not just wrong, it is also the only *fast* prefill available; the windows path is 7–10x slower. SSD expert streaming dominates both, but the windows path pays KWin-sized per-window work on the CPU lane (12.7–14K routed experts here). ## Clue for the author This Mac build also prints `ds4: tensor parallel 2 -> 1: the experts' 256-value blocks split n_ff 2304 no other way (each GPU its own layers)`. Happy to run a bisect build or dump `DS4_DUMP_L` records if useful — the isolated source build here (`0.1.55-metal`, no code changed) reports the same garbling as the signed engine, so it reproduces from a clean source build. ## Request If the fix lands in an engine update, the ~10x prefill gap makes `prefill-chunk=0` painful for 30K+ prompts; a correct-and-chunked path would restore the documented 600+ tok/s long-prompt prefill on the Mac. Happy to re-run the needle check and coding suite against a test build. Raw result files (JSON, engine logs, memory samples) retained locally and can be attached on request.
Author
Owner

@mikog8tor commented on GitHub (Nov 3, 2026):

Follow-up: M4 Max (128 GB) against the freshly released dsv41 0.1.56-macos-arm64-metal (built from f457ed7b9 per the release notes).

  1. The chunked default prompt path still garbles prompts >= ~96 tokens here: a 6,567-token needle echoes filler text in both Faster (5 experts) and Full (6 experts). --set prefill-chunk=0 (windows of 16) stays the quality-safe path on Mac; this comment replaces an earlier draft with corrected engine versions.

  2. Coder support works on Mac (thanks for #4706): from --model-path against the HF repository folder (IQ2_XXS/ + Engram gguf at the top), all 7,680 experts stay resident (66 GB; CPU lane ~2%). 3-repo hidden-test coding harness: 15 of 15 with the windows path. 6K needle found and quoted exactly. Windows prefill 41 tok/s; decode 17-19 tok/s.

  3. For bug-hunters: engine prompt slots persist across launches (ds4-slots/, STRATA_DS4 slot files). A rerun after a chunked-path run reads back the saved conversation and its KV and answers with the old garbage while reading 0 new prompt tokens (6533 reused + 1 read). Reproduce cleanly with --set STRATA_DS4_SLOT_KEEP=0 --set STRATA_DS4_REUSE=0 and wipe the ds4-slots folder. May be worth an invalidation when the primary path settings change a prompt-affecting flag.

Reference numbers on this Mac for the same Coder files via llama.cpp (requires b11870+ and the Engram gguf from the HF repository directly; the Strata repack of the Engram file lacks llama.cpp split metadata): prefill ~210 tok/s, short-answer decode ~28 tok/s, same 15/15 harness in 23.3%/13% of the Strata wall time (3.3 min vs 23.3 min).

<!-- gh-comment-id:6595279215 --> @mikog8tor commented on GitHub (Nov 3, 2026): Follow-up: M4 Max (128 GB) against the freshly released dsv41 0.1.56-macos-arm64-metal (built from f457ed7b9 per the release notes). 1. The chunked default prompt path still garbles prompts >= ~96 tokens here: a 6,567-token needle echoes filler text in both Faster (5 experts) and Full (6 experts). `--set prefill-chunk=0` (windows of 16) stays the quality-safe path on Mac; this comment replaces an earlier draft with corrected engine versions. 2. Coder support works on Mac (thanks for #4706): from `--model-path` against the HF repository folder (IQ2_XXS/ + Engram gguf at the top), all 7,680 experts stay resident (66 GB; CPU lane ~2%). 3-repo hidden-test coding harness: 15 of 15 with the windows path. 6K needle found and quoted exactly. Windows prefill 41 tok/s; decode 17-19 tok/s. 3. For bug-hunters: engine prompt slots persist across launches (ds4-slots/, STRATA_DS4 slot files). A rerun after a chunked-path run reads back the saved conversation and its KV and answers with the old garbage while reading 0 new prompt tokens (6533 reused + 1 read). Reproduce cleanly with `--set STRATA_DS4_SLOT_KEEP=0 --set STRATA_DS4_REUSE=0` and wipe the ds4-slots folder. May be worth an invalidation when the primary path settings change a prompt-affecting flag. Reference numbers on this Mac for the same Coder files via llama.cpp (requires b11870+ and the Engram gguf from the HF repository directly; the Strata repack of the Engram file lacks llama.cpp split metadata): prefill ~210 tok/s, short-answer decode ~28 tok/s, same 15/15 harness in 23.3%/13% of the Strata wall time (3.3 min vs 23.3 min).
Author
Owner

@shpati commented on GitHub (Nov 4, 2026):

The same issue is seen on a Mac M1 Ultra 128GB running ISTA-DASLab DeepSeek-V4.1-Flash-1017 IQ2_XXS "ist-das-2.25bpw"
on dsv41 0.1.56 . The issue has been there in several (perhaps all) revisions of the dsv4.1 engine.
--set prefill-chunk=0 seems to fix it. Currently getting 9.9 t/s in inference.

<!-- gh-comment-id:6619016880 --> @shpati commented on GitHub (Nov 4, 2026): The same issue is seen on a Mac M1 Ultra 128GB running ISTA-DASLab DeepSeek-V4.1-Flash-1017 IQ2_XXS "ist-das-2.25bpw" on dsv41 0.1.56 . The issue has been there in several (perhaps all) revisions of the dsv4.1 engine. --set prefill-chunk=0 seems to fix it. Currently getting 9.9 t/s in inference.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2279
No description provided.