Skip to content

Eval bug: qwen4exp (Qwen3.8-Flash-Next) on Metal: decode emits 1 token then EOS at long context — silent empty output, stochastic at threshold, threshold moves with model quant / KV quant / n_ctx #28805

Description

@dongzhang777-source

Name and Version

0.3.0-dev (build 37, commit 8e53fce), built with AppleClang 21.0.0 for Darwin arm64 (Metal, default flags, Release)

Operating systems

Mac

GGML backends

Metal

Hardware

2x Apple M1 Max (24-core and 32-core GPU), 64 GB unified memory each — reproduced on both

Models

  • unsloth-style AD-3.84bpw-IQ4_XS-M64 (28 shards) — 16K/64K OK, 128K FAIL
  • AD-4.27bpw-Q4_K_M-M64 (33 shards) — 64K FAIL (q4v4 KV) / 16K FAIL (q8v8 KV)

Problem description & steps to reproduce

llama-server, single slot, GPU flash attention (auto). With prompts beyond a config-dependent threshold:

  • prefill completes normally (e.g. 118-140 tok/s at 64K)
  • decode emits exactly 1 token then stops (EOS): eval time = ... / 1 tokens, answer empty
  • server returns HTTP 200 — silent failure, no error anywhere
  • at/near the threshold the failure is STOCHASTIC: same server, same config, same prompt size → 64K x3 = PASS, PASS, FAIL on consecutive runs
  • threshold moves with model quant (Q4_K_M << IQ4_XS), KV quant (q8v8+b256: 16K vs q4v4+b512: 64K), and possibly n_ctx window size (64K probes 3/3 @ n_ctx 208896 vs 2/3 @ n_ctx 262144, same 64K prompts)
  • with mixed-precision KV (-ctk q8_0 -ctv q4_0) Metal rejects FA → attention falls back to CPU → 200K needle tests pass 3/3 (correct but slow) — so the failure is specific to the GPU attention path
  • -fa off cannot be tested with quantized KV ("quantized V cache requires flash_attn to be enabled"); with f16 KV + -fa off decode fails immediately with Compute error. off = 0, n_batch = 256, ret = -3 on the first token
  • memory pressure excluded (failures observed with < 600 MB swap)
  • needle-in-haystack probe (3 pins at 10/50/90% depth), warmup, temperature 0

Matrix (all llama-server, GPU FA, IQ4_XS unless noted):

model KV -b/-ub n_ctx 16K 64K 128K
IQ4_XS q4v4 512 208896 3/3 3/3,3/3,3/3 0/3 (1 tok)
IQ4_XS q4v4 1024 208896 (A machine, +ngram spec) 3/3 (32K/64K) 0/3 (1 tok)
IQ4_XS q8v8 1024 262144 3/3,3/3,0/3 (stochastic!) not reached
Q4_K_M q4v4 512 208896 0/3
Q4_K_M q8v8 256 208896 0/3

First Bad Commit

Unknown; qwen4exp support landed via #27742 (2026-08-27) — all failures observed on builds containing it. Retested on master df03399 (0.4.0-dev build 300, contains #27941, #28023, #28098): the bug reproduces identically. 64K x1 = 3/3 (prefill 153.8 tok/s, decode 11.1 — sparse-FA perf improvements visible), 128K x1 = 0/3, decode 0.0 (1 tok) — same signature, same threshold. So #27941 (block position keying), #28023 (indexer head summation) and Metal sparse FA do not resolve it.

Related

#27856 (HIP: depth-decay only, output correct), #28734 (CUDA: dense top-k TODO), #25722 (Metal: degenerate-token silent empty output, different arch), #21450 (Metal mixed KV rejection — the mechanism that pushes attention to CPU and avoids this bug)

Disclosure: issue text prepared with AI assistance (GLM-5.3-Flash via ZCode), verified against server logs and raw probe JSONs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions