Skip to content

Eval bug: DeepSeek-V4-Flash lightning-indexer materialises a ctx-proportional (4 GiB/layer) score buffer #25468

Description

@TacoTakumi

Name and Version

$ llama-cli --version
version: 9924 (90e0f5c)
built with GNU 13.3.0 for Linux x86_64

Operating systems

Linux

GGML backends

CUDA

Hardware

GPU: 5x NVIDIA CUDA (2x RTX 3090, RTX 5060 Ti, 2x RTX 4060 Ti), 96 GiB total VRAM
CPU: Intel Core i5-13600K (14 cores / 20 threads)
RAM: 128 GB DDR4-3200
OS: Linux x86_64 (Ubuntu 24.04)

Models

DeepSeek-V4-Flash (DSV4-Flash), GGUF, MXFP4 quant, 5 shards.

Problem description & steps to reproduce

Edit (root cause found): (see comment below) The driver is not the KV cache and not a host-side allocation as such, it is the DSV4 lightning-indexer compute buffer. The scores lid_kq = ggml_mul_mat(indexer_k, indexer_q) in build_lid_top_k() are materialised full-width per CSA layer (4 GiB/layer at ctx 131072, 512 MiB at 16384 -- exactly ctx-proportional, x21 layers) just to pick a top-512, and are not covered by flash-attention. The host-RAM growth is a second-order effect of MoE expert-offload under memory pressure. Full analysis + GGML_SCHED_DEBUG=2 evidence in the followup comment below.

With my setup, loading DeepSeek V4 Flash with --ctx-size 131072 uses about 110.5 GiB of system RAM on current master (90e0f5c, v9924) vs 71 GiB on the older fairydreaming be00e7771 build with identical flags. That's about 38-40 GiB more and it grows with context, roughly 0.33 MiB per token. GPU VRAM is comparable across builds at matched splits (~82 GiB old vs ~85 GiB new), so the increase is host side, and it reproduces on unmodified master.

Binary: Commit: RSS @ ctx 131072:
fairydreaming be00e7771 (v9854) 71 GiB
master with #25402 15f7321 (v9907) 110 GiB
clean master 90e0f5c (v9924) 110.5 GiB
local stall-fix branch ec1c342da (v9910) 107 GiB

Regression ~+38 GiB at ctx 131072, ~0.33 MiB per token of ctx.
GPU VRAM comparable across builds (~82-86 GiB total; run-to-run --fit variation).

Reproduction:

llama-server --ctx-size 131072 --ubatch-size 512 --fit on --fit-ctx 131072
--fit-target 1024,1024,2048,2048,2048 --no-mmap --flash-attn on --parallel 1

--fit-target is my 5-device split, adjust for your setup
env: GGML_CUDA_NO_PINNED=1 ; model: DeepSeek-V4-Flash MXFP4
poll /health until {"status":"ok"}, then read VmRSS from /proc//status
repeat per commit, GPUs drained between runs

Both my local build ec1c342da (107 vs 110 GiB) and #25402 (a checkpointing PR, now closed) are exonerated. I think the problem is somewhere between be00e7771 and 90e0f5c. I'll likely dig deeper when I have the cycles but wanted to get this out there.

I searched open and closed issues and found no existing report, the closest ones (#25408, #24265, #21690) are distinct.

The measurements and tracker search were aided by Claude.

First Bad Commit

Not bisected. Last known good: be00e7771 (v9854, 71 GiB). Known bad: 90e0f5c (v9924, 110.5 GiB). First bad commit is somewhere in that range.

Relevant log output

Logs
# Load-time host RSS at /health OK, ctx 131072, identical llama-server flags.
# RSS = VmRSS from /proc/<pid>/status. VRAM = per-device used at load (MiB, 5 GPUs).
# GPUs drained between runs.

be00e7771  v9854  old fairydreaming base
  RSS  = 71 GiB
  VRAM = 22079 22686 13163 13265 13160 MiB   (total ~82 GiB)

15f732183  v9907  new base
  RSS  = 110 GiB
  VRAM = 22859 22824 13407 13823  1904 MiB   (total ~73 GiB; the 5th device took a
         degenerate --fit split from VRAM residue, so ~11 GiB spilled to host here)

ec1c342da  v9910  stall-fix branch on the new base
  RSS  = 107 GiB
  VRAM = 22857 22826 13045 13989 13908 MiB   (total ~85 GiB)

90e0f5cfc  v9924  clean current master (separately drained run)
  RSS  = 110.5 GiB

# Cleanest matched-VRAM comparison: be00e7771 (71 GiB at ~82 GiB VRAM) vs the new-base
# build ec1c342da (107 GiB at ~85 GiB VRAM). VRAM is comparable, slightly higher on the
# new build, yet host RSS is +36 GiB. The ~110 GiB new-lineage figure and the
# ~0.33 MiB/token slope reproduce across three independent new-base builds vs the old
# base. The 15f732183 row's low VRAM total is the noted degenerate split and is not the
# basis of the claim.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions